/*
 * Shared styles for the free tools pages (/max-offer-calculator/,
 * /used-car-inspection-checklist/).
 *
 * The tokens below are copied from website/index.html's :root block (Carbon
 * Navy, .claude/skills/design_tokens.md). index.html keeps its own inline
 * copy; until #381 decides on one shared stylesheet, keep the two in step.
 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0F1623;
  --surface: #1A2332;
  --surface-elevated: #222D40;
  --surface3: #152030;
  --border: #2A3445;
  --border-hover: #3A4A63;
  --text: #E8E4DC;
  --text-secondary: #B8B4BC;
  --muted: #8A8F9C;
  --brand: #F07020;
  --brand-dim: #CC5A10;
  --fine: #4CAF7D;
  --flagged: #EF5350;
  --heading: #fff;
  --on-brand: #0F1623;
  --brand-hover: #FF8A3D;
  --field-border: #5E7092;
  --danger-text: #F28B88;
  --danger-border: color-mix(in srgb, var(--flagged) 60%, transparent);
  --danger-hover-text: #FFB4B2;
  --nav-bg: rgba(15,22,35,.92);
  --nav-bg-solid: rgba(15,22,35,.97);
  --hairline: rgba(255,255,255,.05);
  --shadow: rgba(0,0,0,.35);
  --display: 'Bebas Neue', sans-serif;
  --body: 'DM Sans', sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --r: 16px;
  --r-sm: 8px;
}

/* ── LIGHT THEME: follows the device setting only (no toggle, no storage).
   Warm Paper tokens from .claude/skills/design_tokens.md, with orange
   darkened for text and fills on light backgrounds (WCAG AA, measured).
   Screen only: print keeps its own black-on-white rules. ── */
