/* ============================================
   monopole.cloud - Blobitecture Scholarly Design
   ============================================ */

/* === Custom Properties & @property === */
@property --border-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

@property --border-draw {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

/* === Color Palette === */
:root {
    --magnetic-black: #0a0a12;
    --midnight-indigo: #12122e;
    --electric-magenta: #e91e8c;
    --plasma-cyan: #00e5ff;
    --monopole-violet: #8b5cf6;
    --vellum-white: #e8e0d4;
    --bright-parchment: #f5f0e8;
    --clay-umber: #8b6f47;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--magnetic-black);
    color: var(--vellum-white);
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1rem, 1.1vw, 1.2rem);
    font-weight: 400;
    line-height: 1.75;
    overflow-x: hidden;
    position: relative;
}

/* === Genesis Screen === */
#genesis-screen {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 10;
}

#genesis-blob {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--electric-magenta);
    border-radius: 50%;
    opacity: 0;
    transform: scale(1);
    transition: none;
    z-index: 1;
}

#genesis-blob.expanding {
    opacity: 1;
    animation: blobExpand 2000ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#genesis-blob.breathing {
    animation: blobBreathe 8s ease-in-out infinite;
}

@keyframes blobExpand {
    0% {
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background: var(--electric-magenta);
    }
    30% {
        border-radius: 45% 55% 50% 50% / 50% 50% 55% 45%;
    }
    60% {
        border-radius: 40% 60% 55% 45% / 55% 45% 60% 40%;
    }
    100% {
        width: 90vw;
        height: 85vh;
        border-radius: 40% 60% 55% 45% / 55% 45% 60% 40%;
        background: radial-gradient(ellipse at 40% 40%, var(--midnight-indigo), var(--magnetic-black));
    }
}

@keyframes blobBreathe {
    0%, 100% {
        transform: scale(1);
        border-radius: 40% 60% 55% 45% / 55% 45% 60% 40%;
    }
    25% {
        border-radius: 45% 55% 50% 50% / 50% 50% 55% 45%;
    }
    50% {
        transform: scale(1.02);
        border-radius: 55% 45% 60% 40% / 45% 55% 40% 60%;
    }
    75% {
        border-radius: 50% 50% 45% 55% / 55% 45% 50% 50%;
    }
}

/* === Title Container === */
#title-container {
    position: relative;
    z-index: 5;
    text-align: center;
    opacity: 0;
}

#title-container.visible {
    opacity: 1;
}

#site-title {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 900;
    font-size: clamp(3rem, 8vw, 7rem);
    font-variation-settings: 'WONK' 1, 'SOFT' 100, 'opsz' 144;
    color: var(--bright-parchment);
    letter-spacing: -0.02em;
    display: inline-flex;
    align-items: baseline;
    flex-wrap: wrap;
    justify-content: center;
}

/* Character-level kinetic animation */
.char {
    display: inline-block;
    opacity: 0;
    border-radius: 50%;
    transform: scale(0.3);
    animation: none;
}

.char.animate {
    animation: charMorph 1200ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes charMorph {
    0% {
        opacity: 0;
        border-radius: 50%;
        transform: scale(0.3);
        filter: blur(4px);
    }
    40% {
        opacity: 1;
        border-radius: 30%;
        transform: scale(1.1);
        filter: blur(1px);
    }
    100% {
        opacity: 1;
        border-radius: 0;
        transform: scale(1);
        filter: blur(0);
    }
}

/* Period pulse */
.title-period {
    display: inline-block;
    color: var(--electric-magenta);
    opacity: 0;
}

.title-period.visible {
    opacity: 1;
    animation: periodPulse 3s ease-in-out infinite;
}

@keyframes periodPulse {
    0%, 100% {
        transform: scale(0.8);
    }
    50% {
        transform: scale(1.2);
    }
}

/* Cloud word particle scatter */
.cloud-char {
    display: inline-block;
    opacity: 0;
    transform: translate(0, 0);
}

.cloud-char.scatter-in {
    animation: cloudScatterIn 800ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes cloudScatterIn {
    0% {
        opacity: 0;
        transform: translate(var(--scatter-x, 40px), var(--scatter-y, -30px)) scale(0.5);
        filter: blur(3px);
    }
    100% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
        filter: blur(0);
    }
}

/* Hover scatter effect on "cloud" */
#word-cloud {
    cursor: default;
    position: relative;
}

