/**
 * FotoDigital Photobook - 3D Preview Styles
 * CSS3 3D transforms per l'anteprima libro sfogliabile.
 */

/* ── OVERLAY ──────────────────────────────────────────── */

.pb3d-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    animation: pb3d-fadeIn 0.3s ease forwards;
}

@keyframes pb3d-fadeIn {
    to { opacity: 1; }
}

.pb3d-overlay.pb3d-closing {
    animation: pb3d-fadeOut 0.25s ease forwards;
}

@keyframes pb3d-fadeOut {
    to { opacity: 0; }
}

/* ── TOOLBAR ──────────────────────────────────────────── */

.pb3d-toolbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 0 16px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 10;
}

.pb3d-page-indicator {
    color: #ddd;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.3px;
    user-select: none;
}

.pb3d-goto-btn {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.pb3d-goto-btn:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.45);
}

.pb3d-close-btn {
    position: absolute;
    right: 12px;
    top: 6px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pb3d-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ── BOOK CONTAINER ───────────────────────────────────── */

.pb3d-book-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    width: 100%;
    max-width: 1100px;
    padding: 0 60px;
    box-sizing: border-box;
}

/* ── BOOK ─────────────────────────────────────────────── */

.pb3d-book {
    position: relative;
    display: flex;
    perspective: 1500px;
    transform-style: preserve-3d;
}

/* Shadow under book */
.pb3d-book::after {
    content: '';
    position: absolute;
    bottom: -18px;
    left: 5%;
    right: 5%;
    height: 20px;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0.45) 0%, transparent 70%);
    pointer-events: none;
}

/* Spine / center shadow */
.pb3d-book-spine {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 6px;
    margin-left: -3px;
    background: linear-gradient(to right, rgba(0,0,0,0.3), rgba(0,0,0,0.08), rgba(0,0,0,0.3));
    z-index: 5;
    pointer-events: none;
}

/* ── PAGE ─────────────────────────────────────────────── */

.pb3d-page {
    position: relative;
    width: 340px;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform-style: preserve-3d;
}

.pb3d-page-inner {
    width: 100%;
    height: 100%;
    position: relative;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.pb3d-page img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pb3d-page-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    color: #bbb;
    font-size: 13px;
    user-select: none;
}

/* Left page: slight inner shadow on the right edge */
.pb3d-page.pb3d-left {
    border-radius: 3px 0 0 3px;
    transform-origin: right center;
}

.pb3d-page.pb3d-left::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to left, rgba(0,0,0,0.08), transparent);
    pointer-events: none;
    z-index: 2;
}

/* Right page: slight inner shadow on the left edge */
.pb3d-page.pb3d-right {
    border-radius: 0 3px 3px 0;
    transform-origin: left center;
}

.pb3d-page.pb3d-right::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to right, rgba(0,0,0,0.08), transparent);
    pointer-events: none;
    z-index: 2;
}

/* ── COVER EFFECT ─────────────────────────────────────── */

.pb3d-page.pb3d-cover {
    box-shadow: 0 3px 16px rgba(0, 0, 0, 0.35);
}

.pb3d-page.pb3d-cover.pb3d-left {
    border-left: 4px solid #8b7355;
}

.pb3d-page.pb3d-cover.pb3d-right {
    border-right: 4px solid #8b7355;
}

/* ── PAGE FLIP ANIMATION ─────────────────────────────── */

.pb3d-flip-container {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    transform-style: preserve-3d;
    z-index: 10;
}

.pb3d-flip-container.pb3d-flip-right {
    right: 0;
    left: auto;
    transform-origin: left center;
}

.pb3d-flip-container.pb3d-flip-left {
    left: 0;
    right: auto;
    transform-origin: right center;
}

.pb3d-flip-front,
.pb3d-flip-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    background: #fff;
    overflow: hidden;
}

.pb3d-flip-front img,
.pb3d-flip-back img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pb3d-flip-back {
    transform: rotateY(180deg);
}

/* Forward flip: right page folds to the left */
.pb3d-flip-container.pb3d-flipping-forward {
    animation: pb3d-flipForward 0.6s ease-in-out forwards;
}

@keyframes pb3d-flipForward {
    0%   { transform: rotateY(0deg); }
    100% { transform: rotateY(-180deg); }
}

/* Backward flip: left page folds to the right */
.pb3d-flip-container.pb3d-flipping-backward {
    animation: pb3d-flipBackward 0.6s ease-in-out forwards;
}

@keyframes pb3d-flipBackward {
    0%   { transform: rotateY(0deg); }
    100% { transform: rotateY(180deg); }
}

/* Shadow on the page during flip */
.pb3d-flip-shadow {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.3s;
}

.pb3d-flipping-forward .pb3d-flip-shadow,
.pb3d-flipping-backward .pb3d-flip-shadow {
    opacity: 1;
    background: linear-gradient(to right, rgba(0,0,0,0.15), transparent 60%);
}

/* ── NAV ARROWS ───────────────────────────────────────── */

.pb3d-nav {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.pb3d-nav:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.08);
}

.pb3d-nav:active {
    transform: scale(0.95);
}

.pb3d-nav:disabled {
    opacity: 0.25;
    cursor: default;
    transform: none;
}

.pb3d-nav:disabled:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* ── RESPONSIVE ───────────────────────────────────────── */

@media (max-width: 900px) {
    .pb3d-book-container {
        gap: 12px;
        padding: 0 12px;
    }

    .pb3d-page {
        width: 42vw;
    }

    .pb3d-nav {
        width: 36px;
        height: 36px;
        font-size: 22px;
    }
}

@media (max-width: 600px) {
    .pb3d-book-container {
        gap: 6px;
        padding: 0 6px;
    }

    .pb3d-page {
        width: 46vw;
    }

    .pb3d-toolbar {
        height: 44px;
        gap: 8px;
        padding: 0 8px;
    }

    .pb3d-page-indicator {
        font-size: 12px;
    }

    .pb3d-goto-btn {
        font-size: 11px;
        padding: 4px 10px;
    }

    .pb3d-close-btn {
        width: 34px;
        height: 34px;
        font-size: 24px;
    }

    .pb3d-nav {
        width: 30px;
        height: 30px;
        font-size: 18px;
    }
}
