/* Spidey Stories — unofficial fan dashboard. System fonts only; no remote assets. */
:root {
  color-scheme: light dark;
  --bg: #eef1f6;
  --bg-accent: #e3e8f0;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --text: #1a2030;
  --muted: #5a6578;
  --line: #d5dce6;
  --line-strong: #c3ccd8;
  --accent: #2155cc;
  --accent-soft: #e8eefc;
  --accent-text: #153a9a;
  --hero: #2155cc;
  --hero-bg: #e8eefc;
  --villain: #b4232c;
  --villain-bg: #fdecee;
  --switch: #8a5a00;
  --switch-bg: #fff3d6;
  --chart: #2155cc;
  --chart-track: #e6ebf2;
  --shadow: 0 1px 2px rgba(20, 28, 45, 0.06), 0 8px 24px rgba(20, 28, 45, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1218;
    --bg-accent: #151b24;
    --surface: #171d27;
    --surface-2: #1d2430;
    --text: #e8edf5;
    --muted: #9aa6b8;
    --line: #2a3342;
    --line-strong: #3a4658;
    --accent: #7ea0ff;
    --accent-soft: #1c2a4d;
    --accent-text: #c5d4ff;
    --hero: #8fb0ff;
    --hero-bg: #1c2a4d;
    --villain: #ff8b8f;
    --villain-bg: #3a1c20;
    --switch: #f0c36a;
    --switch-bg: #3a2e16;
    --chart: #7ea0ff;
    --chart-track: #2a3342;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.28);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover { text-decoration-thickness: 2px; }

.wrap {
  width: min(1180px, calc(100% - 1.5rem));
  margin: 0 auto;
}

/* Header */
.top {
  padding: 0.85rem 0 0.7rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.top-row, .nav, .controls, .control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.top-row {
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.nav { gap: 0.35rem; }

.nav a {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.nav a:hover { background: var(--accent-soft); color: var(--accent-text); }

.nav a[aria-current="page"] {
  background: var(--accent);
  color: #fff;
}

@media (prefers-color-scheme: dark) {
  .nav a[aria-current="page"] { color: #0e1218; }
}

/* Controls */
.controls-bar {
  padding: 0.7rem 0;
  background: var(--bg);
}

.controls { gap: 0.55rem 0.7rem; }

.control {
  flex-direction: column;
  align-items: stretch;
  gap: 0.2rem;
  min-width: 9.5rem;
  flex: 1 1 9.5rem;
}

.control.search { flex: 2 1 16rem; }

.control label {
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.control select,
.control input[type="search"],
.control input[type="text"] {
  appearance: none;
  width: 100%;
  margin: 0;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}

.control select {
  padding-right: 1.8rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 54%, calc(100% - 9px) 54%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.control select:focus,
.control input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.controls button {
  margin-top: 1.05rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

.controls button:hover { background: var(--accent-soft); color: var(--accent-text); }

/* 16:9 stage */
.stage-frame {
  padding: 0 0 1.25rem;
}

.stage {
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 28rem;
  max-height: min(75vh, 46rem);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  container-type: size;
  container-name: stage;
}

.panel {
  min-height: 100%;
  padding: 1.1rem 1.2rem 1.2rem;
}

.overview {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.overview .charts {
  flex: 1 1 auto;
  align-items: stretch;
}

.overview .chart {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.overview .chart svg {
  flex: 1 1 auto;
  min-height: 10rem;
}

/* Overview */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.7rem;
  margin-bottom: 0.9rem;
}

.metric {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem 0.8rem;
}

.metric .value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.metric .label {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

.charts {
  display: grid;
  grid-template-columns: 0.9fr 1.15fr 1.15fr;
  gap: 0.8rem;
  min-height: 0;
}

.chart {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.75rem 0.6rem;
  min-width: 0;
}

.chart h2 {
  margin: 0 0 0.45rem;
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.chart svg { display: block; width: 100%; height: auto; }

.note {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

/* List */
.list-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.list-head h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.list-head p { margin: 0; color: var(--muted); font-size: 0.85rem; }

.story-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.story-table th,
.story-table td {
  text-align: left;
  padding: 0.42rem 0.5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.story-table th {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  background: var(--surface);
}

.story-table th.num, .story-table td.num { text-align: right; white-space: nowrap; }

.story-table button.title-btn {
  all: unset;
  cursor: pointer;
  color: var(--accent-text);
  font-weight: 650;
  text-align: left;
}

.story-table button.title-btn:hover { text-decoration: underline; }
.story-table button.title-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.story-table tr:hover td { background: var(--accent-soft); }

.empty {
  margin: 1.5rem 0;
  color: var(--muted);
}

/* Detail */
.detail-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.detail h2 {
  margin: 0 0 0.15rem;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.back {
  flex: 0 0 auto;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.back:hover { background: var(--accent-soft); color: var(--accent-text); }

.summary {
  margin: 0.8rem 0 0.9rem;
  font-size: 1rem;
  max-width: 62ch;
}

.cast-block { margin-top: 0.7rem; }

.cast-block h3 {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 650;
}

.pill.hero { background: var(--hero-bg); color: var(--hero); }
.pill.villain { background: var(--villain-bg); color: var(--villain); }
.pill.switch { background: var(--switch-bg); color: var(--switch); }
.pill.theme { background: var(--accent-soft); color: var(--accent-text); }

.warn {
  margin: 0.8rem 0 0;
  padding: 0.65rem 0.75rem;
  border-left: 3px solid var(--switch);
  background: var(--switch-bg);
  color: var(--text);
  font-size: 0.88rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* About page */
.page {
  padding: 1.5rem 0 3rem;
}

.prose {
  max-width: 42rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.6rem 1.7rem 2rem;
}

.prose h1 {
  margin: 0 0 0.4rem;
  font-size: 1.6rem;
  letter-spacing: -0.03em;
}

.prose h2 {
  margin: 1.5rem 0 0.45rem;
  font-size: 1.1rem;
}

.prose p, .prose li { color: var(--text); }

.prose ul { padding-left: 1.2rem; }

.prose .lede {
  color: var(--muted);
  margin-top: 0;
}

.disclaimer {
  margin-top: 1.5rem;
  padding: 0.85rem 0.95rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.themes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0;
  list-style: none;
}

footer {
  padding: 0 0 1.6rem;
  color: var(--muted);
  font-size: 0.78rem;
}

footer p { margin: 0; }

@media (max-width: 800px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .charts { grid-template-columns: 1fr; }
  .stage {
    aspect-ratio: auto;
    max-height: none;
    min-height: 32rem;
  }
  .brand h1 { font-size: 1.05rem; }
  .detail h2 { font-size: 1.25rem; }
  .col-theme { display: none; }
}

@container stage (max-width: 720px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .charts { grid-template-columns: 1fr; }
}

@container stage (max-width: 500px) {
  .col-date, .col-theme { display: none; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric .value { font-size: 1.05rem; }
}
