/* ─────────────────────────────────────────────────────────────────────────────
   Tally design system — tokens and shared components
   Source of truth: docs/TALLY-DESIGN.md (v1.1). Class names start with "t-"
   so they never collide with the legacy css/style.css while pages move over.
   Fonts: load once per page —
   <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Young+Serif&family=Figtree:wght@400;500;600;700&display=swap">
   ───────────────────────────────────────────────────────────────────────────── */

:root {
  /* Surfaces */
  --butter:      #FFF4D9;
  --cream:       #FFFBF0;
  --sand:        #F0DFB8;
  --white:       #FFFFFF;

  /* Lines */
  --line:        #EBDDB6;
  --line-step:   #E3D3A8;
  --line-strong: #8A7A4E;

  /* Text */
  --ink:         #14383B;
  --muted:       #4F5F5E;

  /* Brand */
  --door:        #0F5E63;
  --door-hover:  #0B4A4E;
  --door-tint:   #E3EEE9;

  /* Accent: link hover, destructive actions, the logo's slash */
  --brick:        #B8472A;
  --brick-strong: #A33D22;
  --brick-light:  #E0714F;

  /* Overlays on --door */
  --on-door-text:  #FFF4D9;
  --on-door-line:  rgba(255, 244, 217, 0.30);
  --on-door-chip:  rgba(255, 244, 217, 0.18);
  --on-door-track: rgba(255, 244, 217, 0.25);

  --font-display: 'Young Serif', Georgia, serif;
  --font-body:    'Figtree', system-ui, sans-serif;

  --container: 1152px;
}

/* ── Base ─────────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.t-page {
  margin: 0;
  background: var(--butter);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.t-page img, .t-page svg { display: block; max-width: 100%; }
.t-page a { color: var(--door); }
.t-page a:hover { color: var(--brick); }

.t-container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 32px;
}
@media (max-width: 640px) { .t-container { padding: 0 20px; } }

.t-skip {
  position: absolute; left: -9999px; top: 8px;
  background: var(--door); color: var(--white); padding: 10px 16px; border-radius: 999px;
}
.t-skip:focus { left: 16px; z-index: 200; color: var(--white); }

/* Visible focus on every interactive element */
.t-page :focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

/* ── Type ─────────────────────────────────────────────────────────────────── */

.t-display, .t-h1-hero, .t-h1, .t-h2, .t-h2-band, .t-h3 {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--ink);
  margin: 0;
  text-wrap: balance;
}
.t-h1-hero { font-size: clamp(40px, 6vw, 68px); line-height: 1.06; letter-spacing: -0.01em; }
.t-h1      { font-size: clamp(32px, 4.6vw, 48px); line-height: 1.08; }
.t-h2      { font-size: clamp(30px, 4vw, 44px);   line-height: 1.1; }
.t-h2-band { font-size: clamp(32px, 4.6vw, 52px); line-height: 1.08; }
.t-h3      { font-size: 24px; line-height: 1.2; }
@media (max-width: 640px) {
  .t-h1-hero { font-size: 38px; }
  .t-h1      { font-size: 34px; }
  .t-h2      { font-size: 30px; }
  .t-h2-band { font-size: 32px; }
}

.t-subhead {
  font-size: 20px; line-height: 1.55; color: var(--muted);
  text-wrap: pretty; margin: 0;
}
@media (max-width: 640px) { .t-subhead { font-size: 18px; } }

.t-eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted); margin: 0;
}
.t-muted   { color: var(--muted); }
.t-caption { font-size: 14px; line-height: 1.5; color: var(--muted); }

/* ── Logo ─────────────────────────────────────────────────────────────────── */

.t-logo {
  display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--door);
}
.t-logo:hover { color: var(--door); }
.t-logo__mark { width: 28px; height: 32px; flex: none; }
.t-logo__word {
  font-family: var(--font-display); font-size: 30px; line-height: 1;
  letter-spacing: -0.02em; color: var(--door);
}
.t-logo--small .t-logo__mark { width: 24px; height: 28px; }
.t-logo--small .t-logo__word { font-size: 26px; }
@media (max-width: 640px) {
  .t-logo__mark { width: 24px; height: 28px; }
  .t-logo__word { font-size: 26px; }
}

