/* monopole.tech - Victorian field-science meets magnetic monopole theory */

/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
    --vellum: #f2ece3;
    --deep-umber: #2c261e;
    --iron-gall: #3a3228;
    --faded-notation: #7b6d5c;
    --tarnished-brass: #a89460;
    --pressed-sage: #7a8c6e;
    --dried-lavender: #8a7b8c;
    --oxidized-copper: #6b8a7a;
    --light-text: #d4c8b6;
    --functional: #8a7e70;
    --accent-specimen: #6b5e50;
    --text-secondary: #4a4035;

    --font-heading: 'Libre Baskerville', Georgia, 'Times New Roman', serif;
    --font-body: 'Libre Baskerville', Georgia, 'Times New Roman', serif;
    --font-functional: 'Source Sans 3', 'Source Sans Pro', sans-serif;
    --font-accent: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;

    --ease-gentle: cubic-bezier(0.25, 0.1, 0.25, 1);
}

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

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

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1.05rem, 1.8vw, 1.25rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    color: var(--text-secondary);
    background-color: var(--vellum);
    overflow-x: hidden;
}

/* ============================================================
   Grain Overlay
   ============================================================ */
#grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 200px 200px;
}

body.grain-dark #grain-overlay {
    opacity: 0.05;
    filter: invert(1);
}

/* ============================================================
   Progress Indicator
   ============================================================ */
#progress-indicator {
    position: fixed;
    right: 2vw;
    top: 50%;
    transform: translateY(-50%);
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

#progress-track {
    width: 2px;
    height: 120px;
    background: rgba(123, 109, 92, 0.2);
    position: relative;
    border-radius: 1px;
}

#progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: var(--faded-notation);
    border-radius: 1px;
    transition: height 0.4s var(--ease-gentle);
}

#progress-numeral {
    font-family: var(--font-functional);
    font-weight: 300;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--functional);
    transition: color 0.6s var(--ease-gentle);
}

/* ============================================================
   Sections
   ============================================================ */
.section {
    position: relative;
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: background-color 0.8s var(--ease-gentle);
}

.section--light {
    background-color: var(--vellum);
}

.section--dark {
    background-color: var(--deep-umber);
}

/* ============================================================
   Section 1: Title Page
   ============================================================ */
.section__label {
    position: absolute;
    top: 5vh;
    left: 5vw;
    font-family: var(--font-functional);
    font-weight: 300;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--functional);
    opacity: 0;
    transition: opacity 1.2s var(--ease-gentle);
}

.section__label.visible {
    opacity: 1;
}

.section__monopole-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(600px, 80vw);
    height: min(600px, 80vw);
}

.monopole-point-svg {
    width: 100%;
    height: 100%;
}

.field-line {
    fill: none;
    stroke: var(--oxidized-copper);
    stroke-width: 1.2;
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 4s var(--ease-gentle);
}

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

#monopole-point {
    opacity: 0;
    transition: opacity 0.8s var(--ease-gentle);
}

#monopole-point.visible {
    opacity: 1;
    animation: monopole-pulse 6s ease-in-out infinite;
}

@keyframes monopole-pulse {
    0%, 100% { transform: scale(1); transform-origin: 300px 300px; }
    50% { transform: scale(1.08); transform-origin: 300px 300px; }
}

.section__title {
    position: absolute;
    top: 58%;
    left: 50%;
    transform: translateX(-50%);
    width: max(300px, 60vw);
    max-width: 680px;
    text-align: center;
    font-family: var(--font-accent);
    font-weight: 600;
    font-style: italic;
    font-size: clamp(2.4rem, 5.5vw, 4.5rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--iron-gall);
    opacity: 0;
    transition: opacity 2s var(--ease-gentle);
}

.section__title em {
    color: var(--accent-specimen);
}

.section__title.visible {
    opacity: 1;
}

/* ============================================================
   Organic Blob Shapes
   ============================================================ */
.section__blob {
    position: absolute;
    pointer-events: none;
    transition: border-radius 3s ease;
}

.blob--sage {
    width: clamp(180px, 25vw, 350px);
    height: clamp(200px, 28vw, 380px);
    background-color: var(--pressed-sage);
    opacity: 0.15;
    border-radius: 42% 58% 63% 37% / 45% 55% 60% 40%;
    bottom: 5vh;
    right: -3vw;
    transform: translateX(0);
    animation: blob-drift 20s ease-in-out infinite alternate;
}

.blob--sage:hover {
    border-radius: 55% 45% 50% 50% / 60% 40% 55% 45%;
}

.blob--brass {
    width: clamp(200px, 22vw, 320px);
    height: clamp(240px, 26vw, 360px);
    background-color: var(--tarnished-brass);
    opacity: 0.18;
    border-radius: 58% 42% 55% 45% / 40% 60% 45% 55%;
    left: -4vw;
    top: 50%;
    transform: translateY(-50%);
}

.blob--brass:hover {
    border-radius: 45% 55% 48% 52% / 55% 45% 50% 50%;
}

.blob--lavender {
    width: clamp(250px, 30vw, 450px);
    height: clamp(300px, 35vw, 500px);
    background-color: var(--dried-lavender);
    opacity: 0.12;
    border-radius: 52% 48% 45% 55% / 48% 52% 58% 42%;
    right: 5vw;
    top: 50%;
    transform: translateY(-50%);
}

.blob--lavender:hover {
    border-radius: 48% 52% 55% 45% / 52% 48% 42% 58%;
}

