/* =========================================================================
   The comic: the reader pages and the /comic/ hub.
   Same room as the rest of netizen.hamcodes.com: ground #0d0b14, one red,
   Sora / Plus Jakarta Sans / IBM Plex Mono. The fonts are served from
   /comic/fonts so these pages make no request to any other domain.
   The hub also loads /styles.css; the reader loads only this file.
   ========================================================================= */

@font-face { font-family: "Sora"; font-weight: 600; font-style: normal; font-display: swap; src: url("/comic/fonts/sora-600.woff2") format("woff2"); }
@font-face { font-family: "Sora"; font-weight: 700; font-style: normal; font-display: swap; src: url("/comic/fonts/sora-700.woff2") format("woff2"); }
@font-face { font-family: "Sora"; font-weight: 800; font-style: normal; font-display: swap; src: url("/comic/fonts/sora-800.woff2") format("woff2"); }
@font-face { font-family: "Plus Jakarta Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("/comic/fonts/jakarta-400.woff2") format("woff2"); }
@font-face { font-family: "Plus Jakarta Sans"; font-weight: 700; font-style: normal; font-display: swap; src: url("/comic/fonts/jakarta-700.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-style: normal; font-display: swap; src: url("/comic/fonts/plexmono-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-style: normal; font-display: swap; src: url("/comic/fonts/plexmono-500.woff2") format("woff2"); }

:root {
  --ink-0: #0d0b14;
  --ink-1: #15111e;
  --ink-2: #1b1626;
  --red: #f05254;
  --red-2: #ff6f71;
  --paper: #f3f1f9;
  --body: #afaac4;
  --muted: #6e6a7c;
  --line: rgba(243, 241, 249, .10);
  --line-lit: rgba(240, 82, 84, .30);
  --display: "Sora", system-ui, -apple-system, sans-serif;
  --text: "Plus Jakarta Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace;
  --rd-h: 56px;
  color-scheme: dark;
}

/* =========================================================================
   The reader
   ========================================================================= */
body.reader {
  margin: 0;
  background: var(--ink-0);
  color: var(--body);
  font-family: var(--text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
body.reader * { box-sizing: border-box; }
body.reader a { color: var(--paper); }
body.reader :focus-visible { outline: 3px solid var(--paper); outline-offset: 3px; border-radius: 4px; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--paper); color: var(--ink-0) !important; padding: 10px 16px; border-radius: 8px;
  font-family: var(--mono); font-size: 12px; text-decoration: none;
}
.skip:focus { top: 12px; }

/* progress */
.rd-progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 60; background: rgba(243, 241, 249, .08); pointer-events: none; }
.rd-progress i { display: block; height: 100%; background: var(--accent, var(--red)); transform: scaleX(0); transform-origin: left; }

/* header */
.rd-bar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px;
  min-height: var(--rd-h); padding: 9px 16px;
  background: rgba(13, 11, 20, .94);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  transition: transform .25s ease;
}
.rd-bar.is-hidden { transform: translateY(-100%); }
.rd-series {
  font-family: var(--mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  text-decoration: none; color: var(--paper); opacity: .85;
}
.rd-series:hover { opacity: .5; }
.rd-ep { font-family: var(--display); font-weight: 700; font-size: 15px; color: var(--paper); letter-spacing: -.01em; }
.rd-ep b { font-family: var(--mono); font-weight: 500; font-size: 12px; letter-spacing: .16em; color: var(--accent, var(--red)); margin-right: .35em; }
.rd-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.seg { display: inline-flex; border: 1px solid rgba(243, 241, 249, .24); border-radius: 999px; overflow: hidden; }
.seg[hidden] { display: none; }
.seg button, .rd-text {
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--paper); background: transparent; border: 0; cursor: pointer;
  padding: 10px 14px; min-height: 40px;
}
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink-0); }
.rd-text { border: 1px solid rgba(243, 241, 249, .24); border-radius: 999px; }
.rd-text[aria-pressed="true"] { background: var(--paper); color: var(--ink-0); }
.seg button:hover:not([aria-pressed="true"]), .rd-text:hover:not([aria-pressed="true"]) { background: rgba(243, 241, 249, .08); }

main#story { outline: none; }

/* the three views: scroll, pages, text. Without JS only the scroll view and the
   end card show, which is a complete way to read the episode. */
.pv, .tx { display: none; }
html[data-mode="pages"] .sv { display: none; }
html[data-mode="pages"] .pv { display: flex; }
html[data-view="text"] .sv, html[data-view="text"] .pv { display: none; }
html[data-view="text"] .tx { display: block; }
html[data-mode="pages"] .end { display: none; }
html[data-mode="pages"][data-end] .end { display: block; }
html[data-mode="pages"][data-end] .pv { display: none; }
html[data-mode="pages"][data-view="text"] .end { display: block; }

