/* =============================================
   dilemma.dev — Light-Academia Candlelit Parchment
   Colors: #F5EFE0, #FAF7F0, #3D2B1F, #8B7355,
           #C4A35A, #A8872E, #5E7B52, #B8706A, #593E1D, #F0E8D0
   Fonts: Baloo 2, Nunito, Libre Baskerville
   ============================================= */

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

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

body {
    background-color: #F5EFE0;
    color: #3D2B1F;
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 17px;
    line-height: 1.65;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Reading Progress Bar --- */
#reading-progress {
    position: fixed;
    top: 0;
    left: 16px;
    width: 3px;
    height: 100vh;
    z-index: 1000;
    pointer-events: none;
}

#progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background-color: #C4A35A;
    border-radius: 0 0 2px 2px;
    transition: height 0.15s ease-out;
}

#progress-candle {
    position: absolute;
    left: -6.5px;
    top: 0;
    transform: translateY(-100%);
    transition: top 0.15s ease-out;
}

/* --- Candle Flame Animation --- */
.candle-flame {
    transform-origin: center bottom;
    animation: candleFlicker 3s ease-in-out infinite;
    will-change: transform;
}

.candle-flame-inner {
    transform-origin: center bottom;
    animation: candleFlickerInner 3s ease-in-out infinite;
    will-change: transform;
}

@keyframes candleFlicker {
    0%, 100% { transform: scaleX(1) translateX(0); }
    25% { transform: scaleX(0.92) translateX(-1px); }
    50% { transform: scaleX(1.08) translateX(0.5px); }
    75% { transform: scaleX(0.96) translateX(-0.5px); }
}

@keyframes candleFlickerInner {
    0%, 100% { transform: scaleX(1) translateX(0); }
    30% { transform: scaleX(1.06) translateX(0.5px); }
    60% { transform: scaleX(0.94) translateX(-0.5px); }
    80% { transform: scaleX(1.03) translateX(0.3px); }
}

.candle-flame.scrolling,
.scrolling .candle-flame {
    animation-duration: 1.8s;
}

.candle-flame-inner.scrolling,
.scrolling .candle-flame-inner {
    animation-duration: 1.8s;
}

/* --- Hero / Title Page --- */
#hero {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: #F5EFE0;
}

#hero-roots {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 40px 20px;
    max-width: 700px;
}

#hero-content h1 {
    font-family: 'Baloo 2', 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 64px;
    color: #3D2B1F;
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 16px;
}

#hero-subtitle {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-style: italic;
    font-size: 20px;
    color: #8B7355;
    line-height: 1.5;
    min-height: 30px;
    margin-bottom: 28px;
}

#hero-divider {
    position: relative;
    width: 60%;
    margin: 0 auto 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#hero-divider .vine-line {
    width: 100%;
    height: 20px;
}

#hero-divider .vine-path {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    animation: vineDrawHero 2s ease-out 0.5s forwards;
}

@keyframes vineDrawHero {
    to { stroke-dashoffset: 0; }
}

#hero-divider .divider-candle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    animation: candleFadeIn 0.6s ease-out 1.8s forwards;
}

@keyframes candleFadeIn {
    to { opacity: 1; }
}

/* --- Scroll Chevron --- */
#scroll-chevron {
    animation: chevronBob 2s ease-in-out infinite;
    opacity: 0.7;
    cursor: pointer;
}

@keyframes chevronBob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(4px); }
}

/* --- Masonry Container --- */
#masonry-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 60px 24px 100px;
    display: grid;
    grid-template-columns: 5fr 4fr 5fr;
    grid-auto-rows: 10px;
    gap: 0 24px;
    position: relative;
}

/* --- Full-Width Interstitial Dividers --- */
.interstitial-divider.full-width {
    grid-column: 1 / -1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
    margin: 20px 0;
}

.vine-divider {
    width: 100%;
    height: 40px;
}

.vine-draw {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
}

.vine-draw.animate {
    animation: vineDraw 1.2s ease-out forwards;
}

@keyframes vineDraw {
    to { stroke-dashoffset: 0; }
}

.divider-candle-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
}

.divider-candle-icon.animate {
    animation: candleFadeIn 0.5s ease-out forwards;
}

