/* MonopoleAI - Dark Academia Nocturne */
/* Color Palette */
:root {
    --bg-primary: #1a1410;
    --bg-secondary: #2c2218;
    --bg-deep: #0f0c08;
    --text-primary: #e8dcc8;
    --text-secondary: #a89878;
    --accent-primary: #d4722a;
    --accent-hover: #e8943c;
    --accent-cool: #8b9ea8;
    --candle-halo: rgba(245, 201, 99, 0.25);
    --candle-glow-subtle: rgba(245, 201, 99, 0.07);
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 350;
    font-size: clamp(1.05rem, 1.8vw, 1.2rem);
    line-height: 1.72;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Vignette - page edge foxing */
.vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    box-shadow: inset 0 0 150px 50px rgba(15, 12, 8, 0.6);
    z-index: 100;
}

/* Candle Atmospheric Glow */
.candle-glow {
    position: fixed;
    pointer-events: none;
    border-radius: 50%;
    z-index: 0;
}

.candle-glow--1 {
    width: 60vw;
    height: 60vh;
    top: 10%;
    left: 20%;
    background: radial-gradient(ellipse at 50% 30%, rgba(245, 201, 99, 0.07) 0%, transparent 65%);
    animation: candleBreathe1 8s ease-in-out infinite;
}

.candle-glow--2 {
    width: 40vw;
    height: 50vh;
    top: 30%;
    left: 40%;
    background: radial-gradient(ellipse at 50% 50%, rgba(212, 114, 42, 0.04) 0%, transparent 60%);
    animation: candleBreathe2 11s ease-in-out infinite;
}

.candle-glow--3 {
    width: 50vw;
    height: 40vh;
    top: 50%;
    left: 10%;
    background: radial-gradient(ellipse at 40% 40%, rgba(245, 201, 99, 0.05) 0%, transparent 55%);
    animation: candleBreathe3 13s ease-in-out infinite;
}

@keyframes candleBreathe1 {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.7; }
}

@keyframes candleBreathe2 {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

@keyframes candleBreathe3 {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.6; }
}

/* Sections */
.section {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10vh 5vw;
    z-index: 1;
}

/* Content Blocks - The Candle-Column */
.content-block {
    max-width: 680px;
    width: 54%;
    position: relative;
    margin: 3rem auto;
}

.content-block--right {
    transform: translateX(3vw);
}

.content-block--left {
    transform: translateX(-3vw);
}

.content-block--center {
    transform: translateX(0);
}

/* Progressive Disclosure - reveal animation */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 400ms ease-out, transform 400ms ease-out;
}

.reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

.content-block--right.revealed {
    transform: translate(3vw, 0);
}

.content-block--left.revealed {
    transform: translate(-3vw, 0);
}

.content-block--center.revealed {
    transform: translate(0, 0);
}

/* Typography */
.site-title {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 300;
    font-optical-sizing: auto;
    font-variation-settings: 'WONK' 1, 'opsz' 72;
    font-size: clamp(2.8rem, 6vw, 4.5rem);
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text-primary);
    opacity: 0;
    animation: titleFadeIn 2s ease-out 2s forwards;
}

.site-subtitle {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(1.2rem, 2.5vw, 1.6rem);
    color: var(--text-secondary);
    margin-top: 1rem;
    opacity: 0;
    animation: titleFadeIn 2s ease-out 2.8s forwards;
}

@keyframes titleFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

h2 {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 700;
    font-optical-sizing: auto;
    font-variation-settings: 'WONK' 1;
    font-size: clamp(1.6rem, 3.2vw, 2.4rem);
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text-primary);
}

.body-text {
    color: var(--text-primary);
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 350;
    font-size: clamp(1.05rem, 1.8vw, 1.2rem);
    line-height: 1.72;
}

/* Margin Notes */
.margin-note {
    display: block;
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 1.2rem;
    color: var(--text-secondary);
    position: absolute;
    transform: rotate(-2deg);
}

.margin-note--left {
    left: -2.5rem;
    top: 0.5rem;
}

.margin-note--right {
    right: -3rem;
    bottom: 1rem;
    transform: rotate(-1.5deg);
}

/* Margin Icons */
.margin-icon {
    position: absolute;
    opacity: 0.4;
    z-index: 0;
}

.margin-icon--dipole {
    width: 30px;
    right: calc(50% - 400px);
    top: 40%;
}

.margin-icon--solenoid {
    width: 45px;
    left: calc(50% - 420px);
    top: 55%;
}

