/* ============================================================
   riron.net - Design System
   Blobitecture + Scholar's Study
   ============================================================ */

/* --- Palette ---
   Deep Ink:         #1A1A2E
   Ivory Vellum:     #F5F0E8
   Scholarly Crimson: #9B2335
   Tarnished Gold:   #B8963E
   Smoke:            #6B6B7B
   Parchment Shadow: #D4C5A9
   Blush Theory:     #C4727F
   ------------------------------------------------------------ */

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

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

body {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1.05rem, 1.8vw, 1.25rem);
    line-height: 1.72;
    color: #1A1A2E;
    background-color: #F5F0E8;
    overflow-x: hidden;
}

/* --- Typography --- */

h1, h2, .chapter-heading {
    font-family: 'Cormorant Garamond', 'Times New Roman', serif;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.1;
    color: #1A1A2E;
}

.hero-title {
    font-family: 'Cormorant Garamond', 'Times New Roman', serif;
    font-size: clamp(3.5rem, 10vw, 7rem);
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.0;
    color: #1A1A2E;
}

.chapter-heading {
    font-size: clamp(2.8rem, 7vw, 5.5rem);
    margin-bottom: 1.5rem;
}

.chapter-number {
    color: #9B2335;
    font-style: italic;
}

.hero-subtitle {
    font-family: 'Karla', 'Helvetica Neue', sans-serif;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    font-weight: 400;
    color: #6B6B7B;
    letter-spacing: 0.15em;
    text-transform: lowercase;
    margin-top: 1rem;
}

.body-text p {
    margin-bottom: 1.5rem;
}

.body-text p + p {
    text-indent: 2em;
}

.body-text .first-para {
    text-indent: 0;
}

.annotation {
    font-family: 'Karla', sans-serif;
    font-size: clamp(0.75rem, 1.2vw, 0.9rem);
    font-weight: 400;
    color: #6B6B7B;
    font-style: italic;
}

/* --- The Spine --- */

#spine {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 0%;
    background: #1A1A2E;
    z-index: 100;
    pointer-events: none;
    transition: height 0.1s linear;
}

/* --- Chapter Indicator --- */

#chapter-indicator {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    background: #F5F0E8;
    border: 2px solid #9B2335;
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: indicator-pulse 5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    box-shadow: 0 4px 20px rgba(26, 26, 46, 0.12);
}

#chapter-label {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.4rem;
    font-weight: 600;
    font-style: italic;
    color: #9B2335;
}

@keyframes indicator-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
        border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    }
    50% {
        transform: scale(1.03);
        opacity: 0.92;
        border-radius: 50% 50% 50% 50% / 60% 40% 60% 40%;
    }
}

/* --- Chapters --- */

.chapter {
    position: relative;
    min-height: 100vh;
    width: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Chapter Watermarks --- */

.chapter-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Cormorant Garamond', serif;
    font-size: 20vw;
    font-style: italic;
    font-weight: 600;
    color: #1A1A2E;
    opacity: 0.04;
    pointer-events: none;
    z-index: 0;
    line-height: 1;
}

/* --- Background Blobs --- */

.bg-blob {
    position: fixed;
    pointer-events: none;
    z-index: 0;
    opacity: 0.35;
    background: #D4C5A9;
}

.bg-blob-1 {
    width: 500px;
    height: 500px;
    top: -100px;
    left: -150px;
    border-radius: 40% 60% 55% 45% / 55% 40% 60% 45%;
    animation: blob-drift-1 28s ease-in-out infinite;
}

.bg-blob-2 {
    width: 400px;
    height: 400px;
    bottom: -80px;
    right: -120px;
    border-radius: 55% 45% 40% 60% / 45% 55% 45% 55%;
    animation: blob-drift-2 35s ease-in-out infinite;
}

.bg-blob-3 {
    width: 300px;
    height: 300px;
    top: 40%;
    right: 10%;
    border-radius: 45% 55% 60% 40% / 50% 45% 55% 50%;
    animation: blob-drift-3 22s ease-in-out infinite;
    opacity: 0.2;
}

@keyframes blob-drift-1 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(40px, 30px) rotate(5deg); }
    50% { transform: translate(-20px, 60px) rotate(-3deg); }
    75% { transform: translate(30px, -20px) rotate(4deg); }
}

@keyframes blob-drift-2 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(-50px, -30px) rotate(-4deg); }
    66% { transform: translate(30px, -50px) rotate(6deg); }
}

@keyframes blob-drift-3 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-40px, 30px) scale(1.08); }
}

/* --- Chapter 0: Hero --- */

#chapter-0 {
    flex-direction: column;
    background: #F5F0E8;
}

.hero-blob-mask {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(80vw, 700px);
    height: min(70vh, 600px);
    border-radius: 35% 65% 55% 45% / 40% 50% 50% 60%;
    overflow: hidden;
    animation: hero-blob-pulse 6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    z-index: 1;
}

.hero-photo {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #D4C5A9 0%, #B8963E 30%, #F5F0E8 60%, #D4C5A9 100%);
    background-size: 200% 200%;
    animation: warm-shift 12s ease-in-out infinite;
}

