/* aiice.quest - Dark-Academia AI Oracle */
:root {
    --charred-walnut: #1A120B;
    --smoke-library: #2C1E12;
    --parchment: #D4C5B2;
    --gilt: #C9A84C;
    --phosphor: #7B9E6B;
    --sealing-wax: #8B2E1A;
    --binding: #4A3728;
}

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

html { scroll-behavior: smooth; }

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

/* Grain Canvas */
#grainCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    pointer-events: none;
    mix-blend-mode: overlay;
    opacity: 0.04;
}

/* Vertical Spine */
.spine {
    position: fixed;
    left: 50%;
    top: 0;
    width: 1px;
    height: 100%;
    background: var(--binding);
    opacity: 0.2;
    z-index: 10;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.spine-node {
    position: absolute;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid var(--binding);
    background: transparent;
    z-index: 11;
}

.spine-node.illuminated {
    border-color: var(--gilt);
    background: var(--gilt);
    box-shadow: 0 0 12px rgba(201, 168, 76, 0.3);
}

.node-diagram {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    opacity: 0.4;
    transition: opacity 0.6s ease;
}

.spine-node.illuminated .node-diagram {
    opacity: 1;
}

.spine-node.illuminated .node-diagram circle,
.spine-node.illuminated .node-diagram line {
    stroke: var(--gilt);
}

.spine-node.illuminated .node-diagram circle[fill] {
    fill: var(--gilt);
}

/* Scroll Progress */
.scroll-progress {
    position: fixed;
    right: 20px;
    top: 0;
    width: 1px;
    height: 0%;
    background: var(--binding);
    z-index: 100;
    transition: height 0.1s linear;
}

/* Reveal Intro */
.reveal-intro {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 1000;
    background: var(--charred-walnut);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: introFade 0.8s ease 3s forwards;
}

.reveal-curtain {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    background: var(--charred-walnut);
    z-index: 1001;
}

.reveal-curtain-left {
    left: 0;
    transform-origin: left center;
    animation: curtainLeft 2s cubic-bezier(0.16, 1, 0.3, 1) 0.5s forwards;
}

.reveal-curtain-right {
    right: 0;
    transform-origin: right center;
    animation: curtainRight 2s cubic-bezier(0.16, 1, 0.3, 1) 0.5s forwards;
}

@keyframes curtainLeft {
    0% { transform: scaleX(1); }
    100% { transform: scaleX(0); }
}

@keyframes curtainRight {
    0% { transform: scaleX(1); }
    100% { transform: scaleX(0); }
}

@keyframes introFade {
    0% { opacity: 1; pointer-events: all; }
    100% { opacity: 0; pointer-events: none; }
}

.reveal-title {
    z-index: 1002;
    position: relative;
}

.reveal-domain {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(4rem, 10vw, 12rem);
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.gilt { color: var(--gilt); }
.parchment { color: var(--parchment); }
.gilt-color { color: var(--gilt); }
.parchment-color { color: var(--parchment); }

/* Chapters */
.chapter {
    position: relative;
    min-height: 100svh;
    padding: clamp(3rem, 12vw, 10rem);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6vh;
}

.chapter:nth-child(even) {
    background: var(--smoke-library);
}

.chapter-content {
    max-width: 38ch;
    position: relative;
    z-index: 5;
}

.content-left {
    margin-right: auto;
    margin-left: calc(50% - 38ch - 4vw);
}

.content-right {
    margin-left: auto;
    margin-right: calc(50% - 38ch - 4vw);
}

.content-center {
    margin: 0 auto;
    text-align: center;
}

/* Typography */
.display-heading {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(4rem, 10vw, 12rem);
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-bottom: 2rem;
}

.section-heading {
    font-family: 'Playfair Display', serif;
    font-weight: 400;
    font-size: clamp(2rem, 5vw, 4.5rem);
    line-height: 1.1;
    color: var(--gilt);
    margin-bottom: 2rem;
    position: relative;
}

.section-heading::after {
    content: '';
    position: absolute;
    bottom: -0.5rem;
    left: 0;
    width: 3rem;
    height: 1px;
    background: var(--sealing-wax);
    opacity: 0.6;
}

.italic { font-style: italic; }

.section-heading.glow-active::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200%;
    height: 200%;
    transform: translate(-50%, -50%);
    background: radial-gradient(ellipse at 45% 40%, rgba(201, 168, 76, 0.15) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

.body-text {
    font-family: 'Libre Baskerville', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    line-height: 1.75;
    color: var(--parchment);
    margin-bottom: 1.5rem;
}

.epigraph {
    font-family: 'Libre Baskerville', serif;
    font-style: italic;
    font-weight: 400;
    font-size: clamp(1.1rem, 1.4vw, 1.35rem);
    line-height: 1.85;
    color: var(--parchment);
    opacity: 0.85;
}

.mono-annotation {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--phosphor);
    display: block;
    margin: 1.5rem 0;
}

/* Pull Quotes */
.pull-quote-container {
    position: relative;
    z-index: 5;
}

.pull-quote {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-weight: 400;
    font-size: clamp(1.5rem, 2.5vw, 2.2rem);
    line-height: 1.4;
    color: var(--parchment);
    border-left: 2px solid var(--sealing-wax);
    padding-left: 1.5rem;
    max-width: 28ch;
    opacity: 0.9;
}

.content-right .pull-quote {
    border-left: none;
    border-right: 2px solid var(--sealing-wax);
    padding-left: 0;
    padding-right: 1.5rem;
    text-align: right;
}

/* Punch Card Decorations */
.punch-card-decoration {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 1rem;
    max-width: 200px;
}

.punch-row {
    display: flex;
    gap: 3px;
}

.punch {
    width: 8px;
    height: 4px;
    border-radius: 1px;
    border: 1px solid var(--binding);
    opacity: 0.1;
}

.punch.filled {
    background: var(--binding);
    opacity: 0.12;
}

.punch-border {
    margin: 2rem auto 0;
}

/* Fade Reveal */
.fade-reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease 0.2s, transform 0.6s ease 0.2s;
}

.fade-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Border Animate on Links */
.body-text a {
    color: var(--phosphor);
    text-decoration: none;
    position: relative;
    display: inline;
}

.body-text a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--phosphor);
    transition: width 0.4s ease;
}

.body-text a:hover::after {
    width: 100%;
}

/* Final Text */
.final-text {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: clamp(1.3rem, 2vw, 1.8rem);
    color: var(--parchment);
    opacity: 0.7;
}

.chapter-final {
    min-height: 60vh;
}

/* Responsive */
@media (max-width: 768px) {
    .content-left, .content-right {
        margin-left: 6vw;
        margin-right: 6vw;
    }
    .spine { opacity: 0.08; }
    .node-diagram { display: none; }
    .chapter { padding: clamp(2rem, 6vw, 4rem); }
}
