/* =========================================================
   CALCULATORS APP — STYLES
   Organized top to bottom: tokens, base, layout, components.
   Every color/spacing value lives in :root so redesigning
   is mostly a matter of changing the variables below.
   ========================================================= */

:root {
  /* --- Color tokens --- */
  --color-bg: #2b2e33; /* graphite — the "casing" the app sits in */
  --color-bg-soft: #34373d; /* slightly lighter panel background */
  --color-surface: #e9eae6; /* light keypad/card surface */
  --color-ink: #23262b; /* main text on light surfaces */
  --color-ink-soft: #6b6e73; /* secondary text on light surfaces */
  --color-line: #d6d7d1; /* dividers / borders on light surfaces */

  --color-screen: #1b1d1a; /* LCD-style display background */
  --color-digit: #ff8a3d; /* amber — LCD digits, primary accent */
  --color-blue: #6c8eff; /* periwinkle — age/calendar accent */
  --color-danger: #ff5c5c; /* clear / remove actions */

  /* --- Type tokens --- */
  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  /* --- Layout tokens --- */
  --radius-card: 20px;
  --radius-control: 12px;
  --max-width: 480px;
}

/* --- Reset / base --- */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-surface);
  min-height: 100vh;
}

.page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 20px 60px;
}

/* =========================================================
   HEADER
   ========================================================= */

.site-header {
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 700;
  background: var(--color-digit);
  color: var(--color-screen);
  width: 52px;
  height: 52px;
  min-width: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand h1 {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.1;
}

.tagline {
  margin: 4px 0 0;
  color: rgba(233, 234, 230, 0.55);
  font-size: 0.9rem;
}

/* =========================================================
   TABS
   ========================================================= */

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 5px;
  position: relative;
  z-index: 1;
}

.tab {
  flex: 1;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 12px 16px;
  border: none;
  border-radius: 14px 14px 0 0;
  background: var(--color-bg-soft);
  color: rgba(233, 234, 230, 0.55);
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.tab:hover {
  color: var(--color-surface);
}

.tab--active {
  background: var(--color-surface);
  color: var(--color-ink);
}

.tab:focus-visible {
  outline: 3px solid var(--color-digit);
  outline-offset: 2px;
}

/* =========================================================
   CARD / PANELS
   ========================================================= */

.card {
  background: var(--color-surface);
  color: var(--color-ink);
  border-radius: var(--radius-card);
  padding: 20px;
}

.panel {
  display: none;
}

.panel--active {
  display: block;
}

.panel h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin: 0 0 6px;
}

.panel-hint {
  color: var(--color-ink-soft);
  margin: 0 0 20px;
  font-size: 0.9rem;
}

/* =========================================================
   ARITHMETIC CALCULATOR
   ========================================================= */

.screen {
  background: var(--color-screen);
  border-radius: var(--radius-control);
  padding: 20px 18px;
  margin-bottom: 16px;
  text-align: right;
}

.screen-expression {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: rgba(255, 138, 61, 0.55);
  min-height: 1.2em;
  overflow-x: auto;
  white-space: nowrap;
}

.screen-display {
  font-family: var(--font-mono);
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--color-digit);
  overflow-x: auto;
  white-space: nowrap;
  line-height: 1.2;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.key {
  font-family: var(--font-body);
  font-size: 1.15rem;
  font-weight: 600;
  padding: 16px 0;
  border: none;
  border-radius: var(--radius-control);
  background: #fff;
  color: var(--color-ink);
  cursor: pointer;
  box-shadow: 0 2px 0 var(--color-line);
  transition:
    transform 0.08s ease,
    box-shadow 0.08s ease;
}

.key:hover {
  background: #fbfbfa;
}

.key:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 var(--color-line);
}

.key:focus-visible {
  outline: 3px solid var(--color-blue);
  outline-offset: 2px;
}

.key--muted {
  background: #dddfda;
  color: var(--color-ink-soft);
  box-shadow: 0 2px 0 #c7c9c3;
}

.key--op {
  background: var(--color-ink);
  color: var(--color-digit);
  box-shadow: 0 2px 0 #14161a;
}

.key--op:hover {
  background: #14161a;
}

.key--equals {
  background: var(--color-digit);
  color: var(--color-screen);
  box-shadow: 0 2px 0 #c96a1f;
}

.key--equals:hover {
  background: #e77b34;
}

.key--wide {
  grid-column: span 2;
}

/* =========================================================
   AGE CALCULATOR
   ========================================================= */

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-ink-soft);
  margin-bottom: 6px;
}

input[type="date"] {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 12px 14px;
  border: 2px solid var(--color-line);
  border-radius: var(--radius-control);
  background: #fff;
  color: var(--color-ink);
  width: 100%;
}

input[type="date"]:focus-visible {
  outline: none;
  border-color: var(--color-blue);
}

.btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  border-radius: var(--radius-control);
  padding: 13px 18px;
  cursor: pointer;
  width: 100%;
  margin-top: 4px;
  transition:
    transform 0.1s ease,
    box-shadow 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:focus-visible {
  outline: 3px solid var(--color-blue);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--color-ink);
  color: var(--color-digit);
}

.btn-primary:hover {
  box-shadow: 0 4px 14px rgba(35, 38, 43, 0.3);
}

.age-result {
  margin-top: 22px;
}

.age-result--hidden {
  display: none;
}

.age-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.age-tile {
  background: var(--color-screen);
  border-radius: var(--radius-control);
  padding: 16px 8px;
  text-align: center;
}

.age-tile-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-blue);
}

.age-tile-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(233, 234, 230, 0.55);
  margin-top: 4px;
}

.age-total {
  text-align: center;
  color: var(--color-ink-soft);
  font-size: 0.85rem;
  margin: 14px 0 0;
}

/* =========================================================
   FOOTER
   ========================================================= */

.site-footer {
  margin-top: 28px;
  text-align: center;
}

.site-footer p {
  color: rgba(233, 234, 230, 0.4);
  font-size: 0.8rem;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 400px) {
  .screen-display {
    font-size: 1.9rem;
  }

  .key {
    padding: 14px 0;
    font-size: 1rem;
  }

  .age-tile-value {
    font-size: 1.4rem;
  }
}

/* Respect users who've asked for less motion */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
