/* ============================================
   sarampass.com - Candlelit Isometric Sanctuary
   ============================================ */

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

:root {
    /* Color Palette */
    --obsidian-night: #0D0A07;
    --charred-stone: #1E1710;
    --smoke-alcove: #2D2318;
    --candle-amber: #F2A154;
    --flame-gold: #E8B84D;
    --twilight-indigo: #3A4F8A;
    --mountain-dusk: #5C6FA6;
    --warm-parchment: #F5E6D0;
    --sandstone: #D4C4A8;
    --ember-glow: #D45F2E;
    --burnt-umber: #2A1F14;
    --deep-brown: #2D1B0A;

    /* Spring Physics Easing */
    --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --spring-gentle: cubic-bezier(0.34, 1.2, 0.64, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--obsidian-night);
    color: var(--warm-parchment);
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Opening Overlay --- */
#opening-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--obsidian-night);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.8s ease-out;
    pointer-events: all;
}

#opening-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

#opening-overlay.hidden {
    display: none;
}

#opening-flame-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#opening-flame {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.6s ease-out, transform 0.6s var(--spring);
    animation: flameFlicker1 3.2s ease-in-out infinite, flameFlicker2 2.7s ease-in-out infinite;
}

#opening-flame.visible {
    opacity: 1;
    transform: scale(1);
}

#opening-glow {
    position: absolute;
    width: 40px;
    height: 40px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background:
        radial-gradient(circle at center, rgba(242, 161, 84, 0.4) 0%, transparent 40%),
        radial-gradient(circle at center, rgba(232, 184, 77, 0.15) 0%, transparent 60%),
        radial-gradient(circle at center, rgba(212, 95, 46, 0.08) 0%, transparent 80%);
    transition: width 1.5s var(--spring-gentle), height 1.5s var(--spring-gentle);
    pointer-events: none;
}

#opening-glow.expand {
    width: 200vmax;
    height: 200vmax;
}

/* --- Lantern Navigation --- */
#lantern-nav {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 900;
    opacity: 0;
    transition: opacity 0.6s ease-out;
}

#lantern-nav.visible {
    opacity: 1;
}

#lantern-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: rgba(30, 23, 16, 0.85);
    backdrop-filter: blur(8px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    box-shadow: 0 0 30px rgba(242, 161, 84, 0.2);
    transition: box-shadow 0.4s var(--spring), transform 0.4s var(--spring);
}

#lantern-btn:hover {
    box-shadow: 0 0 50px rgba(242, 161, 84, 0.4);
    transform: scale(1.08);
}

#lantern-btn svg {
    animation: flameFlicker1 3.2s ease-in-out infinite;
}

#lantern-menu {
    position: absolute;
    top: 26px;
    right: 26px;
    width: 0;
    height: 0;
}

#lantern-menu .waypoint {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 110px;
    height: 44px;
    background: var(--smoke-alcove);
    border: 1px solid rgba(242, 161, 84, 0.2);
    clip-path: polygon(10% 0%, 90% 0%, 100% 50%, 90% 100%, 10% 100%, 0% 50%);
    text-decoration: none;
    opacity: 0;
    transform: scale(0.3);
    transition: opacity 0.4s var(--spring), transform 0.4s var(--spring);
    pointer-events: none;
}

#lantern-menu .waypoint span {
    font-family: 'Caveat', cursive;
    font-size: clamp(1rem, 2vw, 1.3rem);
    color: var(--candle-amber);
    white-space: nowrap;
}

#lantern-menu.open .waypoint {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* Waypoint positions - fan arc from 7 o'clock to 11 o'clock */
#lantern-menu .waypoint[data-index="0"] {
    top: -30px;
    right: 60px;
    transition-delay: 0ms;
}
#lantern-menu .waypoint[data-index="1"] {
    top: -80px;
    right: 30px;
    transition-delay: 50ms;
}
#lantern-menu .waypoint[data-index="2"] {
    top: -110px;
    right: -30px;
    transition-delay: 100ms;
}
#lantern-menu .waypoint[data-index="3"] {
    top: -110px;
    right: -100px;
    transition-delay: 150ms;
}
#lantern-menu .waypoint[data-index="4"] {
    top: -80px;
    right: -160px;
    transition-delay: 200ms;
}

