/* ========================================================================
   Toy Tagger — AML Research Brief
   Editorial aesthetic: Fraunces serif · Bricolage Grotesque · IBM Plex Mono
   Single accent (vermillion). No gradients. Mobile-first.
   ======================================================================== */

:root {
  /* Paper palette */
  --paper:      #f6f2ea;
  --paper-2:    #f0ebdf;
  --surface:    #ffffff;
  --ink:        #161512;
  --ink-2:      #2a2925;
  --muted:      #6b6862;
  --muted-2:    #9d9889;
  --rule:       #d8d0bf;
  --rule-soft:  #eae3d3;

  /* Single accent */
  --accent:      #b6331b;    /* vermillion — editorial warm red */
  --accent-ink:  #8e2411;    /* darker for text on paper       */
  --accent-soft: #f3ddd2;

  /* Semantic (functional, not decorative) */
  --gt:          #1a6030;
  --gt-soft:     #e5eddf;

  /* Elevation — a single scale, never extended ad-hoc */
  --elev-1: 0 1px 2px rgba(20, 16, 10, 0.04);
  --elev-2: 0 2px 12px -2px rgba(20, 16, 10, 0.08), 0 1px 2px rgba(20, 16, 10, 0.04);

  /* Radii — restrained, editorial */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;

  /* Layout */
  --wrap:  1240px;
  --pad-x: clamp(16px, 5vw, 48px);

  /* Type */
  --f-display: "Fraunces", "Iowan Old Style", "Georgia", serif;
  --f-sans:    "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono:    "IBM Plex Mono", ui-monospace, SFMono-Regular, "Menlo", monospace;

  /* z scale — fixed */
  --z-nav:     10;
  --z-sticky:  20;
  --z-dialog:  40;
  --z-toast:   100;
}

/* ---------------- Reset / base ---------------- */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-sans);
  font-size: 16px;          /* iOS min to prevent auto-zoom on focus */
  font-variation-settings: "opsz" 14;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* subtle paper grain — SVG noise */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.086 0 0 0 0 0.082 0 0 0 0 0.07 0 0 0 0.35 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.55'/></svg>");
  background-size: 160px 160px;
  opacity: 0.18;
  mix-blend-mode: multiply;
}

img { max-width: 100%; display: block; }

h1, h2, h3, h4 { margin: 0; }

a {
  color: var(--accent-ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 150ms ease;
}

a:hover { color: var(--ink); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 14px;
  border-radius: var(--r-xs);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  z-index: var(--z-toast);
}

.skip-link:focus {
  left: 16px;
  top: 16px;
}

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding-left: var(--pad-x);
  padding-right: var(--pad-x);
  width: 100%;
}

.rule {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 0;
  width: 100%;
}

.rule-strong { border-top-color: var(--ink); border-top-width: 2px; }

/* ---------------- Masthead ---------------- */

.masthead {
  padding-top: max(14px, env(safe-area-inset-top));
}

.masthead-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  padding-bottom: 12px;
  flex-wrap: wrap;
}

.dateline {
  font-family: var(--f-sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 10px;
}

.dateline .date-sep { color: var(--muted-2); }

.dateline .date-part-wide,
.dateline .date-sep-wide { display: none; }

@media (min-width: 560px) {
  .dateline .date-part-wide,
  .dateline .date-sep-wide { display: inline; }
}

.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;
}