@media screen and (prefers-color-scheme: light) {
  :root {
    --bg: #F5EFE4;
    --surface: #FBF7F0;
    --surface-elevated: #EDE5D8;
    --surface3: #EEE7DA;
    --border: #D4C9B8;
    --border-hover: #A89880;
    --field-border: #8C7E68;
    --text: #1C1610;
    --text-secondary: #5A5040;
    --muted: #6B604F;
    --heading: #1C1610;
    --brand: #A83508;
    --brand-dim: #8A2C06;
    --brand-hover: #8A2C06;
    --on-brand: #FFFFFF;
    --fine: #276B43;
    --fine-bg: rgba(39,107,67,.10);
    --flagged: #B3261E;
    --flagged-bg: rgba(179,38,30,.08);
    --danger-text: #B3261E;
    --danger-border: #B3261E;
    --danger-hover-text: #8E1D17;
    --nav-bg: rgba(245,239,228,.92);
    --nav-bg-solid: rgba(245,239,228,.98);
    --hairline: rgba(28,22,16,.10);
    --shadow: rgba(28,22,16,.12);
  }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: var(--body); font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
::selection { background: var(--brand); color: var(--on-brand); }
a { color: var(--brand); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }

.skip { position: absolute; left: -9999px; top: 8px; background: var(--brand); color: var(--on-brand); padding: 10px 16px; border-radius: var(--r-sm); z-index: 300; }
.skip:focus { left: 16px; }

/* ── NAV ── */
.t-nav {
  position: sticky; top: 0; z-index: 200;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 64px; min-height: 64px;
  background: var(--nav-bg); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--hairline);
}
.nav-logo { font-family: var(--display); font-size: 22px; letter-spacing: .08em; color: var(--brand); text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.nav-tools { display: flex; align-items: center; gap: 28px; list-style: none; }
.nav-tools a { font-size: 13px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
/* Every top-level item (links and the Free tools button) shares one box. */
.nav-tools > li > a, .nav-tools > li > .nav-dd-btn { min-height: 44px; padding: 0; line-height: 1; white-space: nowrap; }
.nav-cta { white-space: nowrap; }
/* Spanish labels are longer: tighter tracking, and the hamburger takes over
   earlier so the row never wraps. */
html:lang(es) .nav-tools { gap: 22px; }
html:lang(es) .nav-tools > li > a, html:lang(es) .nav-tools > li > .nav-dd-btn { letter-spacing: .05em; }
/* Collapse to the hamburger below 1280px. Re-measured 2026-11-10 with the
   "Guides" item: EN tool and guide pages need 1275px (the homepage, 1315px,
   has its own breakpoint in home.css). */
@media (max-width: 1279px) {
  .t-nav .nav-tools, .t-nav .lang-switch { display: none; }
  .t-nav .hamburger { display: flex; }
}
/* Spanish labels are longer. Re-measured 2026-11-10 with "Guías" + EN badge:
   the ES tool pages need 1403px, so collapse below 1420px (the full menu fits at 1440px). */
@media (max-width: 1419px) {
  html:lang(es) .t-nav .nav-tools, html:lang(es) .t-nav .lang-switch { display: none; }
  html:lang(es) .t-nav .hamburger { display: flex; }
}
.nav-tools a:hover, .nav-tools a[aria-current="page"] { color: var(--text); }
/* "EN" badge on the ES "Guías" link: the guides are English-only. The link's
   accessible name is "Guías (en inglés)" (visually hidden text); the badge is
   aria-hidden. Owner decision 2026-11-10. */
.lang-badge { display: inline-flex; align-items: center; margin-left: 6px; padding: 1px 5px; font-family: var(--mono); font-size: 10px; font-weight: 500; line-height: 1.4; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); border: 1px solid var(--field-border); border-radius: 4px; vertical-align: middle; }
.nav-right { display: flex; align-items: center; gap: 8px; }

/* "Free tools" dropdown: opens on click/tap/keyboard, never hover-only (nav.js).
   Same look as the homepage's copy of these rules. */
.nav-dd { position: relative; }
.nav-dd-btn { font: inherit; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0; margin: 0; background: none; border: 0; cursor: pointer; font-family: var(--body); font-size: 13px; font-weight: 500; line-height: 1; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.nav-dd-btn:hover, .nav-dd.open .nav-dd-btn { color: var(--text); }
.nav-dd-btn svg { transition: transform .2s var(--ease); }
.nav-dd.open .nav-dd-btn svg { transform: rotate(180deg); }
.nav-dd-menu { position: absolute; top: 100%; right: 0; min-width: 230px; list-style: none; margin-top: 6px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); box-shadow: 0 12px 32px var(--shadow); z-index: 210; }
.nav-tools .nav-dd-menu a { display: flex; min-height: 44px; padding: 0 12px; border-radius: 6px; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text-secondary); }
.nav-tools .nav-dd-menu a:hover, .nav-tools .nav-dd-menu a:focus-visible, .nav-tools .nav-dd-menu a[aria-current="page"] { background: var(--surface3); color: var(--text); }

/* Hamburger + mobile menu (tool pages; same pattern as the homepage) */
.hamburger { display: none; flex-direction: column; align-items: center; justify-content: center; gap: 5px; width: 44px; height: 44px; padding: 0; margin-right: -11px; background: none; border: none; cursor: pointer; }
.hamburger span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; transition: all .3s var(--ease); }
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.mobile-menu { display: none; position: fixed; top: 64px; left: 0; right: 0; z-index: 190; background: var(--nav-bg-solid); backdrop-filter: blur(20px); border-bottom: 1px solid var(--border); flex-direction: column; padding: 16px 16px 24px; }
.mobile-menu.open { display: flex; }
.mobile-menu a { display: flex; align-items: center; min-height: 48px; font-size: 15px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--border); }
.mobile-menu a:hover, .mobile-menu a[aria-current="page"] { color: var(--text); }
.mobile-menu .m-label { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 18px 0 2px; }
.mobile-menu a.m-tool { text-transform: none; letter-spacing: 0; color: var(--text-secondary); }
.mobile-menu a:last-child { border-bottom: none; }