#lantern-menu.closed .waypoint {
    opacity: 0;
    transform: scale(0.3);
    pointer-events: none;
}

#lantern-menu.closed .waypoint[data-index="0"] { transition-delay: 200ms; }
#lantern-menu.closed .waypoint[data-index="1"] { transition-delay: 150ms; }
#lantern-menu.closed .waypoint[data-index="2"] { transition-delay: 100ms; }
#lantern-menu.closed .waypoint[data-index="3"] { transition-delay: 50ms; }
#lantern-menu.closed .waypoint[data-index="4"] { transition-delay: 0ms; }

/* --- Display Heading --- */
.display-heading {
    font-family: 'Archivo Black', sans-serif;
    font-weight: 400;
    font-size: clamp(1.8rem, 4.5vw, 3.6rem);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--warm-parchment);
    text-shadow: 0 0 20px rgba(242, 161, 84, 0.3);
    line-height: 1.2;
    margin-bottom: 0.6em;
}

/* --- Accent Text --- */
.accent-text {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(1rem, 2vw, 1.3rem);
    color: var(--candle-amber);
    line-height: 1.5;
}

/* --- Body Text Color --- */
.masonry-cell p:not(.accent-text) {
    color: var(--sandstone);
}

/* --- Masonry Grid --- */
#masonry-grid {
    display: grid;
    grid-template-columns: 32% 36% 32%;
    gap: 0;
    padding: 0;
    max-width: 1400px;
    margin: 0 auto;
}

/* --- Masonry Cell --- */
.masonry-cell {
    position: relative;
    padding: clamp(1.2rem, 3vw, 2.4rem);
    opacity: 0;
    transform: translateY(30px) scale(0.85);
    transition:
        opacity 0.6s var(--spring),
        transform 0.6s var(--spring);
    transition-delay: calc(var(--stagger-index, 0) * 80ms);
    overflow: hidden;
}

.masonry-cell.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Cell spans */
.cell-span-1 { grid-row: span 1; min-height: 250px; }
.cell-span-2 { grid-row: span 2; min-height: 380px; }
.cell-span-3 { grid-row: span 1; min-height: 200px; }

/* --- Isometric Platform --- */
.iso-platform {
    position: absolute;
    inset: 12px;
    clip-path: polygon(50% 5%, 98% 25%, 98% 80%, 50% 100%, 2% 80%, 2% 25%);
    background:
        /* Stone grain texture */
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 2px,
            rgba(245, 230, 208, 0.02) 2px,
            rgba(245, 230, 208, 0.02) 3px
        ),
        /* Subtle cracks */
        linear-gradient(127deg, transparent 40%, rgba(45, 35, 24, 0.3) 40.5%, transparent 41%),
        linear-gradient(237deg, transparent 60%, rgba(45, 35, 24, 0.2) 60.3%, transparent 60.6%),
        /* Base color */
        linear-gradient(180deg, var(--charred-stone) 0%, var(--smoke-alcove) 100%);
    opacity: 0.6;
    z-index: 0;
}

/* --- Cell Content --- */
.cell-content {
    position: relative;
    z-index: 2;
    padding: clamp(0.8rem, 2vw, 1.6rem);
}

.cell-content h2 {
    font-size: clamp(1.2rem, 3vw, 2rem);
}

