/* ============================================================
   memorial.wiki - Styles
   Cinematic minimalism / sepia-toned memorial architecture
   ============================================================ */

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

:root {
    /* Color Palette */
    --bg-deep: #1A1C20;
    --bg-warm: #2A2520;
    --gold-accent: #C9A84C;
    --gold-dim: #8B7635;
    --parchment: #D4CFC6;
    --stone: #8A7F6E;
    --amber-glow: #E8A840;
    --rose-dust: #9E7B6B;

    /* Fibonacci spacing scale */
    --sp-1: 8px;
    --sp-2: 13px;
    --sp-3: 21px;
    --sp-4: 34px;
    --sp-5: 55px;
    --sp-6: 89px;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    background-color: var(--bg-deep);
}

body {
    font-family: 'Lora', Georgia, serif;
    color: var(--parchment);
    background-color: var(--bg-deep);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Typography --- */
.site-title,
.memorial-name {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-weight: 300;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold-accent);
}

.site-title {
    font-size: clamp(2.5rem, 6vw, 5rem);
    line-height: 1.1;
    opacity: 0;
    animation: fadeInTitle 2s ease-out 2s forwards;
}

.memorial-name {
    font-size: clamp(2rem, 5vw, 4rem);
    line-height: 1.15;
    margin-bottom: var(--sp-2);
}

.memorial-dates {
    font-family: 'Baskervville', 'Baskerville', serif;
    font-size: 0.85rem;
    font-weight: 400;
    letter-spacing: 0.05em;
    color: var(--stone);
    margin-bottom: var(--sp-4);
}

.memorial-text {
    font-family: 'Lora', Georgia, serif;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.85;
    font-weight: 400;
    color: var(--parchment);
    max-width: 580px;
}

.memorial-text p {
    margin-bottom: var(--sp-3);
}

.memorial-text p:last-child {
    margin-bottom: 0;
}

.site-subtitle {
    font-family: 'Lora', Georgia, serif;
    font-size: clamp(1rem, 1.4vw, 1.25rem);
    line-height: 1.8;
    color: var(--parchment);
    opacity: 0;
    animation: fadeInSubtitle 2s ease-out 2.5s forwards;
    max-width: 520px;
    margin: var(--sp-4) auto 0;
    text-align: center;
}

/* --- Eternal Flame --- */
.eternal-flame {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    animation: flameAppear 2s ease-out 1.5s forwards;
    width: 100px;
    height: 160px;
}

.flame-core {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 18px;
    height: 50px;
    background: radial-gradient(ellipse at 50% 90%, #E8A840 0%, #C9A84C 40%, transparent 70%);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    filter: blur(3px);
    mix-blend-mode: screen;
    animation: flickerCore 3s ease-in-out infinite alternate;
}

.flame-glow {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 80px;
    background: radial-gradient(ellipse at 50% 80%, rgba(232, 168, 64, 0.5) 0%, rgba(201, 168, 76, 0.2) 40%, transparent 70%);
    border-radius: 50%;
    filter: blur(12px);
    mix-blend-mode: screen;
    animation: flickerGlow 4s ease-in-out infinite alternate;
}

.flame-ambient {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 300px;
    background: radial-gradient(ellipse at 50% 20%, rgba(232, 168, 64, 0.12) 0%, rgba(201, 168, 76, 0.04) 40%, transparent 70%);
    filter: blur(30px);
    mix-blend-mode: screen;
    pointer-events: none;
}

@keyframes flameAppear {
    from { opacity: 0; }
    to { opacity: 0.8; }
}

@keyframes flickerCore {
    0% { transform: translateX(-50%) scaleY(0.96) scaleX(1); }
    25% { transform: translateX(-50%) scaleY(1.04) scaleX(0.97); }
    50% { transform: translateX(-50%) scaleY(0.98) scaleX(1.02); }
    75% { transform: translateX(-50%) scaleY(1.03) scaleX(0.98); }
    100% { transform: translateX(-50%) scaleY(0.95) scaleX(1.01); }
}

@keyframes flickerGlow {
    0% { transform: translateX(-50%) scaleY(0.97); opacity: 0.8; }
    33% { transform: translateX(-50%) scaleY(1.03); opacity: 0.9; }
    66% { transform: translateX(-50%) scaleY(0.99); opacity: 0.85; }
    100% { transform: translateX(-50%) scaleY(1.02); opacity: 0.95; }
}

/* --- Spine Line --- */
.spine-line {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 100vh;
    background: rgba(201, 168, 76, 0.2);
    z-index: 5;
    pointer-events: none;
}

/* --- Leaf Fall System --- */
.leaf-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    overflow: hidden;
}

