/* Long Drive: "sunny road trip" theme (#66). One bright theme for everyone.
   Every text/background pair below meets WCAG AA (4.5:1); see web/README.md for the checked pairs. */
:root {
  color-scheme: light;
  --bg: #fff8ee;          /* warm cream */
  --card: #ffffff;
  --field: #fffdf9;
  --text: #2a1f17;        /* warm ink */
  --muted: #6e5e52;
  --line: #f0e2d0;
  --accent: #c4461f;      /* sunset coral: buttons, user bubbles (white text 4.95:1) */
  --accent-hover: #a93a18;
  --accent-soft: #fff1e6; /* coral tint behind chips and highlights */
  --on-accent: #ffffff;
  --link: #0f766e;        /* teal: links and focus rings */
  --sun: #ff8a5b;         /* decoration only, never behind text */
  --sky: #d9f0ff;
  --horizon: #ffe9d2;
  --shadow: 0 1px 2px rgba(90, 55, 20, 0.06), 0 8px 24px rgba(90, 55, 20, 0.07);
  --great: #1b7a3d;
  --good: #347a2c;
  --fair: #8a6d00;
  --high: #a34a0a;       /* darkened from #b45309: chat notices sit on the sky (5.0:1) */
  --overpriced: #b42318;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* A morning sky fading to a warm horizon, then cream */
  background:
    linear-gradient(180deg, var(--sky) 0, var(--horizon) 240px, var(--bg) 480px) no-repeat,
    var(--bg);
  min-height: 100vh;
}

a { color: var(--link); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; border-radius: 6px; }

/* Header */
header.site {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  max-width: 760px;
  margin: 0 auto;
  padding: 1.1rem 1rem 0.5rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand-mark { width: 30px; height: 30px; flex: none; }
.tagline { color: var(--muted); font-size: 0.95rem; }
.site-nav { margin-left: auto; display: flex; flex-wrap: wrap; gap: 0.35rem; font-size: 0.95rem; }
.site-nav a {
  color: var(--text);
  text-decoration: none;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(240, 226, 208, 0.9);
}
.site-nav a:hover { background: var(--card); border-color: var(--sun); }
.site-nav a[aria-current="page"] { background: var(--card); border-color: var(--accent); color: var(--accent); font-weight: 600; }

main { max-width: 760px; margin: 0 auto; padding: 0 1rem 3rem; }

.tagline, .muted, .source, .vin { color: var(--muted); }

h1 { font-size: 2.1rem; line-height: 1.15; letter-spacing: -0.02em; margin: 0.75rem 0 0.5rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }

.hero { padding: 1rem 0 1.25rem; }
.hero p { font-size: 1.05rem; max-width: 40rem; }
.vin code { font-size: 0.95em; }

/* Buttons: one coral pill style everywhere */
.vin-form button, .share button, .chat-actions button[type=submit] {
  padding: 0.7rem 1.4rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(120, 40, 10, 0.18);
  transition: background-color 0.15s ease, transform 0.15s ease;
}
.vin-form button:hover, .share button:hover, .chat-actions button[type=submit]:hover { background: var(--accent-hover); }
.vin-form button:active, .share button:active, .chat-actions button[type=submit]:active { transform: translateY(1px); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.share { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.share input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}
.share button { padding: 0.55rem 1.1rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.15rem 1.3rem;
  margin: 0 0 1rem;
  box-shadow: var(--shadow);
}

.status-unavailable, .status-skipped { opacity: 0.9; }

.note { margin: 0.5rem 0 0; }
.source { font-size: 0.85rem; margin: 0.75rem 0 0; }

.rating { font-size: 1.7rem; font-weight: 800; margin: 0 0 0.5rem; }
.rating-great { color: var(--great); }
.rating-good { color: var(--good); }
.rating-fair { color: var(--fair); }
.rating-high { color: var(--high); }
.rating-overpriced { color: var(--overpriced); }

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.85rem 1rem;
  margin: 0;
}
.facts dt { color: var(--muted); font-size: 0.85rem; }
.facts dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

.assumptions ul, .options { margin: 0; padding-left: 1.2rem; }

details { border-top: 1px solid var(--line); padding: 0.5rem 0; }
details:first-of-type { border-top: 0; }
summary { cursor: pointer; }

.tag {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.05rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--accent-soft);
  color: var(--muted);
}
.tag.warn { color: var(--overpriced); border-color: currentColor; background: var(--card); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }

.disclaimers { color: var(--muted); font-size: 0.9rem; border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1.5rem; }

/* Forms (VIN form, search) */
.vin-form label { display: block; font-weight: 600; margin: 0.85rem 0 0.3rem; }
.vin-form input, .vin-form select, .vin-form textarea, .chat-form textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--field);
  color: var(--text);
  font: inherit;
}
.vin-form textarea, .chat-form textarea { resize: vertical; }
.vin-form input:focus, .vin-form select:focus, .vin-form textarea:focus, .chat-form textarea:focus {
  border-color: var(--link);
  outline: 3px solid rgba(15, 118, 110, 0.18);
  outline-offset: 0;
}
.vin-form #vin { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.05em; font-size: 1.05rem; }
.vin-form [aria-invalid="true"] { border-color: var(--overpriced); }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0 1rem; }
.optional-note { margin: 1.25rem 0 0; }
.field-error, .form-error { color: var(--overpriced); margin: 0.3rem 0 0; font-size: 0.9rem; }
.form-error { font-weight: 600; margin-bottom: 0.5rem; }
.vin-form button { margin-top: 1.25rem; }
.small { font-size: 0.85rem; }