/* --- Candle Glow Layer (inside masonry cells) --- */
.candle-glow-layer {
    position: absolute;
    bottom: 20px;
    right: 30px;
    z-index: 1;
    width: 20px;
    height: 30px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.candle-glow-layer .candle-glow {
    position: absolute;
    width: 180px;
    height: 180px;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 50%;
    background:
        radial-gradient(circle at center, rgba(242, 161, 84, 0.4) 0%, transparent 40%),
        radial-gradient(circle at center, rgba(232, 184, 77, 0.15) 0%, transparent 60%),
        radial-gradient(circle at center, rgba(212, 95, 46, 0.08) 0%, transparent 80%);
    pointer-events: none;
    transition: transform 0.4s var(--spring), opacity 0.4s var(--spring);
}

.masonry-cell:hover .candle-glow-layer .candle-glow {
    transform: translateX(-50%) scale(1.35);
}

.masonry-cell:hover .candle-glow-layer .flame-svg {
    transform: scale(1.1);
}

.candle-glow-layer .flame-svg {
    position: relative;
    z-index: 2;
    animation: flameFlicker1 3.2s ease-in-out infinite, flameFlicker2 2.7s ease-in-out infinite;
    transition: transform 0.4s var(--spring);
}

/* --- Smoke Wisps --- */
.smoke-wisp {
    position: absolute;
    width: 4px;
    height: 20px;
    border-radius: 50%;
    background: rgba(245, 230, 208, 0.05);
    pointer-events: none;
}

.smoke-wisp.smoke-1 {
    bottom: 100%;
    left: 50%;
    animation: smokeRise1 10s linear infinite;
}

.smoke-wisp.smoke-2 {
    bottom: 100%;
    left: 40%;
    animation: smokeRise2 12s linear infinite;
    animation-delay: -3s;
}

.smoke-wisp.smoke-3 {
    bottom: 100%;
    left: 60%;
    animation: smokeRise3 8s linear infinite;
    animation-delay: -5s;
}

/* --- Corridor Sections --- */
.corridor {
    grid-column: 1 / -1;
    position: relative;
    height: 40vh;
    min-height: 300px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.corridor-layers {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.corridor-layer {
    position: absolute;
    inset: 0;
    will-change: transform;
}

.corridor-distant {
    background: linear-gradient(
        180deg,
        var(--twilight-indigo) 0%,
        var(--mountain-dusk) 40%,
        var(--smoke-alcove) 100%
    );
    opacity: 0.7;
}

.corridor-mid {
    background: linear-gradient(
        0deg,
        var(--smoke-alcove) 0%,
        transparent 50%
    );
    clip-path: polygon(
        0% 60%, 10% 45%, 20% 55%, 35% 35%, 45% 50%,
        55% 30%, 65% 45%, 75% 35%, 85% 50%, 100% 40%,
        100% 100%, 0% 100%
    );
}

.corridor-fore {
    background: linear-gradient(
        0deg,
        var(--charred-stone) 0%,
        transparent 40%
    );
    clip-path: polygon(
        0% 75%, 15% 65%, 30% 72%, 50% 60%,
        70% 68%, 85% 62%, 100% 70%,
        100% 100%, 0% 100%
    );
}

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

.corridor-content .display-heading {
    font-size: clamp(2rem, 5vw, 4rem);
    margin-bottom: 0.3em;
}

.corridor-subtitle {
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
}

/* --- Corridor Candles --- */
.corridor-candle {
    position: absolute;
    bottom: 20%;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.corridor-candle-left {
    left: 8%;
}

.corridor-candle-right {
    right: 8%;
}

.corridor-candle .candle-glow {
    position: absolute;
    width: 250px;
    height: 250px;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 50%;
    background:
        radial-gradient(circle at center, rgba(242, 161, 84, 0.4) 0%, transparent 40%),
        radial-gradient(circle at center, rgba(232, 184, 77, 0.15) 0%, transparent 60%),
        radial-gradient(circle at center, rgba(212, 95, 46, 0.08) 0%, transparent 80%);
    pointer-events: none;
}

.corridor-candle .flame-svg {
    position: relative;
    z-index: 2;
    animation: flameFlicker1 3.2s ease-in-out infinite, flameFlicker2 2.7s ease-in-out infinite;
}

/* --- Flame Flicker Animations --- */
@keyframes flameFlicker1 {
    0%, 100% { transform: scale(1, 1); }
    25% { transform: scale(0.97, 1.04); }
    50% { transform: scale(1.02, 0.97); }
    75% { transform: scale(0.95, 1.08); }
}

@keyframes flameFlicker2 {
    0%, 100% { transform: scale(1, 1) rotate(0deg); }
    33% { transform: scale(0.98, 1.03) rotate(-1deg); }
    66% { transform: scale(1.01, 0.98) rotate(1deg); }
}

/* --- Smoke Rise Animations --- */
@keyframes smokeRise1 {
    0% {
        transform: translateY(0) translateX(0) scale(1);
        opacity: 0.05;
    }
    50% {
        transform: translateY(-60px) translateX(5px) scale(1.5);
        opacity: 0.03;
    }
    100% {
        transform: translateY(-120px) translateX(-3px) scale(2);
        opacity: 0;
    }
}

@keyframes smokeRise2 {
    0% {
        transform: translateY(0) translateX(0) scale(1);
        opacity: 0.04;
    }
    50% {
        transform: translateY(-70px) translateX(-6px) scale(1.8);
        opacity: 0.02;
    }
    100% {
        transform: translateY(-140px) translateX(4px) scale(2.5);
        opacity: 0;
    }
}

@keyframes smokeRise3 {
    0% {
        transform: translateY(0) translateX(0) scale(1);
        opacity: 0.04;
    }
    50% {
        transform: translateY(-50px) translateX(8px) scale(1.3);
        opacity: 0.025;
    }
    100% {
        transform: translateY(-100px) translateX(-2px) scale(1.8);
        opacity: 0;
    }
}

/* --- Site Title Letter Animation --- */
#site-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s var(--spring), transform 0.4s var(--spring);
}

#site-title .letter.visible {
    opacity: 1;
    transform: translateY(0);
    text-shadow: 0 0 20px rgba(242, 161, 84, 0.3), 0 4px 15px rgba(242, 161, 84, 0.15);
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    #masonry-grid {
        grid-template-columns: 50% 50%;
    }
}

@media (max-width: 640px) {
    #masonry-grid {
        grid-template-columns: 100%;
    }

    .cell-span-1,
    .cell-span-2,
    .cell-span-3 {
        grid-row: span 1;
        min-height: 200px;
    }

    .corridor {
        height: 30vh;
        min-height: 220px;
    }

    .corridor-candle-left { left: 3%; }
    .corridor-candle-right { right: 3%; }

    #lantern-nav {
        top: 16px;
        right: 16px;
    }

    #lantern-menu .waypoint {
        width: 90px;
        height: 38px;
    }

    #lantern-menu .waypoint[data-index="0"] {
        top: -26px;
        right: 50px;
    }
    #lantern-menu .waypoint[data-index="1"] {
        top: -68px;
        right: 24px;
    }
    #lantern-menu .waypoint[data-index="2"] {
        top: -94px;
        right: -24px;
    }
    #lantern-menu .waypoint[data-index="3"] {
        top: -94px;
        right: -82px;
    }
    #lantern-menu .waypoint[data-index="4"] {
        top: -68px;
        right: -130px;
    }
}

/* --- Ambient Background Glow (behind everything) --- */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse 60% 40% at 20% 50%, rgba(242, 161, 84, 0.03) 0%, transparent 100%),
        radial-gradient(ellipse 50% 50% at 80% 30%, rgba(58, 79, 138, 0.04) 0%, transparent 100%);
    pointer-events: none;
}

/* --- Selection Colors --- */
::selection {
    background: rgba(242, 161, 84, 0.3);
    color: var(--warm-parchment);
}

/* --- Scrollbar (Webkit) --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--obsidian-night);
}

::-webkit-scrollbar-thumb {
    background: var(--smoke-alcove);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--candle-amber);
}