#word-cloud:hover .cloud-char.scatter-in {
    animation: cloudScatterOut 400ms ease-out forwards;
}

#word-cloud:not(:hover) .cloud-char.scatter-in {
    animation: cloudScatterIn 800ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes cloudScatterOut {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0.3;
        transform: translate(var(--scatter-x, 40px), var(--scatter-y, -30px)) scale(0.6);
        filter: blur(2px);
    }
}

/* === Blob Sections === */
.blob-section {
    position: relative;
    width: min(65ch, 88vw);
    margin: -3vh auto 0;
    padding: clamp(2rem, 5vw, 4rem);
    border-radius: 40% 60% 55% 45% / 55% 45% 60% 40%;
    background: radial-gradient(ellipse at 40% 40%, var(--midnight-indigo), var(--magnetic-black));
    z-index: 5;
    overflow: hidden;
}

.blob-section::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: conic-gradient(from var(--border-angle), var(--electric-magenta), var(--monopole-violet), var(--plasma-cyan), var(--electric-magenta));
    z-index: -1;
    opacity: 0;
    animation: rotateBorder 6s linear infinite;
    transition: opacity 600ms ease;
}

.blob-section.border-visible::before {
    opacity: 1;
}

.blob-section.border-faded::before {
    opacity: 0.3;
}

@keyframes rotateBorder {
    to {
        --border-angle: 360deg;
    }
}

/* Border draw-in animation */
.blob-section.border-draw::before {
    opacity: 1;
    mask-image: conic-gradient(from 0deg, black var(--border-draw), transparent var(--border-draw));
    -webkit-mask-image: conic-gradient(from 0deg, black var(--border-draw), transparent var(--border-draw));
    animation: rotateBorder 6s linear infinite, borderDrawIn 600ms ease-out forwards;
}

@keyframes borderDrawIn {
    from {
        --border-draw: 0deg;
    }
    to {
        --border-draw: 360deg;
    }
}

/* Chapter sections alternate widths */
.chapter-section:nth-child(odd of .chapter-section) {
    width: min(60ch, 85vw);
}

.chapter-section:nth-child(even of .chapter-section) {
    width: min(75ch, 92vw);
}

/* Subtitle blob */
.subtitle-blob {
    width: min(55ch, 80vw);
    margin-top: -5vh;
    text-align: center;
    padding: clamp(2.5rem, 6vw, 5rem);
    border-radius: 55% 45% 50% 50% / 50% 50% 45% 55%;
}

.subtitle-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    font-weight: 400;
    line-height: 1.8;
    color: var(--vellum-white);
    max-width: 55ch;
    margin: 0 auto;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 600ms ease, transform 600ms ease;
}

.subtitle-text.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* === Chapter Markers === */
.chapter-marker {
    position: relative;
    height: 8vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    margin: 2vh auto;
}

.chapter-numeral {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 200;
    font-size: 2rem;
    font-variation-settings: 'WONK' 1, 'SOFT' 100;
    color: var(--monopole-violet);
    opacity: 0;
    transition: opacity 500ms ease;
    letter-spacing: 0.1em;
}

.chapter-marker.visible .chapter-numeral {
    opacity: 0.6;
}

/* === Section Headings === */
.section-heading {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 900;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    font-variation-settings: 'WONK' 1, 'SOFT' 100;
    color: var(--bright-parchment);
    letter-spacing: -0.02em;
    margin-bottom: 1.5em;
    animation: headingFloat 4s ease-in-out infinite;
}

