/* hensai.quest — frozen receipt, translucent-frost, bebas-bold, stagger, layered-depth */

:root {
  --frost-paper: #eef4f8;
  --frosted-glass: #c8dde8;
  --glacier-mid: #7ba8c4;
  --deep-ink: #0e1a26;
  --annotation-slate: #4a6b80;
  --receipt-marigold: #f4b95c;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--frost-paper);
  color: var(--deep-ink);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  overflow-x: hidden;
  position: relative;
  cursor: default;
}

/* Welded grain — fixed to viewport, never scrolls */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  opacity: 0.07;
  filter: url(#grainFilter);
  background: transparent;
  mix-blend-mode: multiply;
}
/* fallback texture if filter unsupported */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 8999;
  pointer-events: none;
  opacity: 0.04;
  background-image:
    radial-gradient(circle at 25% 35%, rgba(14,26,38,0.4) 0.5px, transparent 1px),
    radial-gradient(circle at 75% 65%, rgba(14,26,38,0.3) 0.5px, transparent 1px);
  background-size: 3px 3px, 4px 4px;
}

.grain-defs { position: absolute; }

/* ===== Cursor frost trail ===== */
.cursor-frost {
  position: fixed;
  top: 0; left: 0;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(200, 221, 232, 0.4);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  pointer-events: none;
  z-index: 9500;
  transform: translate(-50%, -50%);
  transition: opacity 0.4s;
  mix-blend-mode: screen;
}

/* ===== Sections / acts ===== */
main { position: relative; z-index: 1; }

