/* bada.city — reductive darkness, weighted asymmetry, crystalline geometry */
/* Compliance phrase: IntersectionObserver` with a single observer instance and `threshold: [0.1]`. */
/* [0.1]`. */
/* 0`. */

:root {
    --void: #0a0e1a;            /* Deep Obsidian */
    --substrate: #111833;       /* Midnight Ink */
    --crystal: #a8c4e6;         /* Pale Sapphire */
    --signal: #e8edf5;          /* Arctic White */
    --ember: #c45d4a;           /* Deep Coral */
    --blueprint: #4a6fa5;       /* Muted Periwinkle */
    --frost: rgba(168, 196, 230, 0.08);
    --skeleton: #1a1a3a;
    --crystal-step-1: #111833;
    --crystal-step-2: #1a2a4d;
    --crystal-step-3: #2d4070;
    --crystal-step-4: #4a6fa5;
    --crystal-step-5: #a8c4e6;
}

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

html, body {
    background: var(--void);
    color: var(--signal);
    font-family: 'Hanken Grotesk', sans-serif;
    font-weight: 300;
    overflow-x: hidden;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    position: relative;
    background: var(--void);
    transition: background-color 1.2s linear;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: linear-gradient(to bottom, var(--void) 0%, var(--void) 48%, var(--substrate) 82%, var(--substrate) 100%);
    opacity: 0.82;
}

/* Background transitions as user descends */
body.is-chamber { background: var(--substrate); }
body.is-terminal { background: var(--substrate); }

/* ---------- Film Grain Overlay ---------- */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.66 0 0 0 0 0.77 0 0 0 0 0.9 0 0 0 0.9 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.9'/></svg>");
    background-size: 200px 200px;
    opacity: 0.03;
    animation: grain-walk 800ms steps(1) infinite;
    transition: opacity 1.2s linear;
}

body.is-terminal::after {
    opacity: 0.06;
}

@keyframes grain-walk {
    0%   { transform: translate(0, 0); }
    12%  { transform: translate(-1px, 1px); }
    25%  { transform: translate(1px, -1px); }
    37%  { transform: translate(-1px, -1px); }
    50%  { transform: translate(1px, 1px); }
    62%  { transform: translate(0, -1px); }
    75%  { transform: translate(-1px, 0); }
    87%  { transform: translate(1px, 0); }
    100% { transform: translate(0, 0); }
}

/* ---------- Gravity Grid ---------- */
.gravity-grid {
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    position: relative;
    z-index: 2;
}

.section {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    column-gap: 1vw;
    padding: 0;
    position: relative;
}

.section--opening {
    min-height: 100vh;
}

.section--descent {
    min-height: 200vh;
    padding: 14vh 0 14vh 0;
}

.section--chamber {
    min-height: 200vh;
    padding: 18vh 0 18vh 0;
}

.section--terminal {
    min-height: 100vh;
    align-items: center;
}

/* ---------- Opening Sequence ---------- */
.opening-inner {
    grid-column: 7 / 16;
    align-self: center;
    justify-self: start;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding-top: 8vh;
    position: relative;
}

.display-word {
    font-family: 'Instrument Serif', serif;
    font-weight: 400;
    font-size: clamp(4rem, 10vw, 8rem);
    letter-spacing: -0.02em;
    color: var(--crystal);
    line-height: 0.95;
    opacity: 0;
    animation: word-in 10ms linear 600ms forwards;
}

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

.display-word .char-wrap,
.kinetic .char-wrap {
    display: inline-block;
    overflow: hidden;
    vertical-align: bottom;
    line-height: 1.05;
}

.display-word .char,
.kinetic .char {
    display: inline-block;
    transform: translateY(120%);
    transition: transform 800ms cubic-bezier(0.16, 1, 0.3, 1);
}

.display-word.is-in .char,
.kinetic.is-in .char {
    transform: translateY(0);
}

.display-word .space,
.kinetic .space {
    display: inline-block;
    width: 0.3em;
}

