/* ===== RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --abyss: #070b1a;
    --deep-indigo: #0d1428;
    --midnight-steel: #121d36;
    --gold: #c4a14a;
    --aged-brass: #8a7234;
    --steel-mist: #b8c4d8;
    --slate-fog: #5a6b8a;
    --toxic-mint: #4af0c8;
    --rebellion-red: #f04a6c;
    --frost: #e8ecf4;
}

html {
    background: var(--abyss);
    color: var(--steel-mist);
    font-family: 'Jost', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

body {
    background: var(--abyss);
    min-height: 100vh;
    opacity: 0;
    transition: opacity 0.3s;
}

body.loaded {
    opacity: 1;
}

/* ===== ELEVATOR LINES ===== */
.elevator-line {
    position: fixed;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--gold);
    z-index: 1000;
    top: 50%;
    transform: scaleX(0);
    pointer-events: none;
}

#elevator-top {
    transform-origin: center;
}

#elevator-bottom {
    transform-origin: center;
}

.elevator-line.animate {
    animation: elevatorOpen 800ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes elevatorOpen {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

#elevator-top.migrate {
    animation: migrateTop 1200ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#elevator-bottom.migrate {
    animation: migrateBottom 1200ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes migrateTop {
    from { top: 50%; }
    to { top: 0; }
}

@keyframes migrateBottom {
    from { top: 50%; }
    to { top: calc(100% - 1px); }
}

/* Persistent frame lines */
.frame-line {
    position: fixed;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--gold);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
}

#frame-top { top: 0; }
#frame-bottom { bottom: 0; }

.frame-line.visible {
    opacity: 1;
}

/* ===== NAVIGATION COMPASS ===== */
#nav-compass {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1001;
    background: none;
    border: 1px solid var(--aged-brass);
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    clip-path: polygon(12% 0%, 88% 0%, 100% 12%, 100% 88%, 88% 100%, 12% 100%, 0% 88%, 0% 12%);
    background: rgba(7, 11, 26, 0.8);
    opacity: 0;
    transition: opacity 0.4s, border-color 0.3s;
}

#nav-compass.visible {
    opacity: 1;
}

#nav-compass:hover {
    border-color: var(--gold);
}

/* ===== NAVIGATION OVERLAY ===== */
#nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(7, 11, 26, 0.96);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
}

#nav-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.nav-sunburst {
    position: relative;
    width: 600px;
    height: 600px;
}

#nav-rays {
    position: absolute;
    top: 0;
    left: 0;
}

.nav-links {
    position: absolute;
    inset: 0;
}

.nav-link {
    position: absolute;
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.3em;
    color: var(--gold);
    text-decoration: none;
    transition: color 0.3s, text-shadow 0.3s;
}

.nav-link:hover {
    color: var(--frost);
    text-shadow: 0 0 30px rgba(196, 161, 74, 0.4);
}

/* ===== MONOLITH COLUMN ===== */
.monolith {
    position: relative;
    max-width: 720px;
    margin: 0 auto;
    margin-left: calc(50% - 360px - 4vw);
    padding: 0 24px;
    padding-top: 100vh;
    opacity: 0;
    transition: opacity 0.6s;
}

.monolith.reveal {
    opacity: 1;
}

@media (max-width: 820px) {
    .monolith {
        margin-left: auto;
        margin-right: auto;
    }
}

/* ===== SECTIONS ===== */
.section {
    position: relative;
    margin-bottom: 89px;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.section.in-view {
    opacity: 1;
    transform: translateY(0);
}

/* Ziggurat narrowing */
.section-1 { max-width: 720px; }
.section-2 { max-width: 720px; }
.section-3 { max-width: 640px; }
.section-4 { max-width: 600px; }
.section-5 { max-width: 560px; }
.section-6 { max-width: 520px; }
.section-7 { max-width: 480px; }

/* ===== HERO ===== */
#hero {
    text-align: center;
    padding: 60px 0;
    margin-top: -50vh;
}

.hero-crystal-container {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
}

#hero-crystal {
    max-width: 100%;
    height: auto;
}

.title {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(5rem, 14vw, 12rem);
    letter-spacing: 0.18em;
    color: var(--gold);
    text-shadow: 0 0 40px rgba(196, 161, 74, 0.15);
    line-height: 1;
    opacity: 0;
    transition: opacity 0.4s, letter-spacing 0.2s;
}

.title.fade-in {
    opacity: 0.5;
}

.title.full {
    opacity: 1;
}

.title:hover {
    text-shadow: 0 0 60px rgba(196, 161, 74, 0.3);
    letter-spacing: 0.22em;
}

.subtitle {
    margin-top: 16px;
    opacity: 0;
    transition: opacity 0.6s 0.3s;
}

.section.in-view .subtitle {
    opacity: 1;
}

/* ===== ACCENT LABELS ===== */
.accent-label {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.3em;
    font-size: 0.7rem;
    color: var(--slate-fog);
    display: block;
    margin-bottom: 12px;
}

/* ===== HEADINGS ===== */
h2 {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: clamp(2rem, 5vw, 3.5rem);
    color: var(--gold);
    text-shadow: 0 0 40px rgba(196, 161, 74, 0.15);
    margin-bottom: 24px;
    line-height: 1.2;
    transition: text-shadow 0.2s, letter-spacing 0.2s;
}

h2:hover {
    text-shadow: 0 0 60px rgba(196, 161, 74, 0.3);
    letter-spacing: 0.22em;
}