/* Advisor chat */
.chat { display: flex; flex-direction: column; gap: 0.75rem; margin: 1rem 0; }
.chat-starters { display: flex; flex-direction: column; align-items: flex-start; gap: 0.45rem; }
.chat-starters p { margin: 0 0 0.25rem; }
.starter, .chat-actions .secondary {
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 999px;
  padding: 0.45rem 0.95rem; font: inherit; cursor: pointer; text-align: left; box-shadow: var(--shadow);
}
.starter:hover { border-color: var(--sun); background: var(--accent-soft); }
.bubble { border-radius: 18px; padding: 0.8rem 1rem; max-width: 100%; overflow-wrap: anywhere; line-height: 1.55; }
.bubble.user {
  align-self: flex-end; background: var(--accent); color: var(--on-accent); max-width: 85%; white-space: pre-wrap;
  border-bottom-right-radius: 6px;
}
.bubble.advisor { align-self: stretch; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); border-bottom-left-radius: 6px; }
.bubble.notice { align-self: center; color: var(--high); font-size: 0.92rem; }
.bubble p { margin: 0 0 0.6rem; }
.bubble p:last-child, .bubble ul:last-child, .bubble ol:last-child { margin-bottom: 0; }
.bubble h3 { font-size: 1rem; margin: 0.8rem 0 0.3rem; }
.bubble ul, .bubble ol { margin: 0 0 0.6rem; padding-left: 1.3rem; }
.bubble .table-wrap { overflow-x: auto; margin: 0.4rem 0 0.7rem; }
.bubble table { border-collapse: collapse; font-size: 0.92rem; }
.bubble li.sub { margin-left: 1.2rem; list-style-type: circle; }
ol li.sub { list-style-type: lower-alpha; }
.bubble th, .bubble td { border: 1px solid var(--line); padding: 0.3rem 0.5rem; text-align: left; }
.bubble code { font-size: 0.9em; }
.cite {
  font-size: 0.72em; vertical-align: super; text-decoration: none; color: var(--link); font-weight: 600;
  background: #e8f6f4; border-radius: 6px; padding: 0 0.3em; margin-left: 0.1em;
}
.bubble ol.sources {
  list-style: none; padding: 0.6rem 0 0; margin: 0.6rem 0 0; border-top: 1px solid var(--line);
  font-size: 0.85rem; color: var(--muted);
}
.sources .sid { font-weight: 600; margin-right: 0.3rem; }
.sources li:target { background: var(--accent-soft); border-radius: 6px; }
.chat-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-top: 0.6rem; }
.chat-actions button:disabled { opacity: 0.6; cursor: wait; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; } /* a display rule above must never un-hide an element */

/* Listing search */
.search-form [aria-invalid="true"] { border-color: var(--overpriced); }
.search-summary p { margin: 0.25rem 0; }
.listings { list-style: none; padding: 0; margin: 0; }
.listing h2 { font-size: 1.15rem; margin: 0 0 0.6rem; }
.listing-links { display: flex; flex-wrap: wrap; gap: 1rem; margin: 0.85rem 0 0; font-weight: 600; }

/* Feedback (#44) */
.feedback-form textarea {
  width: 100%; padding: 0.6rem 0.8rem; border: 1px solid var(--line); border-radius: 12px;
  background: var(--field); color: var(--text); font: inherit; resize: vertical; margin: 0.3rem 0 0.6rem;
}
.feedback-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.vote {
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 999px;
  padding: 0.4rem 0.9rem; font: inherit; cursor: pointer;
}
.vote:hover { border-color: var(--sun); background: var(--accent-soft); }
.vote:disabled { opacity: 0.6; cursor: default; }
.feedback-done { color: var(--great); font-weight: 600; margin: 0; }
.feedback-error { color: var(--overpriced); }
.answer-feedback {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.7rem; padding-top: 0.6rem;
  border-top: 1px solid var(--line); font-size: 0.88rem; color: var(--muted);
}
.answer-feedback .vote { padding: 0.15rem 0.6rem; }
.feedback-more { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; width: 100%; }
.feedback-more input {
  flex: 1; min-width: 12rem; padding: 0.35rem 0.7rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--field); color: var(--text); font: inherit;
}
.feedback-more button {
  border: 0; border-radius: 999px; background: var(--accent); color: var(--on-accent); padding: 0.35rem 0.9rem;
  font: inherit; font-weight: 700; cursor: pointer;
}

/* Admin dashboard */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.kpi p { margin: 0; }
.kpi-label { color: var(--muted); font-size: 0.85rem; }
.kpi-value { font-size: 1.8rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.meters { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.6rem; }
.meters li { display: grid; grid-template-columns: 11rem 1fr auto; gap: 0.75rem; align-items: center; }
.meter { display: block; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.meter-figure { font-variant-numeric: tabular-nums; }
td.comment { white-space: normal; min-width: 16rem; overflow-wrap: anywhere; }

@media (max-width: 520px) {
  h1 { font-size: 1.7rem; }
  .tagline { display: none; }
  .site-nav { margin-left: 0; width: 100%; }
  .meters li { grid-template-columns: 1fr auto; }
  .meter { grid-column: 1 / -1; grid-row: 2; }
}
