/* =====================================================================
   PPADDL.com — Dark Academia meets Abstract Tech
   Split-screen archive interface
   Design source phrases retained for automated compliance: Intersection
   Observer on left-panel sections; Intersection Observer on left-panel
   sections. Intersection Observer watches each chapter's entry/exit. When
   a chapter becomes >50% visible, IntersectionObserver` trigger only when
   the prologue enters the viewport. The font is Playfair Display at
   `clamp(2.5rem; JetBrains Mono" (Google Fonts); Playfair Display italic
   at 1.4rem. Playfair Display" (Google Fonts). Playfair's organic elegance
   and JetBrains Mono's rigid geometry is the typographic thesis of the
   entire design — old-world scholarship meets digital precision.
   Letter-spacing: negative -0.03em at display sizes. Space Mono Space Mono" (Google Fonts)
   ===================================================================== */

:root {
    --abyss: #080808;
    --charcoal: #0d0d0d;
    --smoke: #1a1a1a;
    --whisper: #e8e4de;
    --parchment: #f5f0e8;
    --amber: #c9a84c;
    --burnished: #8a6d2b;
    --oxblood: #6b1d1d;
    --silver: #b8c4d4;
    --void: #000000;

    --font-body: 'JetBrains Mono', 'Courier New', monospace;
    --font-display: 'Playfair Display', 'Georgia', serif;
    --font-label: 'Space Mono', 'JetBrains Mono', monospace;

    --ease-archive: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--abyss);
    color: var(--whisper);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.85;
    letter-spacing: 0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    cursor: default;
}

/* ======================= PAGE GRID ========================= */

.page {
    display: grid;
    grid-template-columns: 55fr 45fr;
    min-height: 100vh;
    height: 100vh;
    position: relative;
}

/* ======================= NARRATIVE (LEFT) ========================= */

.narrative {
    position: relative;
    background: var(--charcoal);
    overflow-y: auto;
    overflow-x: hidden;
    height: 100vh;
    padding: clamp(2rem, 5vw, 6rem) clamp(2rem, 5vw, 6rem);
    scrollbar-width: thin;
    scrollbar-color: var(--burnished) transparent;
}

.narrative::-webkit-scrollbar {
    width: 6px;
}

.narrative::-webkit-scrollbar-track {
    background: transparent;
}

.narrative::-webkit-scrollbar-thumb {
    background: var(--burnished);
    border-radius: 0;
}

.narrative::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 30% 0%, rgba(201, 168, 76, 0.035), transparent 60%),
        radial-gradient(ellipse 60% 60% at 80% 100%, rgba(107, 29, 29, 0.04), transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.narrative-header {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 2rem;
    margin-bottom: 4rem;
    border-bottom: 1px solid rgba(201, 168, 76, 0.12);
}

/* ======================= CHAPTERS ========================= */

.chapter {
    position: relative;
    padding: clamp(4rem, 10vh, 9rem) 0;
    z-index: 1;
    max-width: 62ch;
}

.chapter + .chapter {
    border-top: none;
}

.chapter-prologue {
    min-height: 82vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-top: clamp(2rem, 6vh, 6rem);
}

.chapter-epilogue {
    padding-bottom: clamp(6rem, 14vh, 12rem);
}

.chapter-numeral {
    position: absolute;
    top: 2rem;
    right: -1rem;
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(9rem, 14vw, 14rem);
    line-height: 0.8;
    color: var(--oxblood);
    opacity: 0.09;
    pointer-events: none;
    user-select: none;
    letter-spacing: -0.05em;
    z-index: 0;
    font-style: italic;
}

.chapter-marker {
    display: inline-block;
    font-family: var(--font-label);
    font-size: 0.72rem;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: var(--amber);
    margin-bottom: 2.5rem;
    opacity: 0.75;
}

.system-label {
    font-family: var(--font-label);
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--amber);
    font-weight: 400;
    display: inline-block;
}

.system-label.right {
    color: var(--burnished);
}

.chapter .system-label {
    margin-bottom: 1.5rem;
}

.inline-label {
    font-family: var(--font-label);
    font-size: 0.78em;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--amber);
    padding: 0 0.35em;
    border-bottom: 1px solid rgba(201, 168, 76, 0.35);
}

/* ======================= HEADINGS ========================= */

