/* Archive Watch — web viewer (PARITY: the zero-install reach play).
   Mobile-first; every media query is min-width. Dark theater canvas with the
   shared brand chrome (marquee orange primary). Density from removing chrome. */

:root {
  --color-primary: #FF5C35;   /* marquee orange — chrome/CTA only */
  --color-accent:  #0047FF;   /* links, interactive */
  --bg:        #0A0A0A;
  --bg-raise:  #161616;
  --text:      #F2F2F2;
  --text-dim:  #9A9A9A;
  --border:    #2A2A2A;
  --radius: 10px;
  --pad: 16px;
}

* { box-sizing: border-box; }

/* Safari layout rule: flex column body, scrolling main, no fixed overlays. */
body {
  margin: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

main {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding-bottom: 32px;
}

h1 { font-size: 1.5rem; margin: 16px var(--pad) 8px; }
h2 { font-size: 1.1rem; margin: 20px var(--pad) 8px; }
a { color: var(--color-accent); }
.muted { color: var(--text-dim); font-size: 0.9rem; margin: 4px var(--pad); }
.error {
  background: #3a1410; color: #ffb4a4; border: 1px solid #62221a;
  border-radius: var(--radius); padding: 10px 14px; margin: 12px var(--pad);
}
.boot { color: var(--text-dim); text-align: center; padding: 48px 16px; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px var(--pad);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.brand {
  color: var(--text); text-decoration: none; font-weight: 800;
  letter-spacing: 0.2px; white-space: nowrap;
  display: flex; align-items: center; gap: 10px;
}
.brand-logo { border-radius: 6px; display: block; }
.topnav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; }
.topnav a {
  color: var(--text-dim); text-decoration: none; font-weight: 600;
  font-size: 0.95rem; padding: 6px 10px; border-radius: 999px;
}
.topnav a[aria-current="true"] { color: #fff; background: var(--bg-raise); }

/* Footer reads as quiet chrome, not a stray hyperlink: centered, dim,
   brand-marked; links inherit the dim tone instead of accent blue. */
.foot {
  border-top: 1px solid var(--border);
  padding: 10px var(--pad); font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--text-dim);
}
.foot img { border-radius: 4px; opacity: 0.85; }
.foot a {
  color: var(--text-dim); text-decoration: none; font-weight: 600;
}
.foot a:hover { color: var(--text); }

/* ---- "Marquee" hero (WEB-DESIGN §4.1) ----
   A native scroll-snap carousel. Every dimension is a clamp() in container-
   query units, so the composition scales CONTINUOUSLY with the window — no
   breakpoint jumps. Each slide = ambient blurred-poster atmosphere (never a
   hard crop of key art) + the sharp 2:3 poster + an editorial text block.
   The serif display title is the web twin of the apps' serif headers —
   system serif stack only (§6.2: no webfonts). */
.hero {
  container-type: inline-size;
  position: relative; margin: 0 0 10px;
}
.hero-rail {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.hero-rail::-webkit-scrollbar { display: none; }

.hero-slide {
  position: relative;
  flex: 0 0 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
  display: flex; align-items: center;
  gap: clamp(14px, 4cqi, 40px);
  padding: clamp(16px, 4.5cqi, 48px) clamp(16px, 5cqi, 56px);
  min-height: min(clamp(220px, 52cqi, 460px), 62dvh);
  background: var(--bg-raise);
  cursor: pointer;
}

/* Ambient layer: the poster as atmosphere — blurred past recognition of its
   crop, darkened toward the canvas, slowly breathing. */
.hero-ambient {
  position: absolute; inset: -24px;            /* hide blur edge bleed */
  background-size: cover; background-position: center 30%;
  filter: blur(28px) saturate(1.1) brightness(0.45);
  transform: scale(1.05);
}
@media (prefers-reduced-motion: no-preference) {
  .hero-ambient { animation: hero-breathe 16s ease-in-out infinite alternate; }
}
@keyframes hero-breathe {
  from { transform: scale(1.05); }
  to   { transform: scale(1.16) translateY(-1.5%); }
}
.hero-slide::after {                            /* canvas-edge vignette */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10,10,10,0.25), transparent 30%,
              transparent 65%, rgba(10,10,10,0.8));
  pointer-events: none;
}