@keyframes headingFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-1px);
    }
}

/* === Chapter Watermarks === */
.chapter-watermark {
    position: absolute;
    top: clamp(1rem, 3vw, 2.5rem);
    left: clamp(1rem, 3vw, 2rem);
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 200;
    font-size: 5rem;
    font-variation-settings: 'WONK' 1, 'SOFT' 100;
    color: var(--monopole-violet);
    opacity: 0.06;
    pointer-events: none;
    z-index: 0;
    line-height: 1;
}

/* === Body Text === */
.body-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.1vw, 1.2rem);
    line-height: 1.75;
    color: var(--vellum-white);
    max-width: 65ch;
    margin-bottom: 1.5em;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 400ms ease, transform 400ms ease;
}

.body-text.revealed {
    opacity: 1;
    transform: translateY(0);
}

.body-text em,
.body-text strong {
    font-weight: 600;
    color: var(--bright-parchment);
}

/* === Pull Quotes === */
.pull-quote-blob {
    position: relative;
    margin: 2em 2ch;
    padding: clamp(1.5rem, 4vw, 3rem);
    border-radius: 45% 55% 50% 50% / 50% 50% 55% 45%;
    background: radial-gradient(ellipse at 50% 50%, rgba(18, 18, 46, 0.8), rgba(10, 10, 18, 0.9));
    transform: scale(0.8);
    opacity: 0;
    transition: transform 600ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 600ms ease;
}

.pull-quote-blob.revealed {
    transform: scale(1);
    opacity: 1;
}

.pull-quote-blob::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: conic-gradient(from var(--border-angle), var(--electric-magenta), var(--monopole-violet), var(--plasma-cyan), var(--electric-magenta));
    z-index: -1;
    animation: rotateBorder 6s linear infinite;
}

.pull-quote {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 900;
    font-style: italic;
    font-size: clamp(1.2rem, 2.2vw, 1.8rem);
    font-variation-settings: 'WONK' 1, 'SOFT' 100;
    color: var(--bright-parchment);
    letter-spacing: -0.01em;
    line-height: 1.5;
    text-align: center;
}

/* === Footnote Blobs === */
.footnote-blob {
    position: absolute;
    width: clamp(140px, 18vw, 220px);
    padding: clamp(0.8rem, 2vw, 1.2rem);
    border-radius: 50% 50% 45% 55% / 55% 45% 50% 50%;
    background: radial-gradient(ellipse at 50% 50%, rgba(18, 18, 46, 0.9), rgba(10, 10, 18, 0.95));
    border: 1px solid var(--clay-umber);
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 600ms ease, transform 600ms ease;
    z-index: 10;
}

.footnote-blob.revealed {
    opacity: 1;
    transform: translateX(0);
}

.footnote-right {
    right: -5%;
    top: 30%;
}

.footnote-left {
    left: -5%;
    top: 40%;
    transform: translateX(-20px);
}

.footnote-left.revealed {
    transform: translateX(0);
}

.footnote-marker {
    display: inline-block;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: clamp(0.7rem, 0.85vw, 0.85rem);
    color: var(--plasma-cyan);
    vertical-align: super;
    margin-bottom: 0.3em;
    letter-spacing: 0.06em;
}

.footnote-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: clamp(0.7rem, 0.85vw, 0.85rem);
    line-height: 1.5;
    color: var(--vellum-white);
    opacity: 0.85;
    letter-spacing: 0.02em;
}

/* === Background Decorative Blobs === */
.bg-blob {
    position: fixed;
    border-radius: 40% 60% 55% 45% / 55% 45% 60% 40%;
    background: var(--monopole-violet);
    opacity: 0.04;
    z-index: 0;
    pointer-events: none;
    will-change: transform, border-radius;
}

.bg-blob-1 {
    width: 40vw;
    height: 40vw;
    top: 5%;
    left: -10%;
    animation: bgBlobPulse1 25s ease-in-out infinite;
}

