/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   The Offering — Warm palette
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
:root {
    --bg: #FFF8F0;
    --bg-warm: #F5EDE3;
    --bg-surface: #FAF3EB;
    --text-primary: #2C2420;
    --text-secondary: #6B5D52;
    --text-muted: #9E8E82;
    --accent: #B8864E;
    --accent-hover: #A07240;
    --accent-light: rgba(184, 134, 78, 0.12);
    --wood: #8B6F47;
    --wood-dark: #5C4A32;
    --wood-light: #A68B64;
    --border: rgba(44, 36, 32, 0.1);
    --candle-glow: rgba(255, 214, 153, 0.35);
    --font-serif: 'Libre Baskerville', Georgia, serif;
    --font-sans: 'Inter', -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font-sans); background: var(--bg); color: var(--text-primary); min-height: 100vh; }

/* ── Stage transitions ── */
.stage {
    opacity: 0;
    transition: opacity 0.6s ease;
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.stage.active { opacity: 1; }
.stage-inner {
    max-width: 580px;
    width: 100%;
    padding: 80px 2rem 4rem;
    margin: 0 auto;
    text-align: center;
}

/* ── Typography ── */
.offering-badge {
    display: inline-block;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 5px 14px;
    border-radius: 100px;
    margin-bottom: 1.5rem;
}
.offering-title {
    font-family: var(--font-serif);
    font-size: clamp(1.8rem, 4vw, 2.4rem);
    font-weight: 400;
    line-height: 1.3;
    margin-bottom: 1rem;
    color: var(--text-primary);
}
.offering-desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.75;
    margin-bottom: 2rem;
    max-width: 460px;
    margin-left: auto;
    margin-right: auto;
}
.offering-btn {
    display: inline-block;
    padding: 14px 36px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.offering-btn:hover { background: var(--accent-hover); }
.offering-btn:active { transform: scale(0.98); }
.offering-btn-secondary {
    display: inline-block;
    padding: 10px 24px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
    margin-left: 0.5rem;
}
.offering-btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

/* ── Stage 2: Past Self ── */
.portrait-upload-area {
    width: 180px;
    height: 230px;
    margin: 0 auto 1.5rem;
    border: 2px dashed var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    cursor: pointer;
    transition: border-color 0.3s, background 0.3s;
    background: var(--bg-surface);
    position: relative;
    overflow: hidden;
}
.portrait-upload-area:hover { border-color: var(--accent); background: var(--accent-light); }
.portrait-upload-area.has-photo { border-style: solid; border-color: var(--wood); cursor: default; }
.portrait-upload-area img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.portrait-silhouette {
    font-size: 4rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    line-height: 1;
}
.portrait-upload-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    max-width: 120px;
    line-height: 1.4;
}
.past-self-input {
    width: 100%;
    max-width: 320px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
    text-align: center;
    margin: 0 auto 1rem;
    display: block;
    transition: border-color 0.2s;
}
.past-self-input:focus { border-color: var(--accent); }
.past-self-context {
    width: 100%;
    max-width: 420px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    outline: none;
    resize: vertical;
    min-height: 80px;
    margin: 0 auto 1.5rem;
    display: block;
    line-height: 1.6;
    transition: border-color 0.2s;
}
.past-self-context:focus { border-color: var(--accent); }

/* ── Stage 3: 제사상 ── */
.table-stage-inner {
    max-width: 680px;
    width: 100%;
    padding: 80px 2rem 4rem;
    margin: 0 auto;
}
.table-stage-inner .offering-title,
.table-stage-inner .offering-desc { text-align: center; }

