/* START: Scrapbook / Photo Gallery */

/* ── Wrapper ─────────────────────────────── */
#scrapbook-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 8px 0 4px;
}

/* ── Book shell ──────────────────────────── */
.sb-book {
    position: relative;
    width: 100%;
    max-width: 560px;
    overflow: visible;
    perspective: 1400px;
}

/* ── Spread (two pages + spine) ─────────── */
.sb-spread {
    display: flex;
    align-items: stretch;
    border-radius: 4px;
    overflow: visible;
}

/* ── Individual pages ────────────────────── */
.sb-page {
    flex: 1;
    position: relative;
    min-height: 260px; /* mobile default — shorter so spread looks wider like a book */
    overflow: hidden;
    z-index: 1;
}

.sb-left {
    background: url('../assets/backgrounds/page_1.png') left center / cover no-repeat;
    background-color: #f7edd8;
    border-radius: 4px 0 0 4px;
    box-shadow:
        -3px 3px 0 #e8d9bb,
        -6px 6px 0 #dfd0ae,
        -9px 9px 0 #d5c4a0;
}

.sb-right {
    background: url('../assets/backgrounds/page_1.png') right center / cover no-repeat;
    background-color: #f2e6c8;
    border-radius: 0 4px 4px 0;
    box-shadow:
        3px 3px 0 #e8d9bb,
        6px 6px 0 #dfd0ae,
        9px 9px 0 #d5c4a0;
}

/* Page content — position:relative so polaroids can be absolutely placed */
.sb-page-content {
    position: relative;
    height: 100%;
    min-height: inherit;
}

/* ── Spine (thin crease binding) ────────── */
.sb-spine {
    width: 6px;
    flex-shrink: 0;
    background: linear-gradient(to right,
        rgba(0,0,0,0.12) 0%,
        #d6c29e 40%,
        #d6c29e 60%,
        rgba(0,0,0,0.12) 100%
    );
    box-shadow:
        inset -1px 0 3px rgba(0,0,0,0.18),
        inset  1px 0 3px rgba(0,0,0,0.18);
    position: relative;
    z-index: 3;
    margin-left: -4px;
    margin-right: -4px;
}

/* ── Polaroid ────────────────────────────── */
.sb-polaroid {
    background: #fff;
    padding: 8px 8px 32px;
    box-shadow: 2px 4px 14px rgba(0,0,0,0.28), 0 1px 3px rgba(0,0,0,0.15);
    transform: rotate(var(--rot, 0deg));
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    /* 40% of page width, with sensible floor */
    width: max(130px, 40%);
    box-sizing: border-box;
    /* Hinge from tape at top */
    transform-origin: top center;
}

.sb-polaroid:hover {
    /* Lift bottom toward viewer, hinging off the tape at the top */
    transform: rotate(var(--rot, 0deg)) perspective(600px) rotateX(-14deg);
    box-shadow: 2px 22px 32px rgba(0,0,0,0.38), 0 2px 6px rgba(0,0,0,0.18);
    z-index: 10 !important;
}

.sb-photo-frame {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.sb-photo-missing {
    font-size: 36px;
    color: #bbb;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sb-caption {
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
    text-align: center;
    font-family: 'Georgia', serif;
    font-size: 12px;
    font-style: italic;
    color: #444;
}

.sb-description {
    margin-top: 36px;
    font-family: 'Georgia', serif;
    font-size: 10px;
    font-style: italic;
    color: #666;
    text-align: center;
    line-height: 1.4;
    padding: 0 4px;
}

/* ── Tape decorations ────────────────────── */
.sb-polaroid::before {
    content: '';
    position: absolute;
    background: rgba(210,195,150,0.7);
    border: 1px solid rgba(180,160,110,0.4);
    width: 34px;
    height: 13px;
    border-radius: 2px;
    pointer-events: none;
}
.sb-tape-top-left::before  { top: -7px; left: 16px;  transform: rotate(-8deg); }
.sb-tape-top-right::before { top: -7px; right: 16px; transform: rotate(6deg); }
.sb-tape-center::before    { top: -7px; left: 50%;   transform: translateX(-50%) rotate(1deg); }

/* ── Controls (below the book) ───────────── */
.sb-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 10px;
}

.sb-btn {
    background: var(--surface);
    border: 2px solid var(--border);
    color: var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s ease;
}
.sb-btn:hover:not(:disabled) {
    background: var(--primary);
    color: var(--background);
    transform: scale(1.1);
}
.sb-btn:disabled {
    opacity: 0.25;
    cursor: default;
}

.sb-counter {
    font-family: 'Georgia', serif;
    font-size: 13px;
    color: #999;
    letter-spacing: 1px;
    min-width: 60px;
    text-align: center;
}

/* ── 3D Page flipper ─────────────────────── */
.sb-flipper-face {
    position: absolute;
    inset: 0;
    overflow: hidden;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Back face pre-rotated 180° so it reads correctly when flipped */
.sb-flipper-back {
    transform: rotateY(180deg);
}

/* ── Photo unlock toast ──────────────────── */
.sb-unlock-toast {
    position: fixed;
    bottom: 160px;
    right: 20px;
    background: #2a1a0a;
    border: 2px solid #c8a86b;
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 9999;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
    max-width: 280px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.sb-unlock-toast.sb-unlock-toast-show { transform: translateX(0); }
.sb-unlock-toast img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid #c8a86b;
    flex-shrink: 0;
}
.sb-unlock-title { font-size: 13px; font-weight: bold; color: #c8a86b; }
.sb-unlock-name  { font-size: 15px; font-weight: bold; color: #f5ead8; margin-top: 2px; }
.sb-unlock-sub   { font-size: 11px; color: #999; margin-top: 2px; }

/* ── Mobile photo sizing ─────────────────── */
/* Remove the 130px floor — let photos scale as a clean % of the (small) page width */
@media (max-width: 599px) {
    .sb-polaroid {
        width: 40%;
        padding: 5px 5px 26px;
    }
    .sb-caption {
        font-size: 10px;
        bottom: 5px;
    }
    .sb-description {
        font-size: 9px;
        margin-top: 30px;
    }
}

/* ── Wide modal override (desktop only) ──── */
@media (min-width: 600px) {
    .sb-modal-wide {
        max-width: min(960px, 94vw) !important;
        max-height: calc(100vh - 120px) !important;
        height: calc(100vh - 120px) !important;
        display: flex;
        flex-direction: column;
    }

    #scrapbook-wrap {
        flex: 1;
        overflow-y: auto;
        justify-content: flex-start;
    }

    .sb-book {
        max-width: 100%;
    }

    .sb-page {
        min-height: 460px;
    }
}

/* END: Scrapbook / Photo Gallery */
