:root {
  /* DESIGN tokens: Poiret One (Google Fonts), Josefin Sans (Google Fonts), Libre Baskerville (Google Fonts), IBM Plex Mono (Google Fonts); IntersectionObserver triggers. IntersectionObserver` (threshold: 0.15 */
  --vault-black: #0a0b12;
  --deep-indigo: #1a1c2e;
  --grain-layer: #16172a;
  --cyan: #00e5ff;
  --magenta: #ff00e5;
  --lavender: #e8e4f0;
  --steel: #7a7b92;
  --green: #00ff88;
  --body: #c4c0d2;
  --display: "Poiret One", cursive;
  --label: "Josefin Sans", sans-serif;
  --serif: "Libre Baskerville", serif;
  --mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--body);
  background:
    radial-gradient(circle at 50% 10%, rgba(0, 229, 255, 0.12), transparent 28rem),
    radial-gradient(circle at 86% 42%, rgba(255, 0, 229, 0.08), transparent 22rem),
    linear-gradient(145deg, var(--vault-black) 0%, #090913 48%, var(--grain-layer) 100%);
  font-family: var(--serif);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(0,229,255,0.04) 1px, transparent 1px),
    linear-gradient(0deg, rgba(0,229,255,0.03) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(circle, black 0%, transparent 82%);
}

.grain-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.06;
  mix-blend-mode: overlay;
  will-change: background-position;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)' opacity='0.85'/%3E%3C/svg%3E");
  background-size: 150px 150px;
  animation: grain 0.15s steps(4) infinite;
}

@keyframes grain {
  0%, 100% { background-position: 0 0; }
  25% { background-position: -37px 14px; }
  50% { background-position: 51px -29px; }
  75% { background-position: -18px 43px; }
}

.bubble-field {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.bubble {
  position: absolute;
  left: var(--x);
  bottom: -110px;
  width: var(--size);
  height: var(--size);
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: rgba(0, 229, 255, 0.15);
  font: 300 0.6rem var(--mono);
  background: radial-gradient(circle at 38% 32%, transparent 36%, rgba(0, 229, 255, 0.05) 72%, rgba(0, 229, 255, 0.11) 100%);
  box-shadow: inset 0 0 20px rgba(0, 229, 255, 0.1), 0 0 22px rgba(0, 229, 255, 0.05);
  animation: float-up var(--duration) linear infinite, drift calc(var(--duration) * 0.42) ease-in-out infinite alternate;
  animation-delay: var(--delay), calc(var(--delay) * 0.5);
}

@keyframes float-up {
  from { bottom: -110px; }
  to { bottom: calc(100vh + 110px); }
}

@keyframes drift {
  from { transform: translateX(-30px); }
  to { transform: translateX(30px); }
}

.hud-rail {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 48px;
  z-index: 20;
  background: rgba(10, 11, 18, 0.7);
  border-color: rgba(0, 229, 255, 0.3);
  backdrop-filter: blur(8px);
}

.hud-rail--left {
  left: 0;
  border-right: 1px solid rgba(0, 229, 255, 0.3);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 24px;
}

.hud-rail--right {
  right: 0;
  border-left: 1px solid rgba(0, 229, 255, 0.3);
}

.hud-rail::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent, rgba(0, 229, 255, 0.5), transparent);
  height: 35%;
  animation: rail-scan 5.5s linear infinite;
  opacity: 0.35;
}

@keyframes rail-scan {
  from { transform: translateY(-110%); }
  to { transform: translateY(300%); }
}

.waypoint {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  padding: 0;
  border: 1px solid rgba(0, 229, 255, 0.5);
  background: transparent;
  position: relative;
  cursor: pointer;
  z-index: 2;
  transition: background 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}

