:root {
  --marble-white: #f0ece4;
  --vein-gray: #8a8578;
  --terminal-teal: #2d8a7e;
  --stratum-violet: #7e2d8a;
  --fault-amber: #8a7e2d;
  --deep-stone: #1a1917;
  --fog: #d4d0c8;
  --ease-geological: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Design vocabulary: Intersection Observer. Interval` at 20s for corruption events. Glitch effects on the title use CSS `@keyframes` with `animation-delay` — no JS required. Crack-divider SVGs are generated once on page load via a small JS function and injected as inline SVG. Space Mono against the frosted marble backdrop: Space Mono interspersed with Garamond commentary; Space Mono's rigid monospace creates the core visual tension of the design — antiquity and computation coexisting. Space Mono" (Google Fonts */

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: var(--deep-stone);
}

body {
  margin: 0;
  color: var(--deep-stone);
  font-family: "EB Garamond", Garamond, serif;
  font-feature-settings: 'liga' 1, 'onum' 1;
  overflow-x: hidden;
  background-color: var(--marble-white);
}

body::before {
  content: "";
  position: fixed;
  inset: -12%;
  z-index: -2;
  background:
    radial-gradient(ellipse at 12% 18%, rgba(138, 133, 120, 0.34) 0 1px, transparent 24%),
    radial-gradient(ellipse at 86% 24%, rgba(45, 138, 126, 0.10), transparent 28%),
    radial-gradient(ellipse at 30% 74%, rgba(126, 45, 138, 0.08), transparent 34%),
    linear-gradient(112deg, transparent 0 17%, rgba(138, 133, 120, 0.22) 18%, transparent 19% 42%, rgba(138, 126, 45, 0.15) 43%, transparent 44% 100%),
    linear-gradient(74deg, rgba(240, 236, 228, 0.96), rgba(212, 208, 200, 0.74) 46%, rgba(240, 236, 228, 0.98));
  background-size: 720px 620px, 900px 740px, 840px 680px, 1200px 1200px, 100% 100%;
  background-blend-mode: overlay, multiply, overlay, multiply, normal;
  animation: marbleDrift 45s var(--ease-geological) infinite alternate;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0 31px, rgba(138, 133, 120, 0.045) 32px 33px), linear-gradient(180deg, rgba(240,236,228,0), rgba(26,25,23,0.08));
  mix-blend-mode: multiply;
}

@keyframes marbleDrift {
  0% { background-position: 0 0, 0 0, 0 0, 0 0, 0 0; }
  100% { background-position: 80px -120px, -140px 90px, 110px 150px, -220px 180px, 0 0; }
}

.viewport-shift {
  transition: transform 100ms var(--ease-geological);
}

.viewport-shift.tectonic {
  transform: translateX(3px);
}

.quarry-face {
  min-height: 500vh;
}

.stratum {
  position: relative;
  min-height: 100vh;
  padding: 12vh 8vw;
  display: flex;
  align-items: center;
  isolation: isolate;
}

.stratum::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(102deg, rgba(240, 236, 228, 0.35), rgba(212, 208, 200, 0.15)),
    repeating-linear-gradient(178deg, transparent 0 44px, rgba(138, 133, 120, 0.05) 45px 48px);
  opacity: 0.72;
}

.stratum-inscription {
  min-height: 100vh;
  align-items: flex-end;
  padding-bottom: 16vh;
}

.inscription-block {
  width: min(76vw, 1120px);
  margin-left: 3vw;
}

.title-glitch {
  position: relative;
  margin: 0;
  min-height: clamp(4.6rem, 11vw, 8.4rem);
  font-family: "Cormorant Garamond", Garamond, serif;
  font-size: clamp(3.5rem, 9vw, 7rem);
  font-weight: 300;
  letter-spacing: 0.08em;
  line-height: 0.95;
  text-transform: uppercase;
  color: var(--deep-stone);
}

.title-layer {
  display: block;
  transition: color 30ms linear, opacity 600ms var(--ease-geological);
}

.title-layer-main.chisel-flash { color: var(--terminal-teal); }

.title-layer-teal,
.title-layer-violet,
.title-layer-amber {
  position: absolute;
  inset: 0 auto auto 0;
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: screen;
}

.title-layer-teal { color: var(--terminal-teal); }
.title-layer-violet { color: var(--stratum-violet); }
.title-layer-amber { color: var(--fault-amber); }

.title-glitch.glitching .title-layer-teal {
  opacity: 0.9;
  transform: translate(4px, -1px);
  clip-path: polygon(0 0, 100% 0, 100% 34%, 0 28%);
  animation: titleGlitchTeal 180ms steps(2, end);
  animation-delay: 0ms;
}

.title-glitch.glitching .title-layer-violet {
  opacity: 0.8;
  transform: translate(-3px, 2px);
  clip-path: polygon(0 32%, 100% 38%, 100% 68%, 0 62%);
  animation: titleGlitchViolet 180ms steps(2, end);
  animation-delay: 20ms;
}

.title-glitch.glitching .title-layer-amber {
  opacity: 0.75;
  transform: translate(2px, 3px);
  clip-path: polygon(0 64%, 100% 58%, 100% 100%, 0 100%);
  animation: titleGlitchAmber 180ms steps(2, end);
  animation-delay: 40ms;
}

@keyframes titleGlitchTeal {
  0% { transform: translate(4px, -1px); }
  50% { transform: translate(-2px, 1px); }
  100% { transform: translate(3px, 0); }
}

@keyframes titleGlitchViolet {
  0% { transform: translate(-3px, 2px); }
  50% { transform: translate(3px, -2px); }
  100% { transform: translate(-1px, 1px); }
}

@keyframes titleGlitchAmber {
  0% { transform: translate(2px, 3px); }
  50% { transform: translate(-4px, -1px); }
  100% { transform: translate(1px, 2px); }
}

.subtitle {
  margin: 2rem 0 0;
  font-size: clamp(1.2rem, 2vw, 1.75rem);
  font-style: italic;
  color: var(--vein-gray);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 900ms var(--ease-geological), transform 900ms var(--ease-geological);
}

.subtitle.visible { opacity: 1; transform: translateY(0); }

.opening-crack {
  width: min(68vw, 980px);
  height: 42px;
  margin-top: 2rem;
  opacity: 0;
}

.opening-crack.visible { opacity: 1; }

.opening-crack svg,
.crack-divider svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.crack-path {
  fill: none;
  stroke: var(--fault-amber);
  stroke-width: 2;
  stroke-linecap: square;
  stroke-linejoin: miter;
  filter: drop-shadow(0 0 4px rgba(138, 126, 45, 0.25));
  stroke-dasharray: 1400;
  stroke-dashoffset: 1400;
  transition: stroke-dashoffset 1200ms var(--ease-geological);
}

.crack-divider {
  height: 52px;
  margin: -26px 0;
  position: relative;
  z-index: 3;
  pointer-events: none;
}

.crack-divider.drawn .crack-path,
.opening-crack.visible .crack-path { stroke-dashoffset: 0; }

.crack-strong .crack-path { stroke-width: 3; filter: drop-shadow(0 0 8px rgba(138, 126, 45, 0.42)); }

.content-block {
  position: relative;
  max-width: 55%;
  padding: clamp(2rem, 5vw, 4rem);
  background: rgba(240, 236, 228, 0.42);
  border-left: 1px solid rgba(138, 133, 120, 0.5);
  box-shadow: inset 0 0 0 1px rgba(212, 208, 200, 0.32), 0 24px 80px rgba(26, 25, 23, 0.06);
  backdrop-filter: blur(1.5px);
}

.content-left { margin-left: 0; }
.content-right { margin-left: 35%; max-width: 50%; }

.stratum-manual::before { opacity: 0.92; background-blend-mode: overlay; }
.stratum-dialogue::before { opacity: 0.78; background: linear-gradient(88deg, rgba(212,208,200,0.28), rgba(240,236,228,0.1)), repeating-linear-gradient(181deg, transparent 0 36px, rgba(45,138,126,0.04) 37px 39px); }

.stratum-kicker {
  margin: 0 0 1.25rem;
  font-family: "Space Mono", monospace;
  font-size: clamp(0.72rem, 0.9vw, 0.85rem);
  line-height: 1.5;
  letter-spacing: 0.12em;
  color: var(--fault-amber);
  text-transform: uppercase;
}

h2 {
  margin: 0 0 1.4rem;
  font-family: "Cormorant Garamond", Garamond, serif;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  font-weight: 300;
  line-height: 1.05;
  color: var(--deep-stone);
}

p {
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  line-height: 1.78;
}

.log-dialogue {
  margin: 2rem 0;
  padding: 1.25rem 1.5rem;
  font-family: "Space Mono", monospace;
  color: var(--terminal-teal);
  background: rgba(26, 25, 23, 0.05);
  border: 1px solid rgba(45, 138, 126, 0.28);
}

.log-dialogue p {
  margin: 0.4rem 0;
  font-family: inherit;
  font-size: clamp(0.72rem, 0.9vw, 0.85rem);
  line-height: 1.5;
  letter-spacing: 0.04em;
}

.log-dialogue span { color: var(--stratum-violet); margin-right: 1rem; }

.stratum-void {
  min-height: 50vh;
  animation: voidPulse 15s var(--ease-geological) infinite alternate;
}

@keyframes voidPulse {
  0% { filter: saturate(0.92) brightness(1); }
  100% { filter: saturate(1.18) brightness(0.96); }
}

.stratum-core {
  justify-content: center;
  text-align: center;
}

.core-block {
  max-width: 980px;
  padding: 6vh 6vw;
}

.core-block h2 {
  font-weight: 600;
  font-size: clamp(2.4rem, 6vw, 5.4rem);
  line-height: 0.98;
}

.core-block p:not(.stratum-kicker) {
  max-width: 680px;
  margin: 2rem auto 0;
  color: var(--vein-gray);
}

.stratum-terminal-bed {
  min-height: 50vh;
  align-items: flex-end;
  color: var(--fog);
  background: linear-gradient(180deg, rgba(240,236,228,0), #1a1917 85%);
}

.terminal-bed-line {
  margin-left: 12vw;
  margin-bottom: 8vh;
  font-family: "Space Mono", monospace;
  color: rgba(45, 138, 126, 0.78);
  letter-spacing: 0.08em;
}

.hud {
  position: fixed;
  top: 8vh;
  right: 4vw;
  width: clamp(280px, 22vw, 360px);
  max-height: 84vh;
  z-index: 20;
  padding: 1.2rem;
  font-family: "Space Mono", monospace;
  font-size: clamp(0.72rem, 0.9vw, 0.85rem);
  line-height: 1.5;
  letter-spacing: 0.04em;
  color: var(--terminal-teal);
  background: rgba(212, 208, 200, 0.70);
  border: 1px solid rgba(138, 133, 120, 0.52);
  box-shadow: 0 20px 70px rgba(26, 25, 23, 0.14), inset 0 0 34px rgba(240, 236, 228, 0.36);
  backdrop-filter: blur(9px);
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 600ms var(--ease-geological), transform 600ms var(--ease-geological);
}

.hud.visible { opacity: 0.92; transform: translateX(0); }

.hud-frame,
.hud-divider { color: var(--vein-gray); white-space: pre; overflow: hidden; }

.hud-top { margin-bottom: 1rem; }
.hud-bottom { margin-top: 1rem; }

.hud-line {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.45rem 0;
}

.hud-line span { color: var(--vein-gray); }
.hud-line strong { font-weight: 700; color: var(--terminal-teal); text-align: right; }
.hud-line.current strong { color: var(--fault-amber); }

.progress-shell {
  height: 3px;
  margin: 0.9rem 0 1.1rem;
  background: rgba(138, 133, 120, 0.3);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--terminal-teal), var(--fault-amber));
  transition: width 180ms linear;
}

.flicker { animation: statusFlicker 3s var(--ease-geological) infinite alternate; }
.flicker.delay { animation-delay: 1.4s; }

@keyframes statusFlicker {
  0%, 100% { opacity: 0.62; }
  48% { opacity: 1; }
  51% { opacity: 0.74; }
}

.wave {
  margin: 1rem 0;
  color: var(--stratum-violet);
  font-family: "Space Mono", monospace;
  font-size: 1.1rem;
  white-space: pre-wrap;
}

.hud-register {
  color: var(--terminal-teal);
  border-top: 1px solid rgba(138, 133, 120, 0.32);
  border-bottom: 1px solid rgba(138, 133, 120, 0.32);
  padding: 0.75rem 0;
}

.hud-register p {
  margin: 0.25rem 0;
  font-family: "Space Mono", monospace;
  font-size: clamp(0.72rem, 0.9vw, 0.85rem);
  line-height: 1.5;
}

.corrupt { color: var(--fault-amber) !important; text-shadow: 2px 0 var(--stratum-violet), -2px 0 var(--terminal-teal); }

@media (max-width: 980px) {
  .hud { position: fixed; top: auto; bottom: 1rem; right: 1rem; width: min(88vw, 360px); max-height: 42vh; overflow: hidden; }
  .content-block, .content-right { max-width: 78%; margin-left: 0; }
  .stratum { padding-right: 8vw; }
  .inscription-block { width: 88vw; margin-left: 0; }
}

@media (max-width: 640px) {
  .content-block, .content-right { max-width: 100%; padding: 1.5rem; }
  .title-glitch { font-size: clamp(2.6rem, 15vw, 4.6rem); word-break: break-word; }
  .terminal-bed-line { margin-left: 0; }
}
