/* =========================================
   CSS Resets & Variables
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-color: #fdf5f6;
    --book-cover: #c4849a;
    --book-cover-dark: #a06478;
    --book-page: #fff9f9;
    --text-main: #4a3b40;
    --text-light: #7a6a70;
    --accent: #800020;
    --gold: #d4af37;
    --shadow: rgba(100, 50, 60, 0.18);

    --font-heading: 'Playfair Display', serif;
    --font-body: 'Inter', sans-serif;
    --font-script: 'Dancing Script', cursive;
}

body {
    background-color: var(--bg-color);
    background-image: radial-gradient(ellipse at 50% 30%, #ffe8ee 0%, var(--bg-color) 65%);
    color: var(--text-main);
    font-family: var(--font-body);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
    /* prevent pull-to-refresh on mobile */
    overscroll-behavior: none;
    touch-action: pan-y;
}

.background-decor {
    position: fixed;
    inset: 0;
    background-image: url('data:image/svg+xml;utf8,<svg width="40" height="40" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg"><circle cx="2" cy="2" r="1.2" fill="%23d4a3b3" opacity="0.25"/></svg>');
    z-index: -1;
    pointer-events: none;
}

/* =========================================
   Layout
   ========================================= */
.scrapbook-container {
    display: flex;
    align-items: center;
    gap: 24px;
    position: relative;
}

/* =========================================
   Nav Buttons
   ========================================= */
.nav-btn {
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(8px);
    border: 1.5px solid rgba(212,163,179,0.5);
    color: var(--accent);
    font-size: 1.6rem;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    box-shadow: 0 4px 12px var(--shadow);
    flex-shrink: 0;
}

.nav-btn:hover:not(:disabled) {
    background: white;
    transform: scale(1.1);
    box-shadow: 0 6px 18px var(--shadow);
}

.nav-btn:disabled {
    opacity: 0.2;
    cursor: not-allowed;
    transform: none;
}

/* =========================================
   Book
   ========================================= */
.book {
    position: relative;
    width: 480px;
    height: 620px;
    perspective: 1800px;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.book.open {
    transform: translateX(240px);
}

/* =========================================
   Pages
   ========================================= */
.page {
    position: absolute;
    inset: 0;
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: transform 1s cubic-bezier(0.645, 0.045, 0.355, 1);
    cursor: pointer;
}

.page.flipped {
    transform: rotateY(-180deg);
}

/* Page Faces */
.front, .back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.front {
    border-radius: 6px 16px 16px 6px;
    box-shadow: 4px 0 12px rgba(0,0,0,0.08);
}

.back {
    transform: rotateY(180deg);
    border-radius: 16px 6px 6px 16px;
    box-shadow: -4px 0 12px rgba(0,0,0,0.08);
}

/* =========================================
   Cover
   ========================================= */
.cover {
    background: linear-gradient(145deg, var(--book-cover) 0%, var(--book-cover-dark) 100%);
    color: white;
}

.cover-content {
    text-align: center;
    border: 2px solid rgba(255,255,255,0.35);
    padding: 30px 25px;
    border-radius: 12px;
    width: 88%;
    height: 88%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.06);
    backdrop-filter: blur(2px);
}

.cover-label {
    font-family: var(--font-script);
    font-size: 1.8rem;
    opacity: 0.9;
}

.cover h1 {
    font-family: var(--font-heading);
    font-size: 3.4rem;
    font-style: italic;
    line-height: 1.1;
    text-shadow: 1px 2px 6px rgba(0,0,0,0.15);
}

.cover .subtitle {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    opacity: 0.8;
}

.decorative-line {
    width: 60px;
    height: 2px;
    background: linear-gradient(to right, transparent, var(--gold), transparent);
    margin: 10px auto;
}

.instruction {
    font-family: var(--font-script);
    font-size: 1.4rem;
    margin-top: auto;
    animation: pulse 2.2s ease-in-out infinite;
}

.back-cover .cover-label {
    font-size: 2rem;
    margin-top: 15px;
}

.heart-icon {
    font-size: 5rem;
    color: var(--gold);
    text-shadow: 0 0 20px rgba(212,175,55,0.4);
    animation: heartbeat 1.8s ease-in-out infinite;
}

/* =========================================
   Inner Pages
   ========================================= */