/* ---- scroll mode ---- */
.sv { max-width: 800px; margin: 0 auto; padding: 0; }
.sv img { display: block; width: 100%; height: auto; margin-top: 22px; background: var(--ink-1); }
.sv img:first-child { margin-top: 0; }
.sv img.pg { margin-top: 48px; }
.sv .game-call { margin-top: 22px; }

.game-call {
  margin: 22px auto 0; padding: 18px 20px; max-width: 520px; text-align: center;
  background: var(--ink-1); border: 1px solid var(--line); border-radius: 12px;
}
.game-call p { margin: 0 0 14px; font-size: 14px; }

/* buttons */
.rbtn {
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase;
  text-decoration: none; padding: 16px 26px; min-height: 48px; border-radius: 999px; border: 1px solid transparent;
  cursor: pointer; line-height: 1.2;
}
body.reader .rbtn-primary { background: var(--red); color: #1a0708; }
body.reader .rbtn-primary:hover { background: var(--red-2); }
body.reader .rbtn-ghost { color: var(--paper); border-color: rgba(243, 241, 249, .3); }
body.reader .rbtn-ghost:hover { border-color: var(--paper); }

/* ---- pages mode ---- */
.pv { flex-direction: column; align-items: center; min-height: calc(100vh - var(--rd-h)); min-height: calc(100dvh - var(--rd-h)); }
.pv-stage {
  position: relative; flex: 1 1 auto; width: 100%; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 14px 76px; cursor: pointer;
  container-type: size; height: calc(100vh - var(--rd-h) - 64px); height: calc(100dvh - var(--rd-h) - 64px);
}
.pv-spread { display: flex; align-items: center; justify-content: center; --n: 2; }
.pv-page { position: relative; line-height: 0; }
.pv-page img {
  display: block; width: auto; height: 70vh; /* fallback for browsers without container units */
  height: min(calc(100cqh - 28px), calc((100cqw - 152px) / (var(--n) * .7075)));
  background: var(--ink-1);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .9);
}
.pv-zoom {
  position: absolute; right: 10px; bottom: 10px; opacity: 0;
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--paper); background: rgba(13, 11, 20, .86); border: 1px solid rgba(243, 241, 249, .3);
  border-radius: 999px; padding: 9px 13px; cursor: pointer; line-height: 1;
}
.pv-page:hover .pv-zoom, .pv-zoom:focus-visible { opacity: 1; }
.pv-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 52px; height: 52px; border-radius: 50%;
  font-size: 32px; line-height: 1; padding: 0 0 4px;
  color: var(--paper); background: rgba(21, 17, 30, .92); border: 1px solid rgba(243, 241, 249, .3); cursor: pointer;
}
.pv-prev { left: 12px; }
.pv-next { right: 12px; }
.pv-nav:hover:not(:disabled) { border-color: var(--paper); }
.pv-nav:disabled { opacity: .3; cursor: default; }
.pv-foot {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 26px;
  min-height: 64px; padding: 8px 16px; width: 100%;
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--body);
}
.pv-single { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 40px; }
.pv-single input { width: 18px; height: 18px; accent-color: var(--red); }
.pv-keys { color: var(--muted); }
.pv-game { display: inline-flex; align-items: center; gap: 14px; text-transform: none; letter-spacing: 0; font-family: var(--text); font-size: 13px; }
.pv-game[hidden] { display: none; }
.pv-game .rbtn { min-height: 40px; padding: 11px 20px; font-size: 11px; }
.pv:has(.pv-game:not([hidden])) .pv-keys { display: none; }

dialog.zoom {
  padding: 0; border: 0; background: var(--ink-0); color: var(--paper);
  width: 100vw; max-width: 100vw; height: 100vh; height: 100dvh; max-height: none; overflow: auto;
}
dialog.zoom::backdrop { background: rgba(0, 0, 0, .9); }
dialog.zoom img { display: block; width: min(1132px, 100%); height: auto; margin: 0 auto; }
.zoom-x {
  position: fixed; top: 14px; right: 14px; z-index: 2;
  font-family: var(--mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-0); background: var(--paper); border: 0; border-radius: 999px; padding: 12px 18px; cursor: pointer;
}

/* ---- text mode ---- */
.tx { max-width: 68ch; margin: 0 auto; padding: 28px 18px 8px; }
.tx h2 { font-family: var(--display); font-weight: 700; font-size: 26px; line-height: 1.15; letter-spacing: -.02em; color: var(--paper); margin: 0 0 .4em; }
.tx-note { color: var(--muted); font-size: 14px; margin: 0 0 1.6em; }
.tx-page { padding: 18px 0; border-top: 1px solid var(--line); }
.tx-page h3 { font-family: var(--mono); font-weight: 500; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--accent, var(--red)); margin: 0 0 .7em; }
.tx-page p { margin: 0 0 .5em; }
.answers { margin-top: 12px; padding: 12px 14px; background: var(--ink-1); border: 1px solid var(--line); border-radius: 10px; }
.answers summary { cursor: pointer; font-family: var(--mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--paper); min-height: 32px; }
.answers p { margin: .7em 0 0; }

