/* CarDecision UX system — HIG / Material 3 inspired, principle-driven */

:root {
  --touch-min: 48px;
  --state-hover: rgba(11, 31, 51, 0.06);
  --state-press: rgba(11, 31, 51, 0.10);
  --state-focus: rgba(232, 93, 4, 0.45);
  --elev-1: 0 1px 2px rgba(11, 31, 51, 0.06), 0 1px 3px rgba(11, 31, 51, 0.08);
  --elev-2: 0 4px 12px rgba(11, 31, 51, 0.10);
  --elev-3: 0 12px 32px rgba(11, 31, 51, 0.14);
  --surface: #ffffff;
  --surface-2: #f4f7f9;
  --on-surface: #0B1F33;
  --outline: #C9D4DE;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
  --state-hover: rgba(255, 255, 255, 0.06);
  --state-press: rgba(255, 255, 255, 0.10);
  --elev-1: 0 1px 2px rgba(0, 0, 0, 0.35);
  --elev-2: 0 6px 18px rgba(0, 0, 0, 0.4);
  --surface: #142433;
  --surface-2: #0f1b27;
  --on-surface: #eef3f7;
  --outline: #2e4458;
  --brand-mist: #1a2c3c;
  --brand-sand: #0c1620;
  --brand-white: #142433;
  --brand-line: #2e4458;
  --brand-muted: #9fb0bf;
  --brand-ink: #eef3f7;
}

/* Aesthetic + hierarchy */
body {
  color: var(--on-surface);
  background:
    radial-gradient(1000px 420px at 8% -8%, rgba(30, 90, 122, 0.14), transparent 55%),
    radial-gradient(800px 360px at 100% 0%, rgba(232, 93, 4, 0.07), transparent 50%),
    linear-gradient(180deg, var(--surface-2) 0%, var(--brand-sand) 100%);
}

/* Fitts — minimum interactive size */
.btn, .btn-touch, .tab, .theme-toggle, .nav-more-btn,
.bottom-nav a, .quick-action, .chip[role="button"],
.input, .select, .textarea {
  min-height: var(--touch-min);
}
.btn, .theme-toggle, .nav-more-btn {
  min-width: var(--touch-min);
}
.btn { border-radius: 12px; font-weight: 700; letter-spacing: 0.01em; box-shadow: var(--elev-1); }
.btn:active { transform: scale(0.98); }
.btn-primary { box-shadow: 0 6px 16px rgba(232, 93, 4, 0.28); }
.btn-primary:hover { filter: brightness(1.03); }

/* Focus — accessibility (HIG / MD3) */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--state-focus);
  outline-offset: 2px;
}
.skip-link:focus {
  position: fixed; left: 1rem; top: 1rem; z-index: 300;
  background: var(--brand-accent); color: #fff; padding: 0.75rem 1rem;
  border-radius: 10px; font-weight: 700;
}

/* Header — familiarity + consistency */
.site-header {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--elev-1);
}
.header-inner { gap: 0.75rem; }
.nav-desktop a {
  min-height: 40px; display: inline-flex; align-items: center;
  padding: 0.5rem 0.85rem;
}
.nav-desktop a.active {
  background: var(--brand-mist);
  color: var(--brand-navy);
  box-shadow: inset 0 -2px 0 var(--brand-accent);
}
.header-cta { gap: 0.55rem; }
.theme-toggle {
  width: var(--touch-min); height: var(--touch-min);
  border-radius: 14px; border: 1px solid var(--outline);
  background: var(--surface); color: var(--on-surface); cursor: pointer;
  display: grid; place-items: center;
}
.theme-toggle:hover { background: var(--state-hover); }

/* Proximity — group related actions */
.cluster { display: flex; flex-wrap: wrap; gap: 0.65rem; align-items: center; }
.cluster-stack { display: grid; gap: 0.75rem; }
.field-cluster {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--elev-1);
}
.field-cluster h3 {
  font-size: 0.95rem; margin: 0 0 0.75rem;
  color: var(--brand-steel);
  text-transform: uppercase; letter-spacing: 0.04em;
}

/* Quick actions — recognition over recall */
.quick-actions { margin-bottom: 1.75rem; }
.quick-action {
  border-radius: 16px;
  padding: 1rem 1.05rem;
  min-height: 76px;
  box-shadow: var(--elev-1);
  border: 1px solid var(--outline);
  position: relative;
  overflow: hidden;
}
.quick-action::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--brand-accent); opacity: 0.85;
}
.quick-action:hover { box-shadow: var(--elev-2); border-color: color-mix(in srgb, var(--brand-accent) 45%, var(--outline)); }
.quick-action span { font-size: 1.02rem; }
.quick-action small { line-height: 1.3; }

