/* ==========================================================================
   JOBITRA TEMPLATE #5: THE BIRTHDAY STORYBOOK
   Style Sheet - Digital Storybook & Premium Stationery Experience
   ========================================================================== */

/* 1. COLOR VARIABLES & THEME PRESETS */
:root {
    --ivory: #FFFDF7;
    --paper: #FFF8ED;
    --cream: #FFF1D8;
    --soft-peach: #F9DCCB;
    --dusty-rose: #E8A7B5;
    --terracotta: #C97962;
    --sage: #A8B99A;
    --muted-blue: #AFCFE0;
    --lavender: #D9CBE8;
    --champagne: #D9B96E;
    
    --bg-app: #F4ECE1;
    --bg-book: #FFFDF7;
    --bg-page: #FFF8ED;
    
    --text-primary: #4B403B;
    --text-secondary: #7C6E67;
    --text-muted: #A3968F;
    
    --border-paper: #EADECB;
    --border-gold: #D9B96E;
    
    --accent: var(--terracotta);
    --accent-light: var(--soft-peach);
    
    --font-heading: 'Cormorant Garamond', Georgia, serif;
    --font-handwriting: 'Caveat', cursive;
    --font-body: 'Poppins', -apple-system, sans-serif;
    
    --shadow-book: 0 24px 70px rgba(75, 64, 59, 0.16), 0 0 0 12px rgba(255, 248, 237, 0.9);
    --shadow-paper: 0 8px 24px rgba(75, 64, 59, 0.06);
    --shadow-photo: 0 10px 25px rgba(75, 64, 59, 0.12);
    
    --radius-sm: 6px;
    --radius-md: 14px;
    --radius-lg: 24px;
    --radius-full: 9999px;
    
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-page: 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* AGE THEME ACCENT PRESETS */
.theme-ivory-peach { --accent: var(--terracotta); --bg-page: #FFF8ED; }
.theme-baby-storybook { --accent: var(--dusty-rose); --bg-page: #FFFDF7; }
.theme-kids-adventure { --accent: var(--champagne); --bg-page: #FFF5E6; }
.theme-teen-chapter { --accent: var(--muted-blue); --bg-page: #F5FAFD; }
.theme-milestone-legacy { --accent: var(--sage); --bg-page: #F6F9F3; }

/* 2. BASE RESET & BODY SETUP */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-app);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

img { max-width: 100%; height: auto; display: block; }
button, input, textarea { font-family: inherit; font-size: inherit; }

/* 3. DESKTOP BACKDROP & STORYBOOK STAGE */
.storybook-app-container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    background-color: var(--bg-app);
    background-image: radial-gradient(var(--champagne) 0.5px, transparent 0.5px);
    background-size: 20px 20px;
}

.storybook-stage {
    width: 100%;
    max-width: 460px; /* Mobile Viewport Width */
    min-height: 720px;
    background-color: var(--bg-book);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-book);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    perspective: 1200px;
    border: 2px solid var(--border-gold);
}

/* DESKTOP OPEN BOOK LAYOUT (Side-By-Side 2 Pages) */
@media (min-width: 960px) {
    .storybook-stage {
        max-width: 1020px; /* Dual-Page Desktop Width */
        min-height: 680px;
    }
    
    .desktop-only { display: block !important; }
    
    .book-pages-viewport {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0;
    }
    
    .book-spine-line {
        display: block;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 50%;
        width: 16px;
        transform: translateX(-50%);
        background: linear-gradient(to right, rgba(0,0,0,0.06), rgba(0,0,0,0.15) 50%, rgba(0,0,0,0.06));
        z-index: 20;
        pointer-events: none;
    }
}

@media (max-width: 959px) {
    .desktop-only { display: none !important; }
    .book-spine-line { display: none; }
}

@media (max-width: 480px) {
    .storybook-app-container { padding: 10px; }
    .storybook-stage { max-width: 100%; min-height: 640px; border-radius: var(--radius-md); }
}

/* FINE PAPER GRAIN OVERLAY */
.paper-grain-overlay {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(var(--text-primary) 0.5px, transparent 0.5px);
    background-size: 12px 12px;
    opacity: 0.03;
    pointer-events: none;
    z-index: 1;
}

/* BOOKMARK RIBBON */
.bookmark-ribbon {
    position: absolute;
    top: 0;
    right: 24px;
    width: 28px;
    height: 65px;
    background-color: var(--terracotta);
    color: #FFFFFF;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 12px;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 85%, 0 100%);
    box-shadow: 0 4px 10px rgba(201, 121, 98, 0.4);
    z-index: 50;
}

.ribbon-text {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
}

/* CONTENTS BUTTON TRIGGER */
.btn-contents-trigger {
    position: absolute;
    top: 16px;
    left: 16px;
    background-color: var(--paper);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-full);
    padding: 6px 14px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--text-primary);
    cursor: pointer;
    z-index: 50;
    box-shadow: var(--shadow-paper);
}

.btn-contents-trigger:hover { background-color: var(--cream); }

/* 4. COVER VIEW (SCREEN 1) */
.book-cover-view {
    position: absolute;
    inset: 0;
    background-color: var(--bg-page);
    padding: 24px;
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: transform var(--transition-page), opacity var(--transition-page);
}

.cover-active .book-cover-view { transform: rotateY(0deg); opacity: 1; }
.book-cover-view.closed { transform: rotateY(-100deg); opacity: 0; pointer-events: none; }

.cover-embossed-border {
    flex: 1;
    border: 2px solid var(--border-gold);
    border-radius: var(--radius-md);
    padding: 32px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    background-color: var(--ivory);
    box-shadow: inset 0 0 0 4px var(--cream);
}

.cover-corner {
    position: absolute;
    width: 16px;
    height: 16px;
    border-color: var(--border-gold);
    border-style: solid;
}

.corner-tl { top: 8px; left: 8px; border-width: 2px 0 0 2px; }
.corner-tr { top: 8px; right: 8px; border-width: 2px 2px 0 0; }
.corner-bl { bottom: 8px; left: 8px; border-width: 0 0 2px 2px; }
.corner-br { bottom: 8px; right: 8px; border-width: 0 2px 2px 0; }

.cover-kicker {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.25em;
    color: var(--terracotta);
    display: block;
    margin-bottom: 6px;
}

.cover-person-name {
    font-family: var(--font-heading);
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.cover-subtitle {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    color: var(--text-secondary);
    margin-top: 4px;
}

.cover-portrait-frame {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    border: 2px solid var(--border-gold);
    padding: 4px;
    background-color: var(--paper);
    margin: 20px 0;
    box-shadow: var(--shadow-photo);
}

.cover-portrait-frame img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.cover-age-badge {
    font-family: var(--font-heading);
    font-size: 3.2rem;
    font-weight: 700;
    color: var(--terracotta);
    line-height: 1;
    margin-bottom: 20px;
}

.btn-open-storybook {
    background-color: var(--terracotta);
    color: #FFFFFF;
    border: none;
    border-radius: var(--radius-full);
    padding: 14px 32px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(201, 121, 98, 0.3);
    transition: transform var(--transition-fast);
}

.btn-open-storybook:hover { transform: scale(1.05); }

.btn-skip-cover {
    background: none;
    border: none;
    font-size: 0.72rem;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: underline;
    margin-top: 14px;
}

/* 5. BOOK PAGES VIEWPORT & 3D TURN ENGINE */
.book-pages-viewport {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-page);
    padding: 60px 24px 70px 24px;
}

.page-turn-wrapper {
    flex: 1;
    display: flex;
    gap: 0;
    position: relative;
    transform-style: preserve-3d;
}

.storybook-page-sheet {
    flex: 1;
    background-color: var(--bg-page);
    border-radius: var(--radius-sm);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: var(--shadow-paper);
    backface-visibility: hidden;
    transition: transform var(--transition-page);
}

.page-inner-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.page-number-footer {
    position: absolute;
    bottom: 12px;
    right: 20px;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* PAGE NAVIGATION CONTROLS (BOTTOM BAR) */
.book-bottom-nav {
    position: absolute;
    bottom: 16px;
    left: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 30;
}

.nav-arrow-btn {
    background-color: var(--paper);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-full);
    padding: 8px 18px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.nav-arrow-btn:hover { background-color: var(--cream); }
.nav-arrow-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.page-counter-badge {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--terracotta);
}

/* 6. PAGE TYPES & STORYBOOK DESIGN ELEMENTS */
.storybook-page-title {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: 12px;
    text-align: center;
}

.storybook-page-kicker {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.25em;
    color: var(--terracotta);
    display: block;
    text-align: center;
    margin-bottom: 4px;
}

/* PAGE 1: INVITATION */
.invitation-page-body {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.invitation-name-giant {
    font-family: var(--font-heading);
    font-size: 2.6rem;
    font-weight: 700;
    color: var(--text-primary);
}

.invitation-age-huge {
    font-family: var(--font-heading);
    font-size: 5rem;
    font-weight: 700;
    color: var(--terracotta);
    line-height: 0.9;
    margin: 8px 0;
}

.invitation-date-pill {
    background-color: var(--cream);
    border: 1px solid var(--border-gold);
    padding: 8px 20px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 14px;
}

/* PAGE 2: MEET THE STAR & HANDWRITTEN ANNOTATIONS */
.star-profile-page {
    text-align: center;
    position: relative;
}

.star-photo-frame {
    position: relative;
    width: 160px;
    height: 190px;
    margin: 0 auto 16px auto;
    background-color: #FFFFFF;
    padding: 8px 8px 24px 8px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-photo);
    transform: rotate(-1.5deg);
}

.star-photo-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.handwritten-annotation {
    position: absolute;
    font-family: var(--font-handwriting);
    font-size: 1.25rem;
    color: var(--terracotta);
    white-space: nowrap;
}

.anno-1 { top: -10px; left: -30px; transform: rotate(-8deg); }
.anno-2 { bottom: 10px; right: -25px; transform: rotate(6deg); }

/* PAGE 3: THE STORY SO FAR */
.storybook-text-body {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-primary);
    text-align: justify;
}

