/* ───────────────────────── Slice C — webtoon renderer styles ─────────────────────────
   Loaded only when ?renderer=v2 (or localStorage.codex_renderer="v2").
   Designed to coexist with the existing .chapter-stage SVG embed path.
*/

.ch2 {
  --sfx-rot: -6deg;
  --grid-gap: 4px;
  position: relative;
  background-color: var(--page);
  background-image: radial-gradient(circle, #c8c8c8 1px, transparent 1px);
  background-size: 14px 14px;
  border: 4px solid var(--ink);
  margin-bottom: 28px;
}
/* Stripe-style subtle grain overlay — printed paper texture (REFERENCES.md §2) */
.ch2::before {
  content: "";
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 20;
  mix-blend-mode: multiply;
}

/* ───── top strip with chapter number + masthead + date ───── */
.ch2-head {
  background: var(--ink);
  color: var(--page);
  padding: 14px 22px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 18px;
}
.ch2-ch {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.14em;
}
.ch2-masthead {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 0.08em;
  text-align: center;
}
.ch2-masthead em {
  font-style: normal;
  -webkit-text-stroke: 1.2px var(--page);
  color: transparent;
}
.ch2-date {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-ghost);
  letter-spacing: 0.06em;
}

/* ───── hero episode headline ───── */
.ch2-hero {
  padding: 28px 28px 18px;
  border-bottom: 3px solid var(--ink);
  background: var(--page);
}
.ch2-headline {
  font-family: var(--font-display);
  font-size: 52px;
  line-height: 1.02;
  letter-spacing: 0.01em;
  color: var(--ink);
  margin: 0 0 10px;
  text-transform: uppercase;
}
.ch2-byline {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-fade);
}

/* ───── the panel grid ───── */
.ch2-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;                            /* tight ink gutter */
  padding: 4px;
  background: var(--ink);
  align-items: end;                    /* staircase — panels bottom-align up to climax */
}
.ch2-panel {
  /* All panels span 1 col — height carries the emphasis instead of width */
  position: relative;
  background: var(--page);
  overflow: visible;                   /* SFX can bleed past edges */
  transform: rotate(var(--skew, 0deg));
  transition: transform 180ms ease-out;
  animation: ch2PanelIn 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: var(--delay, 0ms);
}
/* Staircase heights — setup and resolution are shorter, climax tallest */
.ch2-panel[data-slot="setup"]      { height: 260px; z-index: 1; }
.ch2-panel[data-slot="rise"]       { height: 300px; z-index: 2; }
.ch2-panel[data-slot="climax"]     { height: 360px; z-index: 3; }
.ch2-panel[data-slot="resolution"] { height: 260px; z-index: 2; }

.ch2-panel:hover {
  transform: rotate(var(--skew, 0deg)) scale(1.015);
}

@keyframes ch2PanelIn {
  from {
    opacity: 0;
    transform: translateY(30px) rotate(calc(var(--skew, 0deg) - 3deg)) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(var(--skew, 0deg)) scale(1);
  }
}

/* art layer */
.ch2-art {
  position: absolute; inset: 0;
  overflow: hidden;
}
.ch2-art-svg { width: 100%; height: 100%; display: block; }

