/* Theme A ("soft cards"). Light is the default. Dark follows the visitor's device setting,
   unless they pick one with the switch in the header (stored as data-theme on <html>). */

@font-face {
  font-family: Inter;
  src: url("/static/fonts/inter-latin-var.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Space Grotesk";
  src: url("/static/fonts/space-grotesk-latin-var.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --bg: #F4F7FB;
  --surface: #FFFFFF;
  --ink: #0F1B2D;
  --muted: #4A5A70;
  --border: #D9E1EC;
  --accent: #1B4FA8;
  --accent-soft: #8FB3EA;
  --on-accent: #FFFFFF;
  --track: #E6ECF3;
  --slot-bg: #E9EEF5;
  --slot-border: #7C8CA3;
  --map-stroke: #FFFFFF;
  --map-none: #E3E6EA;
  --map-0: #E6EEF9;
  --map-1: #C5D8F4;
  --map-2: #8FB3EA;
  --map-3: #4C83D9;
  --map-4: #1B4FA8;
  --font-body: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Space Grotesk", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* The dark colours appear twice on purpose: once for "device is dark and no choice made",
   once for "visitor chose dark". Keep the two blocks identical. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1626;
    --surface: #162033;
    --ink: #E8EEF9;
    --muted: #A5B4CB;
    --border: #2A3955;
    --accent: #8FB3EA;
    --accent-soft: #2F5FA8;
    --on-accent: #0E1626;
    --track: #2A3955;
    --slot-bg: #121B2C;
    --slot-border: #6B7FA3;
    --map-stroke: #0E1626;
    --map-none: #232B3A;
    --map-0: #26395C;
    --map-1: #2C4C82;
    --map-2: #2F5FA8;
    --map-3: #5C8FE0;
    --map-4: #A9C8F7;
  }
}

:root[data-theme="dark"] {
  --bg: #0E1626;
  --surface: #162033;
  --ink: #E8EEF9;
  --muted: #A5B4CB;
  --border: #2A3955;
  --accent: #8FB3EA;
  --accent-soft: #2F5FA8;
  --on-accent: #0E1626;
  --track: #2A3955;
  --slot-bg: #121B2C;
  --slot-border: #6B7FA3;
  --map-stroke: #0E1626;
  --map-none: #232B3A;
  --map-0: #26395C;
  --map-1: #2C4C82;
  --map-2: #2F5FA8;
  --map-3: #5C8FE0;
  --map-4: #A9C8F7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--accent); }

main {
  flex: 1 0 auto;
}

.wrap {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
}

.header-row .wordmark {
  margin-right: auto;
}

.theme-toggle {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  color: var(--ink);
  cursor: pointer;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 20px;
  color: var(--ink);
  text-decoration: none;
}

.hero {
  padding: 56px 0;
  text-align: center;
}

.hero h1 {
  margin: 0 auto;
  max-width: 760px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(34px, 6vw, 52px);
  line-height: 1.1;
}

.lede {
  margin: 16px auto 0;
  max-width: 560px;
  color: var(--muted);
  font-size: 18px;
}

.header-link {
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
}

.footer-links {
  display: flex;
  gap: 20px;
}

/* Information pages: about, how it works, privacy. */
.prose {
  max-width: 760px;
  margin: 24px auto !important;
  padding: 32px;
}

.prose h1 {
  margin: 0 0 12px;
  font-family: var(--font-head);
  font-size: clamp(26px, 5vw, 34px);
  line-height: 1.15;
}

.card.prose h2 {
  margin: 28px 0 8px;
}

.card.prose p {
  margin: 0 0 12px;
}

.prose ul {
  margin: 0 0 12px;
  padding-left: 22px;
}

.prose li {
  margin-bottom: 6px;
}

.place-actions {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.place-actions[hidden] {
  display: none;
}

.place-actions button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.place-actions button[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.outcome-buttons {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.outcome-buttons button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.outcome-buttons button:hover {
  background: var(--accent);
  color: var(--on-accent);
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 20px 0;
  color: var(--muted);
  font-size: 14px;
}

.visually-hidden {
  position: absolute;
  left: -9999px;
}

.search-form {
  margin: 28px auto 0;
  max-width: 560px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.suggest-wrap {
  position: relative;
  flex: 1 1 240px;
  min-width: 0;
}

.suggest-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 27, 45, 0.18);
}

.suggest-list a {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 12px;
  padding: 10px 14px;
  color: var(--ink);
  text-decoration: none;
}

.suggest-list a:hover,
.suggest-list li[aria-selected="true"] a {
  background: var(--track);
}

.suggest-label {
  font-weight: 600;
}

.suggest-detail {
  color: var(--muted);
  font-size: 14px;
}

.search-form input {
  width: 100%;
  height: 54px;
  padding: 0 16px;
  border: 1px solid var(--muted);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
}

.search-form button {
  flex: 0 0 auto;
  height: 54px;
  padding: 0 24px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}

.results {
  padding: 8px 0 48px;
}

.results h1 {
  margin: 32px 0 12px;
  font-family: var(--font-head);
  font-size: 24px;
}

.notice {
  margin: 32px auto 0;
  max-width: 560px;
  color: var(--muted);
}

.match-list {
  list-style: none;
  margin: 0;
  padding: 0 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.match-list li {
  border-top: 1px solid var(--border);
}

.match-list a {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 16px;
  padding: 14px 0;
  color: var(--ink);
  text-decoration: none;
}

.match-list a:hover .match-label {
  text-decoration: underline;
}

.match-list li:first-child {
  border-top: 0;
}

.match-label {
  font-weight: 600;
}

.match-detail {
  color: var(--muted);
}

.breadcrumbs {
  padding-top: 16px;
  color: var(--muted);
  font-size: 14px;
}

.breadcrumbs + .result-layout {
  padding-top: 12px;
}

.county-facts p + p {
  margin-top: 10px;
}

.home-about p + p {
  margin-top: 12px;
}

.prose ol {
  margin: 0 0 12px;
  padding-left: 22px;
}

.card.prose h3 {
  margin: 18px 0 4px;
  font-size: 17px;
}

.prose .search-form {
  margin: 20px 0 8px;
}

/* Compact search box in the header of result pages. */
.search-form-compact {
  margin: 0;
  flex: 1 1 280px;
  max-width: 440px;
  flex-wrap: nowrap;
  gap: 8px;
}

.search-form-compact input {
  height: 44px;
  font-size: 16px;
  border-radius: 8px;
}

.search-form-compact button {
  height: 44px;
  padding: 0 18px;
  font-size: 16px;
  border-radius: 8px;
}

/* Result page. */
.muted {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.result-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 24px;
  padding: 24px 0;
}

.result-main {
  flex: 999 1 520px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.result-side {
  flex: 1 1 320px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
}

.card h2 {
  margin: 0 0 12px;
  font-family: var(--font-head);
  font-size: 20px;
}

.card p {
  margin: 0;
}

main > .card {
  margin: 24px 0;
}

.answer-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
}

.place {
  color: var(--muted);
  font-size: 14px;
}

.place strong {
  color: var(--ink);
}

.stale-note {
  margin-top: 10px !important;
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
}

.holiday-note {
  margin-top: 12px !important;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--track);
  font-size: 14px;
}

.answer-head {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 28px;
}

.big-number {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(72px, 16vw, 96px);
  line-height: 1;
  color: var(--accent);
}

.verdict {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  font-size: 14px;
}

.tone-none .verdict,
.tone-low .verdict {
  background: var(--track);
  color: var(--ink);
}

.answer-title {
  margin: 8px 0 4px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(20px, 4vw, 26px);
  line-height: 1.2;
}

.odds {
  margin: 24px 0 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.odds-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.odds dt {
  flex: 0 0 112px;
  font-size: 14px;
}

.odds dd {
  margin: 0;
}

.odds-track {
  flex: 1 1 auto;
  height: 12px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}

.odds-track span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.odds-value {
  flex: 0 0 48px;
  text-align: right;
  font-weight: 700;
}

.reasons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px 24px;
}

.reason-title {
  font-weight: 600;
}

.chart {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 6px;
  align-items: end;
  text-align: center;
}

.chart-col {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
}

.chart-value {
  font-size: 13px;
  font-weight: 600;
}

.chart-bar {
  display: block;
  border-radius: 4px 4px 0 0;
  background: var(--accent-soft);
}

.chart-bar-strong {
  background: var(--accent);
}

.chart-label {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.chart-fact {
  margin-top: 16px !important;
}

.day-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.day-card {
  display: flex;
  flex-direction: column;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.day-card-current {
  border: 2px solid var(--accent);
}

.day-number {
  font-weight: 700;
  font-size: 24px;
}

.day-verdict {
  font-size: 13px;
}

/* State map. Colours step from light to strong with the odds of closure. */
/* Every state's map sits in a box of the same size, whatever the state's shape. The map is
   scaled to fit inside the box and centred: tall states (Vermont) touch the top and bottom,
   wide states (Tennessee) touch the sides. Each map states its own width-to-height ratio. */
.state-map-box {
  --map-box-height: 400px;
  container-type: size;
  height: var(--map-box-height);
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-side .state-map-box {
  --map-box-height: 240px;
}

.state-map {
  position: relative;
  flex: none;
  aspect-ratio: var(--map-ratio, 1.6);
  /* For older browsers: fit by height only. */
  width: min(100%, calc(var(--map-box-height) * var(--map-ratio, 1.6)));
  /* The box's own width and height decide the fit. */
  width: min(100cqw, calc(100cqh * var(--map-ratio, 1.6)));
}

.map-tip {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, calc(-100% - 12px));
  padding: 3px 9px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}

.map-tip[hidden] {
  display: none;
}

.state-map svg {
  display: block;
  width: 100%;
  height: auto;
}

.state-map path {
  stroke: var(--map-stroke);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.state-map a:hover path,
.state-map a:focus path {
  stroke: var(--ink);
}

.map-bin-none { fill: var(--map-none); background: var(--map-none); }
.map-bin-0 { fill: var(--map-0); background: var(--map-0); }
.map-bin-1 { fill: var(--map-1); background: var(--map-1); }
.map-bin-2 { fill: var(--map-2); background: var(--map-2); }
.map-bin-3 { fill: var(--map-3); background: var(--map-3); }
.map-bin-4 { fill: var(--map-4); background: var(--map-4); }

.state-map path.map-selected {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
  pointer-events: none;
}

.map-legend {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--muted);
  font-size: 13px;
}

.map-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.map-legend .map-legend-none {
  margin-left: auto;
}

.map-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.list-heading {
  margin: 20px 0 4px;
  font-size: 15px;
}

.county-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.county-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
  color: var(--ink);
  text-decoration: none;
}

.county-list a > span:first-child {
  text-decoration: underline;
  text-decoration-color: var(--accent);
}

.county-list a .muted {
  display: inline-block;
  text-decoration: none;
}

.county-list strong {
  white-space: nowrap;
}

.county-list-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0 32px;
}

.card-link {
  margin-top: 12px !important;
  font-weight: 600;
}

.home-card {
  margin: 0 0 24px;
}

main > .home-card {
  margin: 0 0 24px;
}

.state-grid {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 2px 16px;
}

.letter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.letter-row[hidden],
.letter-group[hidden] {
  display: none;
}

.letter-row button {
  min-width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.letter-row button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.letter-heading {
  margin: 14px 0 2px;
  color: var(--muted);
  font-size: 14px;
}

/* Once the script has turned the list into a picker, the letter buttons replace the headings. */
.state-picker.is-picker .letter-heading {
  display: none;
}

.state-grid a {
  display: flex;
  align-items: center;
  min-height: 40px;
  color: var(--ink);
}

/* Advertising boxes. Sizes are fixed so the page does not jump when an ad loads. */
.ad-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.ad-label {
  color: var(--muted);
  font-size: 12px;
}

.ad-box {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  border: 1px dashed var(--slot-border);
  background: var(--slot-bg);
  color: var(--muted);
  font-weight: 600;
}

.ad-728x90 .ad-box { width: 728px; height: 90px; }
.ad-300x250 .ad-box { width: 300px; height: 250px; }
.ad-320x50 .ad-box { width: 320px; height: 50px; }

main > .ad-slot {
  margin-bottom: 24px;
}

.mobile-only {
  display: none;
}

span.desktop-only {
  display: inline;
}

.ad-anchor {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 4px 0 6px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.ad-anchor .ad-label {
  display: none;
}

@media (max-width: 760px) {
  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: flex;
  }

  span.mobile-only {
    display: inline;
  }

  span.desktop-only {
    display: none;
  }

  .card {
    padding: 20px;
  }

  .result-layout {
    gap: 16px;
    padding: 16px 0;
  }

  .result-main,
  .result-side {
    gap: 16px;
  }

  .header-link {
    display: none;
  }

  /* On a phone the side card is full width, so both kinds of page use the same map box. */
  .state-map-box,
  .result-side .state-map-box {
    --map-box-height: 300px;
  }

  .prose {
    padding: 20px;
  }

  /* Header: name and theme switch on the first line, search box full width below. */
  .header-row .theme-toggle {
    order: 2;
  }

  .search-form-compact {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }

  /* Room for the fixed bottom ad bar so it never covers the footer. */
  body:has(.ad-anchor) {
    padding-bottom: 64px;
  }
}
