/* global.css - CalcsOnly.com */

:root {
  /* High contrast, modern color palette */
  --bg-color: #f4f4f5;
  --text-color: #18181b;
  --card-bg: #ffffff;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #e4e4e7;
  --secondary-hover: #d4d4d8;
  --border: #e4e4e7;
  --error: #ef4444;
  --focus-ring: rgba(37, 99, 235, 0.5);

  /* Typography */
  --font-system: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-system);
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1;
  padding: 2rem 1rem;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

/* Utilities */
.text-center { text-align: center; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 2rem; }
.mt-4 { margin-top: 2rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.w-full { width: 100%; }

/* Typography */
h1, h2, h3 { line-height: 1.2; margin-bottom: 1rem; }
h1 { font-size: 2.5rem; font-weight: 800; letter-spacing: -0.025em; }
h2 { font-size: 1.5rem; font-weight: 700; }
p { margin-bottom: 1rem; }
.text-sm { font-size: 0.875rem; }
.text-muted { color: #52525b; }

/* Links */
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Cards & Layout */
.card {
  background-color: var(--card-bg);
  border-radius: 0.75rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  padding: 1.5rem;
  border: 1px solid var(--border);
}

/* Forms & Inputs */
label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  background-color: #fafafa;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
  background-color: #fff;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s ease;
  font-family: inherit;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: var(--secondary);
  color: var(--text-color);
}
.btn-secondary:hover {
  background-color: var(--secondary-hover);
}

/* Calculator Grid Layout */
.calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}
.calc-grid > * {
  min-height: 3.5rem;
  font-size: 1.25rem;
}
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.col-span-4 { grid-column: span 4; }

/* Custom Inputs & Toggles */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
}
.input-inline-toggle {
  position: absolute;
  left: 0.5rem;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  z-index: 10;
  transition: background 0.15s;
}
.input-inline-label {
  position: absolute;
  left: 0.5rem;
  background: transparent;
  border: 1px solid transparent;
  color: #18181b !important;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
  pointer-events: none;
  z-index: 10;
}
.input-inline-toggle:hover {
  background: var(--secondary-hover);
}
.input-wrapper input {
  padding-left: 3rem; /* space for toggle */
}

/* Top-level Toggles */
.toggle-btn {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: var(--secondary);
  border: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.toggle-btn:hover {
  background: var(--secondary-hover);
}

#clearBtn, #modeToggle, #precisionToggle {
  min-width: 5.5rem;
  text-align: center;
}

/* Operator Container and Swap Button */
.operator-row-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 1.5rem 0;
}

/* Operator Buttons */
.operator-group {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}
.operator-btn {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--card-bg);
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.operator-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.operator-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Fraction Inputs Specifics */
.input-row {
  display: grid;
  /* 4 columns: Inch Mode Tracks */
  grid-template-columns: 1.5fr 1fr 20px 1fr;
  gap: 12px;
  align-items: center; 
  margin-bottom: 20px;
  width: 100%;
}

.input-row.feet-mode {
  /* 5 columns: Feet Mode Tracks */
  grid-template-columns: 1.2fr 1.2fr 1fr 20px 1fr; 
}

.fraction-slash {
  text-align: center;
  font-size: 1.5rem;
  font-weight: bold;
  color: #333;
}

.input-container {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
}

/* Display */
.display-area {
  background-color: var(--bg-color);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
  text-align: right;
  min-height: 4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.display-primary {
  font-size: 2rem;
  font-weight: 700;
  word-break: break-all;
}
.display-secondary {
  font-size: 1rem;
  color: var(--text-muted);
}

/* Header & Footer */
header {
  background-color: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 1rem;
}
.header-container {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.logo {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-color);
  text-decoration: none;
}
.logo span {
  color: var(--primary);
}

footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Tampa Bay Buccaneers Theme - Scoped strictly to .calc-container */
.calc-container {
  background-color: #34302B !important; /* Deep Pewter */
  color: #ffffff !important;
  border: 1px solid #4a4540 !important;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.5) !important;
  /* Natural block flow - height is stabilized by hidden visibility on adjusters */
}

.calc-container h1 {
  color: #ffffff !important;
}

/* Display Area stays high-contrast off-white */
.calc-container .display-area {
  background-color: #fafafa !important;
  color: #18181b !important;
  border: 1px solid #e4e4e7 !important;
}

.calc-container .display-secondary {
  color: #71717a !important;
}

.calc-container .display-primary {
  color: #18181b !important;
}

/* Inputs and Selects stay high-contrast off-white */
.calc-container input[type="number"],
.calc-container input[type="text"],
.calc-container select {
  background-color: #fafafa !important;
  color: #18181b !important;
  border: 1px solid #d4d4d8 !important;
  height: 3rem !important; /* Force identical height across inputs and dropdowns to prevent layout shift */
  box-sizing: border-box !important;
}

.calc-container input::placeholder {
  color: #a1a1aa !important;
}

.calc-container input:focus,
.calc-container select:focus {
  border-color: #D50A0A !important;
  box-shadow: 0 0 0 3px rgba(213, 10, 10, 0.4) !important;
  background-color: #ffffff !important;
}

/* Interactive Control/Math Buttons: Brilliant Red (#D50A0A) */
.calc-container .btn,
.calc-container .toggle-btn,
.calc-container .operator-btn,
.calc-container .input-inline-toggle {
  background-color: #D50A0A !important;
  color: #ffffff !important;
  border: 1px solid #b00808 !important;
  transition: background-color 0.1s ease, box-shadow 0.1s ease;
  font-weight: 700;
}

/* Inset icon colors / glyphes */
.calc-container .operator-btn {
  color: #ffffff !important;
}

/* Active Operator button highlight */
.calc-container .operator-btn.active {
  background-color: #8B0000 !important;
  border-color: #600000 !important;
  box-shadow: inset 0 4px 6px rgba(0, 0, 0, 0.6) !important;
}

/* Hover state: slightly darken background layers on pointer mouseover */
.calc-container .btn:hover,
.calc-container .toggle-btn:hover,
.calc-container .operator-btn:hover:not(.active),
.calc-container .input-inline-toggle:hover {
  background-color: #B30808 !important;
}

/* Active/Press state: darken significantly and apply crisp internal box-shadow */
.calc-container .btn:active,
.calc-container .toggle-btn:active,
.calc-container .operator-btn:active,
.calc-container .input-inline-toggle:active {
  background-color: #7A0000 !important;
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.7) !important;
  transition: none !important;
}