.bg-blob-2 {
    width: 35vw;
    height: 35vw;
    top: 30%;
    right: -8%;
    animation: bgBlobPulse2 22s ease-in-out infinite;
}

.bg-blob-3 {
    width: 50vw;
    height: 50vw;
    top: 55%;
    left: -15%;
    opacity: 0.03;
    animation: bgBlobPulse3 28s ease-in-out infinite;
}

.bg-blob-4 {
    width: 30vw;
    height: 30vw;
    top: 75%;
    right: -5%;
    animation: bgBlobPulse1 20s ease-in-out infinite reverse;
}

.bg-blob-5 {
    width: 45vw;
    height: 45vw;
    top: 15%;
    right: -20%;
    opacity: 0.03;
    animation: bgBlobPulse2 30s ease-in-out infinite;
}

.bg-blob-6 {
    width: 38vw;
    height: 38vw;
    top: 85%;
    left: 5%;
    opacity: 0.035;
    animation: bgBlobPulse3 24s ease-in-out infinite;
}

@keyframes bgBlobPulse1 {
    0%, 100% {
        border-radius: 40% 60% 55% 45% / 55% 45% 60% 40%;
        transform: translate(0, 0);
    }
    33% {
        border-radius: 55% 45% 40% 60% / 45% 55% 50% 50%;
        transform: translate(2vw, 1vh);
    }
    66% {
        border-radius: 50% 50% 60% 40% / 60% 40% 45% 55%;
        transform: translate(-1vw, 2vh);
    }
}

@keyframes bgBlobPulse2 {
    0%, 100% {
        border-radius: 55% 45% 50% 50% / 50% 50% 55% 45%;
        transform: translate(0, 0);
    }
    33% {
        border-radius: 45% 55% 60% 40% / 55% 45% 40% 60%;
        transform: translate(-2vw, -1vh);
    }
    66% {
        border-radius: 60% 40% 45% 55% / 40% 60% 50% 50%;
        transform: translate(1vw, -2vh);
    }
}

@keyframes bgBlobPulse3 {
    0%, 100% {
        border-radius: 50% 50% 45% 55% / 55% 45% 50% 50%;
        transform: translate(0, 0);
    }
    50% {
        border-radius: 45% 55% 55% 45% / 50% 50% 45% 55%;
        transform: translate(3vw, -2vh);
    }
}

/* === Magnetic Field Lines SVG === */
.field-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.15;
}

.field-line {
    fill: none;
    stroke: var(--electric-magenta);
    stroke-width: 1;
    stroke-dasharray: 20 30;
    animation: fieldFlow 8s linear infinite;
}

.field-line-1 {
    animation-duration: 10s;
    opacity: 0.6;
}

.field-line-2 {
    animation-duration: 12s;
    animation-delay: -3s;
    opacity: 0.4;
    stroke: var(--monopole-violet);
}

.field-line-3 {
    animation-duration: 9s;
    animation-delay: -5s;
    opacity: 0.5;
}

.field-line-4 {
    animation-duration: 11s;
    animation-delay: -7s;
    opacity: 0.35;
    stroke: var(--plasma-cyan);
}

@keyframes fieldFlow {
    0% {
        stroke-dashoffset: 0;
    }
    100% {
        stroke-dashoffset: -200;
    }
}

/* === Floating Chapter Navigation === */
#chapter-nav {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 100;
}

#chapter-nav-current {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(ellipse at 40% 40%, var(--midnight-indigo), var(--magnetic-black));
    border: 2px solid var(--electric-magenta);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: clamp(0.7rem, 0.85vw, 0.85rem);
    letter-spacing: 0.06em;
    color: var(--bright-parchment);
    cursor: pointer;
    transition: transform 300ms ease, box-shadow 300ms ease;
    position: relative;
    z-index: 102;
}

#chapter-nav-current:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(233, 30, 140, 0.4);
}

#chapter-nav-menu {
    position: absolute;
    bottom: 0;
    right: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 300ms ease;
}