.hero-poster {
  position: relative; z-index: 1;
  width: clamp(92px, 26cqi, 230px);
  aspect-ratio: 2 / 3; object-fit: cover; flex: none;
  border-radius: clamp(8px, 1.4cqi, 14px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 clamp(8px, 2cqi, 22px) clamp(20px, 5cqi, 52px) rgba(0, 0, 0, 0.55);
}

.hero-copy { position: relative; z-index: 1; min-width: 0; }
.hero-eyebrow {
  margin: 0 0 clamp(4px, 0.8cqi, 10px);
  font-size: clamp(0.62rem, 1.5cqi, 0.8rem);
  font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--color-primary);
}
.hero-title {
  margin: 0;
  font-family: "Iowan Old Style", Palatino, Georgia, "Times New Roman", serif;
  font-weight: 800;
  font-size: clamp(1.3rem, 5.2cqi, 3.1rem);
  line-height: 1.08;
  text-wrap: balance;
  overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.6);
}
.hero-meta {
  margin: clamp(6px, 1cqi, 12px) 0 0;
  font-size: clamp(0.78rem, 1.8cqi, 0.95rem);
  color: rgba(255, 255, 255, 0.72);
}
.hero-cta {
  display: inline-block; margin-top: clamp(10px, 2.2cqi, 22px);
  padding: clamp(7px, 1.4cqi, 11px) clamp(16px, 3cqi, 26px);
  background: var(--color-primary); color: #fff; border: 0;
  border-radius: 999px; font-weight: 700;
  font-size: clamp(0.82rem, 1.8cqi, 1rem);
}

/* Dots: real buttons, synced from scroll position. */
.hero-dots {
  position: absolute; z-index: 2; inset: auto 0 clamp(8px, 1.6cqi, 16px) 0;
  display: flex; justify-content: center; gap: 10px;
  pointer-events: none;
}
.hero-dots button {
  pointer-events: auto;
  width: 7px; height: 7px; padding: 0; border: 0; border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  transition: width 0.25s ease, background 0.25s ease;
}
.hero-dots button[aria-selected="true"] {
  width: 22px; background: var(--color-primary);
}

/* ---- shelves ---- */
.shelf { margin: 14px 0; }
.shelf-row {
  display: flex; gap: 12px; overflow-x: auto;
  padding: 6px var(--pad);
  scroll-padding-inline: var(--pad);   /* snap respects the inset (#4) */
  scroll-snap-type: x proximity; scrollbar-width: none;
}
.shelf-row::-webkit-scrollbar { display: none; }
.shelf-row .card { flex: 0 0 116px; scroll-snap-align: start; }

/* ---- cards + grid ---- */
.grid {
  display: grid; gap: 14px; padding: 10px var(--pad);
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
}
.card { text-decoration: none; color: var(--text); display: block; }
.card img {
  width: 100%; aspect-ratio: 2 / 3; object-fit: cover; display: block;
  border-radius: var(--radius); background: var(--bg-raise);
  border: 1px solid var(--border);
}
.card .t {
  display: block; font-size: 0.8rem; line-height: 1.25; margin-top: 6px;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.card .y { color: var(--text-dim); font-size: 0.75rem; }

/* Typographic placeholder card (no fetchable art): serif title on the raised
   canvas with the type's semantic accent bar (Decision 013). */
.card-ph {
  width: 100%; aspect-ratio: 2 / 3; border-radius: var(--radius);
  background: var(--bg-raise); border: 1px solid var(--border);
  position: relative; overflow: hidden;
  display: flex; align-items: flex-end; padding: 10px;
}
.card-ph::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: var(--ph-accent, #555);
}
.card-ph span {
  font-family: "Iowan Old Style", Palatino, Georgia, "Times New Roman", serif;
  font-weight: 800; font-size: 0.92rem; line-height: 1.2;
  overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 6; -webkit-box-orient: vertical;
}

.sentinel { height: 1px; }

/* ---- chips + controls ---- */
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px var(--pad);
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: 0 0 auto; border: 1px solid var(--border); background: var(--bg-raise);
  color: var(--text); border-radius: 999px; padding: 6px 14px;
  font-size: 0.9rem; font-weight: 600;
}
.chips button[aria-pressed="true"] {
  background: var(--color-primary); border-color: var(--color-primary); color: #fff;
}
.browse-controls {
  display: flex; gap: 10px; align-items: center; padding: 8px var(--pad);
}
select, input[type="search"] {
  background: var(--bg-raise); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 1rem;
}
input[type="search"] {
  display: block; width: calc(100% - var(--pad) * 2); margin: 4px var(--pad);
}