/* Opening Section */
.section--opening {
    min-height: 100vh;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.opening-glow {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(245, 201, 99, 0.3) 0%, rgba(212, 114, 42, 0.1) 40%, transparent 70%);
    animation: openingGlowExpand 4s ease-out 0.5s forwards, candleBreathe1 8s ease-in-out 4.5s infinite;
    z-index: 0;
}

@keyframes openingGlowExpand {
    from {
        width: 40px;
        height: 40px;
        opacity: 0.6;
    }
    to {
        width: 500px;
        height: 500px;
        opacity: 1;
    }
}

/* Diagram Section */
.section--diagram {
    min-height: 80vh;
    padding: 5vh 5vw;
}

.diagram-container {
    width: 100%;
    max-width: 600px;
    display: flex;
    justify-content: center;
}

.field-diagram {
    width: 100%;
    height: auto;
    max-height: 60vh;
}

.field-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2s ease-out;
}

.revealed .field-line {
    stroke-dashoffset: 0;
}

.field-line--1 { transition-delay: 0s; }
.field-line--2 { transition-delay: 0.3s; }
.field-line--3 { transition-delay: 0.6s; }
.field-line--4 { transition-delay: 0.9s; }
.field-line--terminated { transition-delay: 1.2s; }

.monopole-point {
    animation: monopolePulse 3s ease-in-out infinite;
}

.monopole-halo {
    animation: haloPulse 3s ease-in-out infinite;
}

@keyframes monopolePulse {
    0%, 100% {
        r: 4;
        fill: #f5c963;
    }
    50% {
        r: 6;
        fill: #e8943c;
    }
}

@keyframes haloPulse {
    0%, 100% {
        r: 12;
        opacity: 0.25;
    }
    50% {
        r: 20;
        opacity: 0.5;
    }
}

/* Chalkboard Section */
.section--chalkboard {
    min-height: 80vh;
    padding: 0;
}

.chalkboard-bg {
    width: 100%;
    min-height: 60vh;
    background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-deep) 50%, var(--bg-primary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8vh 5vw;
}

.chalkboard-content {
    text-align: center;
    max-width: 700px;
    width: 100%;
}

.chalk-equation {
    width: 100%;
    max-width: 600px;
    height: auto;
    margin: 0 auto;
    display: block;
}

.chalk-text,
.chalk-label {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 4s ease-out;
}

.reveal-chalk.drawing .chalk-text {
    stroke-dashoffset: 0;
}

.reveal-chalk.drawing .chalk-label {
    stroke-dashoffset: 0;
    transition-delay: 2s;
}

.chalk-annotation {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 1.3rem;
    color: var(--text-secondary);
    margin-top: 2rem;
    transform: rotate(-1deg);
    opacity: 0;
    transition: opacity 1s ease-out 3.5s;
}

.reveal-chalk.drawing .chalk-annotation {
    opacity: 1;
}

/* Close Section */
.section--close {
    min-height: 100vh;
    justify-content: center;
    text-align: center;
}

.closing-title {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 800;
    font-variation-settings: 'WONK' 1, 'opsz' 48;
    font-size: clamp(2.2rem, 5vw, 3.6rem);
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text-primary);
}

.closing-glow {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(245, 201, 99, 0.2) 0%, transparent 70%);
    margin: 3rem auto;
    animation: closingGlowContract 6s ease-in-out infinite alternate;
}

@keyframes closingGlowContract {
    from {
        width: 200px;
        height: 200px;
        opacity: 0.8;
    }
    to {
        width: 40px;
        height: 40px;
        opacity: 0.3;
    }
}

.closing-note {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 1rem;
    color: var(--text-secondary);
    opacity: 0.5;
    margin-top: 4rem;
    transform: rotate(-1deg);
}

/* Links */
a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color 200ms ease;
}

a:hover {
    color: var(--accent-hover);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .content-block {
        width: 90%;
        max-width: none;
    }

    .content-block--right {
        transform: translateX(1vw);
    }

    .content-block--left {
        transform: translateX(-1vw);
    }

    .content-block--right.revealed {
        transform: translate(1vw, 0);
    }

    .content-block--left.revealed {
        transform: translate(-1vw, 0);
    }

    .margin-note {
        position: relative;
        left: auto;
        right: auto;
        top: auto;
        bottom: auto;
        display: block;
        margin-top: 1rem;
        margin-left: 0;
    }

    .margin-icon {
        display: none;
    }

    .vignette {
        box-shadow: inset 0 0 80px 30px rgba(15, 12, 8, 0.5);
    }

    .section {
        padding: 8vh 4vw;
    }
}

/* Selection styling */
::selection {
    background: rgba(212, 114, 42, 0.3);
    color: var(--text-primary);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-secondary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}