.leaf {
    position: absolute;
    width: 20px;
    height: 25px;
    opacity: 0;
    animation-timing-function: cubic-bezier(0.45, 0.05, 0.55, 0.95);
    animation-fill-mode: both;
    animation-iteration-count: infinite;
}

.leaf-1 {
    left: 12%;
    top: -30px;
    width: 18px;
    height: 22px;
    animation: leafFall1 22s 3s infinite;
}

.leaf-2 {
    left: 75%;
    top: -30px;
    width: 16px;
    height: 20px;
    animation: leafFall2 28s 8s infinite;
}

.leaf-3 {
    left: 40%;
    top: -30px;
    width: 22px;
    height: 18px;
    animation: leafFall3 35s 15s infinite;
}

.leaf-4 {
    left: 88%;
    top: -30px;
    width: 14px;
    height: 18px;
    animation: leafFall4 18s 5s infinite;
}

.leaf-5 {
    left: 55%;
    top: -30px;
    width: 20px;
    height: 16px;
    animation: leafFall5 40s 20s infinite;
}

@keyframes leafFall1 {
    0% { transform: translateY(-5vh) rotate(0deg) rotate3d(1, 0.5, 0, 0deg); opacity: 0; }
    5% { opacity: 0.15; }
    50% { transform: translateY(50vh) rotate(180deg) rotate3d(1, 0.5, 0, 45deg) translateX(30px); }
    95% { opacity: 0.15; }
    100% { transform: translateY(105vh) rotate(360deg) rotate3d(1, 0.5, 0, 90deg) translateX(-10px); opacity: 0; }
}

@keyframes leafFall2 {
    0% { transform: translateY(-5vh) rotate(45deg) rotate3d(0, 1, 0.5, 0deg); opacity: 0; }
    5% { opacity: 0.12; }
    50% { transform: translateY(48vh) rotate(190deg) rotate3d(0, 1, 0.5, -40deg) translateX(-40px); }
    95% { opacity: 0.12; }
    100% { transform: translateY(105vh) rotate(330deg) rotate3d(0, 1, 0.5, -80deg) translateX(15px); opacity: 0; }
}

@keyframes leafFall3 {
    0% { transform: translateY(-5vh) rotate(90deg) rotate3d(1, 1, 0, 0deg); opacity: 0; }
    5% { opacity: 0.1; }
    50% { transform: translateY(52vh) rotate(220deg) rotate3d(1, 1, 0, 50deg) translateX(50px); }
    95% { opacity: 0.1; }
    100% { transform: translateY(105vh) rotate(400deg) rotate3d(1, 1, 0, 100deg) translateX(-20px); opacity: 0; }
}

@keyframes leafFall4 {
    0% { transform: translateY(-5vh) rotate(15deg) rotate3d(0.5, 1, 0, 0deg); opacity: 0; }
    5% { opacity: 0.1; }
    50% { transform: translateY(55vh) rotate(160deg) rotate3d(0.5, 1, 0, -35deg) translateX(-25px); }
    95% { opacity: 0.1; }
    100% { transform: translateY(105vh) rotate(310deg) rotate3d(0.5, 1, 0, -70deg) translateX(20px); opacity: 0; }
}