/* ---- the end card ---- */
.end { max-width: 620px; margin: 0 auto; padding: 64px 20px 72px; text-align: center; outline: none; }
.end-k { font-family: var(--mono); font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--accent, var(--red)); margin: 0 0 10px; }
.end h2 { font-family: var(--display); font-weight: 800; font-size: clamp(30px, 8vw, 44px); line-height: 1.05; letter-spacing: -.03em; color: var(--paper); margin: 0 0 14px; }
.end-lead { max-width: 44ch; margin: 0 auto 28px; font-size: 17px; }
.end-btns { display: flex; flex-direction: column; align-items: stretch; gap: 12px; max-width: 360px; margin: 0 auto; }
.end-soon { margin: 0; padding: 14px; font-family: var(--mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); border: 1px dashed var(--line); border-radius: 999px; }
.end-home { margin: 44px auto 0; padding-top: 26px; border-top: 1px solid var(--line); }
.end-home h3 { font-family: var(--mono); font-weight: 500; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.end-home ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; align-items: center; }
body.reader .end-buy { font-size: 14px; color: var(--body); text-underline-offset: 3px; display: inline-block; padding: 8px 4px; }
.end-buy .px { font-family: var(--mono); color: var(--paper); margin-left: .4em; }
.end-all { margin: 26px 0 0; font-family: var(--mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }

@media (min-width: 560px) {
  .end-btns { flex-direction: row; max-width: none; justify-content: center; }
}
@media (max-width: 899px) {
  .rd-series { flex: 1 1 auto; font-size: 10px; letter-spacing: .12em; }
  .rd-tools { flex: 1 1 100%; margin-left: 0; }
  .rd-tools .seg { margin-right: auto; }
}
body.reader main:focus-visible, body.reader .end:focus-visible { outline: none; }
@media (prefers-reduced-motion: reduce) {
  .rd-bar { transition: none; }
}

/* =========================================================================
   The hub, /comic/. It sits on /styles.css, so the header, buttons, hero,
   cards and footer already exist; this adds what the page needs on top.
   ========================================================================= */
body.hub .hero { padding-bottom: clamp(46px, 6vw, 84px); }
body.hub .hero h1 em { display: inline-block; }
.hub-eps, .hub-crew, .hub-take, .hub-note { border-top: 1px solid var(--line); }

.crew-line { margin: 34px auto 0; max-width: 760px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #fbf8ec; }
.crew-line img { display: block; width: 100%; height: auto; }
.crew-grid { list-style: none; margin: 38px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.crew { text-align: center; }
.crew img {
  display: block; width: 100%; max-width: 196px; height: auto; aspect-ratio: 1; margin: 0 auto 14px;
  border-radius: 50%; border: 2px solid var(--line-lit); background: var(--ink-2); object-fit: cover;
}
.crew h3 { font-size: 1.15rem; margin: 0 0 .25em; }
.crew h3 span { font-family: var(--mono); font-weight: 400; font-size: .72rem; letter-spacing: .12em; color: var(--muted); margin-left: .6em; }
.crew p { font-size: .92rem; margin: 0 auto; max-width: 24ch; }
@media (max-width: 820px) { .crew-grid { grid-template-columns: repeat(2, 1fr); } }

.teach { max-width: 760px; margin: 38px auto 0; }
.teach-row { padding: 16px 0 16px 18px; border-left: 3px solid var(--accent, var(--red)); margin-bottom: 14px; background: var(--ink-1); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding-right: 18px; }
.teach dt { font-family: var(--display); font-weight: 700; color: var(--paper); font-size: 1.05rem; }
.teach dt span { font-family: var(--mono); font-weight: 500; font-size: .74rem; letter-spacing: .16em; color: var(--accent, var(--red)); margin-right: .4em; }
.teach dt em { font-family: var(--mono); font-style: normal; font-weight: 400; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-left: .8em; }
.teach dd { margin: .4em 0 0; font-size: .95rem; }
.teach-foot { text-align: center; margin: 22px auto 0; max-width: 56ch; font-size: .95rem; }

.foot-privacy { margin-top: 14px; max-width: 70ch; font-size: .8rem; color: var(--muted); }

/* =========================================================================
   Shared with the homepage cards (the same .ep markup is used in both places)
   ========================================================================= */
.ep-grid-hub { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 820px) {
  .ep-grid-hub { grid-template-columns: 1fr; }
}
