/* ==========================================================================
   RetirementDateCalc — global stylesheet
   Phase 1: design tokens + minimal base only.
   No frameworks. System font stack (fast, private). Light by default with a
   prefers-color-scheme dark variant. Component styles arrive in later phases
   (header/nav in Phase 3, tool UI in Phase 6).
   ========================================================================== */

:root {
  /* ---- color tokens ---- */
  --bg: #ffffff;
  --surface: #f6f8fa;
  --text: #0f172a;
  --muted: #5b6b7f;
  --border: #dbe3ec;
  --accent: #0f766e;            /* calm blue-teal */
  --accent-contrast: #ffffff;
  --success: #15803d;
  --danger: #b91c1c;

  /* ---- type scale ---- */
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;
  --fs-3xl: 2rem;
  --fs-4xl: 2.75rem;

  /* ---- type + layout tokens ---- */
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --max-width: 72rem;           /* single content column */
  --measure: 72ch;              /* comfortable article line length */
  --radius: 0.5rem;

  /* ---- spacing scale ---- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2.5rem;
  --space-6: 4rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1520;
    --surface: #16202e;
    --text: #eef3f7;
    --muted: #9fb0c3;
    --border: #2b3a4e;
    --accent: #2dd4bf;
    --accent-contrast: #0e1520;
    --success: #4ade80;
    --danger: #f87171;
  }
}

/* ---- minimal base (tokens applied, nothing more) ---- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-stack);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.container {
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--space-3);
}

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Skip link: visible on keyboard focus only. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: var(--space-2) var(--space-3);
  border-radius: 0 0 var(--radius) 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* Wordmark: "Date" renders in the accent color (matches logo spec). */
.site-logo__accent { color: var(--accent); }

/* ==========================================================================
   Phase 2 — components.
   Mobile-first. One column on small screens; multi-column from 640px/1024px.
   All color comes from the Phase 1 tokens, so dark mode just works.
   ========================================================================== */

/* ---------- typography ---------- */

h1, h2, h3, h4 {
  line-height: 1.25;
  margin: 0 0 var(--space-3);
  text-wrap: balance;
}
h1 { font-size: var(--fs-3xl); letter-spacing: -0.01em; }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }

p { margin: 0 0 var(--space-3); }

.lede {
  font-size: var(--fs-lg);
  color: var(--muted);
  max-width: var(--measure);
}

/* Article/guide body: comfortable line length. */
.prose { max-width: var(--measure); }
.prose li { margin-bottom: var(--space-2); }

/* ---------- header + navigation ---------- */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-block: var(--space-2);
}
.site-logo { display: inline-flex; line-height: 0; }
.site-logo img { height: 2.25rem; width: auto; display: block; }

.site-nav__list {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
}
.site-nav__list a,
.site-nav__list button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font: inherit;
  font-weight: 600;
  background: none;
  border: 0;
  cursor: pointer;
  white-space: nowrap;
}
.site-nav__list a:hover,
.site-nav__list button:hover { background: var(--surface); }
.site-nav__list a[aria-current="page"] { color: var(--accent); }

.has-dropdown { position: relative; }
.has-dropdown > button::after {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  margin-left: var(--space-2);
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
}
.has-dropdown > ul {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 13rem;
  margin: 0;
  padding: var(--space-2);
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  z-index: 50;
}
.has-dropdown > ul a { display: flex; width: 100%; }
/* Shown on hover/focus now; Phase 3 wires aria-expanded + touch/mkeyboard. */
.has-dropdown:hover > ul,
.has-dropdown:focus-within > ul,
.has-dropdown > button[aria-expanded="true"] + ul { display: block; }

/* Mobile nav toggle (button markup + behavior arrive in Phase 3). */
.nav-toggle { display: none; }

/* ---------- hero ---------- */

.hero { padding-block: var(--space-6) var(--space-4); }
.hero h1 { font-size: var(--fs-4xl); margin-bottom: var(--space-2); }
.trust-line { color: var(--success); font-weight: 600; }

/* ---------- tool ---------- */

.tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
}
.tool__step { margin-bottom: var(--space-4); }
.tool__step:last-child { margin-bottom: 0; }
.tool__step-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  margin-bottom: var(--space-2);
}
.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: var(--fs-sm);
  font-weight: 800;
  flex: none;
}
.tool__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

/* ---------- results ---------- */

.results { margin-top: var(--space-4); }
.result-primary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}
.result-primary__label {
  font-size: var(--fs-sm);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-1);
}
.result-primary__date {
  font-size: var(--fs-3xl);
  font-weight: 800;
  letter-spacing: -0.01em;
}
.result-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
}
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
}
.result-card__label {
  font-size: var(--fs-sm);
  color: var(--muted);
  margin-bottom: var(--space-1);
}
.result-card__value { font-size: var(--fs-xl); font-weight: 700; }
.result-card__note {
  font-size: var(--fs-sm);
  color: var(--muted);
  margin-top: var(--space-1);
}

/* Live countdown line (ticking clock). */
.countdown-line {
  font-size: var(--fs-2xl);
  font-weight: 800;
  margin: var(--space-3) 0;
}
.countdown-clock {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

/* Radio option rows (tool steps). */
.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}
.radio-row label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  cursor: pointer;
}
.radio-row input[type="radio"] {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--accent);
  flex: none;
}

/* Screen-reader-only text (e.g. table captions that would repeat headings). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.calc-note {
  font-size: var(--fs-sm);
  color: var(--muted);
  margin-top: var(--space-3);
}

/* ---------- cards (tool / guide listings) ---------- */

