/* 
 * Digital Shrine Design System
 * Theme: Ethereal Night
 */

:root {
    /* Palette */
    --bg-color: #0d0d11;
    --text-primary: #e6e6e6;
    --text-secondary: #8f8f9b;
    --accent-gold: #cfaa6e;
    --accent-gold-dim: #7a6340;

    /* Candle */
    --candle-wax: #e8e8e8;
    --candle-flame-core: #fff;
    --candle-flame-mid: #ffd700;
    --candle-flame-outer: #ff8c00;

    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 4px 24px -1px rgba(0, 0, 0, 0.25);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Noto Serif SC', serif;
    height: 100vh;
    overflow: hidden;
    /* Canvas handles background */
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* Background Canvas */
#particleCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.6;
}

/* Main Container */
.shrine-container {
    width: 100%;
    max-width: 550px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 2rem;
    padding-bottom: 6rem;
    /* Ensure content doesn't overlap footer */
    position: relative;
    z-index: 10;
    overflow-y: auto;
    scrollbar-width: none;
}

.shrine-container::-webkit-scrollbar {
    display: none;
}

/* Header */
.memorial-header {
    margin-bottom: 3rem;
    opacity: 0;
    animation: fadeSlideUp 1.5s ease-out forwards 0.5s;
}

.subtitle {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: 0.9rem;
    color: var(--accent-gold);
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}

.title {
    font-family: 'Noto Serif SC', serif;
    font-weight: 300;
    font-size: 2.5rem;
    letter-spacing: 0.2rem;
    margin-bottom: 0.8rem;
    background: linear-gradient(to bottom, #fff, #bbb);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.1);
}

.life-span {
    font-family: 'Cinzel', serif;
    color: var(--text-secondary);
    font-size: 0.85rem;
    letter-spacing: 0.15rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: inline-block;
    padding: 0.4rem 1.5rem;
}

/* Candle Section */
.candle-section {
    position: relative;
    height: 160px;
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 3rem;
    opacity: 0;
    animation: fadeSlideUp 1.5s ease-out forwards 1s;
}

.candle-wrapper {
    position: relative;
    width: 30px;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.candle-wax {
    width: 30px;
    height: 80px;
    background: linear-gradient(to right, #e0e0e0, #fff, #d0d0d0);
    border-radius: 4px;
    box-shadow: inset 0 -20px 20px -10px rgba(0, 0, 0, 0.1);
}

.wick {
    width: 2px;
    height: 12px;
    background: #2a2a2a;
    position: absolute;
    bottom: 80px;
    z-index: 2;
}

/* 1. The Energy Container (Size & Brightness) */
.flame-energy-container {
    position: absolute;
    bottom: 92px;
    /* Anchor point near wick */
    width: 16px;
    height: 30px;
    z-index: 3;
    transform-origin: 50% 90%;
    /* Grow from bottom center */

    /* Default state for transition */
    filter: brightness(1);
    transform: scale(1);

    /* Smooth Physics Transition */
    transition: transform 3s ease-in-out, filter 3s ease-in-out;
}

/* 2. The Flame (Shape & Flicker) */
.flame {
    width: 100%;
    height: 100%;
    background: rgba(255, 215, 0, 0.9);
    border-radius: 50% 50% 20% 20%;
    position: absolute;
    bottom: 0;
    left: 0;

    /* Flicker is independent of size */
    animation: flicker 3s infinite ease-in-out alternate;

    box-shadow:
        0 0 10px 2px rgba(255, 215, 0, 0.6),
        0 0 40px 10px rgba(255, 140, 0, 0.3);
    filter: blur(0.5px);
}

.glow-halo {
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, rgba(255, 160, 50, 0.15) 0%, rgba(255, 100, 0, 0) 60%);
    position: absolute;
    bottom: 40px;
    border-radius: 50%;
    pointer-events: none;

    /* Use Transition instead of Animation */
    transform: scale(1);
    opacity: 0.5;
    /* Removed background from transition as it causes snapping */
    transition: transform 3s ease-in-out, opacity 3s ease-in-out;
}

/* --- High Energy State (Surging) --- */
/* We toggle this class on the PARENT wrapper or specific elements */
.surging .flame-energy-container {
    transform: scale(1.4);
    /* Grow significantly */
    filter: brightness(1.3);
}

.surging .glow-halo {
    transform: scale(2.0);
    /* Expand wide */
    opacity: 0.8;
    /* No background change to avoid gradient snapping */
}

/* Keep the flicker loop separate */
@keyframes flicker {
    0% {
        transform: scale(1) rotate(-1deg);
        opacity: 0.9;
    }

    20% {
        transform: scale(1.05) rotate(1deg);
        opacity: 1;
    }

    40% {
        transform: scale(0.95) rotate(-0.5deg);
        opacity: 0.85;
    }

    60% {
        transform: scale(1.02) rotate(2deg);
        opacity: 0.95;
    }

    80% {
        transform: scale(1.1) rotate(-2deg);
        opacity: 1;
    }

    100% {
        transform: scale(1) rotate(0deg);
        opacity: 0.9;
    }
}

/* Remove old flareUp and haloPulse keyframes as we use transitions now */

/* Timer Section */
.timer-section {
    margin-bottom: 3.5rem;
    opacity: 0;
    animation: fadeSlideUp 1.5s ease-out forwards 1.2s;
}

.timer-label {
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
}

.timer-display {
    font-size: 3rem;
    font-family: 'Playfair Display', serif;
    color: var(--text-primary);
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.5rem;
}

.count-label {
    font-size: 1rem;
    font-family: 'Noto Serif SC', serif;
    color: var(--accent-gold);
    font-style: italic;
}

.timer-quote {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

/* Language Toggle */
.lang-toggle {
    position: fixed;
    top: max(20px, env(safe-area-inset-top) + 10px);
    right: max(20px, env(safe-area-inset-right) + 10px);
    z-index: 100;
    color: var(--text-secondary);
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.2);
    /* Subtle background for legibility */
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 6px 14px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    transition: all 0.3s ease;
}

.lang-toggle:hover {
    color: var(--accent-gold);
    border-color: var(--accent-gold);
}

/* Altar / Interaction */
.altar-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    animation: fadeSlideUp 1.5s ease-out forwards 1.4s;
}

.offering-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 12px 32px;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Cinzel', serif;
    letter-spacing: 0.1em;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.4s ease;
    backdrop-filter: blur(10px);
}

