/* ==========================================================================
   COLOR PALETTE (DEEP WINE BURGUNDY & BLUSH SILK - CUSTOM RECOLOR):
   #49150a — Dominant main background (deep rich wine burgundy)
   #fff5f3 — Cream silk (primary text, button backgrounds, photo borders)
   #f4c2c5 — Warm rose champagne (line 2 accent, highlights, hover states)
   #c7afaa — Muted rose dust (date, line 3 accent, subtle borders)
   #260702 — Deepest dark mahogany (button text, contrast badges, shadows)
   #d4a359 — Warm antique gold / brass (curved arrow)
   ========================================================================== */

:root {
    --bg-main: #49150a;
    --text-main: #fff5f3;
    --cream: #fff5f3;
    --warm-accent: #f4c2c5;
    --muted-rose: #c7afaa;
    --deep-wine: #380d05;
    --dark-burgundy: #260702;
    --gold-accent: #d4a359;

    --font-serif: 'Newsreader', Georgia, 'Times New Roman', serif;
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

[hidden] {
    display: none !important;
}

html {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-serif);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    width: 100%;
}

body {
    background-color: var(--bg-main);
    height: 100%;
    height: 100dvh;
    width: 100%;
    overflow: hidden;
    position: relative;
}

::selection {
    background-color: var(--warm-accent);
    color: var(--dark-burgundy);
}

/* ==========================================================================
   COMPACT FLOATING MUSIC TOGGLE
   ========================================================================== */
.music-toggle {
    position: fixed;
    top: clamp(0.75rem, 2vh, 1.25rem);
    right: clamp(0.75rem, 2vw, 1.25rem);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 245, 243, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(199, 175, 170, 0.35);
    color: var(--cream);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
    transition: all 0.25s ease;
    user-select: none;
    padding: 0;
    opacity: 0.85;
}

.music-toggle:hover,
.music-toggle:focus-visible {
    opacity: 1;
    background: rgba(255, 245, 243, 0.22);
    border-color: var(--warm-accent);
    color: var(--warm-accent);
    transform: scale(1.08);
}

.music-toggle:active {
    transform: scale(0.92);
}

.music-toggle.is-playing {
    opacity: 1;
    background: rgba(244, 194, 197, 0.18);
    border-color: rgba(244, 194, 197, 0.7);
    color: var(--warm-accent);
}

.music-toggle.is-playing .music-disc {
    animation: spinDisc 6s linear infinite;
}

.music-disc {
    display: block;
    transform-origin: center;
}

@keyframes spinDisc {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   STATE 1: OPENING SCREEN (NO-SCROLL, FULL VIEWPORT)
   ========================================================================== */
.opening-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    height: 100dvh;
    width: 100%;
    padding: 1.5rem;
    background-color: var(--bg-main);
    transition: opacity 0.45s ease, visibility 0.45s ease;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
}

.opening-container.is-leaving {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.opening-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    max-width: 480px;
    width: 100%;
}

.opening-line {
    font-family: var(--font-serif);
    font-size: clamp(1.2rem, 3.2vh, 1.55rem);
    font-weight: 400;
    line-height: 1.5;
    color: var(--cream);
    margin-bottom: clamp(0.75rem, 2vh, 1.25rem);
    opacity: 0;
    will-change: opacity;
    letter-spacing: -0.01em;
}

.opening-line.line-1 {
    animation: simpleFadeIn 0.7s ease-out 0.2s forwards;
}

.opening-line.line-2 {
    font-style: italic;
    color: var(--warm-accent);
    animation: simpleFadeIn 0.7s ease-out 1.0s forwards;
}

.opening-line.line-3 {
    color: var(--muted-rose);
    animation: simpleFadeIn 0.7s ease-out 1.9s forwards;
    margin-bottom: clamp(1.75rem, 4vh, 2.75rem);
}

.open-button {
    appearance: none;
    background: var(--cream);
    border: 1px solid var(--warm-accent);
    border-radius: 999px;
    outline: none;
    color: var(--dark-burgundy);
    font-family: var(--font-sans);
    font-size: clamp(0.875rem, 2.2vh, 0.95rem);
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    padding: 0.5rem 1.45rem;
    opacity: 0;
    will-change: opacity;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    animation: simpleFadeIn 0.7s ease-out 2.8s forwards;
    transition: all 0.2s ease;
}

.open-button:hover,
.open-button:focus-visible {
    background: var(--warm-accent);
    color: var(--dark-burgundy);
    border-color: var(--cream);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.32);
}

.open-button:active {
    transform: translateY(0);
    opacity: 0.9;
}

/* ==========================================================================
   NAVIGATION TOP BAR (NON-OVERLAPPING & PROPERLY SPACED)
   ========================================================================== */
.letter-nav-bar {
    position: absolute;
    top: clamp(0.75rem, 2vh, 1.25rem);
    left: clamp(0.75rem, 2vw, 1.25rem);
    right: clamp(3.2rem, 5vw, 4rem);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 50;
    pointer-events: none;
}