/* ── Header ───────────────────────────────────────────────────────────────── */

.t-header { background: var(--butter); }
.t-header__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; min-height: 80px;
}
.t-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 28px; }
.t-nav a {
  color: var(--ink); font-size: 16px; font-weight: 500; text-decoration: none;
}
.t-nav a:hover, .t-nav a[aria-current="page"] { color: var(--brick); }
.t-menu-btn {
  display: none; width: 48px; height: 48px; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink); cursor: pointer;
  align-items: center; justify-content: center;
}
.t-menu-btn svg { width: 26px; height: 26px; }
.t-mobile-nav { display: none; }
@media (max-width: 760px) {
  .t-nav { display: none; }
  .t-menu-btn { display: inline-flex; }
  .t-mobile-nav.open {
    display: flex; flex-direction: column; gap: 4px;
    padding: 8px 20px 20px; border-bottom: 1px solid var(--line);
  }
  .t-mobile-nav a {
    color: var(--ink); text-decoration: none; font-size: 18px; font-weight: 500;
    padding: 12px 0; min-height: 48px;
  }
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.t-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 28px; border-radius: 999px;
  font-family: var(--font-body); font-size: 17px; font-weight: 700; line-height: 1;
  text-decoration: none; cursor: pointer; border: 0; white-space: nowrap;
  transition: background-color 150ms, color 150ms;
}
.t-btn--primary { background: var(--door); color: var(--white); }
.t-page .t-btn--primary:hover { background: var(--door-hover); color: var(--white); }
.t-btn--secondary { background: transparent; color: var(--door); border: 2px solid var(--door); }
.t-page .t-btn--secondary:hover { background: var(--door-tint); color: var(--door); }
.t-btn--inverse { background: var(--butter); color: var(--door); }
.t-page .t-btn--inverse:hover { background: var(--cream); color: var(--door); }
.t-btn--inverse-outline { background: transparent; color: var(--butter); border: 2px solid var(--butter); }
.t-btn--small { min-height: 44px; padding: 10px 20px; font-size: 16px; background: transparent; color: var(--door); border: 2px solid var(--door); }
.t-btn--hero { min-height: 60px; }
.t-btn--block { width: 100%; }
.t-btn[disabled], .t-btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
/* Link-styled buttons keep their button colours over .t-page a */
.t-page a.t-btn--primary { color: var(--white); }
.t-page a.t-btn--secondary, .t-page a.t-btn--small, .t-page a.t-btn--inverse { color: var(--door); }
.t-page a.t-btn--inverse-outline { color: var(--butter); }
.t-page a.t-btn { text-decoration: none; }
@media (prefers-reduced-motion: reduce) { .t-btn { transition: none; } }

/* ── Form fields ──────────────────────────────────────────────────────────── */

.t-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.t-input, .t-select {
  width: 100%; height: 52px; padding: 0 16px; border-radius: 16px;
  background: var(--white); border: 1.5px solid var(--line-strong);
  font-family: var(--font-body); font-size: 16px; color: var(--ink);
}
.t-input::placeholder { color: var(--muted); }
.t-input--pill { border-radius: 999px; padding: 0 24px; }
.t-input--hero { height: 60px; border: 2px solid var(--door); font-size: 17px; }

/* The hero address form: field and button side by side, stacked on phones */
.t-address-form { max-width: 620px; margin: 0 auto; text-align: left; }
.t-address-form__row { display: flex; gap: 12px; }
.t-address-form__row .t-input { flex: 1 1 auto; min-width: 0; }
@media (max-width: 560px) {
  .t-address-form__row { flex-direction: column; }
  .t-address-form__row .t-btn { width: 100%; min-height: 56px; }
}

/* ── Cards ────────────────────────────────────────────────────────────────── */

