/* ═══════════════════════════════════════════
   finale — a single cap-toss confetti burst,
   then a still, quiet closing frame.
   No sparkles here: the confetti is the only
   flourish this screen gets, and it does not loop.
   ═══════════════════════════════════════════ */

.finale-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.35rem;
    max-width: 640px;
    margin: 0 auto;
    padding: 2.5rem 1.75rem;
    text-align: center;
}

/* A static wash of warm light behind the closing frame — deliberately
   NOT animated. This screen holds still; nothing here should drift. */
.finale-container::before {
    content: '';
    position: absolute;
    inset: -10% -15%;
    /* --bloom, not --accent-warm-glow-soft: on this cream ground the latter
       is darker than the paper, so the "glow" read as a grey smudge and
       dragged the subtitle to 4.22:1. closest-side, so the gradient reaches
       transparent inside the box -- `circle ... 70%` was clipped at the box
       edge, leaving a hard one-pixel line across the still frame. */
    background: radial-gradient(closest-side at 50% 40%, var(--bloom), transparent);
    z-index: -1;
    pointer-events: none;
}

/* Each line starts hidden; finale.js adds .finale-revealed to the
   container once the confetti burst has fired, and the transition-delay
   stagger below lets the still frame surface as the burst settles. */
.finale-title,
.finale-subtitle,
.finale-message,
.finale-signature {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 1.2s var(--ease-expo-out), transform 1.2s var(--ease-expo-out);
}

.finale-container.finale-revealed .finale-title {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.3s;
}

.finale-container.finale-revealed .finale-subtitle {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 1.6s;
}

.finale-container.finale-revealed .finale-message {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 2.4s;
}

.finale-container.finale-revealed .finale-signature {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 3.4s;
}

.finale-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2.25rem, 7vw, 3.75rem);
    line-height: 1.15;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}

.finale-subtitle {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: clamp(1.05rem, 2.6vw, 1.375rem);
    color: var(--sage);
    letter-spacing: 0.02em;
}

.finale-message {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 2.2vw, 1.1rem);
    line-height: 1.6;
    color: var(--text-secondary);
    max-width: 34ch;
}

.finale-signature {
    font-family: var(--font-script);
    font-size: clamp(2rem, 6vw, 2.75rem);
    color: var(--accent-warm-deep);
    margin-top: 0.5rem;
}

/* ───── Remembered memory — the recipient's own first choice on
   memory-wall, carried forward via window.AppState.firstOpenedMemory
   (js/app.js) and populated by js/finale.js. `display: none` by default:
   a recipient who never opened a card (skipped ahead, or never visited
   memory-wall) gets exactly today's finale -- this block is not just
   invisible, it takes up no space and never renders an empty frame or a
   dangling caption. js/finale.js adds .finale-remembered-visible only
   when there is an actual photo to show. Quiet and small on purpose: the
   still frame is the point, this sits inside it rather than competing. */
.finale-remembered {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 1.2s var(--ease-expo-out), transform 1.2s var(--ease-expo-out);
}

.finale-remembered.finale-remembered-visible {
    display: flex;
}

/* Slots into the same reveal stagger as the other still-frame lines,
   between .finale-message (2.4s) and .finale-signature (3.4s). */
.finale-container.finale-revealed .finale-remembered.finale-remembered-visible {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 2.9s;
}

.finale-remembered-photo {
    display: block;
    width: 8.5rem;
    height: 8.5rem;
    object-fit: cover;
    border-radius: 14px;
    box-shadow: 0 10px 24px rgba(42, 40, 32, 0.18);
}

/* The line that tells the recipient their choice mattered. It was the
   smallest, faintest text on the frame (12px at 0.85 opacity, 3.78:1). */
/* Short phones (375x667, 360x640 -- common in the primary market). With the
   remembered memory the frame is ~220px taller, so at these heights it
   overflowed: the name clipped at the top and the badge sat on the sign-off.
   Tighten the rhythm and the photo rather than let the still frame scroll. */
@media (max-height: 720px) {
    .finale-container {
        gap: 0.8rem;
        padding: 1.25rem 1.5rem 4rem;
    }

    .finale-title {
        font-size: clamp(1.9rem, 6vw, 2.6rem);
    }

    .finale-remembered-photo {
        width: 5.5rem;
        height: 5.5rem;
    }

    .finale-signature {
        font-size: clamp(1.7rem, 5vw, 2.2rem);
        margin-top: 0;
    }
}

.finale-remembered-caption {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    color: var(--text-secondary);
}

/* The buyer's own caption for that photo, so the memory is named, not just
   thumbnailed. Empty, and collapsed, when the photo had no caption. */
.finale-remembered-memory {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1rem;
    line-height: 1.45;
    color: var(--text-primary);
    max-width: 30ch;
}

.finale-remembered-memory:empty {
    display: none;
}