.colophon {
  font-family: var(--f-sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: border-color 150ms ease;
}

.colophon:hover { border-bottom-color: var(--ink); color: var(--ink); }

.colophon span[aria-hidden="true"] {
  color: var(--accent);
  font-size: 10px;
  animation: pulseDot 2s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 70%, 100% { opacity: 1; }
  35%           { opacity: 0.35; }
}

/* ---------------- Hero ---------------- */

/* ---------------- Stat ticker (below masthead, above hero) ---------------- */

.ticker-wrap {
  padding-top: 8px;
  padding-bottom: 10px;
}

.ticker {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 18px;
}

.tick {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.tick dt {
  font-family: var(--f-sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
  white-space: nowrap;
}

.tick dd {
  margin: 0;
  font-family: var(--f-display);
  font-variation-settings: "opsz" 48, "wght" 500;
  font-size: 16px;
  color: var(--ink);
  font-variant-numeric: tabular-nums oldstyle-nums;
  letter-spacing: -0.005em;
  white-space: nowrap;
}

.tick-u {
  font-size: 0.72em;
  font-style: italic;
  color: var(--accent);
  margin-left: 1px;
  font-variation-settings: "opsz" 48, "wght" 500;
}

@media (min-width: 720px) {
  .ticker { grid-template-columns: repeat(4, auto); justify-content: space-between; gap: 0 32px; }
  .tick dd { font-size: 17px; }
}

/* ---------------- Hero ---------------- */

.hero {
  padding-top: clamp(28px, 6vw, 56px);
  padding-bottom: clamp(24px, 4vw, 44px);
}

.hero-inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(18px, 3vw, 32px);
}

@media (min-width: 960px) {
  .hero-inner {
    grid-template-columns: 1.2fr 1fr;
    column-gap: clamp(40px, 5vw, 72px);
    align-items: end;
  }
  .hero-copy { grid-column: 1; }
  .hero .lede { grid-column: 2; margin: 0; max-width: none; }
}

.kicker {
  font-family: var(--f-sans);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin: 0 0 clamp(14px, 2vw, 22px);
}

.hero-title {
  font-family: var(--f-display);
  font-variation-settings: "opsz" 144, "SOFT" 30, "wght" 500;
  font-size: clamp(30px, 8.6vw, 86px);
  font-weight: 500;
  line-height: 1.0;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-wrap: balance;
  overflow-wrap: break-word;
  hyphens: manual;
  margin: 0;
}

.hero-line { display: block; }

.hero-title em {
  font-style: italic;
  font-variation-settings: "opsz" 144, "SOFT" 50, "wght" 500;
  color: var(--accent);
}

.lede {
  font-family: var(--f-display);
  font-variation-settings: "opsz" 48, "wght" 400;
  font-size: clamp(16px, 1.8vw, 21px);
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 64ch;
  margin: clamp(20px, 3vw, 32px) 0 clamp(24px, 3vw, 36px);
  text-wrap: pretty;
  overflow-wrap: break-word;
}

.lede strong {
  color: var(--accent-ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.dropcap {
  font-family: var(--f-display);
  font-variation-settings: "opsz" 144, "wght" 600;
  font-size: clamp(48px, 7vw, 68px);
  float: left;
  line-height: 0.86;
  padding-right: 10px;
  padding-top: 4px;
  color: var(--accent);
}

/* ---------------- Query console (§I pick + §II dispatch together) ---------------- */

.console {
  padding-top: clamp(22px, 4vw, 40px);
  padding-bottom: clamp(22px, 4vw, 40px);
}

.console-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(24px, 3vw, 36px);
}

@media (min-width: 960px) {
  .console-grid {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.75fr);
    column-gap: clamp(32px, 4vw, 56px);
  }
  .console-col-dispatch { border-left: 1px solid var(--rule); padding-left: clamp(24px, 3vw, 40px); }
}

.console-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.results-section { padding-top: clamp(22px, 4vw, 36px); padding-bottom: clamp(40px, 5vw, 64px); }

/* ---------------- Section scaffolding ---------------- */

.section-head {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-items: baseline;
  column-gap: 12px;
  row-gap: 4px;
  margin-bottom: clamp(12px, 1.6vw, 16px);
}

.section-kicker {
  font-family: var(--f-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-ink);
  grid-column: 1 / -1;
  margin: 0;
}

.section-title {
  font-family: var(--f-display);
  font-variation-settings: "opsz" 72, "wght" 500;
  font-size: clamp(24px, 3.2vw, 34px);
  line-height: 1.1;
  color: var(--ink);
  letter-spacing: -0.01em;
  grid-column: 1;
  text-wrap: balance;
}

.section-note {
  font-family: var(--f-display);
  font-variation-settings: "opsz" 18, "wght" 400;
  font-style: italic;
  font-size: 15px;
  color: var(--muted);
  grid-column: 1 / -1;
  margin: 0;
  max-width: 60ch;
  line-height: 1.5;
  text-wrap: pretty;
}

/* ---------------- Chips ---------------- */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  cursor: pointer;
  font-family: var(--f-sans);
  font-size: 14px;
  font-weight: 500;
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-xs);
  padding: 10px 14px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.chip:hover { border-color: var(--ink); color: var(--ink); }

.chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chip[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.chip[aria-pressed="true"] .chip-p { color: var(--paper-2); }

.chip-q {
  font-family: var(--f-display);
  font-variation-settings: "opsz" 24, "wght" 500;
  font-size: 15px;
  letter-spacing: -0.005em;
}

.chip-p {
  font-family: var(--f-mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.select-fallback {
  display: none;
  align-items: center;
  gap: 10px;
  font-family: var(--f-sans);
  font-size: 13px;
  color: var(--muted);
  padding-top: 4px;
}

.select-fallback span { white-space: nowrap; font-weight: 500; }

.select-fallback select {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-family: var(--f-sans);
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-xs);
  padding: 8px 28px 8px 10px;
  color: var(--ink);
  min-height: 36px;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-2) 50%),
    linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: right 13px top 50%, right 8px top 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

/* ---------------- Metric (Dispatch) ---------------- */

.metric {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--rule);
}

.metric .cell {
  padding: 14px 0;
  border-bottom: 1px solid var(--rule-soft);
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr;
  align-items: baseline;
  gap: 12px;
}

.metric .cell:last-child { border-bottom: none; }

.metric .cell dt {
  font-family: var(--f-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.metric .cell dd {
  margin: 0;
  font-family: var(--f-display);
  font-variation-settings: "opsz" 48, "wght" 500;
  font-size: clamp(20px, 2.6vw, 26px);
  color: var(--ink);
  font-variant-numeric: tabular-nums oldstyle-nums;
  letter-spacing: -0.005em;
  line-height: 1.15;
  word-break: break-word;
}

.metric .cell dd small {
  font-family: var(--f-display);
  font-variation-settings: "opsz" 18, "wght" 400;
  font-style: italic;
  font-size: 0.66em;
  color: var(--muted);
  margin-left: 6px;
}

.metric .tag-line {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-ink);
  line-height: 1.4;
}

.metric .tag-line span {
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 2px;
}

/* ---------------- Results grid ---------------- */

.grid {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(18px, 2vw, 28px) clamp(14px, 1.5vw, 20px);
}

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-xs);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--elev-1);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
  animation: cardIn 260ms ease backwards;
  position: relative;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--elev-2);
}