.t-card {
  background: var(--cream); border: 1px solid var(--line);
  border-radius: 28px; padding: 28px;
}
.t-card--large { border-radius: 32px; padding: 32px; }
.t-card--highlight { border: 3px solid var(--door); }
.t-card--door { background: var(--door); border: 0; color: var(--on-door-text); border-radius: 32px; }
.t-card--door .t-eyebrow { color: var(--on-door-text); opacity: 0.9; }
.t-card--sand { background: var(--sand); border: 0; }
.t-card--inset { background: var(--butter); border: 0; border-radius: 16px; padding: 14px 16px; }
@media (max-width: 640px) { .t-card, .t-card--large { padding: 22px; } }

.t-card-grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
}

/* ── Chips and badges ─────────────────────────────────────────────────────── */

.t-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 600; background: var(--sand); color: var(--ink);
}
.t-chip--door { background: var(--door); color: var(--white); }
.t-card--door .t-chip { background: var(--on-door-chip); color: var(--on-door-text); }

/* ── "Tally earns" — always shown, never loud ─────────────────────────────── */
/* Quiet disclosure: muted small print, no bullet or colour (spec 1.4) */

.t-earns {
  margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 14px; font-weight: 400; line-height: 1.4; color: var(--muted);
}
.t-page .t-earns { color: var(--muted); }

/* ── Ticks list (hero) ────────────────────────────────────────────────────── */

.t-ticks {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 24px;
  list-style: none; margin: 18px 0 0; padding: 0; font-size: 15px; color: var(--ink);
}
.t-ticks li { display: inline-flex; align-items: center; gap: 8px; }
.t-ticks svg { width: 16px; height: 16px; color: var(--door); }

/* ── Tally-mark step numerals ─────────────────────────────────────────────── */

.t-steps {
  display: grid; gap: 32px 24px; list-style: none; margin: 0; padding: 0;
  grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
}
.t-steps__mark { height: 36px; margin-bottom: 18px; }
.t-steps__mark svg { height: 36px; width: auto; }
.t-steps__title { font-size: 19px; font-weight: 700; line-height: 1.3; margin: 0 0 8px; }
.t-steps__body { margin: 0; color: var(--muted); font-size: 16px; }
@media (max-width: 640px) { .t-steps__title { font-size: 18px; } }

/* ── Progress stepper (advisor) ───────────────────────────────────────────── */

.t-stepper ol {
  display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0;
}
.t-stepper li {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 999px;
  font-size: 16px; font-weight: 600;
  border: 1.5px solid var(--line-step); color: var(--muted);
}
.t-stepper li.is-done { border-color: var(--door); color: var(--door); }
.t-stepper li.is-done::before {
  content: ""; width: 14px; height: 14px; flex: none;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.t-stepper li[aria-current="step"] { background: var(--door); border-color: var(--door); color: var(--white); }

.t-progress-mobile { display: none; }
@media (max-width: 640px) {
  .t-stepper { display: none; }
  .t-progress-mobile { display: block; }
  .t-progress-mobile__text { font-size: 14px; font-weight: 700; color: var(--door); margin: 0 0 8px; }
  .t-progress-mobile__bars { display: grid; grid-template-columns: repeat(var(--steps, 5), 1fr); gap: 6px; }
  .t-progress-mobile__bars span { height: 6px; border-radius: 999px; background: var(--line-step); }
  .t-progress-mobile__bars span.is-done { background: var(--door); }
}

/* ── Choice rows (radio and checkbox) ─────────────────────────────────────── */

.t-fieldset { border: 0; margin: 0 0 32px; padding: 0; min-width: 0; }
.t-legend {
  font-family: var(--font-display); font-size: 24px; line-height: 1.2;
  color: var(--ink); padding: 0; margin-bottom: 14px;
}
.t-choices { display: grid; gap: 10px; }
.t-choice {
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 10px 18px; border-radius: 16px;
  background: var(--white); border: 1.5px solid var(--line-strong);
  font-size: 16px; cursor: pointer;
}
.t-choice input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--door); }
.t-choice:has(input:checked) { border: 2px solid var(--door); background: var(--door-tint); font-weight: 600; padding: 9.5px 17.5px; }
.t-choice:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 3px; }
.t-choice input:focus-visible { outline: none; }

/* ── Fit badge ────────────────────────────────────────────────────────────── */

