/* ============================================
   riron.xyz - Victorian Botanical Almanac
   Colors: #f4efe8, #2a2220, #6b7f5e, #4a7c72,
           #b5654a, #c9a84c, #d4ccc0, #6b2d2d
   Fonts: Josefin Sans, Nunito
   ============================================ */

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

html {
    scroll-snap-type: y proximity;
    scroll-behavior: smooth;
}

body {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.85;
    letter-spacing: 0.02em;
    color: #2a2220;
    background-color: #f4efe8;
    overflow-x: hidden;
    position: relative;
}

/* Paper grain texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.02;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

/* === Corner Flourishes === */
.corner-flourish {
    position: fixed;
    width: 100px;
    height: 100px;
    z-index: 100;
    pointer-events: none;
    color: #b5654a;
    opacity: 0.08;
    transition: color 0.6s ease, opacity 0.6s ease;
}

.corner-flourish svg {
    width: 100%;
    height: 100%;
}

.corner-tl { top: 0; left: 0; }
.corner-tr { top: 0; right: 0; }
.corner-bl { bottom: 0; left: 0; }
.corner-br { bottom: 0; right: 0; }

body.dark-active .corner-flourish {
    color: #c9a84c;
}

/* === Leaf Trail Container === */
#leaf-trail-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9998;
    overflow: hidden;
}

.trail-leaf {
    position: absolute;
    width: 20px;
    height: 20px;
    pointer-events: none;
    will-change: transform, opacity;
}

/* === Chapter Layout === */
.chapter {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    scroll-snap-align: start;
    padding: 4rem 2rem;
}

.chapter[data-theme="light"] {
    background-color: #f4efe8;
    color: #2a2220;
}

.chapter[data-theme="dark"] {
    background-color: #2a2220;
    color: #f4efe8;
}

/* Dark section wallpaper pattern */
.chapter[data-theme="dark"]::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.04;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cpath d='M60 10 Q45 30 60 50 Q75 30 60 10Z' fill='%236b7f5e' opacity='0.3'/%3E%3Cpath d='M30 60 Q15 80 30 100 Q45 80 30 60Z' fill='%236b7f5e' opacity='0.3'/%3E%3Cpath d='M90 60 Q75 80 90 100 Q105 80 90 60Z' fill='%236b7f5e' opacity='0.3'/%3E%3C/svg%3E");
    background-size: 120px 120px;
}

/* Margin vine borders */
.chapter::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 60px;
    height: 100%;
    pointer-events: none;
    opacity: 0.08;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='300' viewBox='0 0 60 300'%3E%3Cpath d='M30 0 Q20 30 30 60 Q40 90 30 120 Q20 150 30 180 Q40 210 30 240 Q20 270 30 300' fill='none' stroke='%236b7f5e' stroke-width='1.5'/%3E%3Cpath d='M30 40 Q20 35 15 42' fill='none' stroke='%236b7f5e' stroke-width='1'/%3E%3Cpath d='M30 100 Q40 95 45 102' fill='none' stroke='%236b7f5e' stroke-width='1'/%3E%3Cpath d='M30 160 Q20 155 15 162' fill='none' stroke='%236b7f5e' stroke-width='1'/%3E%3Cpath d='M30 220 Q40 215 45 222' fill='none' stroke='%236b7f5e' stroke-width='1'/%3E%3C/svg%3E");
    background-size: 60px 300px;
    background-repeat: repeat-y;
    background-attachment: fixed;
}

.chapter-content {
    width: clamp(320px, 60vw, 680px);
    position: relative;
    z-index: 1;
}

/* === Title Cartouche === */
.title-chapter {
    flex-direction: column;
}

.cartouche-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    width: clamp(320px, 70vw, 700px);
}

.cartouche-frame {
    width: 100%;
    max-width: 600px;
    height: auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 1.2s ease-out;
}

.cartouche-frame.visible {
    opacity: 1;
}

.cartouche-border {
    stroke-dasharray: 1800;
    stroke-dashoffset: 1800;
    transition: stroke-dashoffset 2s ease-in-out;
}

.cartouche-frame.visible .cartouche-border {
    stroke-dashoffset: 0;
}

.cartouche-inner {
    stroke-dasharray: 1700;
    stroke-dashoffset: 1700;
    transition: stroke-dashoffset 2.2s ease-in-out 0.3s;
}

.cartouche-frame.visible .cartouche-inner {
    stroke-dashoffset: 0;
}