@keyframes leafFall5 {
    0% { transform: translateY(-5vh) rotate(60deg) rotate3d(1, 0, 1, 0deg); opacity: 0; }
    5% { opacity: 0.08; }
    50% { transform: translateY(50vh) rotate(200deg) rotate3d(1, 0, 1, 40deg) translateX(-35px); }
    95% { opacity: 0.08; }
    100% { transform: translateY(105vh) rotate(350deg) rotate3d(1, 0, 1, 80deg) translateX(10px); opacity: 0; }
}

/* --- Lens Flare Accents --- */
.lens-flare {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 3;
    mix-blend-mode: screen;
}

.lens-flare-1 {
    top: 15%;
    left: 20%;
    width: 250px;
    height: 200px;
    background: radial-gradient(ellipse, rgba(232, 168, 64, 0.06) 0%, transparent 70%);
    filter: blur(40px);
}

.lens-flare-2 {
    top: 45%;
    right: 15%;
    width: 300px;
    height: 250px;
    background: radial-gradient(ellipse, rgba(232, 168, 64, 0.05) 0%, transparent 70%);
    filter: blur(50px);
}

.lens-flare-3 {
    bottom: 20%;
    left: 35%;
    width: 200px;
    height: 180px;
    background: radial-gradient(ellipse, rgba(201, 168, 76, 0.07) 0%, transparent 70%);
    filter: blur(35px);
}

/* --- Main Scroll Container --- */
.memorial-scroll {
    width: 100%;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-snap-type: y proximity;
    scroll-behavior: smooth;
}

/* --- Memorial Sections --- */
.memorial-section {
    width: 100%;
    min-height: 100svh;
    display: flex;
    align-items: center;
    justify-content: center;
    scroll-snap-align: start;
    position: relative;
    transition: background-color 0.8s ease;
}

.memorial-section[data-bg="dark"] {
    background-color: var(--bg-deep);
}

.memorial-section[data-bg="warm"] {
    background-color: var(--bg-warm);
}

.section-content {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 48px;
    position: relative;
}

/* --- Threshold / Opening Section --- */
.threshold-section {
    background-color: var(--bg-deep);
}

.threshold-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding-top: 120px;
}

.scroll-hint {
    margin-top: var(--sp-6);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-1);
    opacity: 0;
    animation: fadeInHint 1.5s ease-out 4s forwards;
}

.scroll-hint-text {
    font-family: 'Baskervville', 'Baskerville', serif;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--stone);
    opacity: 0.6;
}

.scroll-hint-arrow {
    animation: bobArrow 2s ease-in-out infinite;
    opacity: 0.4;
}

@keyframes fadeInTitle {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInSubtitle {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 0.85; transform: translateY(0); }
}

