/* StreamWatch - hand-written, no build step. Colors are tokens so a shared
   hub.css can override them later. Dark by default, light on request. */
:root {
  --bg: #0f1218;
  --surface: #181d26;
  --surface-2: #212836;
  --text: #e8ebf1;
  --muted: #9aa3b2;
  --accent: #5fb3ff;
  --border: #2a3242;
  --high: #2fbf71;
  --mid: #e0b23b;
  --low: #e0654b;
  --radius: 10px;
  --wrap: 1180px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #eef1f5;
    --text: #18202c;
    --muted: #5d6778;
    --accent: #0a6fd6;
    --border: #dde2ea;
    --high: #1e9b57;
    --mid: #b98a12;
    --low: #c64a31;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: .9em; overflow-wrap: anywhere; }
h1 { font-size: 1.7rem; line-height: 1.2; margin: 1.2rem 0 .6rem; }
h2 { font-size: 1.15rem; margin: 1.4rem 0 .5rem; }
.muted { color: var(--muted); }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }

/* header / footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.header-row { display: flex; align-items: center; gap: 18px; min-height: 56px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); letter-spacing: .2px; }
.main-nav { display: flex; gap: 14px; flex-wrap: wrap; }
.main-nav a { color: var(--muted); }
.main-nav a:hover { color: var(--text); }
.search { margin-left: auto; }
.search input, .filters input, .filters select {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font: inherit; min-width: 0;
}
.site-footer { margin-top: 48px; padding: 20px 0 36px; border-top: 1px solid var(--border); color: var(--muted); font-size: .9rem; }

/* home */
.hero p { color: var(--muted); max-width: 70ch; }
.strip-head { display: flex; align-items: baseline; justify-content: space-between; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; color: var(--text); display: flex; flex-direction: column; }
.card:hover { border-color: var(--accent); text-decoration: none; }
.card img { aspect-ratio: 2 / 3; object-fit: cover; width: 100%; }
.no-poster { aspect-ratio: 2 / 3; display: grid; place-items: center; padding: 10px; text-align: center; background: var(--surface-2); color: var(--muted); }
.card-body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 4px; }
.card-title { font-weight: 600; font-size: .95rem; line-height: 1.25; }
.card-meta { color: var(--muted); font-size: .85rem; display: flex; align-items: center; gap: 6px; }
.card-meta .badge { margin-left: auto; }