.back-button {
    pointer-events: auto;
    background: rgba(255, 245, 243, 0.12);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(199, 175, 170, 0.35);
    border-radius: 999px;
    outline: none;
    font-family: var(--font-sans);
    font-size: clamp(0.75rem, 1.8vh, 0.82rem);
    font-weight: 500;
    color: var(--cream);
    cursor: pointer;
    padding: 0.35rem 0.75rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.back-button:hover,
.back-button:focus-visible {
    background: rgba(255, 245, 243, 0.24);
    color: var(--warm-accent);
    border-color: var(--warm-accent);
    transform: translateX(-2px);
}

.next-button {
    pointer-events: auto;
    background: rgba(255, 245, 243, 0.12);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(199, 175, 170, 0.35);
    border-radius: 999px;
    outline: none;
    font-family: var(--font-sans);
    font-size: clamp(0.75rem, 1.8vh, 0.82rem);
    font-weight: 500;
    color: var(--cream);
    cursor: pointer;
    padding: 0.35rem 0.75rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.next-button:hover,
.next-button:focus-visible {
    background: rgba(255, 245, 243, 0.24);
    color: var(--warm-accent);
    border-color: var(--warm-accent);
    transform: translateX(2px);
}

/* ==========================================================================
   STATE 2: LETTER CONTAINER & UNOBSTRUCTED LAYOUT
   ========================================================================== */
.letter-container {
    width: 100%;
    height: 100%;
    height: 100dvh;
    background-color: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.letter-container.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.letter-wrapper {
    width: 100%;
    max-width: 680px;
    height: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    padding: clamp(0.5rem, 1.5vh, 1.5rem) clamp(0.75rem, 3vw, 1.75rem);
}

/* Central Letter Column */
.letter-column {
    max-width: 460px;
    width: 100%;
    margin: 0 auto;
    text-align: left;
    position: relative;
    z-index: 2;
    max-height: 82vh;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: clamp(2rem, 4.5vh, 3.25rem) 0.5rem clamp(1rem, 2vh, 1.5rem);
}

.letter-column::-webkit-scrollbar {
    display: none;
}

/* Header Row: Date & Keonho Photo placed side-by-side on mobile without overlap */
.letter-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: clamp(0.6rem, 1.5vh, 1rem);
    width: 100%;
}

.letter-date {
    display: block;
    font-family: var(--font-sans);
    font-size: clamp(0.74rem, 1.7vh, 0.82rem);
    font-weight: 600;
    color: var(--warm-accent);
    letter-spacing: 0.03em;
    opacity: 0.95;
    text-transform: lowercase;
}

/* Letter Body: 100% full width, zero text covered */
.letter-body {
    font-family: var(--font-serif);
    font-size: clamp(0.82rem, 2vh, 0.95rem);
    line-height: clamp(1.42, 2.2vh, 1.62);
    font-weight: 400;
    color: var(--cream);
}

.letter-body p {
    margin-bottom: clamp(0.5rem, 1.3vh, 0.9rem);
}

.letter-body p:first-child {
    font-size: clamp(0.88rem, 2.1vh, 1.02rem);
    color: var(--cream);
    font-weight: 500;
}

.letter-body p:last-child {
    margin-bottom: 0;
    color: var(--warm-accent);
}

/* Footer Row: Shabiel Photo on Left, Next Button on Right */
.letter-footer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: clamp(1rem, 2.5vh, 1.6rem);
    width: 100%;
}

.next-pill-btn {
    appearance: none;
    background: var(--cream);
    border: 1px solid var(--warm-accent);
    border-radius: 999px;
    outline: none;
    color: var(--dark-burgundy);
    font-family: var(--font-sans);
    font-size: clamp(0.78rem, 1.8vh, 0.86rem);
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    padding: 0.38rem 1.25rem;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.next-pill-btn:hover,
.next-pill-btn:focus-visible {
    background: var(--warm-accent);
    color: var(--dark-burgundy);
    border-color: var(--cream);
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(0, 0, 0, 0.32);
}

/* Photos: Polaroid frame style */
.photo-wrapper {
    position: relative;
    user-select: none;
    flex-shrink: 0;
}

.letter-photo {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 5;
    object-fit: cover;
    background-color: var(--dark-burgundy);
    border: 2.5px solid var(--cream);
    border-radius: 3px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.32);
}

.photo-top-right {
    width: clamp(58px, 16vw, 75px);
}

.photo-top-right .letter-photo {
    transform: rotate(2.5deg);
}

.photo-bottom-left {
    width: clamp(58px, 16vw, 75px);
}

.photo-bottom-left .letter-photo {
    transform: rotate(-2.5deg);
}

/* Desktop layout enhancement: Photos can position in side margins */
@media (min-width: 720px) {
    .photo-top-right {
        position: absolute;
        top: 6%;
        right: 0;
        width: 105px;
    }

    .photo-bottom-left {
        position: absolute;
        bottom: 6%;
        left: 0;
        width: 105px;
    }

    .letter-footer-row {
        justify-content: center;
    }
}

/* ==========================================================================
   STATE 3: GIFT PAGE (REMOVED BACKGROUND CUTOUTS & SKETCH LAYOUT)
   ========================================================================== */

.gift-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: clamp(3.5rem, 5vh, 4.5rem) clamp(0.75rem, 3vw, 1.5rem) clamp(1.5rem, 3vh, 2.5rem);
    box-sizing: border-box;
}