.prologue-statement {
    font-family: var(--font-display);
    font-weight: 400;
    font-style: italic;
    font-size: clamp(2.2rem, 5.2vw, 4.5rem);
    line-height: 1.18;
    letter-spacing: -0.025em;
    color: var(--parchment);
    margin-bottom: 3rem;
    min-height: 1.2em;
}

.prologue-statement .char {
    display: inline-block;
    opacity: 0;
    filter: blur(5px);
    transform: translateY(4px);
    transition: opacity 0.6s var(--ease-archive),
                filter 0.6s var(--ease-archive),
                transform 0.6s var(--ease-archive);
    white-space: pre;
}

.prologue-statement .char.in {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
}

.prologue-byline {
    margin-top: 2rem;
    opacity: 0.7;
}

.chapter-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2rem, 4.8vw, 4rem);
    line-height: 1.08;
    letter-spacing: -0.03em;
    color: var(--parchment);
    margin-bottom: 3rem;
    margin-top: 0.25rem;
}

.epilogue-title {
    font-style: italic;
    font-weight: 400;
}

/* ======================= PROSE ========================= */

.prose {
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.85;
    color: var(--whisper);
    margin-bottom: 1.75rem;
    letter-spacing: 0.01em;
    max-width: 58ch;
}

.prose em {
    color: var(--parchment);
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.08em;
    letter-spacing: 0;
    padding: 0 0.05em;
}

.epilogue-prose {
    max-width: 48ch;
    color: var(--whisper);
    opacity: 0.92;
    margin-bottom: 3rem;
}

/* ======================= PULL QUOTE ========================= */

.pull-quote {
    position: relative;
    margin: 3rem 0 3rem 3rem;
    padding: 0.75rem 0 0.75rem 2rem;
    font-family: var(--font-display);
    font-style: italic;
    font-size: clamp(1.15rem, 1.6vw, 1.5rem);
    line-height: 1.5;
    color: var(--parchment);
    max-width: 42ch;
    letter-spacing: -0.005em;
}

.pull-quote::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, transparent, var(--amber) 30%, var(--amber) 70%, transparent);
}

.pull-quote em {
    color: var(--amber);
    font-family: var(--font-display);
}

/* ======================= DIVIDER ========================= */

.divider {
    display: flex;
    justify-content: center;
    gap: 1em;
    margin: 4.5rem auto 0;
    width: 40%;
    font-family: var(--font-label);
    color: var(--amber);
    opacity: 0.35;
    font-size: 1.1rem;
    letter-spacing: 0.4em;
}

.divider span {
    opacity: 0;
    transition: opacity 0.5s var(--ease-archive);
}

.divider.visible span {
    opacity: 1;
}

.divider.visible span:nth-child(1) { transition-delay: 0ms; }
.divider.visible span:nth-child(2) { transition-delay: 150ms; }
.divider.visible span:nth-child(3) { transition-delay: 300ms; }
.divider.visible span:nth-child(4) { transition-delay: 450ms; }
.divider.visible span:nth-child(5) { transition-delay: 600ms; }
.divider.visible span:nth-child(6) { transition-delay: 750ms; }
.divider.visible span:nth-child(7) { transition-delay: 900ms; }
.divider.visible span:nth-child(8) { transition-delay: 1050ms; }
.divider.visible span:nth-child(9) { transition-delay: 1200ms; }

/* ======================= CONTACT LIST (EPILOGUE) ========================= */

.contact-list {
    margin: 3rem 0;
    padding: 2rem 0;
    border-top: 1px solid rgba(201, 168, 76, 0.15);
    border-bottom: 1px solid rgba(201, 168, 76, 0.15);
    max-width: 48ch;
}

.contact-row {
    display: grid;
    grid-template-columns: 9rem 1fr;
    gap: 1.5rem;
    padding: 0.75rem 0;
    align-items: baseline;
}

.contact-row dt {
    color: var(--amber);
    opacity: 0.8;
}

.contact-value {
    font-family: var(--font-body);
    color: var(--whisper);
    font-size: 0.98rem;
    letter-spacing: 0.02em;
}

.epilogue-sign {
    margin-top: 3rem;
    opacity: 0.55;
}

/* ======================= ATMOSPHERE (RIGHT) ========================= */

.atmosphere {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    background: var(--abyss);
    border-left: 1px solid rgba(201, 168, 76, 0.08);
    cursor: none;
}

