/* Shared chapter pieces: opener, section bits, download panel, image viewer, grid overlay. */

/* ================================================================ chapter opener (every chapter) */
.opener { position: relative; padding-top: var(--bar-h); background: var(--ink); color: var(--paper); overflow: hidden; }
.opener-band { --tile: 40px; position: relative; z-index: 2; }
.opener-grid { display: grid; grid-template-columns: 1fr; min-height: calc(100svh - var(--bar-h) - 40px); }
@media (min-width: 900px) { .opener-grid { grid-template-columns: 1fr 1fr; } .opener--solo .opener-grid { grid-template-columns: 1fr; } }
.opener-left { display: flex; flex-direction: column; justify-content: flex-end; gap: 22px; padding: 56px var(--gutter) clamp(48px, 7vw, 88px); position: relative; z-index: 1; }
.opener-title { font-size: clamp(60px, min(19vw, calc(205vw / var(--wlen, 7))), 290px); padding-top: .04em; margin-top: -.04em; }
@media (min-width: 900px) { .opener-title { font-size: clamp(60px, min(17vw, calc(108vw / var(--wlen, 7))), 290px); } }
.opener-title .ow { display: inline-block; overflow: hidden; vertical-align: top; padding-top: .03em; white-space: nowrap; }
.opener-title > .oc { display: inline-block; }
.opener-title .oc { display: inline-block; will-change: transform; }
.opener-lede { color: rgba(255, 255, 255, .86); }
.opener-count { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 13px; opacity: .75; }
.opener-count span + span::before { content: "\2192  "; }
.opener-scroll { position: absolute; left: var(--gutter); bottom: 22px; display: none; align-items: center; gap: 10px; font-size: 12px; color: rgba(255, 255, 255, .7); }
.opener-scroll i { width: 2px; height: 34px; background: currentColor; transform-origin: top; animation: scrollcue 1.8s var(--ease-out) infinite; }
@keyframes scrollcue { 0% { transform: scaleY(0); } 55% { transform: scaleY(1); transform-origin: top; } 56% { transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }
@media (min-width: 900px) { .opener-scroll { display: flex; } .opener-left { padding-bottom: 96px; } }

.op-art { position: relative; overflow: hidden; min-height: 56svh; border-left: var(--line) solid var(--ink); }
.op-img img, .op-imgs img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; transform-origin: 50% 40%; }
.op-img--contain img { object-fit: contain; padding: 6%; }
.op-imgs { display: grid; grid-template-columns: 1fr 1fr; gap: var(--line); background: var(--ink); }
.op-imgs .op-img { position: relative; overflow: hidden; }
.op-grid { background: var(--c); }
.opg-lines, .opg-fx { position: absolute; inset: 0; }
.opg-v, .opg-h { position: absolute; background: var(--on); opacity: .32; display: block; }
.opg-v { top: 0; bottom: 0; width: 2px; transform-origin: top; }
.opg-h { left: 0; right: 0; height: 2px; transform-origin: left; }
.opg-fx b { position: absolute; background: var(--on); opacity: 0; mix-blend-mode: overlay; }
.op-type { background: var(--c); color: var(--ink); display: flex; align-items: flex-end; container-type: inline-size; }
.opt-word { display: block; width: 100%; font-size: min(calc(94cqw / (var(--n, 10) * .4)), 240px); line-height: .82; padding: 0 2%; white-space: nowrap; }
.opt-word .ow { display: inline-block; overflow: hidden; vertical-align: bottom; }
.opt-word .oc { display: inline-block; }
.op-pattern { display: grid; grid-template-columns: repeat(4, 1fr); align-content: center; background: var(--ink); }
.op-pattern .tile { display: block; aspect-ratio: 1; }
.op-pattern .tile svg { width: 100%; height: 100%; display: block; }
@media (max-width: 899px) { .op-art { border-left: 0; border-top: var(--line) solid var(--ink); } }

