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

html {
    scroll-behavior: smooth;
    scroll-snap-type: y mandatory;
    overflow-x: hidden;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: #f5f0e8;
    color: #2c3e50;
    overflow-x: hidden;
    /* palette: #1A2A3A #B8C9D4 #C48B6C */
}

/* === Lecture Counter === */
.lecture-counter {
    position: fixed;
    top: 2rem;
    right: 2.5rem;
    z-index: 100;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    color: #3d4f5f;
    opacity: 0.7;
    transition: opacity 0.4s ease;
}

.counter-current {
    font-weight: 500;
    font-size: 1.1rem;
    color: #2c3e50;
}

.counter-divider {
    margin: 0 0.15em;
    opacity: 0.4;
}

/* === Lecture Sections === */
.lecture {
    display: flex;
    width: 100vw;
    height: 100vh;
    scroll-snap-align: start;
    position: relative;
}

.lecture-left {
    width: 50%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.lecture-right {
    width: 50%;
    height: 100%;
    background: #e8eff4;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* === Marble Background === */
.marble-bg {
    position: absolute;
    inset: 0;
    background: #f5f0e8;
    overflow: hidden;
}

.marble-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 600px 200px at 20% 30%, rgba(212, 205, 196, 0.3) 0%, transparent 70%),
        radial-gradient(ellipse 400px 300px at 70% 60%, rgba(212, 205, 196, 0.2) 0%, transparent 70%),
        radial-gradient(ellipse 300px 500px at 50% 80%, rgba(212, 205, 196, 0.15) 0%, transparent 70%);
}

.marble-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(135deg, transparent 40%, rgba(212, 205, 196, 0.15) 41%, rgba(212, 205, 196, 0.15) 41.5%, transparent 42%),
        linear-gradient(160deg, transparent 55%, rgba(212, 205, 196, 0.12) 55.5%, rgba(212, 205, 196, 0.12) 56%, transparent 56.5%),
        linear-gradient(110deg, transparent 30%, rgba(212, 205, 196, 0.1) 30.5%, rgba(212, 205, 196, 0.1) 31%, transparent 31.5%);
}

/* === Lecture Content (Left Panel) === */
.lecture-content {
    position: relative;
    z-index: 2;
    padding: 4rem;
    max-width: 520px;
}

.lecture-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #5b8fa8;
    display: block;
    margin-bottom: 1.5rem;
}

.lecture-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(2.8rem, 6vw, 5.5rem);
    line-height: 1.08;
    letter-spacing: -0.015em;
    color: #2c3e50;
    margin-bottom: 2rem;
}

.lecture-body {
    font-family: 'Source Serif 4', serif;
    font-size: 1.1rem;
    line-height: 1.7;
    color: #3d4f5f;
    margin-bottom: 1.5rem;
}

.lecture-note {
    font-family: 'Cormorant Garamond', serif;
    font-size: 0.95rem;
    font-style: italic;
    color: #7a9bb5;
    line-height: 1.5;
}

/* === Visualization Panel (Right) === */
.viz-container {
    width: 80%;
    max-width: 400px;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.curve-svg {
    width: 100%;
    height: 100%;
}

/* === Vertical Divider === */
.lecture-left::after {
    content: '';
    position: absolute;
    right: 0;
    top: 15%;
    height: 70%;
    width: 1px;
    background: linear-gradient(to bottom, transparent, #d4cdc4, transparent);
}

/* === Alternating Layout for Even Lectures === */
.lecture:nth-child(even) {
    flex-direction: row-reverse;
}

.lecture:nth-child(even) .lecture-left::after {
    right: auto;
    left: 0;
}

/* === Animation States === */
.lecture-content {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.lecture.is-active .lecture-content {
    opacity: 1;
    transform: translateY(0);
}

.viz-container {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.8s ease 0.2s, transform 0.8s ease 0.2s;
}

.lecture:nth-child(even) .viz-container {
    transform: translateX(-20px);
}

.lecture.is-active .viz-container {
    opacity: 1;
    transform: translateX(0);
}

/* === SVG Curve Animations === */
.supply-curve, .demand-curve, .ppf-curve, .scurve-1, .scurve-2, .scurve-3 {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1.5s ease 0.4s;
}

.lecture.is-active .supply-curve,
.lecture.is-active .demand-curve,
.lecture.is-active .ppf-curve,
.lecture.is-active .scurve-1 {
    stroke-dashoffset: 0;
}

.lecture.is-active .scurve-2 {
    stroke-dashoffset: 0;
    transition-delay: 0.7s;
}

.lecture.is-active .scurve-3 {
    stroke-dashoffset: 0;
    transition-delay: 1s;
}

.equilibrium-dot, .ppf-dot {
    opacity: 0;
    transition: opacity 0.5s ease 1.5s;
}

.lecture.is-active .equilibrium-dot,
.lecture.is-active .ppf-dot {
    opacity: 1;
}

/* === Agent dots pulse === */
.agent, .agent-outer {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.lecture.is-active .agent {
    opacity: 1;
    animation: agentPulse 3s ease-in-out infinite;
}

.lecture.is-active .agent-outer {
    opacity: 0.6;
    animation: agentPulse 3s ease-in-out infinite 0.5s;
}

@keyframes agentPulse {
    0%, 100% { r: 4; }
    50% { r: 6; }
}

.agent-line {
    opacity: 0;
    transition: opacity 0.8s ease 0.6s;
}

.lecture.is-active .agent-line {
    opacity: 0.4;
}

/* === Right panel subtle patterns per lecture === */
#lecture1 .lecture-right {
    background: linear-gradient(170deg, #e8eff4 0%, #f0f4f8 100%);
}

#lecture2 .lecture-right {
    background: linear-gradient(200deg, #e8eff4 0%, #eee9e0 100%);
}

#lecture3 .lecture-right {
    background: linear-gradient(150deg, #e8eff4 0%, #e4ecf2 100%);
}

#lecture4 .lecture-right {
    background: linear-gradient(180deg, #e8eff4 0%, #f2ede5 100%);
}

#lecture5 .lecture-right {
    background: linear-gradient(160deg, #e8eff4 0%, #e6edf4 100%);
}

/* === Responsive === */
@media (max-width: 768px) {
    .lecture {
        flex-direction: column !important;
        height: auto;
        min-height: 100vh;
    }

    .lecture-left, .lecture-right {
        width: 100%;
        height: auto;
        min-height: 50vh;
    }

    .lecture-content {
        padding: 2.5rem 2rem;
    }

    .lecture-left::after {
        display: none;
    }

    .lecture-counter {
        top: 1rem;
        right: 1.5rem;
    }

    .viz-container {
        max-width: 300px;
        padding: 2rem 0;
    }
}
