/* ==============================================
   plotgrapher.com - Styles
   Colors: #0D1321, #1C2440, #00E5CC, #C44536, #F0EBD8, #3D5A80, #E8AA42
   Fonts: Syne (display), Instrument Serif (body), Inconsolata (annotations)
   ============================================== */

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

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

body {
    background: #0D1321;
    color: #F0EBD8;
    font-family: 'Instrument Serif', Georgia, serif;
    font-size: clamp(1rem, 1.25vw, 1.2rem);
    font-weight: 400;
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    cursor: default;
}

/* --- Coordinate Grid Background --- */
#grid-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

/* --- Cursor Trail Canvas --- */
#cursor-trail {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    pointer-events: none;
}

/* --- Scroll Progress Indicator --- */
#scroll-progress {
    position: fixed;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 200px;
    z-index: 100;
    opacity: 0.7;
}

#scroll-progress svg {
    width: 100%;
    height: 100%;
}

#progress-dot {
    transition: cy 0.1s linear;
}

/* --- Acts (Sections) --- */
.act {
    position: relative;
    z-index: 1;
    min-height: 100vh;
}

/* --- ACT I: Origin Point --- */
#act-1 {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#act-1 .act-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Axes SVG */
#axes-svg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 1000px;
    height: auto;
    z-index: 2;
}

.axis-line {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
}

.axis-label {
    font-family: 'Inconsolata', monospace;
    font-size: 11px;
    letter-spacing: 0.05em;
}

/* Origin burst animation */
.origin-burst {
    opacity: 0;
    transform-origin: center;
}

.origin-ring {
    opacity: 0;
    transform-origin: center;
}

.origin-burst.animate {
    animation: burstIn 0.3s ease-out forwards;
}

.origin-ring.animate {
    animation: ringExpand 0.8s ease-out forwards;
}

.ring-delay.animate {
    animation-delay: 0.1s;
}

@keyframes burstIn {
    0% { opacity: 0; r: 2; }
    50% { opacity: 1; r: 8; }
    100% { opacity: 1; r: 4; }
}

@keyframes ringExpand {
    0% { opacity: 0.8; r: 4; }
    100% { opacity: 0; r: 40; }
}

/* Coordinate letters on right side */
.coord-letter {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    opacity: 0;
}

.coord-dot {
    opacity: 0;
}

/* Axis pulsing */
#axes-svg::after {
    content: '';
}

@keyframes axisPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Hero text (PLOT) */
#hero-text {
    position: absolute;
    left: 6%;
    top: 50%;
    transform: translateY(-60%);
    z-index: 3;
    display: flex;
    gap: 0.02em;
}

.hero-letter {
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: clamp(4rem, 12vw, 9rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #F0EBD8;
    opacity: 0;
    transform: translateY(20px);
    display: inline-block;
}

.hero-letter.visible {
    animation: letterReveal 0.4s ease-out forwards;
}

@keyframes letterReveal {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Tagline */
#tagline {
    position: absolute;
    bottom: 18%;
    left: 6%;
    right: 6%;
    font-family: 'Instrument Serif', Georgia, serif;
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    color: #F0EBD8;
    opacity: 0;
    z-index: 3;
    line-height: 1.75;
}

#tagline.visible {
    animation: fadeInSlow 1.2s ease-out forwards;
}

@keyframes fadeInSlow {
    0% { opacity: 0; }
    100% { opacity: 0.85; }
}

/* Coordinate Labels */
.coord-label {
    font-family: 'Inconsolata', monospace;
    font-size: 10px;
    color: #3D5A80;
    position: absolute;
    letter-spacing: 0.05em;
    z-index: 5;
}

/* --- ACT II: The Rising Curve --- */
#act-2 {
    padding: 5vh 0;
    min-height: 200vh;
}

/* Section dividers */
.section-divider {
    width: 100%;
    height: 120px;
    display: block;
    overflow: visible;
}

.divider-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
}

.divider-path.drawn {
    transition: stroke-dashoffset 1.5s ease-out;
    stroke-dashoffset: 0;
}

/* Content blocks */
.content-block {
    position: relative;
    max-width: 1100px;
    margin: 8vh auto;
    padding: 4vh 6vw;
}

.content-block .coord-label {
    top: -10px;
    left: 6vw;
}

.section-title {
    font-family: 'Syne', sans-serif;
    font-weight: 600;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: 0.04em;
    color: #F0EBD8;
    margin-bottom: 3vh;
}

.content-row {
    display: flex;
    gap: 5vw;
    align-items: flex-start;
}