@keyframes warm-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@keyframes hero-blob-pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        border-radius: 35% 65% 55% 45% / 40% 50% 50% 60%;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.02);
        border-radius: 45% 55% 60% 40% / 50% 40% 60% 50%;
    }
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    opacity: 0;
    animation: hero-fade-in 2s ease-out 0.5s forwards;
}

@keyframes hero-fade-in {
    to {
        opacity: 1;
    }
}

/* --- Bookmark Ribbons --- */

.bookmark-ribbon {
    position: absolute;
    top: 0;
    width: 18px;
    height: 120px;
    background: #9B2335;
    z-index: 10;
    clip-path: polygon(0 0, 100% 0, 100% 85%, 50% 100%, 0 85%);
    animation: ribbon-sway 4s ease-in-out infinite;
    transform-origin: top center;
}

.ribbon-hero {
    right: 12%;
}

.ribbon-chapter-2 {
    left: 8%;
}

.ribbon-chapter-4 {
    right: 15%;
}

@keyframes ribbon-sway {
    0%, 100% { transform: rotate(-2deg); }
    50% { transform: rotate(2deg); }
}

/* --- Chapter Spread Layout --- */

.chapter-spread {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.left-page {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem 4rem 4rem;
}

.right-page {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 4rem 4rem 2rem;
    position: relative;
}

/* --- Blob Containers --- */

.blob-container {
    padding: 3rem;
    position: relative;
    max-width: 600px;
}

.blob-shape-1 {
    background: rgba(245, 240, 232, 0.9);
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    border: 1px solid rgba(155, 35, 53, 0.15);
    animation: blob-breathe-1 6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.blob-shape-2 {
    border-radius: 60% 40% 45% 55% / 50% 60% 40% 50%;
    overflow: hidden;
    animation: blob-breathe-2 7s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

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

.blob-shape-4 {
    border-radius: 55% 45% 50% 50% / 40% 60% 40% 60%;
    overflow: hidden;
    animation: blob-breathe-3 8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.blob-shape-5 {
    background: rgba(245, 240, 232, 0.9);
    border-radius: 45% 55% 60% 40% / 55% 45% 55% 45%;
    border: 1px solid rgba(155, 35, 53, 0.15);
    animation: blob-breathe-1 7s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.blob-shape-6 {
    background: rgba(245, 240, 232, 0.9);
    border-radius: 50% 50% 45% 55% / 55% 45% 55% 45%;
    border: 1px solid rgba(155, 35, 53, 0.15);
    animation: blob-breathe-2 6.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.blob-shape-7 {
    border-radius: 45% 55% 55% 45% / 50% 50% 50% 50%;
    overflow: hidden;
    animation: blob-breathe-3 7s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.blob-shape-8 {
    background: rgba(245, 240, 232, 0.95);
    border-radius: 40% 60% 50% 50% / 45% 55% 45% 55%;
    border: 2px solid rgba(155, 35, 53, 0.2);
    animation: blob-breathe-1 6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes blob-breathe-1 {
    0%, 100% {
        transform: scale(1);
        border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    }
    50% {
        transform: scale(1.02);
        border-radius: 40% 60% 60% 40% / 40% 40% 60% 60%;
    }
}

@keyframes blob-breathe-2 {
    0%, 100% {
        transform: scale(1);
        border-radius: 60% 40% 45% 55% / 50% 60% 40% 50%;
    }
    50% {
        transform: scale(1.025);
        border-radius: 50% 50% 55% 45% / 55% 50% 50% 55%;
    }
}

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

/* --- Image Blobs --- */

.image-blob {
    padding: 0;
    width: min(400px, 35vw);
    height: min(450px, 50vh);
}

.plate-photo {
    width: 100%;
    height: 100%;
}

.plate-library {
    background: linear-gradient(160deg, #B8963E 0%, #D4C5A9 40%, #6B6B7B 80%, #1A1A2E 100%);
}

.plate-desk {
    background: linear-gradient(200deg, #D4C5A9 0%, #B8963E 35%, #9B2335 70%, #1A1A2E 100%);
}

.plate-pages {
    background: linear-gradient(140deg, #F5F0E8 0%, #D4C5A9 30%, #B8963E 60%, #6B6B7B 100%);
}

/* --- Marginalia --- */

.marginalia {
    position: absolute;
    max-width: 180px;
}

.marginalia-right {
    right: -60px;
    top: 50%;
    transform: translateY(-50%);
}

.marginalia-left {
    left: -40px;
    bottom: 20%;
}

.marginalia .annotation {
    display: block;
    opacity: 0.7;
    line-height: 1.5;
}

/* --- Marginalia Field (Chapter II) --- */

.marginalia-field {
    position: absolute;
    left: 4%;
    top: 0;
    width: 35%;
    height: 100%;
    z-index: 1;
}

.scattered-annotation {
    position: absolute;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.scattered-annotation.visible {
    opacity: 0.6;
}

.ann-1 { top: 15%; left: 10%; }
.ann-2 { top: 30%; left: 25%; }
.ann-3 { top: 50%; left: 5%; }
.ann-4 { top: 65%; left: 30%; }
.ann-5 { top: 80%; left: 15%; }

/* --- Chapter II: Crimson Intrusion --- */

#chapter-2 {
    background: #F5F0E8;
}

.crimson-intrusion {
    position: absolute;
    right: -5%;
    top: 50%;
    transform: translateY(-50%);
    width: 55%;
    z-index: 2;
}

.crimson-blob {
    background: #9B2335;
    padding: 4rem 5rem;
    animation: crimson-breathe 5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

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

.thesis-quote p {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1.8rem, 4vw, 3rem);
    font-weight: 600;
    font-style: italic;
    color: #F5F0E8;
    line-height: 1.3;
    letter-spacing: 0.01em;
}

/* --- Chapter V: Closing --- */

#chapter-5 {
    flex-direction: column;
}

.closing-content {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 700px;
    padding: 2rem;
}

.closing-blob {
    text-align: center;
}

.closing-heading {
    font-size: clamp(2.2rem, 5vw, 4rem);
    margin-bottom: 2rem;
}

.closing-text {
    font-size: clamp(1rem, 1.6vw, 1.2rem);
    line-height: 1.8;
    margin-bottom: 2rem;
    color: #1A1A2E;
}

.closing-invitation {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1.4rem, 3vw, 2rem);
    font-weight: 600;
    font-style: italic;
    color: #9B2335;
    margin-top: 2rem;
}

.colophon {
    margin-top: 4rem;
}

.colophon-text {
    font-family: 'Karla', sans-serif;
    font-size: 0.85rem;
    color: #6B6B7B;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

/* --- Footnote Circles --- */

.footnote-cluster {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
}

.footnote-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: 2px solid #B8963E;
    color: #B8963E;
    font-family: 'Karla', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-radius 0.3s ease, background 0.3s ease, color 0.3s ease, transform 0.3s ease;
    will-change: transform, border-radius;
}

.footnote-circle:hover {
    border-radius: 40% 60% 55% 45% / 50% 50% 50% 50%;
    background: #B8963E;
    color: #F5F0E8;
    transform: scale(1.15);
}

/* --- Footnote Tooltip --- */

.footnote-tooltip {
    position: fixed;
    padding: 1rem 1.5rem;
    background: #1A1A2E;
    color: #F5F0E8;
    font-family: 'Karla', sans-serif;
    font-size: 0.85rem;
    line-height: 1.5;
    border-radius: 40% 60% 55% 45% / 50% 50% 50% 50%;
    max-width: 280px;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 500;
}

.footnote-tooltip.active {
    opacity: 1;
    transform: scale(1);
}

/* --- Text Fade-In --- */

.fade-in-element {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.fade-in-element.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Scroll Morph (custom property targets) --- */

.blob-container {
    will-change: transform;
}

/* --- Mobile Responsive --- */

@media (max-width: 768px) {
    .chapter-spread {
        flex-direction: column;
    }

    .left-page, .right-page {
        padding: 3rem 1.5rem;
    }

    .blob-container {
        max-width: 100%;
    }

    .image-blob {
        width: 80vw;
        height: 40vh;
    }

    #spine {
        left: 12px;
        transform: none;
    }

    .marginalia {
        position: relative;
        right: auto;
        left: auto;
        top: auto;
        bottom: auto;
        max-width: 100%;
        margin-top: 1rem;
    }

    .marginalia-right, .marginalia-left {
        right: auto;
        left: auto;
        top: auto;
        bottom: auto;
        transform: none;
    }

    .marginalia-field {
        position: relative;
        left: auto;
        width: 100%;
        height: auto;
        padding: 2rem 1.5rem;
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .scattered-annotation {
        position: relative;
        top: auto;
        left: auto;
        opacity: 0.6;
    }

    .crimson-intrusion {
        position: relative;
        right: auto;
        top: auto;
        transform: none;
        width: 90%;
        margin: 2rem auto;
    }

    .hero-blob-mask {
        width: 85vw;
        height: 50vh;
    }

    .hero-title {
        font-size: clamp(2.5rem, 12vw, 4rem);
    }

    .chapter-watermark {
        font-size: 30vw;
    }

    .bg-blob-1 { width: 300px; height: 300px; }
    .bg-blob-2 { width: 250px; height: 250px; }
    .bg-blob-3 { width: 200px; height: 200px; }

    #chapter-indicator {
        width: 44px;
        height: 44px;
        bottom: 1rem;
        right: 1rem;
    }

    #chapter-label {
        font-size: 1.1rem;
    }

    .bookmark-ribbon {
        width: 14px;
        height: 90px;
    }

    .thesis-quote p {
        font-size: clamp(1.3rem, 5vw, 2rem);
    }

    .crimson-blob {
        padding: 2.5rem 2rem;
    }
}

@media (max-width: 480px) {
    .left-page, .right-page {
        padding: 2rem 1rem;
    }

    .blob-container {
        padding: 2rem 1.5rem;
    }

    .image-blob {
        width: 90vw;
        height: 35vh;
    }
}