@keyframes fadeInHint {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* --- Memorial Entry Layout --- */
.entry-content {
    display: flex;
    align-items: center;
    gap: 48px;
    min-height: 60vh;
}

.entry-left,
.entry-right {
    flex: 1;
    max-width: 580px;
}

/* F-pattern: left-aligned entries */
.memorial-entry[data-side="left"] .entry-content {
    justify-content: flex-start;
}

.memorial-entry[data-side="left"] .entry-left {
    padding-right: 48px;
}

/* F-pattern: right-aligned entries */
.memorial-entry[data-side="right"] .entry-content {
    justify-content: flex-end;
}

.memorial-entry[data-side="right"] .entry-right {
    padding-left: 48px;
}

/* Entry motifs */
.entry-motif {
    flex: 0 0 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.entry-motif svg {
    width: 120px;
    height: 200px;
}

/* Scroll-triggered entry animations */
.memorial-entry .memorial-name,
.memorial-entry .memorial-dates,
.memorial-entry .memorial-text,
.memorial-entry .entry-motif {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.memorial-entry.in-view .memorial-name {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0ms;
}

.memorial-entry.in-view .memorial-dates {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 200ms;
}

.memorial-entry.in-view .memorial-text {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 400ms;
}

.memorial-entry.in-view .entry-motif {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 600ms;
}

/* --- Memorial Dividers --- */
.memorial-divider {
    width: 100%;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(201, 168, 76, 0.08) 50%,
        transparent 100%
    );
}

.olive-branch {
    width: 300px;
    height: 30px;
    opacity: 0;
    transition: opacity 1s ease-out;
}

.memorial-divider.in-view .olive-branch {
    opacity: 1;
}

.branch-line {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 1.5s ease-out;
}

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

.branch-leaf {
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

.memorial-divider.in-view .branch-leaf {
    opacity: 0.35;
    transition-delay: 0.8s;
}

/* --- Closing Section --- */
.closing-section {
    background-color: var(--bg-deep);
}

.closing-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--sp-3);
}

.closing-flame-echo {
    width: 40px;
    height: 60px;
    background: radial-gradient(ellipse at 50% 80%, rgba(232, 168, 64, 0.4) 0%, rgba(201, 168, 76, 0.15) 40%, transparent 70%);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    filter: blur(6px);
    mix-blend-mode: screen;
    animation: flickerCore 3.5s ease-in-out infinite alternate;
    margin-bottom: var(--sp-4);
}

.closing-text {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: clamp(1.8rem, 4vw, 3rem);
    font-weight: 300;
    letter-spacing: 0.08em;
    color: var(--gold-accent);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease-out, transform 1s ease-out;
}

.closing-text-secondary {
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    color: var(--parchment);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease-out 0.3s, transform 1s ease-out 0.3s;
}

.closing-section.in-view .closing-text {
    opacity: 1;
    transform: translateY(0);
}

.closing-section.in-view .closing-text-secondary {
    opacity: 0.7;
    transform: translateY(0);
}

.closing-domain {
    font-family: 'Baskervville', 'Baskerville', serif;
    font-size: 0.85rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--stone);
    margin-top: var(--sp-5);
    opacity: 0;
    transition: opacity 1.2s ease-out 0.6s;
}

.closing-section.in-view .closing-domain {
    opacity: 0.5;
}

/* --- Dissolve Gradient Zones --- */
.memorial-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: linear-gradient(to bottom, var(--bg-deep), transparent);
    pointer-events: none;
    z-index: 1;
    opacity: 0.5;
}

.memorial-section[data-bg="warm"]::before {
    background: linear-gradient(to bottom, var(--bg-warm), transparent);
}

.memorial-section::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: linear-gradient(to top, var(--bg-deep), transparent);
    pointer-events: none;
    z-index: 1;
    opacity: 0.5;
}

.memorial-section[data-bg="warm"]::after {
    background: linear-gradient(to top, var(--bg-warm), transparent);
}

.threshold-section::before {
    display: none;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .section-content {
        padding: 0 24px;
    }

    .entry-content {
        flex-direction: column;
        gap: var(--sp-4);
        text-align: center;
    }

    .memorial-entry[data-side="left"] .entry-left,
    .memorial-entry[data-side="right"] .entry-right {
        padding: 0;
    }

    .memorial-entry[data-side="right"] .entry-content {
        flex-direction: column-reverse;
    }

    .entry-motif {
        display: none;
    }

    .memorial-text {
        max-width: 100%;
    }

    .memorial-name {
        font-size: clamp(1.8rem, 5vw, 3rem);
    }

    .spine-line {
        opacity: 0.1;
    }

    .lens-flare {
        display: none;
    }

    .memorial-divider {
        height: 120px;
    }

    .olive-branch {
        width: 200px;
    }
}

@media (max-width: 480px) {
    .site-title {
        font-size: clamp(2rem, 8vw, 3rem);
    }

    .site-subtitle {
        font-size: 1rem;
    }

    .eternal-flame {
        width: 60px;
        height: 100px;
    }

    .flame-ambient {
        width: 150px;
        height: 150px;
    }
}

/* --- Scrollbar styling --- */
.memorial-scroll::-webkit-scrollbar {
    width: 4px;
}

.memorial-scroll::-webkit-scrollbar-track {
    background: var(--bg-deep);
}

.memorial-scroll::-webkit-scrollbar-thumb {
    background: rgba(201, 168, 76, 0.2);
    border-radius: 2px;
}

.memorial-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(201, 168, 76, 0.35);
}