.act {
  min-height: 100vh;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* --- Act 1: The Owing — massive ma-negative-space --- */
.act-owing {
  background: linear-gradient(180deg, var(--frost-paper) 0%, var(--frosted-glass) 100%);
}
.kanji-hero {
  font-family: "Noto Serif JP", serif;
  font-weight: 700;
  font-size: 24vw;
  color: var(--deep-ink);
  line-height: 1;
  transform: rotate(-3deg);
  opacity: 0.92;
  will-change: transform;
  letter-spacing: -0.04em;
}
.annotation {
  font-family: "JetBrains Mono", monospace;
  font-style: italic;
  font-size: 12px;
  color: var(--annotation-slate);
  line-height: 1.6;
}
.annotation-corner {
  position: absolute;
  bottom: 6vh;
  right: 6vw;
  max-width: 320px;
  text-align: right;
}
.annotation-center {
  position: absolute;
  bottom: 12vh;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  max-width: 480px;
}
.watermark-num {
  position: absolute;
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(6rem, 12vw, 14rem);
  color: var(--glacier-mid);
  opacity: 0.45;
  top: 4vh;
  left: 4vw;
  line-height: 1;
  will-change: transform;
}

/* --- Act 3: The Frost meditation --- */
.act-frost-act {
  background: linear-gradient(180deg, var(--frost-paper) 0%, var(--frosted-glass) 60%, var(--glacier-mid) 100%);
}
.kanji-meditate {
  font-family: "Noto Serif JP", serif;
  font-weight: 400;
  font-size: 40vw;
  color: var(--deep-ink);
  line-height: 1;
  opacity: 0.5;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  transition: opacity 0.6s ease, filter 0.6s ease;
  will-change: transform, opacity;
}

/* --- Act 5: The Receipt — closing slip --- */
.act-receipt-final {
  background: var(--frost-paper);
  flex-direction: column;
}
.final-slip {
  width: 92vw;
  max-width: 420px;
  background: #fbfdfe;
  padding: 48px 28px 0;
  box-shadow: 0 10px 40px rgba(14,26,38,0.08);
  text-align: center;
  position: relative;
}
.slip-head, .slip-foot {
  letter-spacing: 0.06em;
  color: var(--annotation-slate);
  word-break: break-all;
}
.slip-foot { margin-top: 28px; padding-bottom: 36px; }
.slip-line {
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(2.5rem, 8vw, 4rem);
  margin: 22px 0 6px;
  letter-spacing: -0.02em;
  color: var(--deep-ink);
}
.slip-sentence {
  font-family: "Inter", sans-serif;
  font-weight: 500;
  font-size: 18px;
  line-height: 1.7;
  max-width: 30ch;
  margin: 0 auto;
  color: var(--deep-ink);
}
.torn-edge {
  height: 32px;
  margin: 0 -28px;
  background:
    linear-gradient(135deg, transparent 50%, #fbfdfe 50%) 0 0 / 16px 32px repeat-x,
    linear-gradient(-135deg, transparent 50%, #fbfdfe 50%) 0 0 / 16px 32px repeat-x;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, transparent 100%);
}

/* ===== Receipt column ===== */
.receipt-column {
  width: 92vw;
  max-width: 640px;
  margin: 0 auto;
  padding: 16vh 0;
  position: relative;
  min-height: 100vh;
}
.receipt-indent { margin-left: max(80px, calc(50vw - 320px - 40px)); }
.receipt-flushright { margin-right: 6vw; margin-left: auto; }
.receipt-rotated { transform: rotate(-2deg); transform-origin: center top; }

.perforation {
  border-top: 1px dashed var(--annotation-slate);
  position: relative;
  margin-bottom: 40px;
  height: 0;
}
.perf-scissor {
  position: absolute;
  right: 0;
  top: -9px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--annotation-slate);
  background: var(--frost-paper);
  padding-left: 6px;
  letter-spacing: 0.1em;
}

/* ===== Bebas shout headlines ===== */
.shout {
  font-family: "Bebas Neue", sans-serif;
  font-weight: 400;
  font-size: clamp(4rem, 18vw, 16rem);
  line-height: 0.92;
  letter-spacing: -0.02em;
  color: var(--deep-ink);
  margin-bottom: 0.4em;
  position: relative;
  display: inline-block;
  clip-path: inset(0 100% 0 0);
}
.shout.revealed {
  animation: shoutSwipe 0.6s cubic-bezier(0.85, 0, 0.15, 1) forwards;
}
@keyframes shoutSwipe {
  to { clip-path: inset(0 0 0 0); }
}

/* ===== Masking tape strips ===== */
.tape {
  position: absolute;
  width: 110px;
  height: 26px;
  background: rgba(244, 185, 92, 0.78);
  box-shadow: 0 2px 6px rgba(14,26,38,0.12);
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.2,0.7,0.1,1);
  z-index: 20;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 6px, #000 calc(100% - 6px), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 6px, #000 calc(100% - 6px), transparent 100%);
}
.tape.taped { opacity: 1; }
.tape-a { top: 14vh; left: 40px; transform: rotate(-8deg); }
.tape-a.taped { transform: rotate(-6deg); }
.tape-b { top: 14vh; right: 30px; transform: rotate(5deg); }
.tape-b.taped { transform: rotate(7deg); }
.tape-c { top: 13vh; left: 60px; transform: rotate(-12deg); }
.tape-c.taped { transform: rotate(-10deg); }

/* ===== Body text + annotations ===== */
.body-text {
  font-size: 17px;
  line-height: 1.65;
  max-width: 60ch;
  margin-bottom: 1.6em;
  color: var(--deep-ink);
}
.body-text em { font-style: italic; }
.annotation-margin {
  color: var(--annotation-slate);
  margin: 1.2em 0;
  max-width: 50ch;
}

/* hover-reveal word */
.reveal-word {
  position: relative;
  cursor: pointer;
  border-bottom: 2px solid var(--receipt-marigold);
  white-space: nowrap;
}
.reveal-word::after {
  content: attr(data-annotation);
  position: absolute;
  left: 0;
  top: -2.6em;
  transform: translateY(-8px) rotate(-3deg);
  background: rgba(244, 185, 92, 0.9);
  color: var(--deep-ink);
  font-family: "JetBrains Mono", monospace;
  font-style: italic;
  font-size: 11px;
  padding: 5px 10px;
  white-space: nowrap;
  box-shadow: 0 3px 8px rgba(14,26,38,0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.2,0.7,0.1,1);
  z-index: 40;
}
.reveal-word:hover::after,
.reveal-word.show-annotation::after {
  opacity: 1;
  transform: translateY(0) rotate(-3deg);
}

/* ===== Cascade / stagger lists ===== */
.cascade-list { list-style: none; margin: 2em 0; }
.cascade-item {
  margin-bottom: 1.4em;
}
.cascade-list:not(.cascade-list-wide) .cascade-item:nth-child(2) { margin-left: 0; }
.cascade-list .cascade-item:nth-child(3) { margin-left: 32px; transform-origin: left; }
.cascade-list .cascade-item:nth-child(4) { margin-left: 64px; }
.cascade-list .cascade-item:nth-child(5) { margin-left: 96px; }
.cascade-list .cascade-item:nth-child(6) { margin-left: 128px; }

.cascade-list-wide { margin: 2.4em 0; }
.card-ish {
  background: rgba(200, 221, 232, 0.35);
  border-left: 3px solid var(--glacier-mid);
  padding: 16px 18px;
  margin-bottom: 28px;
}
.card-ish:nth-child(1) { transform: rotate(-1.5deg); margin-left: 0; }
.card-ish:nth-child(2) { transform: rotate(0.8deg); margin-left: 32px; }
.card-ish:nth-child(3) { transform: rotate(-2deg); margin-left: 64px; }
.card-num {
  display: block;
  font-family: "Bebas Neue", sans-serif;
  font-size: 1.6rem;
  color: var(--annotation-slate);
  line-height: 1;
  margin-bottom: 4px;
}

/* ===== Stagger reveal mechanics ===== */
.stagger-child {
  opacity: 0;
  transform: translateY(40px) translateX(8px) rotate(-1deg);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.1, 1);
  transition-delay: calc(var(--i, 0) * 120ms);
}
.stagger-child.in-view {
  opacity: 1;
  transform: translateY(0) translateX(0) rotate(0);
}
/* keep card rotations after reveal */
.card-ish.stagger-child.in-view:nth-child(1) { transform: rotate(-1.5deg); }
.card-ish.stagger-child.in-view:nth-child(2) { transform: rotate(0.8deg); }
.card-ish.stagger-child.in-view:nth-child(3) { transform: rotate(-2deg); }