.t-badge {
  display: inline-flex; align-self: flex-start; padding: 6px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 700; background: var(--sand); color: var(--ink);
}
.t-badge--best { background: var(--door); color: var(--white); }

/* ── Money ────────────────────────────────────────────────────────────────── */

.t-money { font-family: var(--font-display); font-size: 32px; line-height: 1.1; margin: 0; }
.t-money--lg { font-size: clamp(36px, 5vw, 52px); }

/* ── Value range display (on a door panel) ────────────────────────────────── */

.t-range__bar { position: relative; height: 14px; margin: 22px 0 10px; border-radius: 999px; background: var(--on-door-track); }
.t-range__fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; background: var(--butter); }
.t-range__marker {
  position: absolute; top: 50%; width: 24px; height: 24px; margin: -12px 0 0 -12px;
  border-radius: 50%; background: var(--door); border: 4px solid var(--butter);
}
.t-range__labels { display: flex; justify-content: space-between; gap: 8px; font-size: 15px; font-weight: 600; }
.t-range__chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

/* ── Key-value rows ───────────────────────────────────────────────────────── */

.t-kv { margin: 0; }
.t-kv > div {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px;
}
.t-kv dt { color: var(--muted); }
.t-kv dd { margin: 0; font-weight: 600; text-align: right; }

/* ── Sources list ─────────────────────────────────────────────────────────── */

.t-sources { list-style: none; margin: 0; padding: 0; }
.t-sources > li { padding: 16px 0; border-top: 1px solid var(--line); }
.t-source { display: flex; justify-content: space-between; gap: 16px; }
.t-source__name { font-size: 17px; font-weight: 700; display: flex; align-items: center; flex-wrap: wrap; gap: 0 2px; }
.t-source__method { display: block; font-size: 14px; line-height: 1.45; color: var(--muted); margin: 2px 0 0; }
.t-source__value { text-align: right; font-weight: 700; white-space: nowrap; }
.t-source__date { display: block; font-size: 14px; font-weight: 400; color: var(--muted); }

/* ── Explain button "(?)" and its popover ─────────────────────────────────── */

.t-explain {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; margin: -12px -8px; padding: 0;
  background: none; border: 0; cursor: pointer; vertical-align: middle;
  color: var(--muted); font-family: var(--font-body);
}
.t-explain span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid currentColor;
  font-size: 13px; font-weight: 700; line-height: 1;
}
.t-explain:hover, .t-explain[aria-expanded="true"] { color: var(--door); }
.t-card--door .t-explain { color: var(--on-door-text); }
.t-explain__pop {
  max-width: 320px; margin: 8px 0 4px; padding: 12px 16px;
  background: var(--cream); color: var(--ink); border: 1px solid var(--line); border-radius: 16px;
  font-size: 14px; font-weight: 400; line-height: 1.5; text-align: left; white-space: normal;
}
.t-explain__pop--wide { max-width: none; }
@media (max-width: 640px) { .t-explain__pop { max-width: none; } }

/* ── Status messages ──────────────────────────────────────────────────────── */

.t-alert { padding: 14px 18px; border-radius: 16px; background: var(--sand); font-size: 16px; }
.t-alert[hidden] { display: none; }

/* ── Sections ─────────────────────────────────────────────────────────────── */

.t-section { padding: 72px 0; }
.t-section--band { background: var(--cream); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.t-section--door { background: var(--door); color: var(--on-door-text); }
.t-section--door .t-h2-band, .t-section--door .t-label { color: var(--on-door-text); }
@media (max-width: 640px) { .t-section { padding: 48px 0; } }

/* ── Footer ───────────────────────────────────────────────────────────────── */

.t-footer { padding: 40px 0 48px; }
.t-footer__top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 20px; margin-bottom: 24px;
}
.t-footer__nav { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.t-footer__nav a { color: var(--ink); font-size: 15px; text-decoration: none; }
.t-footer__nav a:hover { color: var(--brick); }
.t-footer__fine { margin: 0 0 4px; font-size: 14px; line-height: 1.5; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .t-page *, .t-page *::before, .t-page *::after { transition: none !important; scroll-behavior: auto !important; }
}
