/* ═══════════════════════════════════════════════════════════
   A Letter Through Time — Stylesheet
   Classic Vintage • Elegant • Warm
   ═══════════════════════════════════════════════════════════ */

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

:root {
    --ivory:       #F5F0E8;
    --cream:       #EDE4D3;
    --parchment:   #E8DCC8;
    --ink:         #3B2F2F;
    --ink-light:   #5C4A3A;
    --gold:        #B8963E;
    --gold-muted:  #C9A96E;
    --sage:        #8A9A7B;
    --sage-light:  #A3B299;
    --dust:        rgba(184, 150, 62, 0.08);
    --shadow:      rgba(59, 47, 47, 0.12);
    --font-display: 'Cormorant Garamond', 'Georgia', serif;
    --font-body:    'Lora', 'Georgia', serif;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--ivory);
    line-height: 1.7;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── Paper Texture Overlay ────────────────────────────────── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(139, 119, 90, 0.015) 2px,
            rgba(139, 119, 90, 0.015) 4px
        );
    pointer-events: none;
    z-index: 9999;
}

/* ── Grain Overlay ────────────────────────────────────────── */
.grain {
    position: fixed;
    inset: 0;
    opacity: 0.04;
    pointer-events: none;
    z-index: 9998;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
}

/* ── Dust Particles ───────────────────────────────────────── */
.dust-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9997;
    overflow: hidden;
}

.dust {
    position: absolute;
    width: 3px;
    height: 3px;
    background: var(--gold-muted);
    border-radius: 50%;
    opacity: 0;
    animation: dustFloat 8s ease-in-out infinite;
}

.dust:nth-child(1) { left: 10%; animation-delay: 0s; animation-duration: 7s; }
.dust:nth-child(2) { left: 25%; animation-delay: 1.5s; animation-duration: 9s; }
.dust:nth-child(3) { left: 45%; animation-delay: 3s; animation-duration: 6s; }
.dust:nth-child(4) { left: 65%; animation-delay: 0.8s; animation-duration: 8s; }
.dust:nth-child(5) { left: 80%; animation-delay: 2.2s; animation-duration: 10s; }
.dust:nth-child(6) { left: 35%; animation-delay: 4s; animation-duration: 7.5s; }
.dust:nth-child(7) { left: 55%; animation-delay: 1s; animation-duration: 8.5s; }
.dust:nth-child(8) { left: 90%; animation-delay: 3.5s; animation-duration: 6.5s; }

@keyframes dustFloat {
    0%   { transform: translateY(100vh) scale(0); opacity: 0; }
    10%  { opacity: 0.6; }
    90%  { opacity: 0.3; }
    100% { transform: translateY(-10vh) scale(1); opacity: 0; }
}

/* ── Page Wrapper ─────────────────────────────────────────── */
.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    position: relative;
}

.scene {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    position: relative;
    width: 100%;
}

.opening-btn-wrap {
    margin-top: 1.5rem;
}