/* ===== CHAMFERED FRAMES ===== */
.chamfered-frame {
    position: relative;
    background: var(--deep-indigo);
    padding: 48px 40px;
    clip-path: polygon(
        20px 0%, calc(100% - 20px) 0%,
        100% 20px, 100% calc(100% - 20px),
        calc(100% - 20px) 100%, 20px 100%,
        0% calc(100% - 20px), 0% 20px
    );
    transition: background 0.3s;
}

.chamfered-frame::before {
    content: '';
    position: absolute;
    inset: 0;
    clip-path: polygon(
        20px 0%, calc(100% - 20px) 0%,
        100% 20px, 100% calc(100% - 20px),
        calc(100% - 20px) 100%, 20px 100%,
        0% calc(100% - 20px), 0% 20px
    );
    border: 1px solid var(--gold);
    pointer-events: none;
    z-index: 1;
}

/* Simulated chamfered border with outline overlay */
.chamfered-frame::after {
    content: '';
    position: absolute;
    inset: 1px;
    clip-path: polygon(
        20px 0%, calc(100% - 20px) 0%,
        100% 20px, 100% calc(100% - 20px),
        calc(100% - 20px) 100%, 20px 100%,
        0% calc(100% - 20px), 0% 20px
    );
    background: var(--deep-indigo);
    z-index: 0;
    transition: background 0.3s;
}

.chamfered-frame:hover {
    background: var(--midnight-steel);
}

.chamfered-frame:hover::after {
    background: var(--midnight-steel);
}

.chamfered-frame > * {
    position: relative;
    z-index: 2;
}

/* ===== PARAGRAPHS ===== */
p {
    margin-bottom: 18px;
    color: var(--steel-mist);
}

p:last-child {
    margin-bottom: 0;
}

/* ===== CODE ===== */
code {
    font-family: 'Space Mono', monospace;
    font-size: 0.9em;
    color: var(--toxic-mint);
    background: rgba(74, 240, 200, 0.06);
    padding: 2px 6px;
    border-radius: 2px;
}

.code-block {
    background: rgba(74, 240, 200, 0.04);
    border-left: 2px solid var(--toxic-mint);
    padding: 20px 24px;
    margin: 24px 0;
    overflow-x: auto;
    transition: border-width 0.3s, background 0.3s;
}

.code-block:hover {
    border-left-width: 6px;
    background: rgba(74, 240, 200, 0.08);
}

.code-block code {
    display: block;
    background: none;
    padding: 2px 0;
    line-height: 1.6;
}

.code-keyword { color: var(--rebellion-red); }
.code-string { color: var(--gold); }
.code-fn { color: var(--toxic-mint); }
.code-value { color: var(--frost); }
.code-comment { color: var(--slate-fog); }

/* ===== RADIAL BURST DIVIDERS ===== */
.radial-burst {
    display: flex;
    justify-content: center;
    margin: 55px 0;
    opacity: 0;
    transition: opacity 0.6s;
}

.radial-burst.in-view {
    opacity: 1;
}

/* ===== DENDRITES ===== */
.dendrite-container {
    display: flex;
    justify-content: center;
    margin: 34px 0;
}

.dendrite path {
    stroke: var(--aged-brass);
    stroke-width: 0.5;
    fill: none;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 1.5s ease-out;
}

.dendrite.drawn path {
    stroke-dashoffset: 0;
}

/* ===== MORPH GLYPHS ===== */
.morph-glyph {
    display: flex;
    justify-content: center;
    margin: 34px 0;
}

.morph-glyph .glyph-shape {
    animation: morphGlyph 4s ease-in-out infinite;
    transform-origin: center;
}

@keyframes morphGlyph {
    0%   { d: path("M24,4 L44,16 L44,32 L24,44 L4,32 L4,16 Z"); }
    25%  { d: path("M24,2 L46,24 L24,46 L2,24 Z"); }
    50%  { d: path("M24,6 L42,18 L42,30 L24,42 L6,30 L6,18 Z"); }
    75%  { d: path("M24,4 A20,20 0 1,1 23.99,4 Z"); }
    100% { d: path("M24,4 L44,16 L44,32 L24,44 L4,32 L4,16 Z"); }
}

/* ===== VIZ BREAKOUTS ===== */
.viz-breakout {
    position: relative;
    width: 100vw;
    left: 50%;
    transform: translateX(-50%);
    margin: 89px 0;
    height: 300px;
    overflow: hidden;
}

.lattice-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ===== CHEVRON WATERMARKS ===== */
.chevron-watermark {
    position: absolute;
    width: 300px;
    height: 200px;
    pointer-events: none;
    z-index: 0;
}

.chevron-watermark::before,
.chevron-watermark::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 18px,
        rgba(196, 161, 74, 0.03) 18px,
        rgba(196, 161, 74, 0.03) 20px
    );
    clip-path: polygon(50% 100%, 0% 0%, 100% 0%);
}

.chevron-1 { top: 20%; right: -50px; }
.chevron-2 { top: 50%; left: -80px; }
.chevron-3 { top: 75%; right: -30px; }

/* ===== SCROLL VELOCITY DIMMING ===== */
.decorative-dim .radial-burst,
.decorative-dim .dendrite-container,
.decorative-dim .morph-glyph,
.decorative-dim .chevron-watermark {
    opacity: 0.3 !important;
    transition: opacity 0.15s;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    .chamfered-frame {
        padding: 32px 24px;
    }

    .monolith {
        padding: 0 16px;
        padding-top: 100vh;
    }

    .section-3,
    .section-4,
    .section-5,
    .section-6,
    .section-7 {
        max-width: 100%;
    }
}

/* Selection color */
::selection {
    background: rgba(196, 161, 74, 0.3);
    color: var(--frost);
}