/* ================================================================ shared section bits */
.sec-lede { display: grid; gap: 14px; align-self: end; }
.eyebrow--pill { padding: 6px 12px 5px 10px; border-radius: 999px; background: var(--pill); border: 2px solid var(--ink); }
.eyebrow--pill::before { width: 14px; }
.box { border: var(--line) solid var(--ink); border-radius: var(--r); overflow: hidden; }
.frame { position: relative; overflow: hidden; border: var(--line) solid var(--ink); border-radius: var(--r); background: var(--ink); }
.frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.note { border-top: var(--line) solid var(--ink); padding-top: 14px; display: grid; gap: 6px; }
.note .t-label { font-size: 22px; }
.chip-label { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 5px; border-radius: 999px; border: 2px solid var(--ink); font-family: var(--font-mono); font-size: 13px; }
.chip-label i { width: 16px; height: 16px; border-radius: 50%; background: var(--c); border: 2px solid var(--ink); }
.btn-link { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 14px; text-decoration: underline; text-underline-offset: 4px; }

/* ================================================================ download panel */
.dl { display: grid; gap: 14px; padding: 18px; border: var(--line) solid var(--ink); border-radius: var(--r); background: var(--paper); color: var(--ink); }
.dl-title { font-size: 24px; line-height: 1; }
.dl-row { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; }
.dl-k { font-size: 12px; opacity: .7; }
.dl-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.dl-chip { position: relative; width: 32px; height: 32px; border-radius: 50%; background: var(--c); border: var(--line) solid var(--ink); transition: transform .3s var(--ease-out), box-shadow .3s; }
.dl-chip:hover { transform: scale(1.1); }
.dl-chip[aria-checked="true"] { box-shadow: 0 0 0 3px var(--paper), 0 0 0 6px var(--ink); }
.dl-chip[aria-checked="true"]::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--on); }
.dl-fmts { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.dl-fmt { padding: 7px 14px 5px; border: 2px solid var(--ink); border-radius: 999px; font-size: 18px; line-height: 1; transition: background .25s, color .25s; }
.dl-fmt[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.dl-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.dl-go { position: relative; overflow: hidden; }
.dl-go-ok { position: absolute; inset: 0; display: grid; place-items: center; background: var(--ok); color: var(--ink); transform: translateY(105%); transition: transform .45s var(--ease-out); }
.dl-go.is-done .dl-go-ok { transform: none; }
.dl-go.is-busy { opacity: .6; }
.dl-zip { font-size: 17px; }

/* ================================================================ image viewer */
.lb { position: fixed; inset: 0; z-index: 95; display: none; place-items: center; }
.lb.is-open { display: grid; }
.lb-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .92); }
.lb-fig { position: relative; margin: 0; display: grid; gap: 12px; justify-items: center; max-width: min(1200px, 92vw); }
.lb-img { max-width: 100%; max-height: 80vh; object-fit: contain; border-radius: 10px; }
.lb-cap { color: #fff; font-size: 13px; }
.lb-x { position: absolute; top: 18px; right: var(--gutter); }
.lb-nav { position: absolute; top: 50%; width: 56px; height: 56px; margin-top: -28px; border-radius: 50%; background: var(--paper); color: var(--ink); font-family: var(--font-accent); font-size: 26px; display: grid; place-items: center; }
.lb-prev { left: var(--gutter); }
.lb-next { right: var(--gutter); }
.lb-count { position: absolute; left: var(--gutter); top: 26px; color: #fff; font-size: 13px; }
@media (max-width: 700px) { .lb-nav { top: auto; bottom: 18px; margin-top: 0; } }

/* ================================================================ grid overlay (press G) */
.grid-ov { position: fixed; inset: 0; z-index: 85; pointer-events: none; display: none; }
.grid-ov.is-on { display: block; }
.grid-ov .wrap { height: 100%; display: grid; grid-template-columns: repeat(12, 1fr); gap: 20px; }
.grid-ov i { background: color-mix(in srgb, var(--accent) 22%, transparent); border-inline: 1px solid color-mix(in srgb, var(--accent) 70%, transparent); }
.grid-ov-tag { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); padding: 6px 12px; border-radius: 999px; background: var(--ink); color: var(--paper); font-size: 12px; }

/* ================================================================ common chapter layouts */
.split { display: grid; gap: clamp(24px, 4vw, 56px); }
@media (min-width: 960px) { .split { grid-template-columns: 1fr 1fr; align-items: center; } .split--wide-left { grid-template-columns: 1.3fr 1fr; } .split--wide-right { grid-template-columns: 1fr 1.3fr; } }
.stack { display: grid; gap: 16px; }
.reveal-img { clip-path: inset(0 0 0 0); }