#chapter-nav.open #chapter-nav-menu {
    pointer-events: auto;
    opacity: 1;
}

.nav-blob {
    position: absolute;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: radial-gradient(ellipse at 40% 40%, var(--midnight-indigo), var(--magnetic-black));
    border: 1.5px solid var(--monopole-violet);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: var(--bright-parchment);
    text-decoration: none;
    transform: scale(0) translate(0, 0);
    transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1), border-color 200ms ease, background 200ms ease;
}

.nav-blob:hover {
    border-color: var(--electric-magenta);
    box-shadow: 0 0 12px rgba(233, 30, 140, 0.3);
}

.nav-blob.active {
    border-color: var(--electric-magenta);
    background: radial-gradient(ellipse at 40% 40%, rgba(233, 30, 140, 0.2), var(--midnight-indigo));
}

/* Radial positions for 7 chapter nav blobs */
#chapter-nav.open .nav-blob:nth-child(1) { transform: scale(1) translate(-75px, -10px); }
#chapter-nav.open .nav-blob:nth-child(2) { transform: scale(1) translate(-70px, -55px); }
#chapter-nav.open .nav-blob:nth-child(3) { transform: scale(1) translate(-50px, -95px); }
#chapter-nav.open .nav-blob:nth-child(4) { transform: scale(1) translate(-20px, -125px); }
#chapter-nav.open .nav-blob:nth-child(5) { transform: scale(1) translate(10px, -145px); }
#chapter-nav.open .nav-blob:nth-child(6) { transform: scale(1) translate(-85px, -140px); transition-delay: 50ms; }
#chapter-nav.open .nav-blob:nth-child(7) { transform: scale(1) translate(-55px, -170px); transition-delay: 80ms; }

/* === Section Content === */
.section-content {
    position: relative;
    z-index: 2;
}

/* === Scroll-driven parallax for bg blobs === */
.bg-blob {
    transition: transform 200ms ease-out;
}

/* === Responsive Adjustments === */
@media (max-width: 768px) {
    .blob-section {
        width: 92vw !important;
        border-radius: 30% 70% 60% 40% / 60% 40% 70% 30%;
        padding: clamp(1.5rem, 4vw, 2.5rem);
    }

    .subtitle-blob {
        width: 90vw;
    }

    .footnote-blob {
        position: relative;
        width: 85%;
        margin: 1.5em auto;
        right: auto;
        left: auto;
        top: auto;
    }

    .footnote-right,
    .footnote-left {
        right: auto;
        left: auto;
        top: auto;
    }

    #chapter-nav {
        bottom: 1rem;
        right: 1rem;
    }

    #chapter-nav-current {
        width: 48px;
        height: 48px;
    }

    .nav-blob {
        width: 38px;
        height: 38px;
    }

    #chapter-nav.open .nav-blob:nth-child(1) { transform: scale(1) translate(-60px, -8px); }
    #chapter-nav.open .nav-blob:nth-child(2) { transform: scale(1) translate(-56px, -46px); }
    #chapter-nav.open .nav-blob:nth-child(3) { transform: scale(1) translate(-40px, -80px); }
    #chapter-nav.open .nav-blob:nth-child(4) { transform: scale(1) translate(-16px, -106px); }
    #chapter-nav.open .nav-blob:nth-child(5) { transform: scale(1) translate(8px, -122px); }
    #chapter-nav.open .nav-blob:nth-child(6) { transform: scale(1) translate(-68px, -118px); }
    #chapter-nav.open .nav-blob:nth-child(7) { transform: scale(1) translate(-44px, -146px); }

    .chapter-watermark {
        font-size: 3.5rem;
    }

    .bg-blob {
        display: none;
    }
}

@media (max-width: 480px) {
    #site-title {
        font-size: clamp(2rem, 10vw, 3.5rem);
    }

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

    .pull-quote {
        font-size: clamp(1rem, 4vw, 1.3rem);
    }
}
