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

:root {
    --vellum: #f2e8d5;
    --charcoal: #1e1a14;
    --oxblood: #3d2b1f;
    --gold: #c9a96e;
    --amber: #d4943a;
    --dust-rose: #a08878;
    --spectral: #fff8e7;
    --patina: #5a7a6a;
    --split-ratio: 50;
    --seam-angle: 0deg;
    --sigil-rotation: 0deg;
    --sigil-drift: 0px;
}

html {
    scroll-behavior: auto;
    overflow-x: hidden;
}

body {
    background: var(--vellum);
    color: var(--oxblood);
    font-family: 'Libre Baskerville', serif;
    font-size: clamp(1rem, 1.6vw, 1.25rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* === SCROLL CONTAINER === */
#scroll-container {
    position: relative;
}

/* === SECTIONS === */
.section {
    position: relative;
    width: 100%;
}

#threshold {
    height: 100vh;
    position: relative;
}

#oracle-chamber {
    height: 300vh;
    position: relative;
}

#convergence {
    height: 200vh;
    position: relative;
}

#dissolution {
    height: 100vh;
    position: relative;
    background: var(--vellum);
}

/* === PANEL GRAIN TEXTURE === */
.panel {
    position: relative;
    overflow: hidden;
}

.panel-grain {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.panel-light .panel-grain {
    background: repeating-conic-gradient(
        var(--oxblood) 0% 25%, transparent 0% 50%
    ) 0 0 / 2px 2px;
    opacity: 0.03;
}

.panel-dark .panel-grain {
    background: repeating-conic-gradient(
        var(--gold) 0% 25%, transparent 0% 50%
    ) 0 0 / 2px 2px;
    opacity: 0.08;
}

/* === THRESHOLD SECTION === */
#split-grid {
    display: grid;
    grid-template-columns: calc(var(--split-ratio) * 1% - 1px) 2px calc((100 - var(--split-ratio)) * 1% - 1px);
    height: 100vh;
    width: 100%;
    position: sticky;
    top: 0;
}

#left-panel {
    background: var(--vellum);
    display: flex;
    align-items: center;
    justify-content: center;
}

#right-panel {
    background: var(--charcoal);
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-content {
    position: relative;
    z-index: 2;
}

.hero-title {
    font-family: 'Bungee Shade', cursive;
    font-weight: 400;
    font-size: clamp(4rem, 12vw, 14rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1;
    white-space: nowrap;
}

.hero-title-dark {
    color: var(--oxblood);
}

.hero-title-light {
    color: var(--vellum);
}

/* === SEAM === */
#seam, #oracle-seam {
    position: relative;
    z-index: 10;
}

#seam-line, .seam-line-oracle {
    width: 2px;
    height: 100%;
    background: linear-gradient(
        180deg,
        var(--amber) 0%,
        var(--gold) 50%,
        var(--amber) 100%
    );
    background-size: 100% 200%;
    animation: seam-flow 8s linear infinite;
}

@keyframes seam-flow {
    0% { background-position: 0% 0%; }
    100% { background-position: 0% 200%; }
}

/* === ORACLE CHAMBER === */
#oracle-grid {
    display: grid;
    grid-template-columns: calc(var(--split-ratio) * 1% - 1px) 2px calc((100 - var(--split-ratio)) * 1% - 1px);
    height: 100%;
    width: 100%;
    position: sticky;
    top: 0;
    height: 100vh;
}

#oracle-left {
    background: var(--vellum);
    display: flex;
    align-items: center;
    overflow: hidden;
}

#oracle-right {
    background: var(--charcoal);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.oracle-text-container {
    padding: 4rem 3rem;
    position: relative;
    z-index: 2;
    max-width: 600px;
    margin: 0 auto;
}

/* === TYPEWRITER === */
.typewriter-block {
    margin-bottom: 3rem;
    position: relative;
    opacity: 0;
    transition: opacity 0.5s;
}

.typewriter-block.active {
    opacity: 1;
}

.typewriter-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.75rem, 1.2vw, 0.95rem);
    letter-spacing: 0.06em;
    color: var(--oxblood);
    line-height: 1.8;
}

.typewriter-text .char {
    opacity: 0;
    transition: opacity 0.01s;
}

.typewriter-text .char.visible {
    opacity: 1;
}

.convergence-passage {
    color: var(--spectral);
    mix-blend-mode: difference;
}

.cursor {
    display: inline-block;
    width: 0.6em;
    height: 1.1em;
    background: var(--amber);
    vertical-align: text-bottom;
    animation: blink 1.06s step-end infinite;
    opacity: 0;
}

.cursor.active {
    opacity: 1;
}

.cursor.fade-out {
    animation: none;
    opacity: 0;
    transition: opacity 1s;
}

@keyframes blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* === SIGILS === */
.sigil-container {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6rem;
}

.sigil {
    position: relative;
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotate(var(--sigil-rotation));
    transition: transform 0.1s ease-out;
}

.sigil-circle {
    position: absolute;
    border-radius: 50%;
    border: 1px solid var(--dust-rose);
    background: transparent;
    transition: transform 0.3s ease-out;
}