.cartouche-text {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 4rem 2rem;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.6s ease-out 2s, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 2s;
}

.cartouche-text.visible {
    opacity: 1;
    transform: scale(1);
}

.domain-title {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #2a2220;
    line-height: 1.1;
    margin-bottom: 0.5em;
}

.tagline {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(0.85rem, 1.5vw, 1.1rem);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #6b7f5e;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.5s ease-out 2.6s, transform 0.5s ease-out 2.6s;
}

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

.scroll-invite {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    animation: floatDown 2s ease-in-out infinite;
}

.falling-leaf {
    width: 24px;
    height: 24px;
    opacity: 0.6;
}

@keyframes floatDown {
    0%, 100% { transform: translateX(-50%) translateY(0); opacity: 0.6; }
    50% { transform: translateX(-50%) translateY(10px); opacity: 1; }
}

/* === Bracket Frames === */
.bracket-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.bracket {
    position: absolute;
    width: 30px;
    height: 30px;
}

.bracket-tl { top: -10px; left: -15px; }
.bracket-tr { top: -10px; right: -15px; }
.bracket-bl { bottom: -10px; left: -15px; }
.bracket-br { bottom: -10px; right: -15px; }

.bracket-path {
    stroke-dasharray: 80;
    stroke-dashoffset: 80;
    transition: stroke-dashoffset 0.4s ease-out;
}

.chapter.in-view .bracket-path {
    stroke-dashoffset: 0;
}

/* === Leaf Markers === */
.leaf-marker {
    text-align: center;
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(-15px);
    transition: opacity 0.3s ease-out 0.2s, transform 0.3s ease-out 0.2s;
}

.chapter.in-view .leaf-marker {
    opacity: 1;
    transform: translateY(0);
}

.leaf-marker svg {
    width: 36px;
    height: 36px;
}

/* === Chapter Headings === */
.chapter-heading {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 2rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease-out 0.4s, transform 0.5s ease-out 0.4s;
}

.chapter.in-view .chapter-heading {
    opacity: 1;
    transform: translateY(0);
}

.chapter[data-theme="dark"] .chapter-heading {
    color: #f4efe8;
}

/* === Chapter Body Text === */
.chapter-body {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.85;
    letter-spacing: 0.02em;
    max-width: 60ch;
    margin: 0 auto 1.5rem;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.chapter.in-view .chapter-body {
    opacity: 1;
    transform: translateY(0);
}

.chapter[data-theme="dark"] .chapter-body {
    color: #f4efe8;
}

.chapter-body em {
    font-style: italic;
    color: #6b2d2d;
}

.chapter[data-theme="dark"] .chapter-body em {
    color: #c9a84c;
}

/* === Specimen Cards === */
.specimen-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2rem;
    margin-top: 2.5rem;
}

.specimen-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 160px;
    opacity: 0;
    transform: scale(0.7);
    transition: opacity 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chapter.in-view .specimen-card {
    opacity: 1;
    transform: scale(1);
}

.specimen-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 0.75rem;
    transition: transform 0.2s ease;
}

.specimen-card:hover .specimen-icon {
    transform: scale(1.1);
}

.specimen-label {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #2a2220;
    margin-bottom: 0.25rem;
}

.specimen-caption {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-style: italic;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    color: #6b7f5e;
    line-height: 1.4;
}

/* === Pull Quote === */
.pull-quote {
    margin: 2.5rem auto;
    padding: 1.5rem 2rem;
    text-align: center;
    position: relative;
    max-width: 50ch;
}

