/* ==========================================================================
   /comic/comic.css — NOVA DOCK reading page (v7)
   Builds on /site.css tokens + .panel/.bubble. Prefix: cm-
   1 intro · 2 Act A read · 3 bubbles · 4 rail · 5 paper (2×3 page)
   6 Act B assemble · 7 Act C finished page
   ========================================================================== */

/* 1. INTRO --------------------------------------------------------------- */
.cm-intro .lead { margin-top: var(--s2); }
.cm-intro__crew { margin-top: var(--s3); color: var(--ink-2); }
.cm-intro__crew b { font-weight: 800; letter-spacing: .06em; color: var(--ink); }

.cm-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--s3); }
.cm-acts li {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  font-size: .875rem; font-weight: 600; color: var(--ink-2);
}
.cm-acts__k {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  font-size: .75rem; font-weight: 800; color: var(--ink);
}
.cm-acts li:nth-child(1) .cm-acts__k { background: var(--lav); }
.cm-acts li:nth-child(2) .cm-acts__k { background: var(--mint); }
.cm-acts li:nth-child(3) .cm-acts__k { background: var(--peach); }

.cm-intro__cta { margin-top: var(--s4); }
.cm-keys { margin-top: var(--s2); }
.cm-keys kbd {
  display: inline-grid; place-items: center; min-width: 1.75em; padding: 0 .35em;
  border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: .8125rem; font-weight: 700; line-height: 1.6;
}
@media (hover: none) and (pointer: coarse) { .cm-keys { display: none; } }

/* 2. ACT A — READ -------------------------------------------------------- */
.cm-read {
  --cm-reserve: 64px;   /* space kept clear for the bottom rail on small screens */
  --cm-maxh: min(90vh, calc(100vh - var(--header-h) - 64px - var(--cm-reserve)));
  --cm-ratio: .466;     /* 768 / 1648 */
}
@supports (height: 100svh) {
  .cm-read { --cm-maxh: min(90svh, calc(100svh - var(--header-h) - 64px - var(--cm-reserve))); }
}
@media (min-width: 1024px) { .cm-read { --cm-reserve: 0px; } }

.cm-cut {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: calc(100vh - var(--header-h));
  padding: 12px var(--gutter) calc(12px + var(--cm-reserve));
  scroll-margin-top: -16px; /* cancels site scroll-padding extra so a cut fills the view */
}
@supports (height: 100svh) { .cm-cut { min-height: calc(100svh - var(--header-h)); } }
.cm-cut--wide { --cm-ratio: .684; } /* 832 / 1216 */
.cm-cut:focus { outline: none; }
.cm-cut:focus-visible .cm-frame { outline: 3px solid var(--focus); outline-offset: 4px; }