/* Language switcher (EN | ES): header on desktop, mobile menu on phones */
.lang-switch { display: inline-flex; align-items: center; gap: 2px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.lang-switch a, .m-lang a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 6px; color: var(--muted); text-decoration: none; letter-spacing: .06em; }
.lang-switch a:hover, .m-lang a:hover { color: var(--text); }
.lang-switch a[aria-current="true"], .m-lang a[aria-current="true"] { color: var(--text); font-weight: 500; text-decoration: underline; text-underline-offset: 4px; }
.lang-switch a:focus-visible, .m-lang a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.m-lang { display: flex; align-items: center; gap: 4px; padding-top: 12px; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.mobile-menu .m-lang a { min-height: 44px; border-bottom: none; font-size: 13px; letter-spacing: .06em; text-transform: none; }
@media (max-width: 900px) { .lang-switch { display: none; } }

/* Mobile-menu CTA: only on small phones, where the header CTA is hidden */
.mobile-menu .m-cta { display: none; justify-content: center; margin-top: 12px; min-height: 48px; padding: 0 16px; border: none; border-radius: var(--r-sm); background: var(--brand); color: var(--on-brand); font-size: 14px; letter-spacing: .08em; text-transform: uppercase; }
.mobile-menu .m-cta:hover { filter: brightness(1.12); color: var(--on-brand); }
@media (max-width: 480px) {
  .t-nav .nav-cta { display: none; }
  .mobile-menu .m-cta { display: flex; }
}

/* ── PRINT (shared by the tool pages): black on white, no chrome ──
   The checklist adds its own detailed print layout in checklist.css. */
@media print {
  :root { --bg: #fff; --surface: #fff; --surface3: #fff; --surface-elevated: #fff; --border: #999; --field-border: #000; --text: #000; --text-secondary: #222; --muted: #444; --heading: #000; --brand: #000; --on-brand: #fff; --hairline: #ccc; }
  html, body { background: #fff !important; color: #000; }
  .t-nav, .mobile-menu, .t-footer, .cta-block, .skip, .lang-switch, .confirm-panel, .btn-clear, .help-link { display: none !important; }
  a { color: #000; }
}

/* Screen-reader-only text */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Inline confirmation panel (clear everything / clear form) */
.confirm-panel { margin: 12px 0 8px; padding: 16px; background: var(--surface); border: 1px solid var(--flagged); border-radius: var(--r-sm); max-width: 640px; }
.confirm-panel:focus { outline: 2px solid var(--flagged); outline-offset: 2px; }
.confirm-panel p { font-size: 15px; color: var(--text); margin-bottom: 12px; }
.confirm-btns { display: flex; flex-wrap: wrap; gap: 10px; }
/* Destructive, filled: "Yes, clear everything" / "Yes, clear all fields" */
.btn-danger { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 18px; font: inherit; font-family: var(--body); font-size: 14px; font-weight: 500; line-height: 1.2; color: #fff; background: #C62828; border: 1.5px solid #C62828; border-radius: var(--r-sm); cursor: pointer; transition: background .15s, border-color .15s; }
.btn-danger:hover { background: #B71C1C; border-color: #B71C1C; }
.btn-danger:active { background: #9F1717; }
.btn-danger:focus-visible { outline: 2px solid var(--flagged); outline-offset: 3px; }

/* Secondary destructive, outlined: "Clear all" / "Clear form". Same box as
   the orange-outlined print button, in a muted red. */
.btn-clear, .btn-s.btn-clear { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; font: inherit; font-family: var(--body); font-size: 14px; font-weight: 500; line-height: 1.2; color: var(--danger-text); background: transparent; border: 1.5px solid var(--danger-border); border-radius: var(--r-sm); cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.btn-clear:hover, .btn-s.btn-clear:hover { color: var(--danger-hover-text); border-color: var(--flagged); background: color-mix(in srgb, var(--flagged) 10%, transparent); }
.btn-clear:active { background: color-mix(in srgb, var(--flagged) 18%, transparent); }
.btn-clear:focus-visible { outline: 2px solid var(--flagged); outline-offset: 3px; background: color-mix(in srgb, var(--flagged) 10%, transparent); }
.btn-clear[aria-expanded="true"] { border-color: var(--flagged); background: color-mix(in srgb, var(--flagged) 10%, transparent); }

/* Ghost: "Cancel" in the confirmation panels */
.confirm-btns .btn-s { color: var(--text); background: transparent; border: 1.5px solid transparent; font: inherit; font-family: var(--body); font-size: 14px; font-weight: 500; line-height: 1.2; transition: background .15s, border-color .15s; }
.confirm-btns .btn-s:hover { background: var(--surface3); border-color: var(--border-hover); }
.confirm-btns .btn-s:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
@media print { .confirm-panel, .btn-clear, .mobile-menu, .hamburger { display: none !important; } }
.btn-p {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px;
  font-family: var(--body); font-size: 14px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
  color: var(--on-brand); background: var(--brand); border: none;
  padding: 12px 24px; border-radius: var(--r-sm); cursor: pointer; text-decoration: none;
  transition: filter .2s, transform .2s var(--ease);
}
.btn-p:hover { filter: brightness(1.12); transform: translateY(-1px); }
.nav-cta { font-size: 12px; padding: 10px 16px; }
.btn-s {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  font-family: var(--body); font-size: 14px; font-weight: 500; color: var(--text);
  background: transparent; border: 1px solid var(--border-hover); border-radius: var(--r-sm);
  padding: 10px 18px; cursor: pointer; text-decoration: none;
}
.btn-s:hover { border-color: var(--brand); }

/* ── PAGE ── */
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 64px; }
.page-hdr { padding: 56px 0 32px; }
h1 { font-family: var(--display); font-weight: 400; font-size: clamp(44px, 6vw, 76px); line-height: .95; color: var(--heading); letter-spacing: .01em; }
.div { width: 48px; height: 3px; background: var(--brand); margin: 20px 0; }
.lede { font-size: 18px; font-weight: 300; color: var(--text-secondary); max-width: 640px; }
h2 { font-family: var(--display); font-weight: 400; font-size: 30px; letter-spacing: .04em; color: var(--heading); line-height: 1.1; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 28px; }
.disclaimer { font-size: 14px; color: var(--text-secondary); border-left: 3px solid var(--brand); background: var(--surface3); padding: 14px 16px; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.muted { color: var(--muted); }

/* ── FORM CONTROLS ── */
.field { margin-bottom: 22px; }
.field > label, .field legend, .lbl { display: block; font-weight: 500; font-size: 15px; color: var(--text); margin-bottom: 4px; }
.help { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
fieldset { border: none; min-width: 0; }
input[type="text"], select, textarea {
  width: 100%; min-height: 48px; font: inherit; color: var(--text);
  background: var(--surface3); border: 1px solid var(--field-border); border-radius: var(--r-sm);
  padding: 10px 14px;
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
input[aria-invalid="true"] { border-color: var(--flagged); }
.money { position: relative; }
.money::before { content: '$'; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.money input { padding-left: 28px; }
.pct { position: relative; }
.pct::after { content: '%'; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.pct input { padding-right: 32px; }
.field-error { font-size: 13px; color: var(--flagged); margin-top: 6px; }
.field-error:empty { display: none; }

/* Segmented radio / checkbox pills: native inputs, 44px targets. */
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 14px; background: var(--surface3); border: 1px solid var(--border); border-radius: var(--r-sm); cursor: pointer; font-size: 14px; color: var(--text-secondary); }
.opt:hover { border-color: var(--border-hover); }
.opt:has(input:checked) { border-color: var(--brand); color: var(--text); }
.opt input, .toggle input {
  appearance: none; -webkit-appearance: none; flex-shrink: 0;
  width: 20px; height: 20px; margin: 0; border: 2px solid var(--muted); border-radius: 4px; background: transparent; display: grid; place-content: center; cursor: pointer;
}
.opt input[type="radio"] { border-radius: 50%; }
.opt input:checked, .toggle input:checked { border-color: var(--brand); background: var(--brand); }
.opt input:checked::after, .toggle input:checked::after { content: ''; width: 8px; height: 8px; background: var(--bg); border-radius: 2px; }
.opt input[type="radio"]:checked::after { border-radius: 50%; }
.opt input:focus-visible, .toggle input:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.toggle { display: flex; align-items: flex-start; gap: 12px; min-height: 44px; padding: 12px 14px; background: var(--surface3); border: 1px solid var(--border); border-radius: var(--r-sm); cursor: pointer; }
.toggle .t-text { font-size: 14px; color: var(--text); }
.toggle .help { margin: 4px 0 0; }

/* ── FOOTER ── */
.t-footer { margin-top: 72px; padding: 32px 64px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.f-logo { font-family: var(--display); font-size: 20px; letter-spacing: .08em; color: var(--brand); }
.f-links { display: flex; flex-wrap: wrap; gap: 4px 24px; list-style: none; }
.f-links a { font-size: 13px; color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.f-links a:hover { color: var(--text); }
.f-copy { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .04em; }

/* ── CTA BLOCK ── */
.cta-block { margin-top: 40px; text-align: left; }
.cta-lead { font-size: 17px; color: var(--text); margin-bottom: 14px; }
.cta-note { font-size: 13px; color: var(--muted); margin-top: 10px; }

/* ── GUIDE: explanatory content below a tool (hidden in print) ── */
.guide { max-width: 760px; margin-top: 72px; }
.guide h2 { font-size: 32px; margin: 48px 0 14px; }
.guide h3 { font-family: var(--body); font-size: 17px; font-weight: 500; color: var(--text); margin: 22px 0 6px; }
.guide p, .guide li { font-size: 16px; color: var(--text-secondary); line-height: 1.7; }
.guide p + p { margin-top: 12px; }
.guide ul, .guide ol { padding-left: 22px; margin: 12px 0; }
.guide li + li { margin-top: 6px; }
.guide strong { color: var(--text); font-weight: 500; }
.guide .example { font-family: var(--mono); font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 14px 16px; margin: 14px 0; line-height: 1.8; overflow-wrap: anywhere; }
.guide .faq { margin-top: 8px; }
.guide .answer { font-size: 17px; color: var(--text); }
.guide .related-guides { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 15px; }

/* ── ANSWER-FIRST HEADER: quotable formula, worked example, page meta ── */
.formula { font-family: var(--mono); font-size: 16px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--brand); border-radius: 0 var(--r-sm) var(--r-sm) 0; padding: 12px 16px; margin: 0 0 16px; max-width: 640px; overflow-wrap: anywhere; }
.example-table { border-collapse: collapse; margin: 0 0 20px; min-width: 260px; max-width: 360px; width: 100%; font-size: 14px; }
.example-table caption { caption-side: top; text-align: left; font-family: var(--mono); font-size: 12px; color: var(--muted); padding-bottom: 6px; }
.example-table th { text-align: left; font-weight: 400; color: var(--text-secondary); padding: 5px 12px 5px 0; border-bottom: 1px solid var(--border); }
.example-table td { text-align: right; font-family: var(--mono); color: var(--text); padding: 5px 0; border-bottom: 1px solid var(--border); white-space: nowrap; }
.example-table .ex-total th, .example-table .ex-total td { color: var(--brand); font-weight: 500; border-bottom: none; border-top: 2px solid var(--brand); }
.page-meta { font-size: 13px; color: var(--muted); margin-top: 8px; max-width: 640px; }
.page-meta + .page-meta { margin-top: 2px; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .t-nav { padding: 0 16px; }
  .nav-tools { display: none; }
  .hamburger { display: flex; }
  .wrap { padding: 0 16px; }
  .t-footer { padding: 28px 16px; }
  .card { padding: 20px 16px; }
  .guide { margin-top: 48px; }
  .guide h2 { font-size: 28px; margin-top: 40px; }
}
@media (max-width: 400px) {
  .nav-logo { font-size: 20px; }
  .nav-cta { font-size: 11px; padding: 8px 10px; letter-spacing: .04em; }
}