/* ===== Frost interludes ===== */
.frost-interlude {
  position: relative;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.frost-interlude-short { height: 80vh; }
.frost-back {
  position: absolute;
  inset: -10% 0;
  z-index: 0;
  will-change: transform;
}
.duotone-photo {
  width: 100%;
  height: 100%;
  filter: url(#duotoneInk);
}
.frost-glass {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(200, 221, 232, 0.85);
  -webkit-backdrop-filter: blur(28px) saturate(110%);
  backdrop-filter: blur(28px) saturate(110%);
  will-change: transform;
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .frost-glass { background: rgba(200, 221, 232, 0.55); }
}
.frost-word {
  position: relative;
  z-index: 30;
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(6rem, 18vw, 22rem);
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--frost-paper);
  text-shadow: 0 4px 30px rgba(14,26,38,0.25);
  clip-path: inset(0 100% 0 0);
  will-change: transform, clip-path;
}
.frost-word.revealed { animation: shoutSwipe 0.6s cubic-bezier(0.85, 0, 0.15, 1) forwards; }
.frost-annotation {
  position: absolute;
  bottom: 10vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  color: var(--deep-ink);
  background: rgba(238,244,248,0.7);
  padding: 6px 12px;
  max-width: 80vw;
  text-align: center;
  will-change: transform;
}

/* ===== Background kanji watermark on act 4 ===== */
.kanji-watermark-bg {
  position: absolute;
  font-family: "Noto Serif JP", serif;
  font-size: 40vw;
  color: var(--deep-ink);
  opacity: 0.08;
  bottom: -8vh;
  right: -6vw;
  line-height: 1;
  pointer-events: none;
  z-index: -1;
}

/* ===== Mobile ===== */
@media (max-width: 720px) {
  .receipt-column { max-width: 480px; padding: 12vh 0; }
  .receipt-indent { margin-left: 0; }
  .receipt-flushright { margin-right: 4vw; }
  .frost-interlude { height: 70vh; }
  .frost-interlude-short { height: 60vh; }
  .cascade-list .cascade-item:nth-child(3),
  .cascade-list .cascade-item:nth-child(4),
  .cascade-list .cascade-item:nth-child(5),
  .cascade-list .cascade-item:nth-child(6) { margin-left: 0; }
  .card-ish:nth-child(2), .card-ish:nth-child(3) { margin-left: 0; }
  .stagger-child {
    transform: translateY(32px) translateX(4px) rotate(-1deg);
  }
  .annotation-corner { right: 4vw; max-width: 70vw; }
  .reveal-word::after { white-space: normal; max-width: 60vw; }
}

@media (prefers-reduced-motion: reduce) {
  .stagger-child, .shout, .frost-word, .tape { transition: none; animation: none; opacity: 1; clip-path: none; transform: none; }
}