.waypoint span {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  font: 300 0.62rem var(--mono);
  color: rgba(0, 229, 255, 0.5);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.waypoint:hover span, .waypoint.is-active span { opacity: 1; }

.waypoint.is-active {
  background: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 18px rgba(0, 229, 255, 0.9);
}

.rail-stamp {
  position: absolute;
  top: 8rem;
  left: 50%;
  width: max-content;
  transform: translateX(-50%) rotate(-90deg);
  font: 300 0.65rem var(--mono);
  letter-spacing: 0.12em;
  color: rgba(122, 123, 146, 0.4);
  white-space: nowrap;
}

.rail-stamp--top { top: 10rem; }
.rail-stamp--bottom { top: auto; bottom: 10rem; }

.vault {
  position: relative;
  z-index: 2;
}

.vault-door {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 8rem 5rem;
  position: relative;
  overflow: hidden;
}

.vignette-ring {
  position: absolute;
  inset: -10%;
  pointer-events: none;
  background: radial-gradient(circle, transparent 42%, rgba(10, 11, 18, 0.52) 75%, #0a0b12 100%);
  animation: vignette-pulse 5s ease-in-out infinite;
}

@keyframes vignette-pulse {
  0%, 100% { opacity: 0.75; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); }
}

.deco-frame {
  width: min(720px, 82vw);
  aspect-ratio: 1;
  border: 1px solid rgba(0, 229, 255, 0.32);
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  box-shadow: 0 0 80px rgba(0, 229, 255, 0.12), inset 0 0 60px rgba(255, 0, 229, 0.06);
}

.deco-frame::before,
.deco-frame::after,
.deco-octagon::before,
.deco-octagon::after,
.drawer-frame::before,
.drawer-frame::after,
.file-card::before,
.seal-frame::before {
  content: "";
  position: absolute;
  pointer-events: none;
}

.deco-frame::before {
  inset: 11%;
  border: 1px solid rgba(255, 0, 229, 0.28);
  border-radius: 50%;
  animation: neon-cycle 6s linear infinite;
}

.deco-frame::after {
  inset: -1px;
  border-radius: inherit;
  background: conic-gradient(from 0deg, transparent, var(--cyan), transparent, var(--magenta), transparent);
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1px));
  animation: rotate-glow 8s linear infinite;
}

@keyframes rotate-glow { to { transform: rotate(360deg); } }

@keyframes neon-cycle {
  0%, 100% { border-color: rgba(0,229,255,0.34); box-shadow: 0 0 24px rgba(0,229,255,0.15); }
  50% { border-color: rgba(255,0,229,0.44); box-shadow: 0 0 28px rgba(255,0,229,0.13); }
}

.deco-octagon {
  width: 68%;
  aspect-ratio: 1;
  clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
  border: 1px solid rgba(0, 229, 255, 0.65);
  background: rgba(26, 28, 46, 0.52);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 4rem;
  position: relative;
  box-shadow: inset 0 0 42px rgba(0, 229, 255, 0.1);
}

.deco-octagon::before {
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(0, 229, 255, 0.9), transparent);
  height: 1px;
  animation: edge-run 4.5s linear infinite;
}

.deco-octagon::after {
  inset: 0;
  background: linear-gradient(180deg, transparent, rgba(255, 0, 229, 0.85), transparent);
  width: 1px;
  margin-left: auto;
  animation: edge-drop 5s linear infinite 0.8s;
}