/* chips + badges */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; font-size: .82rem; color: var(--text); white-space: nowrap; }
a.chip:hover { border-color: var(--accent); text-decoration: none; }
.chip-more, .chip-none { color: var(--muted); }
.badge { display: inline-block; min-width: 2.3em; text-align: center; font-weight: 700; font-size: .85rem; padding: 2px 6px; border-radius: 6px; color: #fff; }
.badge-high { background: var(--high); }
.badge-mid { background: var(--mid); }
.badge-low { background: var(--low); }
.badge-none { background: var(--surface-2); color: var(--muted); }

/* filters + results */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); }
.filters .grow { flex: 1 1 200px; }
.result-count { color: var(--muted); font-size: .9rem; display: flex; flex-wrap: wrap; gap: 8px 16px; }
.share { margin-left: auto; }
.results { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.result { display: grid; grid-template-columns: 2.2em 60px 1fr auto; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; }
.pos { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.thumb img { width: 60px; border-radius: 6px; aspect-ratio: 2 / 3; object-fit: cover; }
.result-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.result-title { font-weight: 600; color: var(--text); font-size: 1.02rem; }
.result-meta { color: var(--muted); font-size: .86rem; }
.result-scores { display: flex; gap: 10px; }
.score-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.score-cell small { color: var(--muted); font-size: .7rem; }
.result-scores.big .badge { font-size: 1.05rem; min-width: 2.8em; padding: 4px 8px; }
.empty { color: var(--muted); padding: 24px 0; }
.htmx-request #results, #results.htmx-request { opacity: .55; transition: opacity .15s; }

/* title page */
.title-page { display: grid; grid-template-columns: 260px 1fr; gap: 28px; margin-top: 18px; }
.title-poster img { border-radius: var(--radius); border: 1px solid var(--border); }
.title-info h1 { margin-top: 0; }
.year { color: var(--muted); font-weight: 400; }
.score-list, .review-links { padding-left: 1.1em; }
/* Rotten Tomatoes badge: fresh (red tomato) / rotten (green splat) */
.tomato { display: inline-flex; align-items: center; gap: 3px; font-size: .8rem; font-weight: 700; white-space: nowrap; vertical-align: middle; }
.tomato svg { width: 1.15em; height: 1.15em; flex: none; }
.tomato.fresh .tomato-value { color: #f0604d; }
.tomato.rotten .tomato-value { color: #8bc34a; }
.tomato.big { flex-direction: column; gap: 2px; }
.tomato.big svg { width: 1.9em; height: 1.9em; }
.tomato.big .tomato-value { font-size: 1rem; }
.tomato.big small { color: var(--muted); font-size: .7rem; font-weight: 400; }
.series-score { margin: 6px 0; }
.review-links li { margin: 4px 0; }
details summary { cursor: pointer; color: var(--muted); }
.prose { max-width: 75ch; }

/* phones */
@media (max-width: 700px) {
  .search { margin-left: 0; flex: 1 1 100%; }
  .search input { width: 100%; }
  .result { grid-template-columns: 44px 1fr; }
  .pos { display: none; }
  .thumb img { width: 44px; }
  .result-scores { grid-column: 1 / -1; justify-content: flex-start; }
  .title-page { grid-template-columns: 1fr; }
  .title-poster img { max-width: 200px; }
  .share { margin-left: 0; }
}

/* ---- v2: browse pager, seasons, heatmap, episodes ---- */
.pager { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 22px 0 6px; }
.pager a, .pager span { min-width: 2.4em; text-align: center; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager .current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.pager span:not(.current) { border-color: transparent; background: none; color: var(--muted); }
.small { font-size: .85rem; }
.version { font-size: .8rem; }
.crumbs { margin-top: 16px; color: var(--muted); font-size: .9rem; }
.season-list { padding-left: 1.1em; }
.season-list li { margin: 3px 0; }
.chip-current { border-color: var(--accent); }
.spoiler-box { margin: 12px 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; }
.spoiler-box p { margin: 8px 0 2px; }
.heatmap-wrap { overflow-x: auto; max-width: 100%; }
.heatmap { border-collapse: separate; border-spacing: 3px; }
.heatmap th { font-size: .8rem; font-weight: 600; padding-right: 6px; text-align: right; white-space: nowrap; }
.heatmap-picker { margin: 8px 0 6px; }
.heatmap-picker select { margin-left: 6px; padding: 4px 8px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.heatmap thead th { padding-right: 0; text-align: center; color: var(--muted); font-weight: 400; }
.heat { display: inline-block; min-width: 2.6em; text-align: center; padding: 3px 4px; border-radius: 5px; font-size: .78rem; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
a.heat:hover { outline: 2px solid var(--text); text-decoration: none; }
.heat.big { font-size: 1.1rem; padding: 5px 10px; }
.heat-none { background: var(--surface-2); color: var(--muted); font-weight: 400; }
.heat-0 { background: #b5483a; }
.heat-1 { background: #c98a2e; }
.heat-2 { background: #a8a831; }
.heat-3 { background: #5ba744; }
.heat-4 { background: #2f9654; }
.heat-5 { background: #1f6fb2; }
.heat-legend { display: flex; gap: 4px; align-items: center; }
.episode-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.episode-row { display: grid; grid-template-columns: 3.2em 1fr auto auto; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; color: var(--text); }
.episode-row:hover { border-color: var(--accent); text-decoration: none; }
.ep-code { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.ep-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.ep-meta { font-size: .85rem; }
.ep-ratings { display: flex; align-items: center; gap: 4px; }
.rate-src { font-size: .7rem; color: var(--muted); margin-left: 4px; }
.episode-page { max-width: 820px; }
.episode-still { border-radius: var(--radius); border: 1px solid var(--border); margin-top: 14px; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.ep-nav { display: flex; justify-content: space-between; gap: 12px; margin: 22px 0 10px; }
@media (max-width: 700px) {
  .episode-row { grid-template-columns: 2.4em 1fr auto; gap: 8px; padding: 8px 10px; }
  .ep-meta { display: none; }
  .ep-ratings .heat { min-width: 2.2em; }
}
/* Grid children default to min-width:auto and grow to fit wide content (a
   28-episode heatmap row stretched phones to 1000px+). Let them shrink so
   .heatmap-wrap scrolls sideways inside its own box instead. */
.title-page > *, .result-main { min-width: 0; }

/* data status page + footer badge */
.sync-badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border: 1px solid var(--border); border-radius: 999px; color: var(--text); }
.sync-badge:hover { border-color: var(--accent); text-decoration: none; }
.sync-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.sync-dot.idle { background: var(--high); }
.sync-dot.building { background: var(--mid); }
.sync-dot.running { background: var(--mid); animation: sync-pulse 1.2s ease-in-out infinite; }
@keyframes sync-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .sync-dot.running { animation: none; } }
.sync-line { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; }
.status-page { max-width: 820px; }
.status-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin: 16px 0; }
.status-card h2 { margin: 0 0 10px; font-size: 1.15rem; }
.step-list { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.step-list li { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); font-size: .9rem; color: var(--muted); }
.step-list li.step-done { color: var(--text); border-color: var(--high); }
.step-list li.step-done::before { content: "✓ "; color: var(--high); }
.step-list li.step-current { color: var(--text); border-color: var(--mid); font-weight: 600; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 10px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.big-number { font-size: 2rem; font-weight: 700; margin: 0 0 8px; }
.big-number .muted { font-size: 1rem; font-weight: 400; }
.bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 4px 0 6px; }
.bar span { display: block; height: 100%; background: var(--accent); }
.status-table { border-collapse: collapse; width: 100%; max-width: 420px; margin-top: 12px; }
.status-table th, .status-table td { padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.status-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.status-errors { margin-top: 10px; padding: 8px 12px; border-left: 3px solid var(--low); background: var(--surface-2); }
.status-errors ul { margin: 4px 0 0; padding-left: 1.2em; }
.activity { margin-top: 10px; }
.activity ul { list-style: none; padding: 0; margin: 6px 0 0; font-size: .85rem; font-family: ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
@media (max-width: 520px) { .facts { grid-template-columns: 1fr; } .facts dd { margin-bottom: 6px; } }