.inner-page {
    background-color: var(--book-page);
    background-image: linear-gradient(to right, rgba(0,0,0,0.04) 0%, transparent 6%);
    border: 1px solid rgba(212,163,179,0.2);
    padding: 24px 22px 22px;
    gap: 14px;
}

.back.inner-page {
    background-image: linear-gradient(to left, rgba(0,0,0,0.04) 0%, transparent 6%);
    padding: 30px 28px;
    justify-content: center;
}

/* Page Title */
.page-title {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    color: var(--accent);
    font-style: italic;
    text-align: center;
    width: 100%;
    border-bottom: 1px solid rgba(212,163,179,0.4);
    padding-bottom: 8px;
    flex-shrink: 0;
}

/* =========================================
   Polaroid Grid
   ========================================= */
.polaroid-grid {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    width: 100%;
    flex: 1;
    padding: 4px 0;
}

/* 2-photo grid */
.grid-2 .polaroid {
    width: 210px;
}

.grid-2 .polaroid img {
    width: 185px;
    height: 225px;
}

/* 3-photo grid */
.grid-3 {
    gap: 8px;
}

.grid-3 .polaroid {
    width: 148px;
}

.grid-3 .polaroid img {
    width: 126px;
    height: 160px;
}

.grid-3 .polaroid .caption {
    font-size: 0.9rem;
}

/* Polaroid card */
.polaroid {
    background: white;
    padding: 10px 10px 32px 10px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.12), 0 2px 4px rgba(0,0,0,0.06);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    flex-shrink: 0;
}

.polaroid img {
    display: block;
    object-fit: cover;
    background-color: #f0e8ea;
}

.polaroid .caption {
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    text-align: center;
    margin-top: 10px;
    color: var(--text-main);
    line-height: 1.3;
}


.polaroid:hover {
    transform: scale(1.07) rotate(0deg) !important;
    box-shadow: 0 12px 28px rgba(0,0,0,0.18);
    z-index: 20;
}

.tilt-left  { transform: rotate(-4deg); }
.tilt-right { transform: rotate(3.5deg); }

/* =========================================
   Text Content
   ========================================= */
h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--accent);
    margin-bottom: 18px;
    font-style: italic;
}

h3 {
    font-family: var(--font-heading);
    font-size: 1.7rem;
    color: var(--accent);
    margin-bottom: 16px;
    font-style: italic;
}

p {
    font-size: 0.98rem;
    line-height: 1.85;
    margin-bottom: 12px;
    color: var(--text-main);
}

.message-content, .memory-note {
    width: 100%;
}

.signature {
    font-family: var(--font-script);
    font-size: 2rem;
    color: var(--accent);
    text-align: right;
    margin-top: 24px;
}

.note-tag {
    font-size: 0.82rem;
    color: var(--text-light);
    margin-top: 8px;
    font-style: italic;
}

.final-message {
    text-align: left;
    padding: 30px;
}

/* Mobile Nav Bar (hidden on desktop, shown via JS on small screens) */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    background: rgba(255,255,255,0.75);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(212,163,179,0.35);
    border-radius: 50px;
    padding: 6px 16px;
    box-shadow: 0 4px 16px var(--shadow);
    gap: 16px;
}

.mobile-nav .page-indicator {
    position: static;
    transform: none;
    font-size: 0.85rem;
}

.love-list-page {
    justify-content: center;
}

.love-list-content {
    width: 100%;
}

.love-list-content h3 {
    margin-bottom: 20px;
}

.love-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.love-list li {
    font-size: 0.93rem;
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(212, 163, 179, 0.1);
    border-left: 3px solid var(--book-cover);
    line-height: 1.4;
    transition: background 0.2s ease;
}

.love-list li:hover {
    background: rgba(212, 163, 179, 0.2);
}

/* =========================================
   Page Indicator
   ========================================= */
.page-indicator {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-heading);
    font-size: 0.9rem;
    color: var(--text-light);
    letter-spacing: 1px;
    font-style: italic;
    z-index: 10;
}

/* =========================================
   Spotify Player
   ========================================= */
.spotify-player {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 320px;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(14px);
    border-radius: 18px;
    border: 1px solid rgba(212,163,179,0.3);
    box-shadow: 0 8px 32px rgba(100,50,60,0.15);
    overflow: hidden;
    z-index: 100;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.spotify-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(212,163,179,0.2);
}

.spotify-icon {
    font-size: 1.1rem;
    color: var(--accent);
}