.first-letter-drop {
    font-size: 3rem;
    font-weight: 700;
    color: var(--terracotta);
    float: left;
    line-height: 0.8;
    padding-right: 8px;
}

/* PAGE 4: PHOTO ALBUM */
.photo-album-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.album-photo-card {
    background-color: #FFFFFF;
    padding: 8px 8px 16px 8px;
    border-radius: 4px;
    box-shadow: var(--shadow-photo);
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.album-photo-card:hover { transform: scale(1.03); }
.album-photo-card:nth-child(odd) { transform: rotate(-2deg); }
.album-photo-card:nth-child(even) { transform: rotate(2deg); }

.album-img-box { width: 100%; aspect-ratio: 1; overflow: hidden; }
.album-img-box img { width: 100%; height: 100%; object-fit: cover; }
.album-caption { font-family: var(--font-handwriting); font-size: 1.1rem; color: var(--text-primary); text-align: center; margin-top: 4px; }

/* PAGE 8: INSERTED EVENT TICKET */
.event-pass-inserted-card {
    background-color: var(--cream);
    border: 2px dashed var(--border-gold);
    border-radius: var(--radius-md);
    padding: 20px 16px;
    text-align: center;
    box-shadow: var(--shadow-paper);
    position: relative;
}

.event-pass-title { font-family: var(--font-heading); font-size: 1.3rem; font-weight: 700; color: var(--terracotta); }
.event-pass-val { font-family: var(--font-heading); font-size: 1.15rem; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }

/* BUTTONS */
.btn-storybook {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    width: 100%;
}

.btn-primary { background-color: var(--terracotta); color: #FFFFFF; }
.btn-secondary { background-color: var(--paper); border: 1px solid var(--border-gold); color: var(--text-primary); }

/* 7. WISH WALL & RSVP PAGES */
.storybook-form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.storybook-input {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-paper);
    background-color: var(--ivory);
    color: var(--text-primary);
    outline: none;
}

.storybook-input:focus { border-color: var(--terracotta); background-color: #FFFFFF; }

.rsvp-options { display: flex; gap: 8px; }
.rsvp-opt-btn {
    flex: 1;
    padding: 10px 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-paper);
    background-color: var(--paper);
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
}

.rsvp-opt-btn.active { background-color: var(--cream); border-color: var(--terracotta); color: var(--terracotta); }

/* 8. MODALS & FLOATING CONTROLS */
.contents-modal-backdrop,
.surprise-modal-backdrop,
.lightbox-backdrop,
.share-sheet-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(75, 64, 59, 0.65);
    backdrop-filter: blur(6px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.contents-modal-backdrop.active,
.surprise-modal-backdrop.active,
.lightbox-backdrop.active,
.share-sheet-backdrop.active { display: flex; }

.contents-paper-card,
.surprise-paper-card {
    width: 100%;
    max-width: 400px;
    background-color: var(--bg-page);
    border-radius: var(--radius-lg);
    border: 2px solid var(--border-gold);
    padding: 28px 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}

.contents-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.btn-close-contents, .btn-close-sheet, .lightbox-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; }

.contents-list { display: flex; flex-direction: column; gap: 8px; }
.contents-item-btn {
    display: flex;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    background-color: var(--ivory);
    border: 1px solid var(--border-paper);
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
}

.contents-item-btn:hover { background-color: var(--cream); border-color: var(--terracotta); }

/* FLOATING BUTTONS */
.music-bookmark-fab, .share-fab {
    position: fixed;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--paper);
    border: 1.5px solid var(--border-gold);
    color: var(--terracotta);
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999;
}