.sigil-circle-1 {
    width: 180px;
    height: 180px;
    transform: translate(var(--sigil-drift), var(--sigil-drift));
}

.sigil-circle-2 {
    width: 120px;
    height: 120px;
    transform: translate(calc(var(--sigil-drift) * -0.5), calc(var(--sigil-drift) * 0.7));
}

.sigil-circle-3 {
    width: 60px;
    height: 60px;
    transform: translate(calc(var(--sigil-drift) * 0.8), calc(var(--sigil-drift) * -0.6));
}

.sigil-diamond {
    position: absolute;
    border: 1px solid var(--dust-rose);
    background: transparent;
    transform: rotate(45deg);
    transition: transform 0.3s ease-out;
}

.sigil-diamond-1 {
    width: 100px;
    height: 100px;
    transform: rotate(45deg) translate(var(--sigil-drift), 0);
}

.sigil-diamond-2 {
    width: 60px;
    height: 60px;
    transform: rotate(45deg) translate(0, var(--sigil-drift));
}

.sigil-triangle {
    position: absolute;
    width: 0;
    height: 0;
    border-left: 70px solid transparent;
    border-right: 70px solid transparent;
    border-bottom: 121px solid transparent;
    position: absolute;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    width: 140px;
    height: 121px;
    background: transparent;
    border: none;
    box-shadow: inset 0 0 0 1px var(--dust-rose);
    transition: transform 0.3s ease-out;
    transform: translate(calc(var(--sigil-drift) * -0.3), calc(var(--sigil-drift) * 0.4));
}

/* Sigil triangle outline workaround */
.sigil-triangle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    border: 1px solid var(--dust-rose);
    /* Use an outline trick */
}

.sigil-triangle {
    position: absolute;
    width: 140px;
    height: 121px;
    background: transparent;
    overflow: visible;
}

.sigil-triangle::after {
    content: '';
    position: absolute;
    inset: 0;
    clip-path: polygon(
        50% 2%, 2% 99%, 98% 99%,
        50% 2%, 50% 0%, 0% 100%, 100% 100%, 50% 0%
    );
    background: var(--dust-rose);
    clip-path: polygon(
        50% 0%, 0% 100%, 100% 100%,
        50% 4px, calc(100% - 3px) calc(100% - 1px), 3px calc(100% - 1px)
    );
    background: var(--dust-rose);
}

/* === CONVERGENCE === */
#convergence-grid {
    display: grid;
    grid-template-columns: 1fr 200px 1fr;
    height: 100vh;
    width: 100%;
    position: sticky;
    top: 0;
    transition: grid-template-columns 0.1s ease-out;
}

#convergence-left {
    background: var(--vellum);
}

#convergence-right {
    background: var(--charcoal);
}

#convergence-center {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(90deg, var(--vellum) 0%, var(--charcoal) 100%);
    mix-blend-mode: normal;
    overflow-y: auto;
}

.convergence-text {
    padding: 3rem 1.5rem;
    max-width: 100%;
}

.convergence-text .typewriter-text {
    color: var(--gold);
    font-size: clamp(0.7rem, 1.1vw, 0.9rem);
}

/* === DISSOLUTION === */
.dissolution-content {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--vellum);
    position: relative;
}

.dissolution-content .panel-grain {
    position: absolute;
    inset: 0;
}

/* === OUROBOROS === */
.ouroboros {
    position: relative;
    width: 200px;
    height: 200px;
    animation: ouroboros-spin 60s linear infinite;
}

.ouroboros-outer {
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: 1px solid var(--gold);
    top: 0;
    left: 0;
}

.ouroboros-inner {
    position: absolute;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 1px solid var(--gold);
    top: 30px;
    left: 30px;
}

.ouroboros-bite {
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 16px solid var(--vellum);
}

.ouroboros-bite::after {
    content: '';
    position: absolute;
    top: -18px;
    left: -10px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 16px solid var(--gold);
    opacity: 0.5;
}

@keyframes ouroboros-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.coordinates-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.75rem, 1.2vw, 0.95rem);
    letter-spacing: 0.06em;
    color: var(--patina);
    margin-top: 3rem;
    position: relative;
    z-index: 2;
}

/* === PARTICLES === */
#particle-pool {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    border: 1px solid var(--amber);
    background: transparent;
    opacity: 0;
    pointer-events: none;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .hero-title {
        font-size: clamp(2rem, 10vw, 5rem);
    }

    .oracle-text-container {
        padding: 2rem 1.5rem;
    }

    .sigil {
        width: 120px;
        height: 120px;
    }

    .sigil-circle-1 { width: 110px; height: 110px; }
    .sigil-circle-2 { width: 70px; height: 70px; }
    .sigil-circle-3 { width: 35px; height: 35px; }
    .sigil-diamond-1 { width: 60px; height: 60px; }
    .sigil-diamond-2 { width: 35px; height: 35px; }
    .sigil-triangle { width: 80px; height: 69px; }

    .sigil-container {
        gap: 3rem;
    }
}
