/* ============================================================
   KAGEMORI PRESS — site.css
   Manga panel grammar: panels, gutters, screentone, ink.
   Motion: CSS scroll-driven timelines + IntersectionObserver
   fallback. Full static fallback under prefers-reduced-motion.
   ============================================================ */

:root {
  --ink:        #12100E;
  --ink-2:      #1D1A17;
  --ink-soft:   #3A342E;
  --paper:      #F2EDE3;
  --paper-2:    #E4DCCC;
  --paper-3:    #D6CCB8;
  --seal:       #A8322A;

  --gutter:     10px;
  --rule:       2px;
  --frame:      3px;

  --f-display: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif;
  --f-ui:      "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  --wrap: 1240px;
}

@media (min-width: 800px) {
  :root { --gutter: 18px; }
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  /* clip, NOT hidden: overflow:hidden would establish a scroll container
     and break every `animation-timeline: scroll(root)` on the page. */
  overflow-x: clip;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 17px;
  line-height: 1.65;
  overflow-x: clip;     /* body must never scroll sideways */
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; }

/* ---------- screentone ---------- */
/* A real halftone dot field, rendered in CSS. Scales with --tone-size. */
.tone {
  position: relative;
}
.tone::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(currentColor 1.05px, transparent 1.15px);
  background-size: 6px 6px;
  opacity: .10;
  z-index: 0;
}
.tone > * { position: relative; z-index: 1; }

/* ---------- shell ---------- */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 20px;
}