/* 영정 frame */
.yeongjeong-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
    position: relative;
}
.yeongjeong-frame {
    width: 120px;
    height: 150px;
    border: 6px solid var(--wood-dark);
    border-radius: 4px;
    background: var(--bg-surface);
    box-shadow:
        inset 0 0 0 2px var(--wood-light),
        0 8px 24px rgba(92, 74, 50, 0.3);
    overflow: hidden;
    position: relative;
}
.yeongjeong-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.yeongjeong-silhouette {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    color: var(--text-muted);
    background: linear-gradient(180deg, var(--bg-warm) 0%, #E8DDD0 100%);
}
.yeongjeong-ribbons {
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    z-index: 2;
}
.yeongjeong-ribbon {
    width: 18px;
    height: 60px;
    background: white;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transform-origin: top center;
}
.yeongjeong-ribbon:first-child { transform: rotate(6deg); }
.yeongjeong-ribbon:last-child { transform: rotate(-6deg); }
.yeongjeong-name {
    margin-top: 0.75rem;
    font-family: var(--font-serif);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Candles */
.candle-row {
    display: flex;
    justify-content: center;
    gap: 2rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}
.candle-row .yeongjeong-wrapper { margin-bottom: 0; }
.candle {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 2rem;
}
.candle-flame {
    width: 10px;
    height: 16px;
    background: radial-gradient(ellipse at 50% 80%, #FFE4A0 0%, #FFB830 50%, #FF8C00 85%, transparent 100%);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    animation: flicker 2.5s ease-in-out infinite;
    margin-bottom: 2px;
    filter: blur(0.5px);
}
.candle-flame::after {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    background: var(--candle-glow);
    border-radius: 50%;
    filter: blur(15px);
    z-index: -1;
}
.candle-stick {
    width: 8px;
    height: 40px;
    background: linear-gradient(180deg, #F5E6D0 0%, #E8D5B8 100%);
    border-radius: 2px;
}
.candle-base {
    width: 22px;
    height: 6px;
    background: var(--wood);
    border-radius: 2px;
}
@keyframes flicker {
    0%, 100% { transform: scale(1) rotate(-1deg); opacity: 1; }
    20% { transform: scale(1.08) rotate(1.5deg); opacity: 0.9; }
    40% { transform: scale(0.94) rotate(-2deg); opacity: 1; }
    60% { transform: scale(1.04) rotate(1deg); opacity: 0.85; }
    80% { transform: scale(0.97) rotate(-1.5deg); opacity: 0.95; }
}

/* 제사상 table (3/4 perspective) */
.jesasang-scene {
    perspective: 900px;
    perspective-origin: 50% 25%;
    margin: 0 auto;
    max-width: 520px;
}
.jesasang-table {
    transform: rotateX(28deg);
    transform-origin: center bottom;
    background: linear-gradient(160deg, #B89E76 0%, #A68B64 30%, #8B6F47 70%, #7A5F3A 100%);
    border-radius: 6px;
    padding: 1.5rem 1.2rem 1.8rem;
    box-shadow:
        0 20px 50px rgba(92, 74, 50, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
}
.jesasang-table::before {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    pointer-events: none;
}

/* Offering slots */
.offering-slots {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.offering-slots-row2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    max-width: 66%;
    margin: 0 auto;
}
.offering-slot {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.08);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
    overflow: hidden;
    position: relative;
}
.offering-slot:hover { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.35); }
.offering-slot.filled {
    border-style: solid;
    border-color: rgba(255, 255, 255, 0.15);
    cursor: default;
    padding: 0;
}
.offering-slot.filled img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
}
.slot-prompt {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    line-height: 1.3;
    padding: 0 0.3rem;
}
.slot-icon {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
}
.slot-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.6));
    color: white;
    font-size: 0.6rem;
    padding: 12px 6px 5px;
    text-align: center;
    border-radius: 0 0 5px 5px;
}