.spotify-label {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-style: italic;
    color: var(--text-main);
    flex: 1;
}

.spotify-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-light);
    line-height: 1;
    transition: transform 0.3s ease;
    padding: 2px 4px;
}

.spotify-player.minimized .spotify-toggle {
    transform: rotate(180deg);
}

.spotify-embed {
    padding: 10px 10px 6px;
    transition: all 0.35s ease;
    overflow: hidden;
    max-height: 380px;
}

.spotify-player.minimized .spotify-embed {
    max-height: 0;
    padding: 0 10px;
}

.spotify-open-link {
    font-size: 0.78rem;
    color: var(--text-main);
    text-decoration: none;
    background: rgba(128, 0, 32, 0.08);
    padding: 4px 10px;
    border-radius: 14px;
    margin-right: 6px;
    font-weight: 600;
    transition: background 0.2s;
}

.spotify-open-link:hover {
    background: rgba(128, 0, 32, 0.18);
}

/* =========================================
   Animations
   ========================================= */
@keyframes pulse {
    0%, 100% { opacity: 0.6; transform: scale(0.98); }
    50%       { opacity: 1;   transform: scale(1.02); }
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    20%      { transform: scale(1.15); }
    40%      { transform: scale(1); }
    60%      { transform: scale(1.08); }
    80%      { transform: scale(1); }
}

/* =========================================
   Responsive
   ========================================= */

/* ── Tablet (601px – 900px) ── */
@media (max-width: 900px) {
    .scrapbook-container { gap: 16px; }

    .book { width: 380px; height: 530px; }
    .book.open { transform: translateX(190px); }

    .nav-btn { width: 44px; height: 44px; font-size: 1.3rem; }

    .cover h1 { font-size: 2.8rem; }
    h2 { font-size: 1.8rem; }
    h3 { font-size: 1.5rem; }

    /* Polaroid sizes for tablet */
    .grid-2 .polaroid { width: 166px; }
    .grid-2 .polaroid img { width: 142px; height: 195px; object-fit: cover; }

    .grid-3 .polaroid { width: 114px; }
    .grid-3 .polaroid img { width: 96px; height: 135px; object-fit: cover; }

    .spotify-player { width: 290px; }
}

/* ═══════════════════════════════════════════
   Mobile (≤ 600px) — Book-like full-screen
   ═══════════════════════════════════════════ */