/* Reading-progress ink line */
.progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 100%;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: var(--seal);
  z-index: 90;
}
@supports (animation-timeline: scroll()) {
  .progress {
    animation: progress-grow linear both;
    animation-timeline: scroll(root block);
  }
}
@keyframes progress-grow {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* ---------- masthead ---------- */
.masthead {
  position: relative;
  z-index: 50;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 20px 18px;
  max-width: var(--wrap);
  margin: 0 auto;
  flex-wrap: wrap;
}
.imprint {
  font-family: var(--f-display);
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}
.imprint .sq {
  display: inline-block;
  width: .55em; height: .55em;
  background: var(--seal);
  margin-right: .6em;
}
.nav {
  display: flex;
  gap: 22px;
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.nav a {
  text-decoration: none;
  padding-bottom: 3px;
  border-bottom: 1px solid transparent;
  opacity: .72;
}
.nav a:hover, .nav a[aria-current="page"] { opacity: 1; border-bottom-color: var(--seal); }

.on-ink { background: var(--ink); color: var(--paper); }
.on-ink .nav a:hover, .on-ink .nav a[aria-current="page"] { border-bottom-color: var(--seal); }

/* ---------- type ---------- */
.kicker {
  font-size: 11px;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--seal);
  margin: 0 0 18px;
  font-weight: 600;
}
.on-ink .kicker { color: #D8564A; }

h1.title {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(2.6rem, 8.4vw, 6.2rem);
  line-height: .94;
  letter-spacing: -.015em;
  margin: 0;
  text-transform: uppercase;
}
.byline {
  font-family: var(--f-display);
  font-size: clamp(.95rem, 2.2vw, 1.2rem);
  letter-spacing: .24em;
  text-transform: uppercase;
  margin: 20px 0 0;
  opacity: .78;
}
.deck {
  font-family: var(--f-display);
  font-size: clamp(1.05rem, 2.1vw, 1.35rem);
  line-height: 1.62;
  max-width: 30ch;
  margin: 26px 0 0;
  opacity: .9;
}

h2.head {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(1.9rem, 4.6vw, 3.3rem);
  line-height: 1.08;
  letter-spacing: -.01em;
  margin: 0 0 22px;
  max-width: 18ch;
}
h3.sub {
  font-family: var(--f-display);
  font-size: 1.15rem;
  letter-spacing: .04em;
  margin: 0 0 10px;
}
p.body { max-width: 60ch; margin: 0 0 18px; }
p.body.lede { font-size: 1.08rem; }

/* the book's own voice — set as a caption box, manga-style */
.caption-box {
  border: var(--rule) solid currentColor;
  padding: 18px 22px;
  font-family: var(--f-display);
  font-size: clamp(1.05rem, 2.4vw, 1.5rem);
  line-height: 1.5;
  max-width: 46ch;
  background: var(--paper);
}
.on-ink .caption-box { background: var(--ink); }

.small {
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .6;
}

/* ---------- panels ---------- */
.panel {
  border: var(--frame) solid var(--ink);
  background: #fff;
  overflow: clip;              /* NOT hidden — hidden breaks scroll() lookups */
  position: relative;
}
.panel img { width: 100%; height: auto; display: block; }
.on-ink .panel { border-color: var(--paper); }

.grid {
  display: grid;
  gap: var(--gutter);
}

/* ---------- HERO ---------- */
.hero {
  background: var(--ink);
  color: var(--paper);
  position: relative;
  overflow: clip;
  padding-bottom: 60px;
}
.hero-page {
  display: grid;
  gap: var(--gutter);
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  padding: 10px 0 0;
}
@media (min-width: 900px) {
  .hero-page {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
    min-height: calc(100vh - 150px);
  }
}
.hero-text {
  border: var(--frame) solid var(--paper);
  padding: clamp(24px, 4vw, 48px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}
.hero-art {
  border: var(--frame) solid var(--paper);
  overflow: clip;
  position: relative;
  min-height: 380px;
  background: #fff;
  min-width: 0;
}
.hero-art img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
  transform: scale(1.02);
  will-change: transform;
}
@supports (animation-timeline: scroll()) {
  .hero-art img {
    animation: hero-push linear both;
    animation-timeline: scroll(root block);
    animation-range: 0 90vh;
  }
}
@keyframes hero-push {
  from { transform: scale(1.02) translateY(0); }
  to   { transform: scale(1.16) translateY(-2%); }
}
.scroll-cue {
  margin-top: 34px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  letter-spacing: .28em;
  text-transform: uppercase;
  opacity: .55;
}
.scroll-cue .bar {
  display: block;
  width: 54px; height: 1px;
  background: currentColor;
  transform-origin: 0 50%;
  animation: cue 2.4s ease-in-out infinite;
}
@keyframes cue { 0%,100% { transform: scaleX(.3); } 50% { transform: scaleX(1); } }

/* ---------- brush divider ---------- */
.brush {
  display: block;
  width: 100%;
  height: 46px;
  margin: 0;
  overflow: clip;
}
.brush svg { width: 100%; height: 100%; }
.brush path {
  fill: none;
  stroke: currentColor;
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 1200;
  stroke-dashoffset: 0;
}
@supports (animation-timeline: view()) {
  .brush path {
    animation: draw linear both;
    animation-timeline: view(block);
    animation-range: entry 10% cover 45%;
  }
}
@keyframes draw {
  from { stroke-dashoffset: 1200; }
  to   { stroke-dashoffset: 0; }
}

/* ---------- sections ---------- */
section { padding: clamp(64px, 9vw, 120px) 0; position: relative; }
.sec-ink { background: var(--ink); color: var(--paper); }
.sec-paper { background: var(--paper); }
.sec-paper-2 { background: var(--paper-2); }

.two-col {
  display: grid;
  gap: clamp(28px, 5vw, 64px);
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}
/* Direct grid-item children default to min-width:auto (their content's
   min-content size). A wide image inside forces that track — and the
   whole row — past the container width; the excess then gets silently
   clipped by html/body's overflow-x:clip (never a scrollbar) instead of
   being visible. min-width:0 lets the track shrink to the actual
   available width instead. Root cause of the M4/M3 marketing-graphic
   crop. */
.two-col > * { min-width: 0; }
@media (min-width: 900px) {
  .two-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .two-col.wide-left { grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); }
  .two-col.wide-right { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }
}

/* The manga page grid. Every cell holds a whole interior page, so the
   cells are pinned to the page's own 7:9 proportion — one panel runs
   double-size, and the bottom-right cell is left deliberately empty
   (gutter as negative space). No page is ever cropped into a band. */
.page-grid {
  display: grid;
  gap: var(--gutter);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 42px;
}
.page-grid .panel { aspect-ratio: 7 / 9; background: #fff; min-width: 0; }
.page-grid .panel img { width: 100%; height: 100%; object-fit: cover; }

@media (min-width: 760px) {
  .page-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .p1 { grid-column: 1 / 3; grid-row: 1 / 3; aspect-ratio: auto; }
  .p2 { grid-column: 3; grid-row: 1; }
  .p3 { grid-column: 3; grid-row: 2; }
  .p4 { grid-column: 1; grid-row: 3; }
  .p5 { grid-column: 2; grid-row: 3; }
  /* cell 3/3 stays empty — the beat of silence at the foot of the page */
}

/* ---------- splash page ---------- */
.splash {
  border: var(--frame) solid var(--paper);
  overflow: clip;
  max-width: 700px;
  margin: 0 auto;
  background: #fff;
  position: relative;
}
.splash img {
  width: 100%;
  height: auto;
  transform-origin: 50% 40%;
  will-change: transform;
}
@supports (animation-timeline: view()) {
  .splash img {
    animation: splash-breathe linear both;
    animation-timeline: view(block);
    animation-range: entry 0% cover 60%;
  }
}
@keyframes splash-breathe {
  from { transform: scale(1.14); }
  to   { transform: scale(1.0); }
}

/* ---------- blanks ---------- */
.blanks {
  display: grid;
  gap: var(--gutter);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 30px;
}
.blanks .panel { background: #fff; aspect-ratio: 7 / 9; min-width: 0; }
.blanks .panel img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }

.spec {
  list-style: none;
  padding: 0;
  margin: 26px 0 0;
  border-top: 1px solid rgba(0,0,0,.18);
}
.spec li {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(0,0,0,.18);
  font-size: 15px;
}
.spec li span:first-child { opacity: .58; letter-spacing: .08em; text-transform: uppercase; font-size: 12px; align-self: center; }
.spec li span:last-child { font-family: var(--f-display); text-align: right; }
.on-ink .spec, .sec-ink .spec { border-color: rgba(255,255,255,.22); }
.sec-ink .spec li { border-color: rgba(255,255,255,.22); }

/* ---------- CTA ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--f-ui);
  font-size: 13px;
  letter-spacing: .18em;
  text-transform: uppercase;
  font-weight: 600;
  text-decoration: none;
  padding: 16px 26px;
  border: 2px solid currentColor;
  background: transparent;
  transition: background .22s ease, color .22s ease, transform .22s ease;
}
.btn:hover { background: var(--seal); border-color: var(--seal); color: #fff; transform: translate(-2px, -2px); }
.btn.solid { background: var(--seal); border-color: var(--seal); color: #fff; }
.btn.solid:hover { background: transparent; color: currentColor; border-color: currentColor; }
.sec-ink .btn.solid:hover { color: var(--paper); }

/* ---------- editions ---------- */
.editions {
  display: grid;
  gap: clamp(24px, 4vw, 44px);
  grid-template-columns: minmax(0, 1fr);
  margin-top: 44px;
}
@media (min-width: 720px) { .editions { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

.edition {
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 480px) { .edition { grid-template-columns: 150px minmax(0, 1fr); } }
@media (min-width: 720px) { .edition { grid-template-columns: minmax(0, 1fr); } }
@media (min-width: 980px) { .edition { grid-template-columns: 170px minmax(0, 1fr); } }
.edition .panel { align-self: start; min-width: 0; }
.edition h3 {
  font-family: var(--f-display);
  font-size: 1.4rem;
  margin: 0 0 4px;
}
.edition .asin {
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  opacity: .55;
  margin: 0 0 14px;
}

/* ---------- footer ---------- */
footer {
  background: var(--ink);
  color: var(--paper);
  padding: 60px 0 44px;
}
footer .cols {
  display: grid;
  gap: 30px;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 760px) { footer .cols { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); } }
footer a { text-decoration: none; opacity: .74; }
footer a:hover { opacity: 1; color: #D8564A; }
footer ul { list-style: none; padding: 0; margin: 0; }
footer li { padding: 4px 0; font-size: 14px; }
.foot-rule {
  margin-top: 44px;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,.18);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  opacity: .5;
}

/* ---------- 404 ---------- */
.empty-panel {
  border: var(--frame) solid var(--ink);
  background: #fff;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px;
  margin-top: 34px;
}
.empty-panel p { font-family: var(--f-display); font-size: clamp(1.1rem, 3vw, 1.8rem); margin: 0; max-width: 22ch; }

/* ============================================================
   REVEAL — IntersectionObserver drives .is-in.
   Hidden and shown states are mutually exclusive BY SELECTOR
   (:not(.is-in)), not by cascade order + !important. Root cause
   of the earlier bug: `.js .reveal` declared an unconditional
   `transition` that keeps matching even after .is-in lands (the
   class is additive). Per the CSS cascade spec, an ACTIVE
   transition occupies the highest-priority origin — ABOVE
   !important author declarations — so if that transition ever
   failed to complete cleanly, no amount of !important on
   `.reveal.is-in` could out-rank it. Scoping the hide rule to
   :not(.is-in) removes the conflict structurally: once .is-in is
   present, the hide rule can never match that element again, so
   there is nothing left to fight. The transition itself now lives
   on the .is-in (shown) rule, which is the standard, safe place
   for it.
   Works in every browser incl. Firefox (no scroll-timeline there).
   ============================================================ */
.js .reveal:not(.is-in) {
  opacity: 0;
  transform: translateY(26px);
  clip-path: inset(0 0 100% 0);
}
.reveal.is-in {
  opacity: 1;
  transform: none;
  clip-path: inset(0 0 0 0);
  transition:
    opacity .7s cubic-bezier(.22,.7,.24,1),
    transform .7s cubic-bezier(.22,.7,.24,1),
    clip-path .9s cubic-bezier(.22,.7,.24,1);
  transition-delay: calc(var(--i, 0) * 90ms);
}
/* ink-bleed variant: irregular wipe, like ink soaking into paper */
.js .bleed:not(.is-in) {
  opacity: 0;
  clip-path: polygon(0 0, 8% 0, 4% 0, 0 0);
}
.bleed.is-in {
  opacity: 1;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
  transition: opacity .5s ease, clip-path 1.1s cubic-bezier(.19,1,.22,1);
  transition-delay: calc(var(--i, 0) * 90ms);
}

/* ============================================================
   REDUCED MOTION — everything lands, nothing moves.
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal, .bleed {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
    transition: none !important;
  }
  .hero-art img, .splash img { animation: none !important; transform: none !important; }
  .brush path { animation: none !important; stroke-dashoffset: 0 !important; }
  .progress { animation: none !important; transform: scaleX(0) !important; }
  .scroll-cue .bar { animation: none !important; transform: none !important; }
  * { scroll-behavior: auto !important; }
}