.cm-cut__inner { width: min(100%, 560px, calc(var(--cm-maxh) * var(--cm-ratio))); }
.cm-cut__meta { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.cm-cut__no { font-size: 1.5rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.cm-cut__label { margin: 0; }
.cm-cut__count { margin-left: auto; font-size: .8125rem; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.cm-frame { width: 100%; }
.cm-open { position: relative; display: block; color: inherit; text-decoration: none; cursor: zoom-in; }
.cm-open img { width: 100%; height: auto; }
.cm-open:focus-visible { outline-offset: -4px; border-radius: inherit; }
.cm-zoom {
  position: absolute; right: 10px; bottom: 10px; display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 50%; background: rgba(255, 255, 255, .94);
  border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 1rem; line-height: 1; color: var(--ink);
  opacity: 0; transition: opacity .15s;
}
.cm-open:hover .cm-zoom, .cm-open:focus-visible .cm-zoom { opacity: 1; }
@media (hover: none) { .cm-zoom { opacity: .9; } }

/* 3. BUBBLES — per-cut positions (% of the cut), top ~20% only ------------ */
.cm-frame .bubble, .cm-paper .bubble { pointer-events: none; }
.cm-shout { font-weight: 800; }
.cm-tail-c::after { left: 50%; margin-left: -.35em; }

.bubble.cm-b1 { top: 4%; left: 5%; }
.bubble.cm-b2-sfx { top: 3.5%; right: 6%; }
.bubble.cm-b2 { top: 10%; left: 5%; }
.bubble.cm-b3 { max-width: 31%; padding: .4em .6em .45em; font-size: clamp(10px, 3.8cqi, 17px); }
.bubble.cm-b3-l { top: 4%; left: 2.5%; }
.bubble.cm-b3-c { top: 8.5%; left: 50%; transform: translateX(-50%); }
.bubble.cm-b3-r { top: 4%; right: 2.5%; }
.bubble.cm-b4 { top: 4%; left: 5%; }
.bubble.cm-b5 { top: 5%; left: 5%; }
.bubble.cm-b6 { top: 4%; right: 5%; }

/* C2 SFX — bold italic butter sticker */
.bubble--sfx.cm-sfx { font-style: italic; font-weight: 900; letter-spacing: .03em; transform: rotate(-6deg); }

/* 4. RAIL ---------------------------------------------------------------- */
.no-js .cm-rail { display: none; }
.cm-rail {
  position: fixed; z-index: 40; left: 50%; bottom: 12px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transition: opacity .2s var(--ease), visibility .2s;
}
.cm-rail.is-on { opacity: 1; visibility: visible; }
.cm-rail__btn {
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--ink);
}
.cm-rail__btn:hover { background: var(--bg-tint); }
.cm-rail__chev { width: 16px; height: 16px; }
.cm-rail__dots { display: flex; align-items: center; }
.cm-rail__dot { display: grid; place-items: center; width: 22px; height: 40px; border-radius: 8px; }
.cm-rail__dot::before {
  content: ""; width: 7px; height: 7px; border-radius: 999px; background: var(--line-2);
  transition: background-color .2s, width .2s var(--ease), height .2s var(--ease);
}
.cm-rail__dot:hover::before { background: var(--ink-3); }
.cm-rail__dot[aria-current]::before { width: 16px; background: var(--ink); }
.cm-rail__count {
  min-width: 40px; padding: 0 6px; text-align: center;
  font-size: .8125rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink);
}
.cm-rail__of { color: var(--ink-3); font-weight: 600; }

@media (min-width: 1024px) {
  .cm-rail {
    left: auto; right: 24px; bottom: auto; top: 50%; transform: translateY(-50%);
    flex-direction: column; padding: 6px 4px; border-radius: 24px;
  }
  .cm-rail__dots { flex-direction: column; }
  .cm-rail__dot { width: 40px; height: 22px; }
  .cm-rail__dot[aria-current]::before { width: 7px; height: 16px; }
  .cm-rail__chev { transform: rotate(90deg); }
  .cm-rail__count { order: 5; padding: 4px 0 2px; border-top: 1px solid var(--line); min-width: 32px; }
}

/* 5. PAPER — the 2×3 page (two rows of three) ---------------------------- */
.cm-paper {
  position: relative; isolation: isolate; container-type: inline-size;
  width: min(100%, 760px); margin-inline: auto; padding: 3.2%;
}
.cm-paper::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg);
}
.cm-paper__head {
  display: flex; align-items: baseline; gap: .6em; margin: 0 0 2.2cqi; padding-bottom: 1.6cqi;
  border-bottom: 1px solid var(--line);
  font-size: clamp(9px, 2.3cqi, 15px); font-weight: 800; line-height: 1.2; letter-spacing: .14em; text-transform: uppercase;
}
.cm-paper__dot { color: var(--ink-3); }
.cm-paper__day { color: var(--ink-2); }
.cm-paper__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.8cqi; align-items: center; }

.cm-paper .panel { border: 1.5px solid var(--ink); border-radius: 4px; }
.cm-paper .panel img { width: 100%; height: auto; }

/* bubbles scale with each small panel */
.cm-paper .panel .bubble {
  max-width: 80%; padding: .35em .6em .4em; border-width: 1.5px;
  font-size: clamp(5px, 5.4cqi, 15px); line-height: 1.25;
}
.cm-paper .panel .bubble::after { border-right-width: 1.5px; border-bottom-width: 1.5px; }
.cm-paper .panel .bubble__who { font-size: .7em; }
.cm-paper .panel .bubble--sfx { padding: .2em .5em; font-size: clamp(6px, 7.5cqi, 22px); }
.cm-paper .panel .bubble.cm-b3 { max-width: 32%; padding: .3em .45em .35em; font-size: clamp(4px, 4.4cqi, 13px); }

.cm-stamp {
  position: absolute; right: 6%; bottom: 5%; z-index: 2;
  padding: .32em .7em .34em; border: 2px solid currentColor; border-radius: 6px;
  background: var(--peach-soft); color: var(--err); opacity: .94;
  font-size: clamp(10px, 3cqi, 22px); font-weight: 900; line-height: 1; letter-spacing: .16em; white-space: nowrap;
  transform: rotate(-7deg);
}

/* 6. ACT B — ASSEMBLE ---------------------------------------------------- */
.cm-assemble { background: var(--bg-tint); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cm-stage { position: relative; padding-block: var(--s8); }
.cm-stage__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 24px; margin-bottom: var(--s4); }
.cm-stage__head .eyebrow { margin-bottom: 8px; }
.cm-stage__head h2 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.125rem); }
.cm-stage__head h2:focus { outline: none; }
.cm-stage__head h2:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
.cm-step {
  padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  font-size: .875rem; font-weight: 700; color: var(--ink-2);
}
.cm-stage__body { padding-inline: var(--gutter); }
.cm-paper--live { width: min(100%, 640px); }
.cm-meter { display: none; }