.card.gt { border-color: var(--gt); }

.card.gt::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--gt);
  pointer-events: none;
  opacity: 0.4;
}

.thumb-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--paper-2);
  overflow: hidden;
  border-bottom: 1px solid var(--rule-soft);
}

.thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--surface);
  transition: transform 300ms ease;
}

.card:hover .thumb { transform: scale(1.035); }

.rank {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--surface);
  border: 1px solid var(--ink);
  color: var(--ink);
  font-family: var(--f-display);
  font-variation-settings: "opsz" 24, "wght" 500;
  font-size: 13px;
  padding: 2px 8px 3px;
  border-radius: 2px;
  font-variant-numeric: oldstyle-nums;
  letter-spacing: 0.02em;
}

.gt-ribbon {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--gt);
  color: #fff;
  font-family: var(--f-sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 2px;
}

.body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.title {
  font-family: var(--f-display);
  font-variation-settings: "opsz" 18, "wght" 500;
  font-size: 14.5px;
  line-height: 1.3;
  color: var(--ink);
  letter-spacing: -0.005em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-wrap: pretty;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag {
  font-family: var(--f-mono);
  font-size: 10.5px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0;
  padding: 0;
  background: transparent;
  white-space: nowrap;
}

.tag::before { content: "#"; opacity: 0.45; }

.card-foot {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px dotted var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.score {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.score strong {
  color: var(--ink);
  font-weight: 500;
}

.verdict {
  font-family: var(--f-display);
  font-variation-settings: "opsz" 14, "wght" 500;
  font-style: italic;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.verdict.gt { color: var(--gt); font-style: italic; }

/* ---------------- Footer ---------------- */

.site-footer { margin-top: clamp(24px, 4vw, 48px); }

.footer-inner {
  padding-top: 20px;
  padding-bottom: max(36px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-title {
  font-family: var(--f-display);
  font-variation-settings: "opsz" 96, "wght" 500;
  font-size: 22px;
  margin: 0;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.footer-title em {
  font-style: italic;
  color: var(--accent);
  font-variation-settings: "opsz" 96, "SOFT" 50, "wght" 500;
}

.footer-body {
  font-family: var(--f-sans);
  font-size: 13px;
  color: var(--ink-2);
  margin: 0;
  max-width: 70ch;
}

.footer-note {
  font-family: var(--f-display);
  font-variation-settings: "opsz" 14, "wght" 400;
  font-style: italic;
  font-size: 12.5px;
  color: var(--muted);
  margin: 4px 0 0;
  max-width: 75ch;
  text-wrap: pretty;
}

/* ---------------- Responsive ---------------- */

@media (min-width: 480px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 960px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  /* Only the wide "findings" section gets the inline-kicker treatment,
     so §I / §II inside the narrow console keep their compact stacked form. */
  .section-head-wide {
    grid-template-columns: auto 1fr;
    column-gap: 28px;
  }
  .section-head-wide .section-kicker {
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: start;
    padding-top: 9px;
    border-right: 1px solid var(--rule);
    padding-right: 14px;
  }
  .section-head-wide .section-title { grid-column: 2; }
  .section-head-wide .section-note  { grid-column: 2; }
}

@media (min-width: 1200px) {
  .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (hover: none) {
  .card:hover { transform: none; box-shadow: var(--elev-1); }
  .card:hover .thumb { transform: none; }
  .chip:hover { border-color: var(--rule); color: var(--ink-2); }
  .colophon:hover { border-bottom-color: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  body::before { display: none; }
  .colophon, .chip-row, .select-fallback { display: none; }
  .site-footer { page-break-inside: avoid; }
}