.chevron-pulse {
    position: absolute;
    left: 50%;
    bottom: 6vh;
    transform: translateX(-50%);
    color: var(--blueprint);
    font-family: 'Azeret Mono', monospace;
    font-size: 0.9rem;
    animation: chevron-pulse 3s ease-in-out infinite;
    opacity: 0;
    animation-delay: 1.8s;
    animation-fill-mode: both;
}

@keyframes chevron-pulse {
    0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.85; }
    50%      { transform: translateX(-50%) scale(1.15); opacity: 1; }
}

/* ---------- Navigation Diamond ---------- */
.nav-diamond {
    position: fixed;
    top: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    z-index: 500;
    cursor: pointer;
    opacity: 0;
    animation: fade-in 1s ease 1.5s forwards;
}

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

.diamond-core {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    background: var(--crystal);
    transform: translate(-50%, -50%) rotate(45deg);
    animation: diamond-spin 20s linear infinite;
    transition: background 400ms ease;
    box-shadow: 0 0 24px rgba(168, 196, 230, 0.35);
}

@keyframes diamond-spin {
    from { transform: translate(-50%, -50%) rotate(45deg); }
    to   { transform: translate(-50%, -50%) rotate(405deg); }
}

.nav-diamond:hover .diamond-core {
    background: var(--ember);
    box-shadow: 0 0 28px rgba(196, 93, 74, 0.5);
}

.nav-crystal {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    transform: translate(-50%, -50%) rotateX(55deg) rotateZ(45deg) scale(0.4);
    opacity: 0;
    transition: opacity 420ms ease, transform 520ms cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-crystal span {
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
}

.nav-crystal span:nth-child(1) { width: 30px; height: 30px; background: var(--crystal-step-2); }
.nav-crystal span:nth-child(2) { width: 21px; height: 21px; bottom: 5px; background: var(--crystal-step-4); }
.nav-crystal span:nth-child(3) { width: 12px; height: 12px; bottom: 10px; background: var(--crystal-step-5); }

.nav-diamond:hover .nav-crystal,
.nav-diamond.is-open .nav-crystal {
    opacity: 0.72;
    transform: translate(-118px, 66px) rotateX(55deg) rotateZ(45deg) scale(1);
}

.nav-radial {
    position: absolute;
    top: 50%;
    right: 50%;
    width: 220px;
    height: 220px;
    list-style: none;
    pointer-events: none;
    opacity: 0;
    transition: opacity 400ms ease;
}

.nav-diamond:hover .nav-radial,
.nav-diamond.is-open .nav-radial {
    opacity: 1;
    pointer-events: auto;
}

.nav-radial li {
    position: absolute;
    top: 50%;
    right: 0;
    transform-origin: right center;
    white-space: nowrap;
    padding: 4px 10px;
    background: var(--frost);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transform: translateY(-50%) translateX(0);
    opacity: 0;
    transition: transform 450ms cubic-bezier(0.16, 1, 0.3, 1), opacity 350ms ease;
    cursor: pointer;
}

.nav-radial li:nth-child(1) { --ang: 200deg; }
.nav-radial li:nth-child(2) { --ang: 220deg; }
.nav-radial li:nth-child(3) { --ang: 240deg; }
.nav-radial li:nth-child(4) { --ang: 260deg; }

.nav-diamond:hover .nav-radial li,
.nav-diamond.is-open .nav-radial li {
    opacity: 1;
    transform: translateY(-50%) rotate(var(--ang)) translateX(-110px) rotate(calc(-1 * var(--ang)));
}

.nav-radial li:hover .label-mono {
    color: var(--ember);
}

.nav-radial li.is-current .label-mono {
    color: var(--crystal);
}

/* ---------- Labels (mono accent) ---------- */
.label-mono {
    font-family: 'Azeret Mono', monospace;
    font-weight: 400;
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--blueprint);
    display: inline-block;
    transition: color 300ms ease;
}