.gift-wrapper .letter-nav-bar {
    position: absolute;
    top: clamp(1.25rem, 2.5vh, 2rem);
    left: clamp(1rem, 4vw, 2rem);
    width: auto;
    z-index: 20;
}

.gift-wrapper::-webkit-scrollbar {
    display: none;
}

/* Header Title in Editorial Serif Italic */
.gift-header {
    margin-top: auto;
    text-align: center;
    margin-bottom: clamp(1rem, 2.5vh, 1.75rem);
    width: 100%;
}

.gift-title {
    font-family: var(--font-serif);
    font-size: clamp(1.25rem, 3.5vw, 1.75rem);
    font-style: italic;
    font-weight: 400;
    color: var(--cream);
    letter-spacing: -0.01em;
    line-height: 1.35;
}

/* Main Collage Stage */
.gift-stage {
    margin-bottom: auto;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    margin-left: auto;
    margin-right: auto;
}

/* Gifts Cluster Box */
.gift-cluster {
    position: relative;
    width: 100%;
    max-width: 360px;
    height: 290px;
    margin-bottom: 0.5rem;
}

/* Cutout Items Styling */
.gift-cutout {
    position: absolute;
    user-select: none;
    transition: transform 0.25s cubic-bezier(0.2, 0, 0.2, 1);
    cursor: pointer;
}

.gift-cutout:hover {
    transform: scale(1.05) !important;
    z-index: 10 !important;
}

.cutout-img {
    display: block;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.45));
}

/* 1. Teddy Bear (Center) */
.gift-cutout-bear {
    width: 170px;
    top: 5px;
    left: 50%;
    margin-left: -85px;
    z-index: 1;
}

/* 2. Ferrero Rocher Box (Left Front Tilted) */
.gift-cutout-chocolate {
    width: 145px;
    top: 130px;
    left: 15px;
    z-index: 3;
    transform: rotate(-7deg);
}

/* 3. Flower Bouquet (Right Front Tilted) */
.gift-cutout-flowers {
    width: 140px;
    top: 35px;
    right: 15px;
    z-index: 4;
    transform: rotate(9deg);
}

/* Curved Arrow Wrap */
.gift-arrow-wrap {
    position: absolute;
    top: 85px;
    left: -10px;
    width: 140px;
    height: 210px;
    z-index: 2;
    pointer-events: none;
}

.gift-curved-arrow {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}

/* Bottom Couple Section */
.gift-couple-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    width: 100%;
    max-width: 360px;
    margin-top: -10px;
    position: relative;
    z-index: 5;
}
/* 4. Couple Bears Hugging */
.gift-cutout-couple {
    position: relative;
    width: 95px;
    flex-shrink: 0;
}

/* Couple Caption matching sketch font & style */
.gift-couple-caption {
    font-family: var(--font-sans);
    font-size: clamp(0.95rem, 2.2vh, 1.15rem);
    font-weight: 700;
    font-style: italic;
    color: var(--cream);
    letter-spacing: -0.01em;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Responsive adjustments for smaller screens */
@media (max-width: 380px) {
    .gift-cluster {
        max-width: 310px;
        height: 260px;
    }

    .gift-cutout-bear {
        width: 150px;
        margin-left: -75px;
    }

    .gift-cutout-chocolate {
        width: 125px;
        top: 115px;
        left: 8px;
    }

    .gift-cutout-flowers {
        width: 125px;
        top: 30px;
        right: 8px;
    }

    .gift-arrow-wrap {
        top: 75px;
        left: -18px;
        width: 125px;
        height: 185px;
    }

    .gift-couple-section {
        padding-left: 12px;
        gap: 0.85rem;
    }

    .gift-cutout-couple {
        width: 82px;
    }

    .gift-couple-caption {
        font-size: 0.92rem;
    }
}

/* ==========================================================================
   ANIMATIONS & REDUCED MOTION
   ========================================================================== */
@keyframes simpleFadeIn {
    0% {
        opacity: 0;
        transform: translateY(4px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        animation-delay: 0ms !important;
    }

    .opening-line,
    .open-button,
    .photo-wrapper {
        opacity: 1 !important;
    }

    .letter-container {
        opacity: 1 !important;
        transform: none !important;
    }
}