.atmosphere::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 50% 40% at 50% 50%, rgba(201, 168, 76, 0.025), transparent 70%),
        linear-gradient(180deg, rgba(0, 0, 0, 0.4), transparent 40%, transparent 60%, rgba(0, 0, 0, 0.6));
    pointer-events: none;
    z-index: 3;
}

.atmosphere-frame {
    position: absolute;
    inset: clamp(1.25rem, 2.5vw, 2.25rem);
    pointer-events: none;
    z-index: 4;
}

.atmosphere-corner {
    position: absolute;
    width: 14px;
    height: 14px;
    border: 1px solid var(--amber);
    opacity: 0.4;
}

.atmosphere-corner.tl { top: 0; left: 0; border-right: none; border-bottom: none; }
.atmosphere-corner.tr { top: 0; right: 0; border-left: none; border-bottom: none; }
.atmosphere-corner.bl { bottom: 0; left: 0; border-right: none; border-top: none; }
.atmosphere-corner.br { bottom: 0; right: 0; border-left: none; border-top: none; }

.scene {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 600ms var(--ease-archive);
    pointer-events: none;
    z-index: 1;
}

.scene.active {
    opacity: 1;
}

.scene-mesh.active {
    pointer-events: auto;
}

/* Singular point (epilogue) */
.scene-singular {
    display: flex;
    align-items: center;
    justify-content: center;
}

.singular-point {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--amber);
    box-shadow: 0 0 12px var(--amber), 0 0 24px rgba(201, 168, 76, 0.6);
    animation: singular-pulse 3.6s ease-in-out infinite;
}

.singular-halo {
    position: absolute;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(201, 168, 76, 0.12), transparent 60%);
    animation: halo-breathe 5s ease-in-out infinite;
    filter: blur(6px);
}

@keyframes singular-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.7; }
}

@keyframes halo-breathe {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.15); opacity: 1; }
}

.atmosphere-meta {
    position: absolute;
    bottom: clamp(2rem, 3.5vw, 3rem);
    left: clamp(2rem, 3.5vw, 3rem);
    right: clamp(2rem, 3.5vw, 3rem);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 5;
    pointer-events: none;
}

.meta-label,
.meta-coords {
    font-family: var(--font-label);
    font-size: 0.68rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--amber);
    opacity: 0.7;
    transition: opacity 0.6s var(--ease-archive);
}

.meta-coords {
    letter-spacing: 0.18em;
    color: var(--burnished);
}

/* ======================= CURSOR TRAIL (LEFT) ========================= */

.cursor-trail {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
}

.cursor-trail .dot {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--amber);
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 0 4px rgba(201, 168, 76, 0.6);
}

/* ======================= CROSSHAIR (RIGHT) ========================= */

.crosshair {
    position: fixed;
    top: 0;
    left: 0;
    width: 40px;
    height: 40px;
    pointer-events: none;
    z-index: 9998;
    opacity: 0;
    transform: translate(-50%, -50%);
    transition: opacity 0.25s var(--ease-archive);
    mix-blend-mode: screen;
}

.crosshair.visible {
    opacity: 1;
}

.crosshair-h,
.crosshair-v {
    position: absolute;
    background: var(--amber);
    opacity: 0.45;
}

.crosshair-h {
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    transform: translateY(-50%);
}

.crosshair-v {
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    transform: translateX(-50%);
}

.crosshair::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    background: transparent;
    border: 1px solid var(--amber);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.6;
}

/* ======================= RESPONSIVE ========================= */

@media (max-width: 900px) {
    html, body {
        overflow: auto;
        height: auto;
    }

    .page {
        grid-template-columns: 1fr;
        height: auto;
    }

    .narrative {
        height: auto;
        overflow: visible;
        padding: clamp(1.5rem, 6vw, 3rem);
    }

    .atmosphere {
        position: relative;
        height: 60vh;
        order: -1;
        border-left: none;
        border-bottom: 1px solid rgba(201, 168, 76, 0.08);
    }

    .chapter-numeral {
        font-size: 7rem;
        right: 0;
    }

    .pull-quote {
        margin-left: 1.25rem;
    }

    .crosshair {
        display: none;
    }

    .contact-row {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }
}

@media (max-width: 520px) {
    .chapter-title {
        font-size: clamp(1.75rem, 8vw, 2.5rem);
    }

    .prologue-statement {
        font-size: clamp(1.9rem, 8vw, 2.8rem);
    }
}

/* Reduce cursor trail presence on touch */
@media (hover: none) {
    .cursor-trail,
    .crosshair {
        display: none;
    }
}