@keyframes edge-run {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

@keyframes edge-drop {
  from { transform: translateY(-100%); }
  to { transform: translateY(100%); }
}

h1, h2 {
  font-family: var(--display);
  color: var(--lavender);
  font-weight: 400;
  letter-spacing: 0.2em;
  margin: 0;
}

h1 {
  font-size: clamp(2.8rem, 7vw, 5.5rem);
  text-shadow: 0 0 22px rgba(0, 229, 255, 0.22);
}

h2 { font-size: clamp(1.8rem, 4vw, 3rem); line-height: 1.2; }

.classification, .eyebrow, .door-caption, .terminal-code, .card-code {
  font-family: var(--mono);
  font-weight: 300;
  letter-spacing: 0.1em;
}

.classification {
  color: rgba(0, 229, 255, 0.5);
  font-size: 0.75rem;
  margin: 0 0 1rem;
}

.japanese-phrase {
  margin: 1.2rem 0 0;
  font-family: var(--label);
  font-size: clamp(0.9rem, 1.5vw, 1.2rem);
  letter-spacing: 0.35em;
  color: var(--cyan);
  opacity: 0;
  animation: phrase-in 2.4s ease 0.8s forwards;
}

@keyframes phrase-in { to { opacity: 1; } }

.door-caption {
  position: absolute;
  bottom: 3.5rem;
  color: rgba(122, 123, 146, 0.78);
  font-size: 0.72rem;
  text-align: center;
}

.drawer, .archive-index, .vault-seal {
  min-height: 100vh;
  padding: 8rem clamp(1rem, 8vw, 7rem);
  display: grid;
  align-items: center;
}

.drawer-frame, .archive-index, .seal-frame {
  position: relative;
  border-radius: 2px;
  border: 1px solid var(--deep-indigo);
  background: rgba(26, 28, 46, 0.64);
  box-shadow: inset 0 0 70px rgba(0, 229, 255, 0.035), 0 26px 80px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  transition: border-color 0.8s ease, box-shadow 0.8s ease, transform 1s ease, opacity 1s ease;
}

.drawer-frame {
  padding: clamp(2rem, 5vw, 5rem);
  transform: translateY(64px);
  opacity: 0.45;
}

.drawer.is-visible .drawer-frame, .archive-index.is-visible, .vault-seal.is-visible .seal-frame {
  border-color: var(--cyan);
  box-shadow: 0 0 40px rgba(0, 229, 255, 0.12), inset 0 0 70px rgba(0, 229, 255, 0.06);
  transform: translateY(0);
  opacity: 1;
}

.drawer-frame::before, .file-card::before, .seal-frame::before {
  left: -100%;
  top: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  animation: border-sweep 4.8s linear infinite;
}

.drawer-frame::after {
  right: 0;
  top: -100%;
  width: 1px;
  height: 100%;
  background: linear-gradient(180deg, transparent, var(--magenta), transparent);
  animation: border-fall 5.6s linear infinite 0.5s;
}

@keyframes border-sweep { to { transform: translateX(200%); } }
@keyframes border-fall { to { transform: translateY(200%); } }

.drawer-content {
  display: grid;
  grid-template-columns: 65fr 35fr;
  gap: clamp(2rem, 6vw, 5rem);
  position: relative;
  z-index: 2;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 1.2s ease 0.3s, transform 1.2s ease 0.3s;
}

.drawer.is-visible .drawer-content { opacity: 1; transform: translateY(0); }

.drawer-primary p:not(.eyebrow), .seal-frame p:not(.eyebrow):not(.terminal-code) {
  font-size: clamp(1rem, 1.3vw, 1.15rem);
  line-height: 1.85;
  color: var(--body);
  max-width: 70ch;
}

.eyebrow {
  margin: 0 0 1.1rem;
  color: var(--cyan);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.drawer-aside {
  border-left: 1px solid rgba(0, 229, 255, 0.24);
  padding-left: 1.5rem;
  align-self: center;
  color: var(--steel);
}

.drawer-aside span {
  display: block;
  font: 300 clamp(0.9rem, 1.5vw, 1.2rem) var(--label);
  letter-spacing: 0.35em;
  color: var(--cyan);
}

.drawer-aside strong {
  display: block;
  margin: 1rem 0;
  font: 400 1.7rem var(--display);
  color: var(--lavender);
  letter-spacing: 0.18em;
}

.drawer-aside p {
  font: 300 0.78rem/1.8 var(--mono);
  color: rgba(196, 192, 210, 0.68);
}

.botanical {
  position: absolute;
  width: min(520px, 70vw);
  height: auto;
  right: -7%;
  top: 8%;
  fill: none;
  stroke: var(--green);
  stroke-width: 1.5;
  opacity: 0.08;
  filter: blur(2px);
  z-index: 1;
}

.botanical path {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  transition: stroke-dashoffset 3s ease-in-out, opacity 4s ease-in-out;
}

.drawer.is-visible .botanical path {
  stroke-dashoffset: 0;
  animation: botanical-pulse 4s ease-in-out 3s infinite;
}

@keyframes botanical-pulse {
  0%, 100% { opacity: 0.08; }
  50% { opacity: 0.12; }
}

.section-heading {
  margin-bottom: 2rem;
}

.archive-index {
  display: block;
  min-height: auto;
  margin: 6rem clamp(1rem, 8vw, 7rem);
  padding: clamp(2rem, 5vw, 5rem);
  transform: translateY(64px);
  opacity: 0.48;
}

.filing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.file-card {
  min-height: 220px;
  position: relative;
  overflow: hidden;
  padding: 1.4rem;
  border: 1px solid rgba(122, 123, 146, 0.32);
  background:
    linear-gradient(rgba(22, 23, 42, 0.78), rgba(26, 28, 46, 0.82)),
    radial-gradient(circle at 70% 20%, rgba(0, 255, 136, 0.08), transparent 45%);
  transition: border-color 0.45s ease, box-shadow 0.45s ease, transform 0.45s ease;
}

.file-card:nth-child(2n)::after {
  content: "菊";
}

.file-card:nth-child(2n+1)::after {
  content: "菖";
}

.file-card::after {
  position: absolute;
  right: 1rem;
  bottom: -0.4rem;
  font-family: var(--display);
  font-size: 8rem;
  color: rgba(0, 255, 136, 0.08);
  transition: color 0.45s ease;
}

.file-card::before { animation-delay: calc(var(--card-delay, 0) * 0.5s); }
.file-card:nth-child(1) { --card-delay: 1; }
.file-card:nth-child(2) { --card-delay: 2; }
.file-card:nth-child(3) { --card-delay: 3; }
.file-card:nth-child(4) { --card-delay: 4; }
.file-card:nth-child(5) { --card-delay: 5; }
.file-card:nth-child(6) { --card-delay: 6; }

.file-card:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 28px rgba(0, 229, 255, 0.14);
  transform: translateY(-6px);
}

.file-card:hover::after { color: rgba(0, 255, 136, 0.25); }

.card-code {
  color: rgba(0, 229, 255, 0.5);
  font-size: 0.75rem;
}

.file-card h3 {
  margin: 2rem 0 1rem;
  font: 300 clamp(0.9rem, 1.5vw, 1.2rem) var(--label);
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--cyan);
}