.music-bookmark-fab { bottom: 20px; left: 20px; }
.share-fab { bottom: 20px; left: 72px; }

.music-bars { display: flex; gap: 2px; align-items: flex-end; height: 12px; margin-left: 3px; }
.m-bar { width: 2px; background-color: var(--terracotta); border-radius: 1px; }
.m-1 { height: 6px; } .m-2 { height: 12px; } .m-3 { height: 8px; }

.music-bookmark-fab.playing .m-1 { animation: mwave 0.8s infinite alternate; }
.music-bookmark-fab.playing .m-2 { animation: mwave 0.6s infinite alternate; }
.music-bookmark-fab.playing .m-3 { animation: mwave 1s infinite alternate; }

@keyframes mwave { 0% { height: 4px; } 100% { height: 12px; } }

/* DEMO SWITCHER WIDGET */
.demo-widget { position: fixed; top: 16px; left: 16px; z-index: 999; }
.demo-widget-toggle { background-color: var(--text-primary); color: #FFFFFF; border: none; padding: 6px 12px; border-radius: var(--radius-full); font-size: 0.68rem; font-weight: 700; cursor: pointer; }
.demo-panel { display: none; position: absolute; top: 38px; left: 0; width: 300px; background-color: #FFFFFF; border-radius: var(--radius-md); border: 1px solid var(--border-paper); box-shadow: 0 16px 40px rgba(0,0,0,0.15); padding: 14px; }
.demo-panel.active { display: block; }
.demo-panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.btn-close-demo { background: none; border: none; font-size: 1.2rem; cursor: pointer; }

.lang-selector-group { display: flex; gap: 6px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border-paper); }
.lang-label { font-size: 0.68rem; font-weight: 700; }
.lang-btn { padding: 4px 8px; border-radius: 4px; border: 1px solid var(--border-paper); background-color: var(--paper); font-size: 0.65rem; cursor: pointer; }
.lang-btn.active { background-color: var(--terracotta); color: #FFFFFF; border-color: var(--terracotta); }

.demo-preset-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; max-height: 200px; overflow-y: auto; }
.preset-btn { padding: 6px; border-radius: 4px; border: 1px solid var(--border-paper); background-color: var(--paper); font-size: 0.68rem; cursor: pointer; text-align: left; }
.preset-btn.active { background-color: var(--cream); border-color: var(--border-gold); }

#confetti-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 9999; }