/* screentone overlay — dot halftone on top of each panel's art */
.ch2-art::after {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(circle, #000 1.2px, transparent 1.2px);
  background-size: 7px 7px;
  opacity: 0.06;
  pointer-events: none;
  z-index: 2;
}

/* slot corner tag  // SETUP · RISE · CLIMAX · RESOLUTION */
.ch2-slot-tag {
  position: absolute;
  top: 10px; right: 10px;
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 700;
  color: var(--ink);
  background: var(--page);
  border: 1.5px solid var(--ink);
  padding: 2px 6px;
  letter-spacing: 0.1em;
  z-index: 4;
}
.ch2-panel[data-slot="climax"] .ch2-slot-tag {
  background: var(--ink);
  color: var(--page);
}

/* time eyebrow pill */
.ch2-eyebrow {
  position: absolute;
  top: 10px; left: 10px;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700;
  color: var(--ink);
  background: var(--page);
  border: 1.5px solid var(--ink);
  padding: 2px 7px;
  letter-spacing: 0.06em;
  z-index: 4;
}

/* caption bubble */
.ch2-bubble {
  position: absolute;
  left: 12px; right: 12px; bottom: 12px;
  background: var(--page);
  border: 2px solid var(--ink);
  padding: 8px 11px 6px;
  z-index: 4;
  max-width: 280px;
  animation: ch2BubbleIn 380ms ease-out both;
  animation-delay: calc(var(--delay, 0ms) + 300ms);
}
.ch2-bubble-body {
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
  margin-bottom: 3px;
  /* pretext sets max-width dynamically */
}
.ch2-bubble-body strong { font-weight: 900; }
.ch2-bubble-tag {
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 500;
  color: var(--ink-fade);
  letter-spacing: 0.08em;
}

@keyframes ch2BubbleIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* SFX — floating layer bleeding across panel edges.
   Solid ink fill + red layered shadow = hand-inked manga weight. Fun > formal. */
.ch2-sfx {
  position: absolute;
  top: 28px; left: 22px;
  font-family: var(--font-sfx);
  font-size: 84px;
  line-height: 0.9;
  color: var(--ink);
  letter-spacing: 0.02em;
  text-shadow: 3px 3px 0 var(--down), 5px 5px 0 rgba(0,0,0,0.22);
  transform: rotate(var(--sfx-rot, -6deg));
  transform-origin: center;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
  animation: ch2SfxPop 480ms cubic-bezier(0.3, 1.5, 0.4, 1) both;
  animation-delay: calc(var(--delay, 0ms) + 650ms);
}
.ch2-panel[data-slot="climax"] .ch2-sfx {
  font-size: 96px;
  top: 8px;
  left: 12px;
  color: var(--ink);
  text-shadow: 4px 4px 0 var(--down), 6px 6px 0 rgba(0,0,0,0.28);
}
.ch2-panel[data-slot="rise"] .ch2-sfx {
  top: 14px;
  right: -18px;
  left: auto;
  font-size: 68px;
}
.ch2-panel[data-slot="setup"] .ch2-sfx {
  top: auto;
  bottom: 80px;
  left: -8px;
  font-size: 56px;
}

@keyframes ch2SfxPop {
  from { opacity: 0; transform: rotate(calc(var(--sfx-rot, -6deg) - 8deg)) scale(0.5); }
  to   { opacity: 1; transform: rotate(var(--sfx-rot, -6deg)) scale(1); }
}

/* ───── prose / narration block ───── */
.ch2-prose {
  background: var(--page);
  padding: 24px 28px;
  border-top: 3px solid var(--ink);
  position: relative;
}
.ch2-prose::before {
  content: ""; position: absolute;
  left: 0; right: 0; top: 0;
  height: 4px;
  background: var(--ink);
}
.ch2-prose-tag {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700;
  color: var(--ink-fade);
  letter-spacing: 0.18em;
  margin-bottom: 12px;
}
.ch2-prose p {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.65;
  color: var(--ink-soft);
  max-width: 68ch;
}

/* ───── NEXT ISSUE teaser ───── */
.ch2-next {
  padding: 18px 28px;
  border-top: 2px solid var(--ink);
  background: var(--page-2);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 22px;
  align-items: center;
}
.ch2-next-label {
  font-family: var(--font-sfx);
  font-size: 32px; line-height: 0.9;
  color: var(--ink);
  -webkit-text-stroke: 0.5px var(--ink);
  text-shadow: 2px 2px 0 var(--page), 3px 3px 0 var(--ink);
  transform: rotate(-3deg);
  letter-spacing: 0.02em;
}
.ch2-next-body {
  font-family: var(--font-body);
  font-size: 14px; font-weight: 500;
  color: var(--ink-soft);
  line-height: 1.5;
}

/* ───── reduced motion ───── */
@media (prefers-reduced-motion: reduce) {
  .ch2-panel, .ch2-bubble, .ch2-sfx {
    animation: none !important;
    opacity: 1 !important;
    transform: rotate(var(--skew, 0deg)) !important;
  }
  .ch2-sfx { transform: rotate(var(--sfx-rot, -6deg)) !important; }
  .ch2-panel:hover { transform: rotate(var(--skew, 0deg)) !important; }
}

/* ───── responsive ───── */
@media (max-width: 800px) {
  .ch2-grid { grid-template-columns: 1fr 1fr; }
  .ch2-panel[data-slot="setup"],
  .ch2-panel[data-slot="resolution"] { height: 220px; }
  .ch2-panel[data-slot="rise"]       { height: 240px; }
  .ch2-panel[data-slot="climax"]     { height: 280px; }
  .ch2-headline { font-size: 38px; }
  .ch2-masthead { font-size: 20px; }
}
@media (max-width: 520px) {
  .ch2-grid { grid-template-columns: 1fr 1fr; }
  .ch2-headline { font-size: 30px; }
}

/* ───── v2 / v1 toggle hint in corner ───── */
.ch2-flag {
  position: absolute;
  bottom: 6px; right: 10px;
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 700;
  color: var(--ink-ghost);
  letter-spacing: 0.15em;
  pointer-events: auto;
  cursor: pointer;
  background: var(--page);
  padding: 2px 6px;
  border: 1px solid var(--ink-ghost);
}
.ch2-flag:hover { color: var(--ink); border-color: var(--ink); }
