/* ============================================================
   eAlbum Flipbook — CSS 3D engine (FlipiX-style)
   No turn.js. Pure CSS perspective/rotateY page flips.
   ============================================================ */

:root {
    --primary: #f4c720;
    --primary-soft: rgba(244, 199, 32, 0.6);
    --bg-1: #000;
    --bg-2: #0d0d0d;
    --text: #ffffff;
    --muted: rgba(255, 255, 255, 0.7);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
*::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; -ms-overflow-style: none; }

a { text-decoration: none; color: inherit; }

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Poppins', 'Inter', system-ui, sans-serif;
    color: var(--text);
    background: var(--bg-1);
    font-size: 16px;
    min-height: 100vh;
}

/* ---------- Background canvas ---------- */
#bg-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* ---------- Header ---------- */
header {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 56px;
    padding: 8px 20px;
    background: linear-gradient(180deg, rgba(23, 26, 29, 0.85), rgba(23, 26, 29, 0.55));
    border-bottom: 1px solid rgba(244, 199, 32, 0.18);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    font-size: 14px;
}

header .badge {
    width: 36px;
    height: 36px;
    object-fit: contain;
    cursor: pointer;
    transition: transform 0.25s;
    border-radius: 6px;
}
header .badge:hover { transform: scale(1.08); }

header .logo {
    flex: 0 1 auto;
    min-width: 0;
}
header .logo h2 {
    font-family: 'Playfair Display', 'Poppins', serif;
    font-size: clamp(0.95rem, 2.2vw, 1.25rem);
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50vw;
}

header .client {
    flex: 1 1 auto;
    display: flex;
    justify-content: center;
    color: var(--primary);
    font-size: 13px;
}
header .client .moving-text {
    text-align: center;
    line-height: 1.3;
}

header .info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    color: var(--muted);
    font-size: 12px;
}
header .info p { display: flex; align-items: center; gap: 6px; margin: 0; }
header .info i { color: var(--primary); }

/* ---------- Main stage ---------- */
.main {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 16px;
    height: calc(100vh - 56px - 56px);
    height: calc(100dvh - 56px - 56px);
}