.letter-scene-inner {
    max-width: 600px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ── Shared Animations ────────────────────────────────────── */
.fade-in {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeIn 1s ease forwards;
}

.fade-in-delay-1 { animation-delay: 0.3s; }
.fade-in-delay-2 { animation-delay: 0.6s; }
.fade-in-delay-3 { animation-delay: 0.9s; }
.fade-in-delay-4 { animation-delay: 1.2s; }

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

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

@keyframes slideUp {
    from { opacity: 0; transform: translateY(40px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Ornament Divider ─────────────────────────────────────── */
.ornament {
    text-align: center;
    color: var(--gold);
    font-size: 1.5rem;
    letter-spacing: 0.5em;
    margin: 1.5rem 0;
    opacity: 0.6;
}

.ornament-line {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 2rem auto;
    max-width: 280px;
}

.ornament-line::before,
.ornament-line::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--gold-muted), transparent);
}

.ornament-line span {
    color: var(--gold);
    font-size: 0.9rem;
}

/* ── Vintage Button ───────────────────────────────────────── */
.btn-vintage {
    display: inline-block;
    padding: 0.9rem 2.5rem;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ivory);
    background: var(--ink);
    border: 2px solid var(--ink);
    cursor: pointer;
    transition: all 0.4s ease;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn-vintage::before {
    content: '';
    position: absolute;
    inset: 3px;
    border: 1px solid var(--gold-muted);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.btn-vintage:hover {
    background: transparent;
    color: var(--ink);
}

.btn-vintage:hover::before {
    opacity: 1;
}

.btn-vintage:active {
    transform: scale(0.97);
}

/* ── SCREEN 1 — Opening ──────────────────────────────────── */
.opening {
    text-align: center;
    max-width: 520px;
}

.opening-ornament {
    font-size: 2.5rem;
    color: var(--gold);
    opacity: 0;
    animation: fadeInOnly 1.5s ease 0.5s forwards;
    margin-bottom: 2rem;
    text-align: center;
}

.opening-text {
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 4vw, 1.6rem);
    font-style: italic;
    color: var(--ink-light);
    line-height: 1.8;
    opacity: 0;
    animation: fadeIn 1.2s ease 1.5s forwards;
    margin-bottom: 3rem;
    text-align: center;
}

/* ── SCREEN 2 — Envelope ─────────────────────────────────── */
.envelope-scene {
    text-align: center;
    perspective: 1000px;
}

.envelope-wrapper {
    position: relative;
    width: 300px;
    height: 220px;
    margin: 0 auto 2.5rem;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.envelope-wrapper:hover {
    transform: scale(1.02);
}

.envelope-body {
    position: absolute;
    inset: 0;
    background: linear-gradient(145deg, var(--cream), var(--parchment));
    border: 1px solid var(--gold-muted);
    border-radius: 4px;
    box-shadow:
        0 4px 20px var(--shadow),
        inset 0 0 30px rgba(139, 119, 90, 0.05);
}

.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(160deg, var(--parchment), var(--cream));
    border: 1px solid var(--gold-muted);
    border-bottom: none;
    clip-path: polygon(0 0, 50% 100%, 100% 0);
    transform-origin: top center;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
}

.envelope-wrapper.opened .envelope-flap {
    transform: rotateX(180deg);
}

.envelope-seal {
    position: absolute;
    top: 42%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: radial-gradient(circle at 35% 35%, #C44536, #8B2500);
    border-radius: 50%;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 2px 8px rgba(139, 37, 0, 0.4),
        inset 0 1px 2px rgba(255, 255, 255, 0.15);
    transition: all 0.6s ease 0.3s;
    cursor: pointer;
}

.envelope-wrapper.opened .envelope-seal {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
}

.envelope-seal-letter {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.envelope-inner {
    position: absolute;
    bottom: 10%;
    left: 10%;
    right: 10%;
    height: 70%;
    background: var(--ivory);
    border: 1px solid rgba(184, 150, 62, 0.3);
    border-radius: 2px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.5s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.envelope-wrapper.opened .envelope-inner {
    opacity: 1;
    transform: translateY(-30px);
}

.envelope-inner-text {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 0.9rem;
    color: var(--ink-light);
    opacity: 0.7;
}

.envelope-hint {
    font-family: var(--font-display);
    font-size: 0.95rem;
    color: var(--ink-light);
    opacity: 0;
    animation: fadeIn 1s ease 2s forwards;
    margin-top: 1rem;
}

.envelope-hint span {
    display: inline-block;
    animation: gentlePulse 2s ease-in-out infinite;
}

@keyframes gentlePulse {
    0%, 100% { opacity: 0.6; }
    50%      { opacity: 1; }
}

/* ── SCREEN 3 — Letter ───────────────────────────────────── */
.letter-paper {
    background: var(--ivory);
    border: 1px solid var(--gold-muted);
    padding: 2.5rem 2rem;
    box-shadow:
        0 2px 30px var(--shadow),
        inset 0 0 60px rgba(237, 228, 211, 0.5);
    position: relative;
    opacity: 0;
    animation: slideUp 0.8s ease forwards;
}

.letter-paper::before {
    content: '';
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    bottom: 12px;
    border: 1px solid rgba(184, 150, 62, 0.2);
    pointer-events: none;
}

.letter-greeting {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 5vw, 2rem);
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 1.5rem;
    text-align: center;
}

.letter-body p {
    font-size: clamp(0.95rem, 3vw, 1.05rem);
    color: var(--ink-light);
    margin-bottom: 1.2rem;
    line-height: 1.9;
    text-align: center;
}

.letter-body p:last-child {
    margin-bottom: 0;
}

.letter-closing {
    font-family: var(--font-display);
    font-style: italic;
    font-size: clamp(1rem, 3.5vw, 1.2rem);
    color: var(--ink);
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(184, 150, 62, 0.3);
    line-height: 1.8;
    text-align: center;
}

/* Typewriter cursor */
.typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background: var(--ink);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 0.8s step-end infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

.letter-nav {
    text-align: center;
    margin-top: 2.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

.letter-nav.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ── SCREEN 4 — Gallery ──────────────────────────────────── */
.gallery-scene {
    max-width: 600px;
    width: 100%;
    text-align: center;
}

.gallery-title {
    font-family: var(--font-display);
    font-size: clamp(1.3rem, 4vw, 1.8rem);
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 0.5rem;
    text-align: center;
}

.gallery-subtitle {
    font-size: 0.95rem;
    color: var(--ink-light);
    font-style: italic;
    margin-bottom: 2rem;
    text-align: center;
}

.gallery-collage {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    max-width: 500px;
    width: 100%;
}

.collage-item {
    background: #fff;
    padding: 10px 10px 32px 10px;
    box-shadow:
        0 3px 15px var(--shadow),
        0 0 0 1px rgba(0,0,0,0.04);
    position: relative;
    transition: transform 0.3s ease;
}

.collage-item:nth-child(odd) {
    transform: rotate(-1.5deg);
}

.collage-item:nth-child(even) {
    transform: rotate(1.5deg);
}

.collage-item:hover {
    transform: rotate(0deg) scale(1.03) !important;
    z-index: 2;
}

.collage-photo {
    width: 200px;
}

.collage-photo img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    filter: sepia(15%) contrast(0.95) brightness(1.02);
}

.collage-video {
    width: 100%;
    max-width: 220px;
}

.collage-video video {
    width: 100%;
    height: auto;
    display: block;
    filter: sepia(10%) contrast(0.95) brightness(1.02);
}

.collage-caption {
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
    font-family: var(--font-display);
    font-size: 0.78rem;
    font-style: italic;
    color: var(--ink-light);
    text-align: center;
}

.gallery-next {
    text-align: center;
    margin-top: 2.5rem;
    opacity: 1;
}

/* ── SCREEN 5 — Surprise ─────────────────────────────────── */
.surprise-scene {
    text-align: center;
    max-width: 500px;
}

.surprise-card {
    background: var(--ivory);
    border: 1px solid var(--gold-muted);
    padding: 3rem 2rem;
    box-shadow: 0 4px 30px var(--shadow);
    position: relative;
    text-align: center;
}

.surprise-card::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 1px solid rgba(184, 150, 62, 0.15);
    pointer-events: none;
}

.surprise-icon {
    font-size: 2rem;
    color: var(--gold);
    margin-bottom: 1.5rem;
    text-align: center;
}

.surprise-text {
    font-family: var(--font-display);
    font-size: clamp(1.1rem, 4vw, 1.4rem);
    font-style: italic;
    color: var(--ink-light);
    line-height: 1.8;
    margin-bottom: 2rem;
    text-align: center;
}

/* ── SCREEN 6 — Final ────────────────────────────────────── */
.final-scene {
    text-align: center;
    max-width: 550px;
}

.final-name {
    font-family: var(--font-display);
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
    text-align: center;
}

.final-date {
    font-size: 0.85rem;
    color: var(--gold);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    margin-bottom: 2rem;
    text-align: center;
}

.final-message {
    font-family: var(--font-display);
    font-size: clamp(1.1rem, 3.5vw, 1.35rem);
    font-style: italic;
    color: var(--ink-light);
    line-height: 1.9;
    margin-bottom: 1.5rem;
    text-align: center;
}

.final-prayer {
    font-size: 1rem;
    color: var(--ink-light);
    margin-bottom: 2.5rem;
    line-height: 1.8;
    text-align: center;
}

.final-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ── Birthday Cake ────────────────────────────────────────── */
.cake-scene {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.cake-decorative {
    pointer-events: none;
}

.cake {
    position: relative;
    width: 180px;
    cursor: pointer;
}

.cake-interactive {
    animation: cakeFloat 3s ease-in-out infinite;
}

@keyframes cakeFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}

/* Plate */
.cake-plate {
    width: 200px;
    height: 12px;
    background: linear-gradient(to bottom, #d4c5a9, #c4b599);
    border-radius: 50%;
    margin: 0 auto;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

/* Cake layers */
.cake-layer {
    width: 100%;
    margin: 0 auto;
    border-radius: 4px;
}

.bot-layer {
    width: 170px;
    height: 40px;
    background: linear-gradient(135deg, #D4A574, #C49660);
    border-radius: 4px 4px 6px 6px;
}

.mid-layer {
    width: 150px;
    height: 36px;
    background: linear-gradient(135deg, #E8C9A0, #D4B88A);
}

.top-layer {
    width: 130px;
    height: 32px;
    background: linear-gradient(135deg, #F0DCC0, #E4CCAA);
    border-radius: 6px 6px 4px 4px;
}

/* Frosting */
.frosting-bot {
    width: 174px;
    height: 10px;
    background: var(--ivory);
    border-radius: 0 0 4px 4px;
    margin: 0 auto;
    position: relative;
}

.frosting-bot::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 5%;
    right: 5%;
    height: 8px;
    background: radial-gradient(circle at 10% 0%, var(--ivory) 40%, transparent 41%),
                radial-gradient(circle at 30% 0%, var(--ivory) 40%, transparent 41%),
                radial-gradient(circle at 50% 0%, var(--ivory) 40%, transparent 41%),
                radial-gradient(circle at 70% 0%, var(--ivory) 40%, transparent 41%),
                radial-gradient(circle at 90% 0%, var(--ivory) 40%, transparent 41%);
    background-size: 20% 100%;
}

.frosting-mid {
    width: 154px;
    height: 10px;
    background: var(--ivory);
    margin: 0 auto;
    position: relative;
}

.frosting-mid::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 5%;
    right: 5%;
    height: 8px;
    background: radial-gradient(circle at 10% 0%, var(--ivory) 40%, transparent 41%),
                radial-gradient(circle at 30% 0%, var(--ivory) 40%, transparent 41%),
                radial-gradient(circle at 50% 0%, var(--ivory) 40%, transparent 41%),
                radial-gradient(circle at 70% 0%, var(--ivory) 40%, transparent 41%),
                radial-gradient(circle at 90% 0%, var(--ivory) 40%, transparent 41%);
    background-size: 20% 100%;
}

.frosting-top {
    width: 134px;
    height: 10px;
    background: var(--ivory);
    border-radius: 6px 6px 0 0;
    margin: 0 auto;
}

/* Candles */
.candle-group {
    display: flex;
    justify-content: center;
    gap: 12px;
    position: relative;
    z-index: 2;
    margin-bottom: -4px;
}

.candle {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.candle-body {
    width: 8px;
    height: 30px;
    background: linear-gradient(90deg, #E8D5B8, #F5EDE0, #E8D5B8);
    border-radius: 2px;
    position: relative;
}

.candle-body::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 1px;
    right: 1px;
    height: 3px;
    background: var(--gold-muted);
    border-radius: 1px;
}

.wick {
    width: 2px;
    height: 6px;
    background: #3B2F2F;
    border-radius: 1px;
}

/* Flame */
.flame {
    width: 14px;
    height: 20px;
    position: relative;
    animation: flicker 0.4s ease-in-out infinite alternate;
}

.flame-inner {
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 80%, #FFD700 0%, #FF8C00 40%, #FF4500 70%, transparent 100%);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    animation: flickerInner 0.3s ease-in-out infinite alternate;
}

@keyframes flicker {
    0%   { transform: scale(1) rotate(-2deg); }
    100% { transform: scale(1.05) rotate(2deg); }
}

@keyframes flickerInner {
    0%   { opacity: 0.9; transform: scaleY(0.95); }
    100% { opacity: 1; transform: scaleY(1.05); }
}

/* Flame extinguish */
.flame.out {
    animation: flameOut 0.4s ease forwards;
}

@keyframes flameOut {
    0%   { transform: scale(1); opacity: 1; }
    50%  { transform: scale(1.3, 0.5); opacity: 0.6; }
    100% { transform: scale(0); opacity: 0; }
}

/* Smoke */
.smoke-group {
    position: absolute;
    top: -20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 8px;
    pointer-events: none;
    opacity: 0;
}

.smoke-group.active {
    opacity: 1;
}

.smoke {
    width: 8px;
    height: 8px;
    background: rgba(180, 170, 155, 0.5);
    border-radius: 50%;
    animation: smokeRise 1.5s ease-out forwards;
}

.smoke:nth-child(1) { animation-delay: 0s; margin-left: -10px; }
.smoke:nth-child(2) { animation-delay: 0.1s; }
.smoke:nth-child(3) { animation-delay: 0.05s; }
.smoke:nth-child(4) { animation-delay: 0.15s; margin-right: -10px; }
.smoke:nth-child(5) { animation-delay: 0.08s; }

@keyframes smokeRise {
    0%   { transform: translateY(0) scale(1); opacity: 0.6; }
    50%  { opacity: 0.3; }
    100% { transform: translateY(-40px) translateX(10px) scale(2.5); opacity: 0; }
}

/* Hint & wish text */
.cake-hint {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-style: italic;
    color: var(--gold-muted);
    margin-top: 1rem;
    animation: gentlePulse 2s ease-in-out infinite;
}

.cake-interactive .cake-hint {
    cursor: pointer;
}

.wish-text {
    font-family: var(--font-display);
    font-size: 1rem;
    font-style: italic;
    color: var(--gold);
    margin-top: 1rem;
    opacity: 0;
    animation: fadeIn 1s ease forwards;
}

.cake-continue {
    margin-top: 1.5rem;
}

/* ── Fireworks / Sparkles ─────────────────────────────────── */
.fireworks-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9990;
    overflow: hidden;
}

.sparkle {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    animation: sparkleBurst var(--dur) ease-out forwards;
}

@keyframes sparkleBurst {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

/* Spinning firework ring */
.firework-ring {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: fireworkSpin var(--dur) ease-out forwards;
}

@keyframes fireworkSpin {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) rotate(720deg) scale(0);
        opacity: 0;
    }
}

/* Sparkle trail */
.sparkle-trail {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    animation: trailUp var(--dur) ease-out forwards;
}

@keyframes trailUp {
    0% {
        transform: translateY(0) scale(1);
        opacity: 0.9;
    }
    100% {
        transform: translateY(var(--ty)) translateX(var(--tx)) scale(0);
        opacity: 0;
    }
}

/* ── Page Transitions ─────────────────────────────────────── */
.page-transition {
    position: fixed;
    inset: 0;
    background: var(--ink);
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.page-transition.active {
    opacity: 1;
    pointer-events: all;
}

/* ── Footer ───────────────────────────────────────────────── */
.vintage-footer {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--gold-muted);
    letter-spacing: 0.2em;
    opacity: 0.4;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 480px) {
    .page {
        padding: 1.5rem 1rem;
    }

    .letter-paper {
        padding: 2rem 1.5rem;
    }

    .polaroid {
        flex: 0 0 240px;
    }

    .gallery-track {
        padding: 0 calc(50% - 120px);
    }

    .envelope-wrapper {
        width: 260px;
        height: 190px;
    }

    .final-actions {
        flex-direction: column;
        align-items: center;
    }

    .btn-vintage {
        width: 100%;
        max-width: 280px;
    }
}

@media (min-width: 768px) {
    .letter-paper {
        padding: 3rem 3rem;
    }

    .polaroid {
        flex: 0 0 300px;
    }

    .gallery-track {
        padding: 0 calc(50% - 150px);
    }
}

/* ── Reduced Motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0ms !important;
        transition-duration: 0.01ms !important;
    }

    .dust { display: none; }

    .fade-in,
    .opening-ornament,
    .opening-text,
    .envelope-hint {
        opacity: 1;
        transform: none;
    }

    .letter-nav,
    .gallery-next {
        opacity: 1;
    }
}

/* ── Placeholder image styling ────────────────────────────── */
.polaroid img.placeholder-img {
    background: linear-gradient(135deg, var(--cream), var(--parchment));
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-style: italic;
    color: var(--gold-muted);
    font-size: 0.85rem;
}