/* --- Masonry Cards (common styles) --- */
.masonry-card {
    background: linear-gradient(to bottom, #FAF7F0, #F5F0E5);
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(89, 62, 29, 0.08), 0 1px 3px rgba(89, 62, 29, 0.12);
    padding: 28px 24px;
    margin-bottom: 24px;
    position: relative;
    overflow: visible;
    opacity: 0;
    transform: translateY(30px);
    clip-path: polygon(
        0% 2px, 3% 0px, 7% 2px, 12% 1px, 18% 2px,
        24% 0px, 30% 1px, 36% 2px, 42% 0px, 48% 1px,
        54% 2px, 60% 0px, 66% 1px, 72% 2px, 78% 0px,
        84% 1px, 90% 2px, 95% 0px, 100% 1px,
        100% 100%, 0% 100%
    );
    --glow-x: 50%;
    --glow-y: 50%;
}

.masonry-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
        120px circle at var(--glow-x) var(--glow-y),
        rgba(196, 163, 90, 0.08),
        transparent
    );
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    border-radius: 8px;
    z-index: 1;
}

.masonry-card:hover::before {
    opacity: 1;
}

.masonry-card.animate-in {
    animation: bounceEnter 600ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

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

/* --- Card Deckled Edge (decorative top border) --- */
.card-deckle-edge {
    position: absolute;
    top: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(
        90deg,
        #C4A35A 0%, transparent 5%,
        #C4A35A 8%, transparent 12%,
        #C4A35A 15%, transparent 20%,
        #C4A35A 25%, transparent 30%,
        #C4A35A 35%, transparent 40%,
        #C4A35A 45%, transparent 50%,
        #C4A35A 55%, transparent 60%,
        #C4A35A 65%, transparent 70%,
        #C4A35A 75%, transparent 80%,
        #C4A35A 85%, transparent 90%,
        #C4A35A 95%, transparent 100%
    );
    border-radius: 8px 8px 0 0;
    opacity: 0.6;
}

/* --- Dilemma Cards --- */
.dilemma-card {
    padding-top: 12px;
}

.dilemma-card .card-botanical-header {
    width: 100%;
    max-width: 300px;
    height: auto;
    display: block;
    margin: 0 auto 16px;
}

.dilemma-card .card-title {
    font-family: 'Nunito', 'Baloo 2', sans-serif;
    font-weight: 600;
    font-size: 24px;
    color: #3D2B1F;
    line-height: 1.25;
    margin-bottom: 16px;
    text-align: center;
}

.dilemma-columns {
    display: flex;
    gap: 0;
    align-items: stretch;
}

.dilemma-side {
    flex: 1;
    padding: 0 12px;
}

.dilemma-side p {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 16px;
    line-height: 1.65;
    color: #3D2B1F;
    max-width: 640px;
}

.dilemma-divider {
    width: 1px;
    background: repeating-linear-gradient(
        to bottom,
        #C4A35A 0px, #C4A35A 6px,
        transparent 6px, transparent 12px
    );
    opacity: 0.3;
    flex-shrink: 0;
    min-height: 60px;
}

/* --- Reflection Cards --- */
.reflection-card {
    position: relative;
    background: linear-gradient(to bottom, rgba(196, 163, 90, 0.03), transparent), linear-gradient(to bottom, #FAF7F0, #F5F0E5);
    text-align: center;
    padding: 36px 28px;
}

.reflection-card .reflection-candle {
    position: absolute;
    top: 12px;
    right: 16px;
}

.pullquote {
    font-family: 'Baloo 2', 'Nunito', sans-serif;
    font-weight: 500;
    font-size: 28px;
    color: #6B4E2E;
    line-height: 1.5;
    text-align: center;
    border-left: 3px solid #C4A35A;
    padding-left: 20px;
    margin: 8px auto;
    max-width: 500px;
    text-align: left;
    font-style: normal;
}

/* --- Botanical Plates --- */
.botanical-plate {
    text-align: center;
    padding: 20px 16px;
}

.botanical-illustration {
    width: 100%;
    max-width: 240px;
    height: auto;
    display: block;
    margin: 0 auto 12px;
}

.botanical-caption {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-style: italic;
    font-size: 13px;
    color: #8B7355;
    line-height: 1.5;
    max-width: 280px;
    margin: 0 auto;
}

/* --- Annotation Cards --- */
.annotation-card {
    background: linear-gradient(to bottom, #F0E8D0, #EDE5CC);
    transform: translateY(30px) rotate(-1.5deg);
    padding: 20px 18px;
}

.annotation-card.animate-in {
    animation: bounceEnterRotated 600ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes bounceEnterRotated {
    0% {
        opacity: 0;
        transform: translateY(30px) rotate(-1.5deg);
    }
    100% {
        opacity: 1;
        transform: translateY(0) rotate(-1.5deg);
    }
}

.annotation-card p {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: 14px;
    color: #3D2B1F;
    line-height: 1.6;
}

.annotation-card em {
    color: #593E1D;
}

/* --- Ink Splatters --- */
.ink-splatters {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.ink-dot {
    position: absolute;
    background-color: #3D2B1F;
    border-radius: 50%;
}

/* --- Link Styles --- */
a {
    color: #593E1D;
    text-decoration: none;
    position: relative;
    display: inline-block;
}

a::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 1.5px;
    background-color: #C4A35A;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 300ms ease-out;
}

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

a:hover {
    color: #A8872E;
}

/* --- Interactive Glow --- */
.masonry-card {
    transition: box-shadow 0.3s ease;
}

.masonry-card:hover {
    box-shadow: 0 4px 20px rgba(89, 62, 29, 0.12), 0 2px 6px rgba(89, 62, 29, 0.15), 0 0 30px rgba(196, 163, 90, 0.06);
}

/* --- Corner Ornaments (pressed flowers) --- */
.dilemma-card:nth-child(3n)::after {
    content: '';
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg stroke='%235E7B52' stroke-width='0.5' fill='none' opacity='0.4'%3E%3Cpath d='M20 35 Q18 28 15 22 Q12 18 10 15'/%3E%3Cpath d='M15 22 Q12 20 8 21 Q12 18 15 22Z' fill='%235E7B52' opacity='0.15'/%3E%3Cpath d='M15 22 Q17 19 20 18 Q17 21 15 22Z' fill='%235E7B52' opacity='0.12'/%3E%3Cpath d='M10 15 Q8 12 7 8' stroke-width='0.4'/%3E%3C/g%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    transform: rotate(20deg);
    opacity: 0.5;
    pointer-events: none;
    z-index: 0;
}

/* --- Responsive Styles --- */
@media (max-width: 1024px) {
    #masonry-container {
        grid-template-columns: 1fr 1fr;
        max-width: 800px;
    }

    #hero-content h1 {
        font-size: 52px;
    }

    .pullquote {
        font-size: 24px;
    }
}

@media (max-width: 640px) {
    #masonry-container {
        grid-template-columns: 1fr;
        max-width: 520px;
        padding: 40px 16px 80px;
    }

    #hero-content h1 {
        font-size: 40px;
    }

    #hero-subtitle {
        font-size: 17px;
    }

    .pullquote {
        font-size: 22px;
    }

    .dilemma-columns {
        flex-direction: column;
        gap: 16px;
    }

    .dilemma-divider {
        width: 60%;
        height: 1px;
        min-height: unset;
        margin: 0 auto;
        background: repeating-linear-gradient(
            to right,
            #C4A35A 0px, #C4A35A 6px,
            transparent 6px, transparent 12px
        );
    }

    .dilemma-side {
        padding: 0;
    }

    #reading-progress {
        left: 8px;
    }

    .masonry-card {
        padding: 22px 18px;
    }

    .card-title {
        font-size: 20px;
    }
}

/* --- Utility --- */
.masonry-card.entered {
    opacity: 1;
    transform: translateY(0);
}

.annotation-card.entered {
    opacity: 1;
    transform: translateY(0) rotate(-1.5deg);
}

/* --- Selection Color --- */
::selection {
    background-color: rgba(196, 163, 90, 0.3);
    color: #3D2B1F;
}

::-moz-selection {
    background-color: rgba(196, 163, 90, 0.3);
    color: #3D2B1F;
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #F5EFE0;
}

::-webkit-scrollbar-thumb {
    background: #C4A35A;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #A8872E;
}