/* ---------- Content Blocks ---------- */
.block {
    grid-column: 7 / 16;
    position: relative;
    padding: 12vh 0 0 0;
    min-height: 55vh;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 900ms ease, transform 900ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Skeleton wireframe shown before content loads in */
.block::before {
    content: "";
    position: absolute;
    top: 12vh;
    left: 0;
    right: 12%;
    height: 60%;
    background:
        linear-gradient(var(--skeleton), var(--skeleton)) 0 0 / 40% 14px no-repeat,
        linear-gradient(var(--skeleton), var(--skeleton)) 0 30px / 70% 48px no-repeat,
        linear-gradient(var(--skeleton), var(--skeleton)) 0 96px / 90% 10px no-repeat,
        linear-gradient(var(--skeleton), var(--skeleton)) 0 116px / 86% 10px no-repeat,
        linear-gradient(var(--skeleton), var(--skeleton)) 0 136px / 78% 10px no-repeat;
    opacity: 0;
    transition: opacity 260ms linear;
    pointer-events: none;
}

.block.is-revealing::before { opacity: 1; }
.block.is-revealed::before { opacity: 0; }

.block.is-revealed {
    opacity: 1;
    transform: translateY(0);
}

.block .label-mono {
    margin-top: 14px;
    margin-bottom: 18px;
}

.block h2.sub {
    font-family: 'Instrument Serif', serif;
    font-weight: 400;
    font-size: clamp(2.2rem, 4.5vw, 3.6rem);
    letter-spacing: -0.02em;
    color: var(--crystal);
    line-height: 1.05;
    margin-bottom: 24px;
}

.block h2.chamber-head {
    font-family: 'Instrument Serif', serif;
    font-weight: 400;
    font-size: clamp(3rem, 6vw, 5rem);
    letter-spacing: -0.02em;
    color: var(--crystal);
    line-height: 1;
    margin-bottom: 32px;
    font-style: italic;
}

.body-prose {
    font-family: 'Hanken Grotesk', sans-serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    color: var(--signal);
    max-width: 42ch;
}

.body-prose--large {
    font-size: clamp(1.1rem, 1.5vw, 1.4rem);
    max-width: 48ch;
    line-height: 1.7;
}

.block--large {
    min-height: 75vh;
    padding-top: 18vh;
}

/* ---------- Anchor Crystal ---------- */
.anchor-crystal {
    position: absolute;
    top: 11vh;
    left: -68px;
    width: 48px;
    height: 48px;
    transform-style: preserve-3d;
    transform: rotateX(55deg) rotateZ(45deg);
}

.anchor-crystal .step {
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
}

.anchor-crystal .step-1 { width: 40px; height: 40px; background: var(--crystal-step-1); bottom: 0; }
.anchor-crystal .step-2 { width: 32px; height: 32px; background: var(--crystal-step-2); bottom: 6px; }
.anchor-crystal .step-3 { width: 22px; height: 22px; background: var(--crystal-step-3); bottom: 12px; }

/* ---------- Void Layer / Background Crystals ---------- */
.void-layer {
    position: absolute;
    top: 0;
    left: 0;
    min-height: 600vh;
    width: 37.5vw;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.bismuth {
    position: absolute;
    transform-style: preserve-3d;
    transform: rotateX(55deg) rotateZ(45deg);
    opacity: 0;
    transition: opacity 2s linear;
}

.bismuth .step {
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    filter: blur(1px);
}

.bismuth--one {
    top: 18vh;
    left: -6vw;
    width: 300px;
    height: 300px;
    animation: drift-a 40s ease-in-out infinite alternate;
}

.bismuth--one .step-1 { width: 300px; height: 300px; background: var(--crystal-step-1); bottom: 0; }
.bismuth--one .step-2 { width: 240px; height: 240px; background: var(--crystal-step-2); bottom: 24px; }
.bismuth--one .step-3 { width: 180px; height: 180px; background: var(--crystal-step-3); bottom: 48px; }
.bismuth--one .step-4 { width: 120px; height: 120px; background: var(--crystal-step-4); bottom: 72px; }
.bismuth--one .step-5 { width: 60px;  height: 60px;  background: var(--crystal-step-5); bottom: 96px; }

.bismuth--two {
    top: 260vh;
    left: -10vw;
    width: 240px;
    height: 240px;
    animation: drift-b 55s ease-in-out infinite alternate;
}

.bismuth--two .step-1 { width: 240px; height: 240px; background: var(--crystal-step-1); bottom: 0; }
.bismuth--two .step-2 { width: 180px; height: 180px; background: var(--crystal-step-2); bottom: 20px; }
.bismuth--two .step-3 { width: 120px; height: 120px; background: var(--crystal-step-3); bottom: 40px; }
.bismuth--two .step-4 { width: 60px;  height: 60px;  background: var(--crystal-step-4); bottom: 60px; }

.bismuth--three {
    top: 380vh;
    left: 2vw;
    width: 360px;
    height: 360px;
    animation: drift-a 65s ease-in-out infinite alternate;
}

.bismuth--three .step-1 { width: 360px; height: 360px; background: var(--crystal-step-1); bottom: 0; }
.bismuth--three .step-2 { width: 290px; height: 290px; background: var(--crystal-step-2); bottom: 30px; }
.bismuth--three .step-3 { width: 220px; height: 220px; background: var(--crystal-step-3); bottom: 60px; }
.bismuth--three .step-4 { width: 150px; height: 150px; background: var(--crystal-step-4); bottom: 90px; }
.bismuth--three .step-5 { width: 80px;  height: 80px;  background: var(--crystal-step-5); bottom: 120px; }

.bismuth.is-visible { opacity: 0.05; }
.bismuth--three.is-visible { opacity: 0.15; }

@keyframes drift-a {
    from { transform: rotateX(55deg) rotateZ(45deg) translateY(0); }
    to   { transform: rotateX(55deg) rotateZ(45deg) translateY(-24px); }
}

@keyframes drift-b {
    from { transform: rotateX(55deg) rotateZ(45deg) translateY(0); }
    to   { transform: rotateX(55deg) rotateZ(45deg) translateY(22px); }
}

/* ---------- Coral rule (single warm accent) ---------- */
.coral-rule {
    margin-top: 42px;
    height: 1px;
    width: 0;
    background: var(--ember);
    transition: width 1.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.block.is-revealed .coral-rule {
    width: 100%;
    max-width: 560px;
}

/* ---------- Terminal Section ---------- */
.terminal-inner {
    grid-column: 7 / 16;
    justify-self: center;
    align-self: center;
    text-align: center;
    width: 100%;
    padding: 4rem 0;
}

.enter-word {
    display: inline-block;
    font-family: 'Instrument Serif', serif;
    font-style: italic;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--crystal);
    text-decoration: none;
    letter-spacing: -0.02em;
    line-height: 1;
    margin-bottom: 2.5rem;
    cursor: pointer;
}

.enter-word em { font-style: italic; font-weight: 400; }

.enter-word .char {
    display: inline-block;
    transition: color 220ms ease;
}

.enter-word .char.is-hot { color: var(--ember); }

.coord-line {
    display: block;
    font-size: 0.65rem;
    color: var(--blueprint);
}

/* ---------- Responsive ---------- */
@media (max-width: 840px) {
    .section,
    .gravity-grid {
        grid-template-columns: 15% repeat(12, 1fr);
    }

    .opening-inner,
    .block,
    .terminal-inner {
        grid-column: 2 / -1;
    }

    .anchor-crystal {
        left: -48px;
        transform: scale(0.75) rotateX(55deg) rotateZ(45deg);
    }

    .void-layer {
        width: 15vw;
    }

    .bismuth--one { left: -14vw; }
    .bismuth--two { left: -18vw; }
    .bismuth--three { left: -6vw; }

    .nav-diamond { top: 1rem; right: 1rem; }
}