.content-row.reverse {
    flex-direction: row-reverse;
}

.text-column {
    flex: 1;
    min-width: 0;
}

.text-column.wide {
    max-width: 700px;
}

.svg-column {
    flex: 0 0 45%;
    min-width: 0;
}

.body-text {
    margin-bottom: 1.5em;
    color: #F0EBD8;
    opacity: 0.9;
}

/* Freytag's Pyramid */
.freytag-pyramid {
    width: 100%;
    max-width: 500px;
}

#freytag-path {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
}

.pyramid-point {
    opacity: 0;
    transition: transform 0.4s ease-out, opacity 0.3s ease-out;
}

.pyramid-point.visible {
    opacity: 1;
    animation: pointPulse 0.4s ease-out;
}

@keyframes pointPulse {
    0% { r: 5; }
    50% { r: 7; }
    100% { r: 5; }
}

.pyramid-label {
    font-family: 'Inconsolata', monospace;
    font-size: 9px;
    text-anchor: middle;
    letter-spacing: 0.08em;
}

/* Curve language SVG */
.curve-language-svg {
    width: 100%;
    max-width: 500px;
}

#tension-curve {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
}

.curve-annotation {
    font-family: 'Inconsolata', monospace;
    font-size: 10px;
    letter-spacing: 0.06em;
}

/* Data point constellations */
.constellation {
    position: relative;
    max-width: 400px;
    margin: 4vh auto;
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

.constellation.visible {
    opacity: 1;
}

.constellation svg {
    width: 100%;
}

.constellation-dot {
    transition: r 0.2s ease-out;
    cursor: default;
}

.constellation-dot:hover {
    r: 8;
}

/* Coordinate glow on scroll */
.content-block.in-view .coord-label {
    text-shadow: 0 0 8px rgba(0, 229, 204, 0.6);
    transition: text-shadow 0.5s ease-out;
}

/* --- ACT III: The Climax (Inverted) --- */
.act-inverted {
    background: #F0EBD8;
    color: #0D1321;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.climax-content {
    width: 100%;
    padding: 5vh 5vw;
    display: flex;
    align-items: center;
    justify-content: center;
}

#universal-curve {
    width: 90%;
    max-width: 1000px;
    height: auto;
}

#master-curve {
    stroke-dasharray: 1600;
    stroke-dashoffset: 1600;
}

.climax-label {
    font-family: 'Inconsolata', monospace;
    font-size: 11px;
    letter-spacing: 0.06em;
}

/* --- ACT IV: The Resolution --- */
#act-4 {
    padding: 5vh 0 10vh 0;
    min-height: 100vh;
}

.resolution-curves {
    max-width: 1000px;
    margin: 4vh auto;
    padding: 0 5vw;
}

.resolution-curves svg {
    width: 100%;
}

.resolution-path {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
}

/* End point */
#end-point {
    text-align: center;
    margin-top: 12vh;
    padding-bottom: 8vh;
}

#end-point svg {
    width: 120px;
    height: 80px;
    display: block;
    margin: 0 auto 2vh auto;
}

.end-label {
    font-family: 'Inconsolata', monospace;
    font-size: 11px;
    letter-spacing: 0.06em;
}

.pulse-slow {
    animation: slowPulse 2s ease-in-out infinite;
}

@keyframes slowPulse {
    0%, 100% { opacity: 0.6; r: 5; }
    50% { opacity: 1; r: 7; }
}

.domain-end {
    font-family: 'Syne', sans-serif;
    font-weight: 600;
    font-size: 1.5rem;
    letter-spacing: 0.04em;
    color: #F0EBD8;
    display: block;
    opacity: 0.7;
}

/* --- draw-on-scroll generic --- */
.draw-on-scroll {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 1.5s ease-out;
}

.draw-on-scroll.drawn {
    stroke-dashoffset: 0;
}

.climax-curve.drawn {
    transition: stroke-dashoffset 0.3s ease-out;
    stroke-dashoffset: 0;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .content-row,
    .content-row.reverse {
        flex-direction: column;
    }

    .svg-column {
        flex: 1;
        width: 100%;
    }

    #hero-text {
        left: 4%;
    }

    #tagline {
        left: 4%;
        right: 4%;
    }

    .content-block {
        padding: 3vh 4vw;
    }

    #scroll-progress {
        display: none;
    }
}

@media (max-width: 480px) {
    .hero-letter {
        font-size: clamp(3rem, 15vw, 5rem);
    }

    .section-title {
        font-size: clamp(1.3rem, 5vw, 2rem);
    }
}