/* ---- detail ---- */
.detail { padding: var(--pad); }
.detail-art img {
  width: min(46vw, 220px); aspect-ratio: 2 / 3; object-fit: cover;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg-raise); display: block; margin: 0 auto;
}
.detail-body h1 { margin: 14px 0 2px; padding: 0; }
.detail-body .muted { margin: 0 0 12px; padding: 0; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.btn-primary {
  background: var(--color-primary); color: #fff; border: 0;
  border-radius: 999px; padding: 10px 22px; font-size: 1rem; font-weight: 700;
}
.btn-primary:disabled { opacity: 0.45; }
.btn-ghost {
  background: var(--bg-raise); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 10px 16px; font-size: 0.95rem; font-weight: 600;
  text-decoration: none; display: inline-block;
}
.btn-ghost[aria-pressed="true"] { border-color: var(--color-primary); color: var(--color-primary); }
#item-desc { padding: 0; margin: 8px 0; color: #d9d9d9; }

/* ---- series episodes ---- */
.episodes { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.episode {
  display: flex; gap: 12px; align-items: center; text-align: left;
  background: var(--bg-raise); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px; color: var(--text);
  width: 100%;
}
.episode img {
  width: 124px; aspect-ratio: 16 / 9; object-fit: cover; flex: none;
  border-radius: 7px; background: #000;
}
.episode .ep-n { color: var(--text-dim); font-size: 0.75rem; display: block; }
.episode .ep-t { font-weight: 600; font-size: 0.9rem; display: block; }
.episode .ep-o {
  color: var(--text-dim); font-size: 0.8rem; margin-top: 2px;
  overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.episode .ep-resume { color: var(--color-primary); font-size: 0.72rem; font-weight: 700; }

/* ---- cast & crew bubbles ---- */
.cast-row {
  display: flex; gap: 16px; overflow-x: auto; padding: 12px 2px 4px;
  scrollbar-width: none;
}
.cast-row::-webkit-scrollbar { display: none; }
.person { flex: 0 0 76px; margin: 0; text-align: center; }
.person img, .person-initial {
  width: 64px; height: 64px; border-radius: 999px; object-fit: cover;
  margin: 0 auto; display: block;
  background: var(--bg-raise); border: 1px solid var(--border);
}
.person-initial {
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.3rem; color: var(--text-dim);
}
.person figcaption {
  font-size: 0.72rem; line-height: 1.25; margin-top: 6px;
  overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.person figcaption span {
  display: block; color: var(--text-dim); font-size: 0.66rem;
  text-transform: uppercase; letter-spacing: 0.08em;
}

/* ---- about & attribution (WEB-DESIGN §6.1/§6.2, §8.1) ----
   Same raised-card vocabulary as episodes/buttons; ✕ + Back close it. */
.about { padding: var(--pad); max-width: 680px; margin: 0 auto; }
.about-head { display: flex; align-items: center; justify-content: space-between; }
.about-head h1 { margin: 0; }
.about-close {
  flex: none; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-raise); border: 1px solid var(--border);
  border-radius: 999px; color: var(--text); text-decoration: none;
  font-size: 0.95rem;
}
.about-close:hover { border-color: var(--text-dim); }
.about-brand {
  display: flex; align-items: center; gap: 12px; margin: 18px 0 4px;
}
.about-brand img { border-radius: 8px; display: block; }
.about-brand strong { display: block; font-size: 1.05rem; }
.about-brand span { color: var(--text-dim); font-size: 0.85rem; }
.about-lede { color: #d9d9d9; margin: 12px 0 18px; }
.about-card {
  background: var(--bg-raise); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin: 14px 0;
}
.about-card h2 { margin: 0 0 8px; }
.about-card p { margin: 8px 0; color: #d9d9d9; font-size: 0.95rem; }
.about-notice { font-weight: 600; color: var(--text); }
.about-donate {
  display: inline-block; margin-top: 6px; text-decoration: none;
  font-size: 0.95rem; padding: 10px 18px;
}
.about-foot { margin: 18px 0 8px; padding: 0; line-height: 1.8; }
.about-foot a { color: var(--text-dim); font-weight: 600; }
.about-foot a:hover { color: var(--text); }
.about-back { margin-top: 4px; }

/* ---- share menu ---- */
dialog.sharemenu {
  background: var(--bg-raise); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; width: min(92vw, 340px);
}
dialog.sharemenu::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog.sharemenu button {
  display: block; width: 100%; margin: 8px 0; text-align: center;
}

/* ---- player ---- */
dialog#player {
  background: #000; color: var(--text); border: 0; border-radius: 12px;
  padding: 0; width: min(96vw, 1100px);
}
dialog#player::backdrop { background: rgba(0, 0, 0, 0.85); }
.player-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; font-weight: 600;
}
.player-head button {
  background: none; border: 0; color: var(--text); font-size: 1.1rem; padding: 4px 8px;
}
#video { width: 100%; aspect-ratio: 16 / 9; display: block; background: #000; }

/* ---- larger screens ---- */
@media (min-width: 700px) {
  :root { --pad: 28px; }
  h1 { font-size: 1.9rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .shelf-row .card { flex-basis: 148px; }
  .detail { display: grid; grid-template-columns: 230px 1fr; gap: 26px; }
  .detail-art img { width: 100%; margin: 0; }
  .detail-body h1 { margin-top: 0; }
}
@media (min-width: 1100px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