.v2 {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.v2 img { width: 28px; height: auto; opacity: 0.9; transition: opacity 0.2s; }
.v2 img:hover { opacity: 1; }

/* ---------- Book (CSS 3D) ---------- */
.book {
    margin: 0 auto;
    width: 320px;
    aspect-ratio: 1.5;
    position: relative;
    transition-duration: 1s;
    perspective: 1500px;
    transform: rotateX(-5deg);
}
.book.portrait { width: 200px; }

.book .front-cover,
.book .back-cover {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 0 15px 15px 0;
    box-shadow: 0 0 5px rgb(41, 41, 41);
    transform-origin: left;
    cursor: pointer;
}
.book .front-cover {
    z-index: var(--reverse-count);
    transition: transform 1.5s;
}
.book .back-cover {
    z-index: var(--reverse-count);
    transition: transform 1.5s, z-index 0.5s 0.5s;
}

.book .page {
    position: absolute;
    width: 100%;
    height: 100%;
    transform-origin: left;
    transform-style: preserve-3d;
    transform: rotateY(-20deg);
    z-index: var(--reverse-count);
    cursor: pointer;
}
.book .page.first-half { transition: transform 1.5s; }
.book .page.last-half  { transition: transform 1.5s, z-index 0.5s 0.5s; }

.book .front-page,
.book .back-page {
    background: #fff;
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}
.book .inner.page .front-page { border-radius: 0 10px 10px 0; }
.book .inner.page .back-page  { border-radius: 10px 0 0 10px; }
.book .back-page { transform: rotateY(180deg); z-index: 99; }

/* Competitor uses <img height:100% width:auto>, right/left aligned.
   Each "inner page image" is actually a full SPREAD — when rendered at
   page-height the image overflows the half-spread page horizontally.
   Right-align on front-page hides the left of the image (showing right
   half), left-align on back-page hides the right (showing left half). */
.book .page img,
.book .front-cover img,
.book .back-cover img {
    position: absolute;
    height: 100%;
    width: auto;
    top: 0;
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
}
.book .front-page img { right: 0; }
.book .back-page  img { left: 0; }

/* Cover images: single full image, fill the face */
.book .front-cover img,
.book .back-cover img {
    height: 100%;
    width: 100%;
    right: 0;
    left: 0;
    object-fit: cover;
}

.book .blank { background: #fff; }

.book .page label {
    position: absolute;
    bottom: 6px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.7);
    opacity: 0.55;
    pointer-events: none;
}
.book .front-page label { right: 8px; }
.book .back-page  label { left: 8px; }

/* Open / close states
   - On open the whole book slides right AND the front cover flips
     away so it doesn't sit visible on the right side of the open book.
   - On close the back cover flips down to cover the (turned) pages so
     the user sees the back-cover artwork as the book closes. */
.book.open {
    transform: translateX(160px) rotateZ(-2deg) rotateX(-5deg);
}
.book.open.portrait {
    transform: translateX(100px) rotateZ(-2deg) rotateX(-5deg);
}
.book.open .front-cover {
    transform: rotateY(-175deg);
    transition: transform 1.5s, z-index 0.5s 0.5s;
    z-index: 1;
}
.book.open .page {
    box-shadow: -1px 0 4px rgba(99, 98, 98, 0.3);
}

.book .page.turn {
    transform: rotateY(-175deg);
    z-index: var(--count);
}
.book .page.first-half.turn { transition: transform 1.5s, z-index 0.5s 0.5s; }
.book .page.last-half.turn  { transition: transform 1.5s; }
.book .back-cover.turn { transition: transform 1.5s; }

/* Closed-at-end: book returns to centre and the back-cover swings
   leftward over the turned inner pages — exactly like closing a real
   album. The back-cover wrapper rotates -175deg around its left edge
   (origin already set). Combined with the back-page's own internal
   rotateY(180deg), the back-page artwork ends up facing the camera,
   so the user sees a single 12x18 closed cover. */
.book.close {
    transform: rotateX(-5deg);
}
.book.close .back-cover {
    transform: rotateY(-175deg);
    z-index: 9999;
    transition: transform 1.5s, z-index 0.5s;
}
.book.close .front-cover {
    /* keep the front cover flipped open (out of the way) while closed-at-end */
    transform: rotateY(-175deg);
    z-index: 1;
}

/* ---------- Right action column ---------- */
.actions {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    padding: 6px 0;
}
.actions .btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid rgba(244, 199, 32, 0.45);
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s ease;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0.85;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.actions .btn:hover,
.actions .btn:focus-visible {
    background: var(--primary);
    color: #000;
    box-shadow: 0 0 18px rgba(244, 199, 32, 0.55);
    opacity: 1;
    outline: none;
    transform: translateY(-1px);
}
.actions .btn.is-active {
    background: var(--primary);
    color: #000;
    box-shadow: 0 0 18px rgba(244, 199, 32, 0.55);
}
.actions .btn.play { color: var(--primary); }

.lock-msg {
    font-size: 11px;
    text-align: center;
    color: var(--primary);
    opacity: 0;
    transition: opacity 0.6s;
    line-height: 1.2;
}

/* ---------- Footer ---------- */
footer {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    width: 100%;
    min-height: 56px;
    padding: 6px 16px;
    background: linear-gradient(0deg, rgba(23, 26, 29, 0.85), rgba(23, 26, 29, 0.55));
    border-top: 1px solid rgba(244, 199, 32, 0.18);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

footer .trust-stamp {
    position: absolute;
    left: 14px;
    width: 38px;
    height: 38px;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.2s;
}
footer .trust-stamp:hover { opacity: 1; }

footer .page-counter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(244, 199, 32, 0.12);
    border: 1px solid rgba(244, 199, 32, 0.35);
    border-radius: 999px;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.04em;
}

footer .nav-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid rgba(244, 199, 32, 0.35);
    background: rgba(0, 0, 0, 0.55);
    color: var(--primary);
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}
footer .nav-btn:hover { background: var(--primary); color: #000; }
footer .nav-btn[disabled] { opacity: 0.35; cursor: not-allowed; }

/* ---------- Welcome / rotate phone overlay ---------- */
.welcome {
    position: fixed;
    inset: 0;
    z-index: 1999;
    display: none;
    align-items: center;
    justify-content: center;
    background: #000;
    color: var(--primary);
    text-align: center;
    padding: 1.5rem;
    font-size: 1rem;
    line-height: 1.5;
}
.welcome .welcome-inner {
    max-width: 320px;
}
.welcome i {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1rem;
    animation: rotatePhone 1.6s ease-in-out infinite;
}
@keyframes rotatePhone {
    0%, 100% { transform: rotate(0deg); }
    50%      { transform: rotate(-90deg); }
}

/* ---------- Theme toggle FAB ---------- */
.anim-toggle-btn {
    position: fixed;
    bottom: 70px;
    left: 16px;
    width: 38px;
    height: 38px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1rem;
    cursor: pointer;
    z-index: 2000;
    transition: 0.3s;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}
.anim-toggle-btn:hover {
    background: var(--primary);
    color: #000;
    box-shadow: 0 0 20px rgba(244, 199, 32, 0.6);
}
.anim-tooltip {
    position: absolute;
    left: 48px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 4px 9px;
    border-radius: 4px;
    font-size: 0.72rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
    border: 1px solid var(--primary);
}
.anim-toggle-btn:hover .anim-tooltip {
    opacity: 1;
    transform: translateX(4px);
}

/* ---------- Loader ---------- */
.fb-loader {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    transition: opacity 0.4s ease;
}
.fb-loader.hidden { opacity: 0; pointer-events: none; }
.fb-loader .spinner {
    width: 42px;
    height: 42px;
    border: 3px solid rgba(244, 199, 32, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}
.fb-loader p {
    color: var(--muted);
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Share popup ---------- */
.popup {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2500;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.popup.is-open { display: flex; }
.popup-content {
    position: relative;
    background: #0f0f0f;
    border: 1px solid rgba(244, 199, 32, 0.35);
    border-radius: 14px;
    padding: 22px 22px 18px;
    max-width: 420px;
    width: 100%;
    color: #fff;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.popup-content h4 {
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--primary);
}
.popup-content p.sub { color: var(--muted); font-size: 0.85rem; margin-bottom: 14px; }
.popup-content .close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: 0;
    color: #888;
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
}
.popup-content .close:hover { color: #fff; }

.share-list { display: grid; gap: 6px; }
.share-list button {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: #fff;
    font-size: 0.92rem;
    cursor: pointer;
    transition: all 0.2s;
}
.share-list button:hover {
    background: rgba(244, 199, 32, 0.12);
    border-color: var(--primary);
    transform: translateX(2px);
}
.share-list .ic {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex: 0 0 auto;
}
.share-list .ic.fb { background: #1877f2; }
.share-list .ic.tw { background: #1da1f2; }
.share-list .ic.wa { background: #25d366; }
.share-list .ic.cp { background: #555; }
.share-url {
    margin-top: 12px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: var(--muted);
    font-size: 0.72rem;
    word-break: break-all;
}

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

/* Tablet */
@media (max-width: 1100px) {
    .book { width: 280px; }
    .book.open { transform: translateX(140px) rotateZ(-2deg) rotateX(-5deg); }
    .book.close { transform: translateX(280px); }
    .book.portrait { width: 180px; }
    .book.open.portrait { transform: translateX(90px) rotateZ(-2deg) rotateX(-5deg); }
    .book.close.portrait { transform: translateX(180px); }
}

/* Wide desktop */
@media (min-width: 1280px) {
    header { min-height: 64px; font-size: 15px; }
    header .logo h2 { font-size: 1.4rem; }
    .book { width: 480px; margin: 30px auto 0; }
    .book.open { transform: translateX(240px) rotateZ(-2deg) rotateX(-5deg); }
    .book.close { transform: translateX(480px); }
    .book.portrait { width: 320px; }
    .book.open.portrait { transform: translateX(160px) rotateZ(-2deg) rotateX(-5deg); }
    .book.close.portrait { transform: translateX(320px); }
    .actions .btn { width: 46px; height: 46px; font-size: 19px; }
    .page label { font-size: 13px; }
}

/* Extra wide */
@media (min-width: 1600px) {
    .book { width: 580px; }
    .book.open { transform: translateX(290px) rotateZ(-2deg) rotateX(-5deg); }
    .book.close { transform: translateX(580px); }
}

/* Mobile */
@media (max-width: 768px) {
    header { padding: 6px 12px; min-height: 48px; }
    header .badge { width: 28px; height: 28px; }
    header .logo h2 { font-size: 0.92rem; max-width: 50vw; }
    header .client { display: none; }
    header .info { display: none; }

    .main {
        height: calc(100vh - 48px - 56px);
        height: calc(100dvh - 48px - 56px);
        padding: 0 8px;
        gap: 6px;
    }
    .v2 { display: none; }

    .book { width: 220px; }
    .book.open { transform: translateX(110px) rotateZ(-2deg) rotateX(-5deg); }
    .book.close { transform: translateX(220px); }
    .book.portrait { width: 150px; }
    .book.open.portrait { transform: translateX(75px) rotateZ(-2deg) rotateX(-5deg); }
    .book.close.portrait { transform: translateX(150px); }

    .actions { gap: 10px; }
    .actions .btn { width: 36px; height: 36px; font-size: 15px; }

    footer { gap: 10px; padding: 6px 8px; }
    footer .trust-stamp { width: 30px; height: 30px; left: 8px; }
    footer .page-counter { font-size: 11px; padding: 4px 10px; }
    footer .nav-btn { width: 34px; height: 34px; font-size: 13px; }

    .anim-toggle-btn { bottom: 70px; left: 8px; width: 32px; height: 32px; font-size: 0.85rem; }
    .anim-tooltip { display: none; }
}

/* Portrait phone — show rotate prompt */
@media (max-width: 600px) and (orientation: portrait) {
    .welcome { display: flex; }
}

/* Small mobile */
@media (max-width: 380px) {
    .book { width: 180px; }
    .book.open { transform: translateX(90px) rotateZ(-2deg) rotateX(-5deg); }
    .book.close { transform: translateX(180px); }
}

/* Landscape phone tweaks */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
    header { min-height: 40px; padding: 4px 10px; }
    footer { min-height: 44px; }
    .main {
        height: calc(100vh - 40px - 44px);
        height: calc(100dvh - 40px - 44px);
    }
    .book { width: 280px; }
    .book.open { transform: translateX(140px) rotateZ(-2deg) rotateX(-5deg); }
    .book.close { transform: translateX(280px); }
}