.card-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: 1fr;
  margin-bottom: var(--space-5);
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
}
.card h3 { font-size: var(--fs-lg); margin-bottom: var(--space-1); }
.card h3 a { color: var(--text); text-decoration: none; }
.card h3 a:hover { color: var(--accent); text-decoration: underline; }
.card p { color: var(--muted); font-size: var(--fs-sm); margin: 0; }

/* ---------- tables ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
caption {
  text-align: left;
  font-weight: 700;
  padding: var(--space-2) var(--space-3);
}
th, td {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th { background: var(--surface); font-weight: 700; }
tr:last-child th, tr:last-child td { border-bottom: 0; }

/* ---------- breadcrumb ---------- */

.breadcrumb { margin-bottom: var(--space-3); }
.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: var(--fs-sm);
  color: var(--muted);
}
.breadcrumb li + li::before {
  content: "›";
  margin-right: var(--space-1);
  color: var(--muted);
}
.breadcrumb [aria-current="page"] { color: var(--text); font-weight: 600; }

/* ---------- FAQ (native details/summary) ---------- */

.faq { margin-bottom: var(--space-5); }
.faq details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: var(--space-2);
}
.faq summary {
  cursor: pointer;
  padding: var(--space-3);
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 800;
  line-height: 1;
}
.faq details[open] summary::before { content: "–"; }
.faq__answer { padding: 0 var(--space-3) var(--space-3); }
.faq__answer > :last-child { margin-bottom: 0; }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: var(--space-6);
  padding-block: var(--space-5) var(--space-4);
}
.site-footer__brand { margin-bottom: var(--space-4); max-width: var(--measure); }
.site-footer__logo img { height: 2rem; width: auto; }
.site-footer__tagline { color: var(--muted); margin-bottom: var(--space-1); }
.site-footer__badge { color: var(--success); font-weight: 600; margin: 0; }
.site-footer__cols {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  margin-bottom: var(--space-4);
}
.site-footer__col h2 {
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}
.site-footer__col h2 a { color: var(--text); text-decoration: none; }
.site-footer__col h2 a:hover { color: var(--accent); }
.site-footer__col ul { list-style: none; margin: 0; padding: 0; }
.site-footer__col li { margin-bottom: var(--space-1); }
.site-footer__col li a {
  color: var(--muted);
  text-decoration: none;
  display: inline-block;
  padding-block: 0.2rem;
}
.site-footer__col li a:hover { color: var(--accent); text-decoration: underline; }
.site-footer__legal {
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
  font-size: var(--fs-sm);
  color: var(--muted);
}
.site-footer__legal p { margin-bottom: var(--space-1); }

/* ---------- forms ---------- */

.field { margin-bottom: var(--space-3); }
.field > label, .field__label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-1);
}
.field input[type="text"],
.field input[type="number"],
.field input[type="email"],
.field select,
.field textarea {
  width: 100%;
  max-width: 22rem;
  padding: var(--space-2) var(--space-3);
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
/* Date input: three separate controls (day / month / year), never one ambiguous field. */
.date-group { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.date-group .field { margin-bottom: 0; }
.date-group select { max-width: none; }
.field__hint { font-size: var(--fs-sm); color: var(--muted); margin-top: var(--space-1); }
.field__error { color: var(--danger); font-size: var(--fs-sm); margin-top: var(--space-1); font-weight: 600; }
[aria-invalid="true"] { border-color: var(--danger); }

.checkbox-field {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  margin-bottom: var(--space-3);
}
.checkbox-field input { width: 1.25rem; height: 1.25rem; margin-top: 0.2rem; flex: none; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--accent-contrast);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.1); }
.btn--secondary {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}
.btn--secondary:hover { background: var(--surface); filter: none; }

/* ---------- responsive ---------- */

@media (min-width: 640px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .card-grid--3 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 767px) {
  /* Hamburger nav: toggle button + accordion behavior arrive in Phase 3. */
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font: inherit;
    cursor: pointer;
  }
  .site-nav__list {
    display: none;
    position: absolute;
    top: 100%;
    right: var(--space-3);
    left: var(--space-3);
    flex-direction: column;
    align-items: stretch;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-2);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    z-index: 50;
  }
  .site-nav.open .site-nav__list { display: flex; }
  .has-dropdown > ul {
    position: static;
    box-shadow: none;
    border: 0;
    border-left: 2px solid var(--border);
    border-radius: 0;
    margin-left: var(--space-3);
  }
  .hero h1 { font-size: var(--fs-3xl); }
  .result-primary__date { font-size: var(--fs-2xl); }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ==========================================================================
   Phase 3 — header/nav/footer behavior styling.
   The hamburger icon is drawn in CSS; it becomes an X when the menu is open.
   Dropdown accordions on mobile are driven by aria-expanded (see main.js).
   ========================================================================== */

.site-nav { position: relative; }

/* Hamburger bars */
.nav-toggle__icon {
  display: block;
  width: 1.25rem;
  height: 2px;
  background: currentColor;
  position: relative;
  border-radius: 1px;
}
.nav-toggle__icon::before,
.nav-toggle__icon::after {
  content: "";
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}
.nav-toggle__icon::before { top: -6px; }
.nav-toggle__icon::after { top: 6px; }

/* Open state: bars become an X */
.site-nav.open .nav-toggle__icon { background: transparent; }
.site-nav.open .nav-toggle__icon::before { top: 0; transform: rotate(45deg); }
.site-nav.open .nav-toggle__icon::after { top: 0; transform: rotate(-45deg); }

@media (max-width: 767px) {
  /* The mobile menu drops below the header, anchored to .site-nav
     (position: relative above). Accordion sections open in place. */
  .has-dropdown > ul {
    border-left-width: 3px;
  }
  .has-dropdown > button[aria-expanded="true"]::after {
    transform: rotate(225deg) translateY(-2px);
  }
}