.offering-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-gold);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(207, 170, 110, 0.15);
}

.offering-btn:active {
    transform: scale(0.98);
}

.offering-btn .icon {
    color: var(--accent-gold);
    font-size: 1.2rem;
}

/* Interaction Mode: Soulful Glow */
.flame.flaring {
    animation: flareUp 2.5s ease-in-out forwards;
}

.glow-halo.flaring {
    animation: haloPulse 2.5s ease-in-out forwards;
}

@keyframes flareUp {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }

    50% {
        transform: scale(1.1);
        filter: brightness(1.3);
    }

    /* Subtle growth */
    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}

@keyframes haloPulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    50% {
        transform: scale(2.0);
        opacity: 0.8;
        background: radial-gradient(circle, rgba(255, 220, 150, 0.25) 0%, rgba(255, 100, 0, 0) 70%);
    }

    /* Expanding warmth */
    100% {
        transform: scale(1);
        opacity: 0.5;
    }
}

/* Footer */
.footer {
    position: absolute;
    bottom: 1rem;
    font-size: 0.7rem;
    color: #333;
    letter-spacing: 0.1rem;
    opacity: 0.6;
}

/* Generic Animations */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 480px) {
    .title {
        font-size: 2rem;
    }

    .timer-display {
        font-size: 2.5rem;
    }

    .shrine-container {
        padding: 1.5rem;
        padding-bottom: 6rem;
    }

    .lang-toggle {
        font-size: 0.75rem;
        padding: 4px 12px;
        background: rgba(0, 0, 0, 0.3);
        /* Slightly darker on mobile */
    }
}