/* Cards — aesthetic usability */
.card, .result-card, .car-card {
  border-radius: 16px;
  border-color: var(--outline);
  box-shadow: var(--elev-1);
}
.car-card:hover { box-shadow: var(--elev-3); }
.section-head h2 { letter-spacing: -0.03em; }
.section-head p { max-width: 52ch; }

/* Bottom nav — Material adaptive + Fitts */
.bottom-nav {
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -8px 24px rgba(11, 31, 51, 0.08);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}
.bottom-nav a {
  min-height: var(--bottom-nav-h);
  gap: 0.2rem;
  font-size: 0.7rem;
  position: relative;
}
.bottom-nav a.active::before {
  content: ""; position: absolute; top: 6px;
  width: 28px; height: 3px; border-radius: 999px;
  background: var(--brand-accent);
}
.bottom-nav svg { width: 22px; height: 22px; }

/* More sheet — user control & freedom */
.more-drawer {
  border-radius: 20px 20px 0 0;
  padding: 0.5rem 1rem calc(var(--bottom-nav-h) + var(--safe-bottom) + 1rem);
  max-height: min(72vh, 560px);
  box-shadow: var(--elev-3);
}
.more-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.65rem 0 0.85rem; border-bottom: 1px solid var(--outline);
  margin-bottom: 0.35rem;
}
.more-drawer-head strong { font-family: var(--font-display); }
.more-drawer-close {
  min-width: var(--touch-min); min-height: var(--touch-min);
  border: 0; background: var(--state-hover); border-radius: 12px;
  font-size: 1.25rem; cursor: pointer; color: var(--on-surface);
}
.more-group-label {
  display: block; margin: 0.85rem 0 0.35rem;
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--brand-muted);
}
.more-drawer a {
  min-height: var(--touch-min); display: flex; align-items: center;
  border-radius: 12px; padding: 0.65rem 0.5rem; border-bottom: 0;
}
.more-drawer a:hover { background: var(--state-hover); }
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 65;
  background: rgba(11, 31, 51, 0.45);
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

/* Forms — error prevention + recovery */
.form-label { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.req-mark { color: var(--brand-danger); font-weight: 800; }
.opt-mark { color: var(--brand-muted); font-size: 0.78rem; font-weight: 600; }
.field-error {
  display: block; margin-top: 0.35rem; color: var(--brand-danger);
  font-size: 0.82rem; font-weight: 600;
}
.input[aria-invalid="true"], .select[aria-invalid="true"] {
  border-color: var(--brand-danger);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.15);
}
.input, .select, .textarea {
  border-radius: 12px;
  border-color: var(--outline);
  background: var(--surface);
  color: var(--on-surface);
}
.form-hint { line-height: 1.4; }

/* Empty / error — diagnose & recover */
.empty-state, .error-state {
  border-radius: 16px;
  padding: 2rem 1.25rem;
  background: var(--surface);
  border: 1px dashed var(--outline);
}
.empty-state .cluster, .error-state .cluster {
  justify-content: center; margin-top: 1rem;
}

/* Toast live region */
.toast-wrap { pointer-events: none; }
.toast {
  pointer-events: auto;
  border-radius: 12px;
  animation: toastIn .25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Progressive disclosure helpers */
.ux-step-hint {
  display: flex; justify-content: space-between; gap: 1rem; align-items: center;
  margin-bottom: 0.75rem; flex-wrap: wrap;
}
.progress-track {
  height: 10px; border-radius: 999px; background: var(--brand-mist); overflow: hidden;
  flex: 1; min-width: 120px;
}
.progress-track > div {
  height: 100%; background: linear-gradient(90deg, var(--brand-accent), #ff7a2f);
  border-radius: inherit; transition: width .25s ease;
}

/* Responsive density */
@media (max-width: 640px) {
  .section { padding: 1.75rem 0; }
  .hero-actions .btn { width: 100%; }
  .hero-search { width: 100%; }
  .hero-search .btn { width: 100%; }
  h1 { font-size: clamp(1.85rem, 8vw, 2.4rem); }
}
@media (min-width: 1100px) {
  .nav-desktop { gap: 0.2rem; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn:active, .toast { animation: none; transform: none; }
}