.pull-quote-mark {
    font-family: 'Josefin Sans', sans-serif;
    font-size: 4rem;
    color: #b5654a;
    line-height: 0.5;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.pull-quote p {
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    font-size: clamp(1.1rem, 2vw, 1.3rem);
    line-height: 1.6;
    color: #6b2d2d;
    font-style: italic;
}

.pull-quote-attr {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-style: italic;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    color: #6b7f5e;
    display: block;
    margin-top: 0.75rem;
}

/* === Ornamental Dividers === */
.ornamental-divider {
    height: 20vh;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    background-color: #f4efe8;
}

.divider-svg {
    width: 100%;
    max-width: 1200px;
    height: auto;
}

.divider-line {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 1.5s ease-in-out;
}

.ornamental-divider.in-view .divider-line {
    stroke-dashoffset: 0;
}

.ornamental-divider.in-view .divider-line-left {
    stroke-dashoffset: 0;
}

.ornamental-divider.in-view .divider-line-right {
    stroke-dashoffset: 0;
}

/* Gate scrollwork animation */
.gate-scroll {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    transition: stroke-dashoffset 1.5s ease-in-out;
}

.ornamental-divider.in-view .gate-scroll {
    stroke-dashoffset: 0;
}

/* Acanthus scroll animation */
.acanthus-scroll {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1.5s ease-in-out;
}

.ornamental-divider.in-view .acanthus-scroll {
    stroke-dashoffset: 0;
}

/* Rosette spin */
.rosette {
    transform: rotate(0deg);
    transition: transform 1.5s ease-in-out;
}

.ornamental-divider.in-view .rosette {
    transform: rotate(360deg);
}

/* Lattice diamonds */
.lattice-group path {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1.5s ease-in-out;
}

.ornamental-divider.in-view .lattice-group path {
    stroke-dashoffset: 0;
}

/* Hover on ornamental leaves */
.rosette-leaf,
.gate-leaf,
.leaf-medallion {
    transition: fill 0.3s ease, transform 0.2s ease, opacity 0.2s ease;
    cursor: default;
}

.rosette-leaf:hover {
    fill: #4a7c72;
}

.leaf-medallion:hover {
    opacity: 1;
    transform: scale(1.15);
}

/* Divider SVG element hover colors */
.divider-svg .divider-line:hover,
.divider-svg line:hover {
    stroke: #c9a84c;
}

/* === Colophon === */
.colophon {
    min-height: 80vh;
}

.colophon-content {
    text-align: center;
    position: relative;
    padding: 3rem 2rem;
}

.colophon-border {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 500px;
    pointer-events: none;
}

.colophon-frame {
    width: 100%;
    height: auto;
}

.colophon-heading {
    margin-top: 1rem;
}

.colophon-text {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: 0.9rem;
    letter-spacing: 0.08em;
    color: #d4ccc0;
    max-width: 45ch;
    margin: 0 auto 1rem;
    line-height: 1.7;
    opacity: 0;
    transition: opacity 0.5s ease-out;
}

.chapter.in-view .colophon-text {
    opacity: 1;
}

.colophon-year {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 0.3em;
    color: #c9a84c;
    margin-top: 1.5rem;
}

.terminal-rosette {
    margin-top: 2rem;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.5s ease-out 0.3s, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s;
}

.chapter.in-view .terminal-rosette {
    opacity: 1;
    transform: scale(1);
}

.terminal-rosette svg {
    width: 60px;
    height: 60px;
}

/* === Links === */
a {
    color: #4a7c72;
    text-decoration: none;
    position: relative;
}

a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 3px;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='3' viewBox='0 0 20 3'%3E%3Cpath d='M0 1.5 Q5 0 10 1.5 Q15 3 20 1.5' fill='none' stroke='%234a7c72' stroke-width='1'/%3E%3C/svg%3E");
    background-size: 20px 3px;
    background-repeat: repeat-x;
}

a:hover::after {
    transform: scaleX(1);
}

/* === Stagger Delays for Body Paragraphs === */
.chapter.in-view .chapter-body:nth-child(1) { transition-delay: 0.55s; }
.chapter.in-view .chapter-body:nth-child(2) { transition-delay: 0.7s; }
.chapter.in-view .chapter-body:nth-child(3) { transition-delay: 0.85s; }
.chapter.in-view .chapter-body:nth-child(4) { transition-delay: 1.0s; }

/* Stagger for specimen cards */
.chapter.in-view .specimen-card:nth-child(1) { transition-delay: 0.9s; }
.chapter.in-view .specimen-card:nth-child(2) { transition-delay: 1.0s; }
.chapter.in-view .specimen-card:nth-child(3) { transition-delay: 1.1s; }

/* === Responsive === */
@media (max-width: 768px) {
    .corner-flourish {
        width: 60px;
        height: 60px;
    }

    .chapter {
        padding: 3rem 1.5rem;
    }

    .chapter::after {
        width: 30px;
        opacity: 0.05;
    }

    .bracket {
        width: 20px;
        height: 20px;
    }

    .specimen-grid {
        flex-direction: column;
        align-items: center;
    }

    .specimen-card {
        width: 200px;
    }

    .ornamental-divider {
        min-height: 80px;
    }
}

@media (max-width: 480px) {
    .corner-flourish {
        width: 40px;
        height: 40px;
    }

    .cartouche-wrap {
        width: 95vw;
    }

    .chapter-content {
        width: 95vw;
    }
}