/* Search modal */
.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(44, 36, 32, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.3s;
}
.search-overlay.visible { opacity: 1; }
.search-panel {
    width: 100%;
    max-width: 480px;
    max-height: 70vh;
    background: var(--bg);
    border-radius: 16px 16px 0 0;
    padding: 1.5rem;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform 0.3s;
}
.search-overlay.visible .search-panel { transform: translateY(0); }
.search-panel-title {
    font-family: var(--font-serif);
    font-size: 1rem;
    margin-bottom: 0.3rem;
    color: var(--text-primary);
}
.search-panel-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.search-input-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.search-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
}
.search-input:focus { border-color: var(--accent); }
.search-go {
    padding: 10px 18px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}
.search-results {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}
.search-result-item {
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s, transform 0.15s;
}
.search-result-item:hover { border-color: var(--accent); transform: scale(1.03); }
.search-result-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.search-status {
    text-align: center;
    padding: 2rem 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.search-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-muted);
    cursor: pointer;
}
.search-alt {
    text-align: center;
    margin-top: 0.75rem;
    font-size: 0.75rem;
}
.search-alt a {
    color: var(--text-muted);
    text-decoration: underline;
    cursor: pointer;
}

/* ── Stage 4: Letter ── */
.letter-stage-inner {
    max-width: 600px;
    width: 100%;
    padding: 80px 2rem 4rem;
    margin: 0 auto;
}
.letter-area {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 1.5rem;
}
.letter-prompt {
    font-family: var(--font-serif);
    font-size: 0.95rem;
    font-style: italic;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.7;
    text-align: center;
}
.letter-textarea {
    width: 100%;
    min-height: 220px;
    padding: 1.2rem;
    border: none;
    border-radius: 8px;
    background: white;
    color: var(--text-primary);
    font-family: var(--font-serif);
    font-size: 1rem;
    line-height: 1.9;
    outline: none;
    resize: vertical;
}
.letter-textarea::placeholder { color: var(--text-muted); }
.letter-buttons { text-align: center; }

/* ── Stage 5: Reveal ── */
.reveal-stage-inner {
    max-width: 600px;
    width: 100%;
    padding: 80px 2rem 4rem;
    margin: 0 auto;
}
.reveal-altar {
    background: var(--bg-warm);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.5rem 2rem;
    margin-bottom: 2rem;
    text-align: center;
}
.reveal-letter {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem 0;
    text-align: left;
}
.reveal-letter-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    margin-bottom: 0.75rem;
}
.reveal-letter-body {
    font-family: var(--font-serif);
    font-size: 0.95rem;
    line-height: 2;
    color: var(--text-primary);
    white-space: pre-wrap;
}
.reveal-moment {
    text-align: center;
    padding: 1.5rem 0;
    font-family: var(--font-serif);
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-style: italic;
    opacity: 0;
    transition: opacity 1.5s ease;
}
.reveal-moment.visible { opacity: 1; }
.reveal-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
}
.reveal-mini-table {
    perspective: 600px;
    perspective-origin: 50% 30%;
    max-width: 380px;
    margin: 1.5rem auto 0;
}
.reveal-mini-surface {
    transform: rotateX(22deg);
    transform-origin: center bottom;
    background: linear-gradient(160deg, #B89E76 0%, #A68B64 30%, #8B6F47 70%, #7A5F3A 100%);
    border-radius: 4px;
    padding: 0.8rem;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
    box-shadow: 0 12px 30px rgba(92, 74, 50, 0.3);
}
.reveal-mini-surface .mini-offering {
    aspect-ratio: 1;
    border-radius: 4px;
    overflow: hidden;
}
.reveal-mini-surface .mini-offering img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .stage-inner, .table-stage-inner, .letter-stage-inner, .reveal-stage-inner {
        padding: 70px 1.2rem 3rem;
    }
    .yeongjeong-frame { width: 100px; height: 125px; }
    .yeongjeong-ribbon { height: 45px; width: 14px; }
    .candle-row { gap: 1.2rem; }
    .offering-slots { gap: 0.5rem; }
    .search-results { grid-template-columns: repeat(2, 1fr); }
    .letter-area { padding: 1.2rem; }
    .reveal-altar { padding: 1.5rem 1.2rem; }
}
