/* Memorial Page — Solemn, reverent design */

@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,600;1,400&family=Inter:wght@300;400;500;600&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Lora', 'Georgia', serif;
    background-color: #0a0a0a;
    color: #d4c5a9;
    line-height: 1.8;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Background ambiance ── */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at 50% 20%, rgba(40, 35, 25, 0.6) 0%, rgba(10, 10, 10, 0.95) 70%);
    pointer-events: none;
    z-index: 0;
}

/* ── Container ── */
.memorial-container {
    position: relative;
    z-index: 1;
    max-width: 700px;
    margin: 0 auto;
    padding: 60px 30px 80px;
    text-align: center;
}

/* ── Candle decoration ── */
.candle-border {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 80px;
    z-index: 1;
    opacity: 0.3;
}

.candle-border.left { left: 20px; }
.candle-border.right { right: 20px; }

.candle-icon {
    font-size: 28px;
    animation: candleFlicker 3s infinite alternate;
}

.candle-icon:nth-child(2) { animation-delay: 0.5s; }
.candle-icon:nth-child(3) { animation-delay: 1s; }
.candle-icon:nth-child(4) { animation-delay: 1.5s; }

@keyframes candleFlicker {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* ── Portrait frame ── */
.portrait-frame {
    width: 220px;
    height: 280px;
    margin: 0 auto 30px;
    border: 3px solid #8a7a5a;
    padding: 8px;
    background: linear-gradient(135deg, #1a1a16, #2a2520);
    box-shadow:
        0 0 30px rgba(138, 122, 90, 0.15),
        inset 0 0 20px rgba(0, 0, 0, 0.5);
    position: relative;
}

.portrait-frame::before {
    content: '';
    position: absolute;
    inset: 3px;
    border: 1px solid rgba(138, 122, 90, 0.3);
}

.portrait-inner {
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #2a2520 0%, #1a1816 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #6a6050;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    overflow: hidden;
}

.portrait-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.portrait-placeholder-text {
    opacity: 0.6;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-size: 12px;
}

.portrait-placeholder-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}

/* ── Black ribbon ── */
.ribbon {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 40px;
    height: 40px;
    overflow: hidden;
}

.ribbon::before {
    content: '';
    position: absolute;
    top: 8px;
    right: -12px;
    width: 50px;
    height: 14px;
    background: #111;
    transform: rotate(45deg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* ── Name and dates ── */
.deceased-name {
    font-size: 32px;
    font-weight: 600;
    color: #e8dcc8;
    margin-bottom: 8px;
    letter-spacing: 3px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.deceased-dates {
    font-size: 16px;
    color: #8a7a5a;
    margin-bottom: 40px;
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    letter-spacing: 1px;
}

/* ── Divider ── */
.divider {
    width: 120px;
    height: 1px;
    background: linear-gradient(90deg, transparent, #8a7a5a, transparent);
    margin: 30px auto;
}

/* ── Obituary section ── */
.obituary-section {
    margin: 40px 0;
    text-align: left;
}

.section-title {
    font-size: 18px;
    color: #c9a96e;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 20px;
    text-align: center;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
}

.obituary-text {
    font-size: 16px;
    line-height: 2;
    color: #b8a88a;
    text-indent: 2em;
}

.obituary-text p {
    margin-bottom: 16px;
}

/* ── Eulogy section ── */
.eulogy-section {
    margin: 40px 0;
    text-align: left;
    padding: 30px;
    background: rgba(30, 28, 22, 0.6);
    border-left: 3px solid #8a7a5a;
    border-radius: 0 8px 8px 0;
}

.eulogy-text {
    font-size: 16px;
    line-height: 2;
    color: #b8a88a;
    font-style: italic;
}

.eulogy-text p {
    margin-bottom: 16px;
}

.eulogy-signature {
    text-align: right;
    color: #8a7a5a;
    font-style: normal;
    font-size: 14px;
    margin-top: 20px;
    font-family: 'Inter', sans-serif;
}

/* ── Flower offering ── */
.flower-section {
    margin: 50px 0 30px;
    text-align: center;
}

.flower-count {
    font-size: 42px;
    font-weight: 600;
    color: #e8dcc8;
    margin-bottom: 5px;
    font-family: 'Inter', sans-serif;
    transition: transform 0.3s cubic-bezier(0.17, 0.89, 0.32, 1.49);
}

.flower-count.bump {
    transform: scale(1.2);
}

.flower-label {
    font-size: 14px;
    color: #8a7a5a;
    margin-bottom: 20px;
    font-family: 'Inter', sans-serif;
    letter-spacing: 1px;
}

.flower-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 16px 40px;
    background: linear-gradient(135deg, #3a3020, #2a2418);
    border: 1px solid #8a7a5a;
    color: #e8dcc8;
    font-size: 17px;
    font-family: 'Lora', serif;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s ease;
    letter-spacing: 1px;
}

.flower-btn:hover {
    background: linear-gradient(135deg, #4a4030, #3a3428);
    border-color: #c9a96e;
    box-shadow: 0 0 20px rgba(201, 169, 110, 0.15);
    transform: translateY(-2px);
}

.flower-btn:active {
    transform: translateY(0) scale(0.97);
}

.flower-btn .flower-icon {
    font-size: 22px;
    transition: transform 0.3s;
}

.flower-btn:hover .flower-icon {
    transform: scale(1.2);
}

/* ── Float animation for offered flowers ── */
.floating-flower {
    position: fixed;
    font-size: 24px;
    pointer-events: none;
    z-index: 100;
    animation: floatUp 2.5s ease-out forwards;
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(-300px) scale(0.3) rotate(45deg);
    }
}

/* ── Music Notes Puzzle ── */
.notes-section {
    margin: 50px 0;
    position: relative;
}

.notes-hint {
    font-size: 13px;
    color: #5a5040;
    font-family: 'Inter', sans-serif;
    margin-bottom: 25px;
    letter-spacing: 0.5px;
    font-style: italic;
}

.notes-container {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
}

.music-note {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(30, 28, 22, 0.8);
    border: 2px solid #3a3428;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.17, 0.89, 0.32, 1.49);
    position: relative;
    user-select: none;
    color: #6a6050;
}

.music-note:hover {
    border-color: #8a7a5a;
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(138, 122, 90, 0.2);
}

.music-note.lit {
    background: radial-gradient(circle, #c9a96e 0%, #8a7a5a 100%);
    border-color: #e8d8b0;
    color: #1a1816;
    box-shadow: 0 0 25px rgba(201, 169, 110, 0.4);
    transform: scale(1.1);
}

.music-note.wrong {
    animation: noteShake 0.5s ease;
    border-color: #8a3030;
}

@keyframes noteShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

.music-note .note-label {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    position: absolute;
    bottom: -20px;
    color: #5a5040;
    white-space: nowrap;
}

/* ── Audio control ── */
.audio-control {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 50;
    background: rgba(30, 28, 22, 0.8);
    border: 1px solid #3a3428;
    color: #8a7a5a;
    padding: 10px 16px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.audio-control:hover {
    border-color: #8a7a5a;
    color: #c9a96e;
}

/* ── Transition overlays ── */
.transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
}

.transition-overlay.active {
    display: flex;
}

.transition-overlay.black-screen {
    background: #000;
    animation: fadeInOverlay 0.5s ease;
}

.transition-overlay.blue-screen {
    background: #0000aa;
    animation: fadeInOverlay 0.3s ease;
    flex-direction: column;
    font-family: 'Courier New', monospace;
    color: #fff;
    padding: 40px;
    text-align: left;
}

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

.bsod-text {
    font-size: 16px;
    line-height: 1.6;
    max-width: 600px;
}

.bsod-title {
    font-size: 20px;
    background: #aaa;
    color: #0000aa;
    padding: 2px 8px;
    display: inline-block;
    margin-bottom: 20px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .memorial-container {
        padding: 40px 20px 60px;
    }

    .candle-border {
        display: none;
    }

    .portrait-frame {
        width: 180px;
        height: 230px;
    }

    .deceased-name {
        font-size: 26px;
    }

    .notes-container {
        gap: 16px;
    }

    .music-note {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .eulogy-section {
        padding: 20px;
    }
}

/* ── Bilingual ── */
.cn {
    display: none;
    color: #7a6a50;
    font-size: 0.88em;
    line-height: 1.8;
    margin-top: -5px;
    margin-bottom: 10px;
    font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
}

body.show-cn .cn {
    display: block;
}