.file-card p {
  color: rgba(196, 192, 210, 0.78);
  font-size: 0.95rem;
  line-height: 1.7;
  position: relative;
  z-index: 1;
}

.vault-seal {
  min-height: 100vh;
  text-align: center;
}

.seal-frame {
  max-width: 880px;
  margin: auto;
  padding: clamp(2rem, 6vw, 5rem);
  transform: translateY(64px);
  opacity: 0.45;
}

.seal-mark {
  width: 8rem;
  height: 8rem;
  margin: 2.5rem auto;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 0, 229, 0.42);
  border-radius: 50%;
  font-family: var(--display);
  font-size: 4rem;
  color: var(--magenta);
  text-shadow: 0 0 28px rgba(255, 0, 229, 0.4);
  box-shadow: inset 0 0 34px rgba(255, 0, 229, 0.08), 0 0 38px rgba(0, 229, 255, 0.1);
}

.terminal-code {
  color: rgba(0, 229, 255, 0.5);
  font-size: 0.75rem;
}

@media (max-width: 900px) {
  .filing-grid { grid-template-columns: repeat(2, 1fr); }
  .drawer-content { grid-template-columns: 1fr; }
  .drawer-aside { border-left: 0; border-top: 1px solid rgba(0, 229, 255, 0.24); padding: 1.5rem 0 0; }
  .deco-octagon { width: 78%; padding: 2rem; }
}

@media (max-width: 768px) {
  .hud-rail { width: 0; overflow: hidden; border: 0; }
  .vault-door, .drawer, .archive-index, .vault-seal { padding-left: 1rem; padding-right: 1rem; }
  .archive-index { margin-left: 1rem; margin-right: 1rem; }
  .filing-grid { grid-template-columns: 1fr; }
  .bubble:nth-child(n+9) { display: none; }
  h1, h2 { letter-spacing: 0.14em; }
  .door-caption { width: calc(100% - 2rem); }
}

@media (max-width: 520px) {
  .deco-frame { width: 92vw; }
  .deco-octagon { width: 82%; }
  .japanese-phrase { letter-spacing: 0.22em; }
  .drawer-frame, .archive-index, .seal-frame { padding: 1.5rem; }
}
