@import url('https://fonts.googleapis.com/css2?family=Klee+One:wght@400;600&family=Orbitron:wght@400;600&family=Sawarabi+Mincho&family=Yuji+Syuku&display=swap');

:root {
  color-scheme: dark;
  --black: #0a0a0a;
  --white: #f5f5f5;
  --silver: #8a8a8a;
  --blood: #a40f18;
  --red: #c62828;
  --cyan: #00e5ff;
  --gold: #ffd700;
  --section-progress: 0;
}

* { box-sizing: border-box; }
html { background: var(--black); scroll-behavior: smooth; }
body {
  margin: 0;
  overflow-x: hidden;
  background: var(--black);
  color: var(--white);
  font-family: 'Klee One', 'Yu Mincho', 'Hiragino Mincho ProN', serif;
  font-feature-settings: 'palt';
}
button, a { font: inherit; }
::selection { color: var(--white); background: var(--blood); }

.loader {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.1rem;
  background: #050505;
  transition: opacity 1.1s ease, visibility 1.1s;
}
.loader::before, .loader::after {
  content: '';
  position: absolute;
  inset: 50%;
  width: 38vmax;
  height: 38vmax;
  border-radius: 48% 52% 37% 63%;
  background: radial-gradient(circle, rgba(139,0,0,.3), rgba(12,12,12,.92) 46%, transparent 70%);
  filter: blur(22px);
  translate: -50% -50%;
  animation: loader-bleed 3.5s ease-in-out infinite alternate;
}
.loader::after { width: 24vmax; height: 24vmax; animation-delay: -1.7s; opacity: .65; }
.loader.is-finished { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-mark {
  position: relative;
  z-index: 2;
  font: 7rem/1 'Yuji Syuku', 'Yu Mincho', serif;
  color: rgba(245,245,245,.92);
  text-shadow: 0 0 22px rgba(198,40,40,.7), 4px 5px 1px rgba(80,0,0,.55);
  animation: ink-pulse 2.4s ease-in-out infinite;
}
.loader-label { position: relative; z-index: 2; margin: 0; letter-spacing: .35em; color: #aaa; font-size: .72rem; }
.loader-track { position: relative; z-index: 2; width: min(54vw, 260px); height: 1px; overflow: hidden; background: #282828; }
.loader-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--blood), var(--white)); box-shadow: 0 0 14px var(--red); transition: width .2s; }
.loader output { position: relative; z-index: 2; font: .63rem 'Orbitron', serif; color: #686868; letter-spacing: .25em; }

.experience { position: relative; min-height: 100vh; opacity: 1; transition: opacity 1.2s ease; }
.experience.is-loading { height: 100vh; overflow: hidden; opacity: 0; }
.visual-stage { position: fixed; z-index: 0; inset: 0; overflow: hidden; background: #050505; }
#frame-sequence {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 38%;
  filter: contrast(1.12) saturate(.86) brightness(.72);
  transform: scale(var(--frame-scale, 1.035));
  opacity: var(--frame-opacity, 1);
  will-change: transform, opacity, filter;
  transition: opacity .28s linear;
}
.frame-ghost {
  position: absolute;
  inset: 0;
  opacity: 0;
  mix-blend-mode: screen;
  background-image: var(--ghost-frame);
  background-position: center 38%;
  background-size: cover;
  filter: sepia(1) saturate(5) hue-rotate(320deg) contrast(1.6);
  transform: translateX(-4px) scale(1.04);
}
.ink-wash { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 42%, transparent 18%, rgba(5,5,5,.13) 47%, #050505 92%); }
.vignette { position: absolute; inset: 0; box-shadow: inset 0 0 16vmax 6vmax #030303; pointer-events: none; }
.film-grain {
  position: absolute;
  inset: -50%;
  opacity: .055;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
  animation: grain .28s steps(2) infinite;
  pointer-events: none;
}

.cyber-grid {
  position: absolute;
  inset: 44% -15% -20%;
  opacity: 0;
  transform: perspective(420px) rotateX(62deg) translateY(12%);
  transform-origin: center top;
  background-image: linear-gradient(rgba(0,229,255,.22) 1px, transparent 1px), linear-gradient(90deg, rgba(0,229,255,.22) 1px, transparent 1px);
  background-size: 55px 44px;
  mask-image: linear-gradient(to bottom, transparent, #000 22%, #000 70%, transparent);
  transition: opacity .7s ease;
  animation: grid-flow 1.7s linear infinite;
}
.glitch-field { position: absolute; inset: 0; opacity: 0; overflow: hidden; mix-blend-mode: screen; }
.glitch-field i { position: absolute; left: -10%; width: 120%; height: 2px; background: var(--red); box-shadow: 0 0 14px var(--red); animation: glitch-scan 2.3s steps(1) infinite; }
.glitch-field i:nth-child(2) { height: 7px; opacity: .45; animation-delay: -.7s; }
.glitch-field i:nth-child(3) { background: #fff; opacity: .22; animation-delay: -1.5s; }
.strobe { position: absolute; inset: 0; opacity: 0; background: linear-gradient(105deg, rgba(198,40,40,.4), transparent 43%, rgba(0,229,255,.35)); mix-blend-mode: screen; }
.circuit-lines { position: absolute; inset: 0; opacity: 0; transition: opacity 1.2s ease; }
.circuit-lines i { position: absolute; display: block; height: 1px; width: 32vw; background: linear-gradient(90deg, transparent, rgba(0,229,255,.62), transparent); box-shadow: 0 0 8px rgba(0,229,255,.45); }
.circuit-lines i:nth-child(1) { top: 18%; left: 0; transform: rotate(22deg); }
.circuit-lines i:nth-child(2) { top: 31%; right: -4%; transform: rotate(-31deg); }
.circuit-lines i:nth-child(3) { bottom: 26%; left: -5%; transform: rotate(-16deg); }
.circuit-lines i:nth-child(4) { bottom: 14%; right: 5%; width: 20vw; transform: rotate(36deg); }
.circuit-lines i:nth-child(5) { top: 52%; left: 37%; width: 25vw; opacity: .35; }
#particles { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.wolf-calligraphy {
  position: absolute;
  top: 46%;
  left: 50%;
  width: min(62vh, 68vw);
  opacity: 0;
  transform: translate(-50%, -50%) scale(.82) rotate(-2deg);
  filter: drop-shadow(0 0 20px rgba(255,215,0,.15));
  transition: opacity .7s ease, transform 1.2s cubic-bezier(.2,.8,.2,1);
}
.wolf-calligraphy .brush { stroke-width: 22; stroke-dasharray: 1600; stroke-dashoffset: 1600; }
.wolf-calligraphy .brush-two { stroke-width: 13; }
.wolf-calligraphy .brush-three { stroke-width: 10; }
.wolf-calligraphy .ink-slash { fill: none; stroke: var(--blood); stroke-width: 9; opacity: .8; }
.wolf-calligraphy text { fill: #ddd; font: 54px 'Yuji Syuku', serif; letter-spacing: .3em; }

body[data-chapter='1'] .cyber-grid, body[data-chapter='1'] .glitch-field { opacity: 1; }
body[data-chapter='1'] .frame-ghost { animation: chroma-jump 2.8s steps(1) infinite; }
body[data-chapter='2'] .frame-ghost { animation: chroma-jump .8s steps(1) infinite; }
body[data-chapter='2'] .strobe { animation: strobe 2.2s steps(1) infinite; }
body[data-chapter='3'] .wolf-calligraphy { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-2deg); }
body[data-chapter='3'] .wolf-calligraphy .brush { animation: brush-draw 2.3s ease forwards; }
body[data-chapter='3'] .wolf-calligraphy .brush-two { animation-delay: .25s; }
body[data-chapter='3'] .wolf-calligraphy .brush-three { animation-delay: .45s; }
body[data-chapter='4'] .circuit-lines { opacity: .75; animation: circuit-pulse 3s ease-in-out infinite; }

.chapter { position: relative; z-index: 2; height: 100svh; min-height: 640px; display: grid; align-items: center; padding: max(5vw, 3rem) max(7vw, 2rem); }
.chapter-copy { position: relative; width: min(750px, 74vw); opacity: 0; transform: translate3d(0, 42px, 0) scale(.965); transition: opacity .8s ease, transform .8s ease; will-change: opacity, transform; }
.chapter.is-active .chapter-copy { opacity: var(--copy-opacity, 1); transform: translate3d(var(--copy-x, 0), var(--copy-y, 0), 0) scale(var(--copy-scale, 1)); }
.chapter-opening .chapter-copy, .chapter-fate .chapter-copy { margin-left: 7vw; }
.chapter-awakening .chapter-copy, .chapter-resolve .chapter-copy { justify-self: end; text-align: right; }
.chapter-roar .chapter-copy { justify-self: center; text-align: center; }
.chapter-fate { align-items: end; padding-bottom: 9vh; }
.chapter-fate .chapter-copy { width: min(670px, 64vw); }
.chapter-resolve { min-height: 720px; }

.eyebrow { margin: 0 0 1.2rem; color: #aaa; font-size: clamp(.64rem, .85vw, .78rem); letter-spacing: .42em; }
.eyebrow::before { content: ''; display: inline-block; width: 36px; height: 1px; margin: 0 14px 3px 0; background: currentColor; }
h1, h2 { margin: 0; font-family: 'Yuji Syuku', 'Yu Mincho', serif; font-weight: 400; text-wrap: balance; }
h1 { font-size: clamp(8rem, 18vw, 17rem); line-height: .78; letter-spacing: -.08em; color: var(--white); text-shadow: 0 0 3px #fff, 0 0 26px rgba(198,40,40,.7), 8px 10px 2px rgba(95,0,0,.65); filter: blur(.15px); }
h2 { font-size: clamp(3.1rem, 7vw, 7rem); line-height: 1.18; text-shadow: 0 0 16px rgba(255,255,255,.16), 5px 6px 1px rgba(0,0,0,.85); }
h2 em { color: #fff; font-style: normal; text-shadow: 0 0 17px rgba(198,40,40,.55), 3px 3px 0 rgba(95,0,0,.7); }
.chapter-awakening h2 em { color: var(--cyan); text-shadow: 0 0 19px rgba(0,229,255,.56); }
.chapter-resolve h2 span { font: 600 clamp(3.2rem, 8vw, 7rem)/1 'Orbitron', 'Yu Mincho', serif; color: transparent; -webkit-text-stroke: 1px rgba(245,245,245,.8); letter-spacing: .08em; text-shadow: 0 0 26px rgba(198,40,40,.4); }
.subtitle { margin: 2.2rem 0 0 4rem; color: #d0d0d0; font-size: clamp(1.05rem, 2.2vw, 1.75rem); letter-spacing: .26em; text-shadow: 0 0 12px rgba(198,40,40,.8); }
.chapter-note { margin: 2rem 0 0; color: #a0a0a0; font-size: clamp(.83rem, 1.35vw, 1.1rem); letter-spacing: .18em; line-height: 2; }
.chapter-roar .chapter-note { font-family: 'Orbitron', 'Sawarabi Mincho', serif; font-size: .62rem; color: var(--cyan); letter-spacing: .42em; }
.seal { position: absolute; top: 9%; right: 9%; display: grid; place-content: center; width: 3.2rem; aspect-ratio: 1; border: 2px solid #b22121; color: #d84c4c; font-family: 'Yuji Syuku', serif; font-size: 1.8rem; transform: rotate(8deg); opacity: .75; }

.chapter-nav { position: fixed; z-index: 20; top: 0; bottom: 0; left: 2.2vw; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 1.5rem; }
.chapter-nav .chapter-label, .frame-readout { position: absolute; font: .5rem 'Orbitron', serif; color: #686868; letter-spacing: .22em; white-space: nowrap; writing-mode: vertical-rl; }
.chapter-label { top: 4vh; }
.frame-readout { bottom: 4vh; }
.chapter-nav ol { display: grid; gap: 1.2rem; margin: 0; padding: 0; list-style: none; }
.chapter-nav li { position: relative; display: grid; place-content: center; }
.chapter-nav li::after { content: ''; position: absolute; top: calc(100% + .2rem); left: 50%; width: 1px; height: .82rem; background: #333; }
.chapter-nav li:last-child::after { display: none; }
.chapter-nav button { width: 1.8rem; height: 1.8rem; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #555; font-family: 'Yuji Syuku', serif; font-size: .85rem; cursor: pointer; transition: color .35s, text-shadow .35s, transform .35s; }
.chapter-nav li.is-active button { color: #fff; transform: scale(1.22); text-shadow: 0 0 10px var(--red); }
.scroll-cue { position: absolute; bottom: 4vh; right: 4vw; display: flex; align-items: center; gap: .9rem; margin: 0; font: .52rem 'Orbitron', serif; color: #888; letter-spacing: .3em; transform: rotate(90deg); transform-origin: right center; }
.scroll-cue i { display: block; width: 54px; height: 1px; overflow: hidden; background: #444; }
.scroll-cue i::after { content: ''; display: block; width: 45%; height: 100%; background: #eee; animation: scroll-line 1.8s ease-in-out infinite; }

.reveal-link { position: relative; display: inline-grid; grid-template-columns: 1fr auto; column-gap: 2rem; min-width: min(420px, 80vw); margin-top: 3.3rem; padding: 1.2rem 1.5rem; overflow: hidden; border: 1px solid rgba(198,40,40,.75); color: #fff; text-align: left; text-decoration: none; background: rgba(70,0,0,.22); box-shadow: inset 0 0 22px rgba(198,40,40,.1), 0 0 22px rgba(198,40,40,.2); transition: border-color .45s, box-shadow .45s, transform .45s; }
.reveal-link::before { content: ''; position: absolute; inset: 0; z-index: -1; opacity: 0; background: linear-gradient(110deg, rgba(198,40,40,.88), rgba(10,10,10,.55) 48%, rgba(0,229,255,.7)); transform: translateX(-50%); transition: opacity .45s, transform .55s; }
.reveal-link small { grid-column: 1 / -1; margin-bottom: .4rem; font: .48rem 'Orbitron', serif; color: #999; letter-spacing: .35em; }
.reveal-link strong { font-family: 'Yuji Syuku', serif; font-size: 1.55rem; font-weight: 400; letter-spacing: .25em; }
.reveal-link span { grid-row: 2; grid-column: 2; font-size: 1.6rem; }
.reveal-link:hover, .reveal-link:focus-visible { border-color: var(--cyan); box-shadow: 0 0 18px var(--blood), 0 0 38px rgba(0,229,255,.33); transform: translateY(-4px); outline: none; }
.reveal-link:hover::before, .reveal-link:focus-visible::before { opacity: 1; transform: translateX(0); }
.site-footer { position: absolute; left: 7vw; right: 4vw; bottom: 2.2vh; display: flex; justify-content: space-between; color: #555; font: .48rem 'Orbitron', serif; letter-spacing: .22em; }

noscript { position: fixed; z-index: 2000; inset: auto 0 0; padding: 1rem; color: white; background: #8b0000; text-align: center; }

@keyframes loader-bleed { to { width: 55vmax; height: 44vmax; transform: rotate(17deg); filter: blur(35px); } }
@keyframes ink-pulse { 50% { transform: scale(1.04); filter: blur(.8px); opacity: .7; } }
@keyframes grain { 0% { transform: translate(2%, -3%); } 50% { transform: translate(-3%, 2%); } 100% { transform: translate(1%, 4%); } }
@keyframes grid-flow { to { background-position: 0 44px, 55px 0; } }
@keyframes glitch-scan { 0% { top: 12%; transform: translateX(-8%); } 21% { top: 67%; transform: translateX(7%); } 43% { top: 34%; } 66% { top: 86%; transform: translateX(-3%); } 100% { top: 9%; } }
@keyframes chroma-jump { 0%, 86%, 100% { opacity: 0; } 87% { opacity: .6; clip-path: inset(28% 0 58%); } 90% { opacity: .4; clip-path: inset(64% 0 14%); transform: translateX(6px) scale(1.04); } 93% { opacity: 0; } }
@keyframes strobe { 0%, 87%, 91%, 100% { opacity: 0; } 88% { opacity: .75; } 89% { opacity: .12; } 90% { opacity: .48; background: linear-gradient(105deg, rgba(0,229,255,.45), transparent 45%, rgba(198,40,40,.35)); } }
@keyframes brush-draw { to { stroke-dashoffset: 0; } }
@keyframes circuit-pulse { 50% { opacity: .35; filter: hue-rotate(24deg); } }
@keyframes scroll-line { from { transform: translateX(-120%); } to { transform: translateX(250%); } }

@media (max-width: 760px) {
  .chapter { padding: 12vh 8vw 10vh 15vw; align-items: end; }
  .chapter-copy, .chapter-fate .chapter-copy { width: 100%; margin: 0; }
  .chapter-awakening .chapter-copy, .chapter-resolve .chapter-copy { justify-self: stretch; text-align: left; }
  .chapter-roar .chapter-copy { text-align: left; }
  .chapter-opening { align-items: center; }
  .chapter-opening .chapter-copy { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 1.1rem; }
  .chapter-opening .eyebrow { grid-column: 1 / -1; }
  .chapter-opening h1 { writing-mode: vertical-rl; font-size: clamp(6.5rem, 30vw, 10rem); line-height: .72; }
  .chapter-opening .subtitle { margin: 0; writing-mode: vertical-rl; font-size: 1rem; line-height: 2; }
  h2 { font-size: clamp(2.5rem, 11vw, 4.4rem); }
  .chapter-note { letter-spacing: .1em; }
  .chapter-nav { left: 2vw; }
  .chapter-nav .chapter-label, .frame-readout { display: none; }
  .chapter-nav ol { gap: .75rem; }
  .scroll-cue { right: 2vw; }
  .wolf-calligraphy { top: 37%; width: 92vw; }
  #frame-sequence { object-position: center center; }
  .site-footer { left: 15vw; font-size: .4rem; }
  .site-footer span:last-child { display: none; }
  .seal { right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .film-grain, #particles, .glitch-field, .strobe { display: none; }
}