/* Sizing Stability for Adjusters */
.calc-container #adjusterGroup {
  display: flex !important;
  height: 2.5rem;
  margin-bottom: 1rem;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.calc-container #adjusterGroup.hidden-adjuster {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

/* Font and typography styling in Pewter background */
.calc-container .fraction-slash {
  color: #ffffff !important;
}

/* History Panel Styling */
.history-container {
  background-color: #34302B !important; /* Deep Pewter */
  color: #ffffff !important;
  border: 1px solid #4a4540 !important;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.5) !important;
  margin-top: 1.5rem;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #4a4540;
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
}

.history-list {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-right: 4px;
}

/* Custom Scrollbar for history list */
.history-list::-webkit-scrollbar {
  width: 6px;
}
.history-list::-webkit-scrollbar-track {
  background: #34302B;
}
.history-list::-webkit-scrollbar-thumb {
  background: #4a4540;
  border-radius: 3px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background-color: #2b2724; /* Darker accent */
  border-radius: 0.25rem;
  font-size: 0.9rem;
  border: 1px solid #3e3a35;
}

.history-equation {
  font-family: var(--font-system);
  word-break: break-all;
  padding-right: 0.5rem;
}

.history-copy-btn {
  background: transparent !important;
  border: none !important;
  cursor: pointer;
  color: #a1a1aa !important;
  padding: 0.25rem !important;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
}

.history-copy-btn:hover {
  color: #D50A0A !important; /* Buccaneers red hover */
}

.history-copy-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Keypad Overhaul */

.calc-container {
  max-width: 390px !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

.toolbar-container {
  display: flex;
  justify-content: space-between;
  width: 100%;
  gap: 0.5rem;
}

.toolbar-container .toggle-btn {
  flex: 1;
  min-width: 0 !important;
  text-align: center;
  padding: 0.5rem 0.25rem !important;
  font-size: 0.85rem !important;
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  gap: 0.5rem;
  width: 100%;
}

.keypad-btn {
  background-color: #D50A0A !important;
  color: #ffffff !important;
  border: 1px solid #b00808 !important;
  border-radius: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  padding: 0.85rem 0.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  font-family: inherit;
  transition: background-color 0.1s ease, box-shadow 0.1s ease, transform 0.05s ease;
  min-width: 0 !important;
  width: 100% !important;
  height: 3.5rem !important;
  box-sizing: border-box !important;
}

#sub32Btn, #add32Btn {
  font-size: 0.85rem !important;
}

.keypad-btn:hover {
  background-color: #B30808 !important;
}

/* Active pressed state: tactile inset shadows */
.keypad-btn:active {
  background-color: #7A0000 !important;
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.7) !important;
  transform: scale(0.97);
  transition: none !important;
}

/* Specific operator / functional key variations */
.keypad-btn.op-btn {
  background-color: #D50A0A !important;
}

.keypad-btn.control-btn {
  background-color: #4a4540 !important;
  border-color: #3e3a35 !important;
}
.keypad-btn.control-btn:hover {
  background-color: #3e3a35 !important;
}
.keypad-btn.control-btn:active {
  background-color: #2b2724 !important;
  box-shadow: inset 0 4px 6px rgba(0, 0, 0, 0.8) !important;
}

/* Default spans for equal submit button: 2 columns in bottom right */
.submit-btn {
  grid-column: span 2 !important;
  background-color: #D50A0A !important;
}

/* 32nds visibility controls */
#frac32Btn {
  display: none;
}

.keypad-grid.has-32nd #frac32Btn {
  display: flex;
}

/* When 32nds is visible, `=` spans 1 column to make room for `/32` in column 5 */
.keypad-grid.has-32nd .submit-btn {
  grid-column: span 1 !important;
}