/* scroll-scrubbed mode (JS adds .cm-scrub; never under reduced motion) */
.cm-scrub .cm-track { height: 300vh; }
@supports (height: 100svh) { .cm-scrub .cm-track { height: 300svh; } }
.cm-scrub .cm-stage {
  position: sticky; top: var(--header-h); overflow: hidden;
  display: flex; flex-direction: column;
  height: calc(100vh - var(--header-h)); padding-block: var(--s2);
}
@supports (height: 100svh) { .cm-scrub .cm-stage { height: calc(100svh - var(--header-h)); } }
.cm-scrub .cm-stage__head { margin-bottom: var(--s2); }
.cm-scrub .cm-stage__body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.cm-scrub .cm-paper--live { width: min(100%, 720px, calc((100vh - var(--header-h) - 200px) * .66)); }
@supports (height: 100svh) {
  .cm-scrub .cm-paper--live { width: min(100%, 720px, calc((100svh - var(--header-h) - 200px) * .66)); }
}
@media (min-width: 768px) {
  .cm-scrub .cm-paper--live { width: min(100%, 720px, calc((100vh - var(--header-h) - 160px) * .66)); }
  @supports (height: 100svh) {
    .cm-scrub .cm-paper--live { width: min(100%, 720px, calc((100svh - var(--header-h) - 160px) * .66)); }
  }
}
.cm-scrub .cm-paper--live::before,
.cm-scrub .cm-paper--live .cm-paper__head { opacity: var(--cm-sheet, 0); }
.cm-scrub .cm-paper--live .panel { will-change: transform; }
.cm-scrub .cm-paper--live .cm-stamp { opacity: 0; visibility: hidden; }
.cm-scrub.is-done .cm-paper--live .cm-stamp { opacity: .94; visibility: visible; animation: cm-stamp .45s var(--ease) both; }
@keyframes cm-stamp {
  from { opacity: 0; transform: rotate(-7deg) scale(1.3); }
  to   { opacity: .94; transform: rotate(-7deg) scale(1); }
}
.cm-scrub .cm-meter { display: block; flex: none; width: min(240px, 60%); height: 2px; margin: var(--s2) auto 0; background: var(--line-2); border-radius: 2px; overflow: hidden; }
.cm-meter span { display: block; height: 100%; background: var(--ink); transform-origin: left center; transform: scaleX(var(--cm-p, 0)); }

/* 7. ACT C — FINISHED PAGE ----------------------------------------------- */
.cm-final__figure { margin: 0 auto; max-width: 760px; }
.cm-final__cap { margin-top: var(--s2); text-align: center; font-size: .875rem; color: var(--ink-3); }
.cm-final__actions { justify-content: center; margin-top: var(--s5); }
.cm-paper--final .cm-open { cursor: zoom-in; }

.cm-reserve { max-width: 520px; margin: var(--s5) auto 0; display: grid; gap: var(--s2); }
.cm-reserve__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cm-reserve__name { font-size: 1.125rem; font-weight: 800; }
.cm-reserve__body { color: var(--ink-2); }

@media print {
  .cm-rail, .cm-assemble, .cm-final__actions, .cm-reserve { display: none !important; }
}

/* ---- v7 polish ---- */

/* ==== QA fixes v7.1 ==================================================== */
/* 8 wider cuts, ratio-driven height */
.cm-cut__inner { width: min(560px, 92vw); max-width: 100%; }
.cm-open img { aspect-ratio: 768 / 1648; object-fit: cover; }
.cm-cut--wide .cm-open img { aspect-ratio: 832 / 1216; }
/* 9 hero thumbnails */
.cm-thumbs { display: none; }
@media (min-width: 900px) {
  .cm-intro__grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 400px); gap: var(--s8); align-items: center; }
  .cm-thumbs { display: block; }
}
.cm-thumbs__list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cm-thumbs__link { position: relative; display: block; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.cm-thumbs__link:hover { border-color: var(--ink-3); box-shadow: var(--shadow-lg); }
.cm-thumbs__link img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; object-position: 50% 20%; }
.cm-thumbs__n { position: absolute; left: 6px; top: 6px; padding: 1px 6px; border-radius: 6px; background: rgba(255, 255, 255, .94); font-size: .75rem; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
/* 10 A/B/C chips are real links */
.cm-acts li { padding: 0; border: 0; background: none; }
.cm-acts__link {
  display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 4px 12px 4px 4px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink-2); text-decoration: none; transition: border-color .15s, color .15s;
}
.cm-acts__link:hover { border-color: var(--ink-3); color: var(--ink); }
.cm-acts__link::after { content: "\2193"; font-size: .8125rem; color: var(--ink-3); }