@keyframes blob-drift {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(10px, -8px) rotate(2deg); }
}

/* ============================================================
   Marginalia
   ============================================================ */
.marginalia {
    position: absolute;
    pointer-events: none;
}

.marginalia--top-right {
    top: 3vh;
    right: -10px;
    width: 80px;
    height: 140px;
    opacity: 0.7;
}

.marginalia--bottom-left {
    bottom: 5vh;
    left: 3vw;
    width: 100px;
    height: 70px;
    opacity: 0.7;
}

.marginalia--right-edge {
    right: -15px;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 200px;
    opacity: 0.7;
}

.marginalia--bottom-center {
    bottom: 5vh;
    left: 50%;
    transform: translateX(-50%);
    width: 140px;
    height: 45px;
    opacity: 0.7;
}

/* ============================================================
   Section 2: First Observation
   ============================================================ */
.section__content {
    position: relative;
    z-index: 10;
    max-width: 680px;
}

.section__content--right {
    margin-left: auto;
    padding-right: 8vw;
    padding-left: 2vw;
}

.section__content--left {
    margin-right: auto;
    padding-left: 8vw;
    padding-right: 2vw;
}

.observation-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1.05rem, 1.8vw, 1.25rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    color: var(--text-secondary);
    max-width: 62ch;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1.5s var(--ease-gentle), transform 1.5s var(--ease-gentle);
}

.observation-text.visible {
    opacity: 1;
    transform: translateY(0);
}

.observation-text--light {
    color: var(--light-text);
}

.section__field-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.field-line--delayed {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 3.5s var(--ease-gentle);
}

.field-line--delayed.animate {
    stroke-dashoffset: 0;
}

/* Glow effect on dark sections */
.field-lines--glow .field-line {
    filter: drop-shadow(0 0 2px var(--oxidized-copper));
}

/* ============================================================
   Section 3: Dark Field
   ============================================================ */
.section--dark .observation-text {
    color: var(--light-text);
}

/* ============================================================
   Section 4: Specimen Plate
   ============================================================ */
.specimen-plate {
    position: relative;
    width: min(70vw, 700px);
    height: min(70vw, 700px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.specimen-diagram {
    width: 100%;
    height: 100%;
}

.field-line--specimen {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 3s var(--ease-gentle);
    filter: drop-shadow(0 0 2px var(--oxidized-copper));
}

.field-line--specimen.animate {
    stroke-dashoffset: 0;
}

.specimen-center-point {
    animation: monopole-pulse-specimen 6s ease-in-out infinite;
}

@keyframes monopole-pulse-specimen {
    0%, 100% { transform: scale(1); transform-origin: 400px 400px; }
    50% { transform: scale(1.08); transform-origin: 400px 400px; }
}

.specimen-label {
    position: absolute;
    font-family: var(--font-functional);
    font-weight: 300;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--light-text);
    opacity: 0;
    transition: opacity 1s var(--ease-gentle);
}

.specimen-label.visible {
    opacity: 1;
}

.specimen-label--top {
    top: 5%;
    left: 50%;
    transform: translateX(-50%);
}

.specimen-label--right {
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.specimen-label--bottom {
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
}

.specimen-label--left {
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

/* ============================================================
   Section 5: Closing Page
   ============================================================ */
.section__closing-content {
    position: relative;
    z-index: 10;
    text-align: center;
    max-width: 680px;
    padding: 0 5vw;
    margin-top: -10vh;
}

.closing-text {
    font-family: var(--font-accent);
    font-weight: 600;
    font-style: italic;
    font-size: clamp(1.4rem, 2.5vw, 1.8rem);
    line-height: 1.6;
    color: var(--iron-gall);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 2s var(--ease-gentle), transform 2s var(--ease-gentle);
}

.closing-text.visible {
    opacity: 1;
    transform: translateY(0);
}

.section__monopole-final {
    position: absolute;
    bottom: 10vh;
    left: 50%;
    transform: translateX(-50%);
    width: min(300px, 60vw);
    height: min(300px, 60vw);
}

.monopole-final-svg {
    width: 100%;
    height: 100%;
}

.field-line--converge {
    stroke-dasharray: 300;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 3s var(--ease-gentle);
}

.field-line--converge.animate {
    stroke-dashoffset: 300;
}

#monopole-final-point {
    transition: opacity 2s var(--ease-gentle);
}

#monopole-final-point.fade-out {
    opacity: 0;
}

/* ============================================================
   Dark mode adjustments for progress indicator
   ============================================================ */
body.in-dark-section #progress-numeral {
    color: var(--light-text);
}

body.in-dark-section #progress-track {
    background: rgba(212, 200, 182, 0.15);
}

body.in-dark-section #progress-fill {
    background: var(--light-text);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .section__content--right {
        padding-right: 5vw;
        padding-left: 5vw;
        margin-left: 0;
    }

    .section__content--left {
        padding-left: 5vw;
        padding-right: 5vw;
        margin-right: 0;
    }

    .section__title {
        top: 62%;
        width: 90vw;
    }

    .specimen-plate {
        width: 90vw;
        height: 90vw;
    }

    .specimen-label {
        font-size: 0.65rem;
    }

    #progress-indicator {
        right: 3vw;
    }

    .section__blob {
        opacity: 0.08;
    }
}

@media (max-width: 480px) {
    .section__title {
        font-size: clamp(1.6rem, 6vw, 2.4rem);
        top: 65%;
    }

    .section__label {
        font-size: 0.65rem;
    }
}