@media (max-width: 600px) {

    body {
        overflow: hidden;
        height: 100svh;
        /* warm "table" backdrop so the book pops */
        background: #c9a07a;
        background-image: radial-gradient(ellipse at 50% 30%, #d4a57a 0%, #a0724a 100%);
    }

    .scrapbook-container {
        width: 100vw;
        height: 100svh;
        gap: 0;
        position: relative;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding-bottom: 68px; /* room for nav pill */
    }

    /* ── Book looks like a real pocket book ── */
    .book {
        position: relative !important;
        width: calc(100vw - 28px) !important;
        height: calc(100svh - 100px) !important;
        max-width: none !important;
        max-height: none !important;
        min-height: unset !important;
        /* Spine: flat left edge, rounded right (like real book pages) */
        border-left: 10px solid #5a0e1f !important;
        border-radius: 2px 14px 14px 2px !important;
        /* Realistic book depth shadows */
        box-shadow:
            inset 12px 0 22px rgba(0,0,0,0.18),
            6px 10px 32px rgba(0,0,0,0.4),
            -2px 2px 10px rgba(0,0,0,0.25) !important;
        /* Perspective for the page-turn 3D effect */
        perspective: 900px !important;
        transform-style: flat !important;
        transform: none !important;
        transition: none !important;
        overflow: hidden;
        background: #faf8f4; /* fallback page colour */
    }
    .book.open { transform: none !important; }

    /* ── Pages: stack on top of each other, only active shows ── */
    .page {
        position: absolute;
        inset: 0;
        /* Default: hidden off-screen to the right, slightly rotated */
        transform: translateX(105%) rotateY(8deg);
        transform-origin: center center;
        transform-style: flat !important;
        transition: transform 0.42s cubic-bezier(0.4, 0, 0.2, 1),
                    opacity   0.30s ease;
        opacity: 0;
        pointer-events: none;
        z-index: 0;
        cursor: default !important;
    }

    /* Active page: flat, facing viewer */
    .page.mobile-active {
        transform: translateX(0) rotateY(0deg);
        opacity: 1;
        pointer-events: all;
        z-index: 10;
    }

    /* Forward exit: slides left and folds slightly away */
    .page.slide-exit-fwd {
        transform: translateX(-30%) rotateY(-6deg) scale(0.97);
        opacity: 0;
        z-index: 5;
    }

    /* Backward exit: slides right (same as initial hidden state) */
    .page.slide-exit-bwd {
        transform: translateX(105%) rotateY(8deg);
        opacity: 0;
        z-index: 5;
    }

    /* ── Page faces fill the entire book ── */
    .front, .back {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        /* Kill the 3D backface hiding — we control visibility via display */
        backface-visibility: visible !important;
        -webkit-backface-visibility: visible !important;
        transform: none !important;
        /* Scrollable */
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        /* Layout */
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start !important;
        gap: 16px;
        border-radius: 0 12px 12px 0 !important;
        box-shadow: none !important;
        padding: 24px 20px 96px !important;
        scroll-padding-top: 24px !important;
    }

    /* Face visibility: JS adds these classes to the active page */
    .page.mobile-face-front .back  { display: none; }
    .page.mobile-face-back  .front { display: none; }

    /* ── Cover page stays centered ── */
    .front.cover {
        justify-content: center !important;
        padding-bottom: 88px;
    }
    .cover-content {
        width: 84%;
        max-width: 300px;
    }

    /* ── Inner pages: warm paper feel with spine shadow ── */
    .inner-page {
        background: linear-gradient(
            to right,
            #e8d2b8 0%, #f0e6d8 6%, #faf8f4 14%, #faf8f4 100%
        ) !important;
        justify-content: flex-start !important;
    }
    .back.inner-page {
        background: #faf8f4 !important;
        padding: 24px 20px 96px !important;
        justify-content: flex-start !important;
    }

    /* ── Typography ── */
    .cover h1    { font-size: 2.6rem; }
    .cover-label { font-size: 1.5rem; }
    h2 { font-size: 1.7rem; }
    h3 { font-size: 1.35rem; }
    p  { font-size: 0.95rem; line-height: 1.65; }
    .page-title { font-size: 1.15rem; width: 100%; }
    .signature  { font-size: 1.7rem; }

    /* ── Polaroids: stack vertically, big and readable ── */
    .polaroid-grid {
        flex-direction: column;
        align-items: center;
        gap: 20px;
        width: 100%;
        padding: 4px 0;
        overflow: visible;
        flex: none;
    }

    .grid-2 .polaroid,
    .grid-3 .polaroid,
    .polaroid {
        width: 90%;
        max-width: 340px;
        padding: 12px 12px 38px;
    }

    /* Images fill the card width with a taller portrait ratio */
    .polaroid img,
    .grid-2 .polaroid img,
    .grid-3 .polaroid img {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 3 / 4 !important;
        object-fit: cover;
        object-position: center top;
    }

    .polaroid .caption,
    .grid-2 .polaroid .caption,
    .grid-3 .polaroid .caption {
        font-size: 1rem;
        margin-top: 10px;
    }

    /* ── Love list ── */
    .love-list li { font-size: 0.9rem; padding: 7px 12px; }

    /* ── Memory note ── */
    .memory-note { width: 100%; }

    /* ── Mobile nav pill ── */
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 14px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 200;
        background: rgba(255,255,255,0.88);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        border: 1px solid rgba(212,163,179,0.45);
        border-radius: 50px;
        padding: 8px 22px;
        box-shadow: 0 4px 20px rgba(90,14,31,0.18);
        gap: 20px;
        align-items: center;
        justify-content: center;
        min-width: 180px;
    }

    .mobile-nav .nav-btn {
        display: flex !important;
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }

    .mobile-nav .page-indicator {
        position: static;
        transform: none;
        font-size: 0.85rem;
        color: var(--accent);
        font-weight: 500;
    }

    /* ── Spotify: minimised, sits above nav pill ── */
    .spotify-player {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 70px;
        left: auto;
        z-index: 1000 !important;
    }

    /* Hide the desktop indicator */
    #page-indicator { display: none; }
}

/* ── Small Mobile (≤ 380px) ── */
@media (max-width: 380px) {
    .cover h1 { font-size: 2.1rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.2rem; }
    .polaroid, .grid-2 .polaroid, .grid-3 .polaroid { width: 94%; max-width: 320px; }
    .book { border-left-width: 8px !important; }
}


