/* ==========================================================================
   ArivaFlip — custom GSAP-powered 3D flipbook (replaces DearFlip)
   Brand: forest #0d2818 · gold #C9A562 · greyLight #F4F4F4
   ========================================================================== */

.aflip {
    --aflip-forest: #0d2818;
    --aflip-forest-dark: #0a1f14;
    --aflip-gold: #C9A562;
    --aflip-paper: #10281b;
    position: relative;
    width: 100%;
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-y;
    outline: none;
}
.aflip:focus-visible {
    box-shadow: 0 0 0 3px rgba(201, 165, 98, 0.55);
    border-radius: 1rem;
}

/* ---- Stage ---- */
.aflip__stage {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1.25rem, 3vw, 2.5rem) clamp(0.5rem, 2vw, 2rem);
    background:
        radial-gradient(120% 90% at 50% 0%, rgba(201, 165, 98, 0.10), transparent 55%),
        linear-gradient(160deg, #0e2419 0%, #0a1f14 60%, #081a11 100%);
    border-radius: 1.25rem;
    border: 1px solid rgba(201, 165, 98, 0.18);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.aflip__viewport {
    position: relative;
    perspective: 2600px;
    perspective-origin: 50% 45%;
    will-change: transform;
}

.aflip__tilt {
    position: relative;
    transform-style: preserve-3d;
    will-change: transform;
}

.aflip__book {
    position: relative;
    width: var(--aflip-book-w, 800px);
    height: var(--aflip-book-h, 267px);
    transform-style: preserve-3d;
}

/* ---- Leaves & faces ---- */
.aflip__leaf {
    position: absolute;
    top: 0;
    height: 100%;
    transform-style: preserve-3d;
    will-change: transform;
    pointer-events: none;
}
.aflip--spread .aflip__leaf {
    left: 50%;
    width: 50%;
    transform-origin: left center;
}
.aflip--single .aflip__leaf {
    left: 0;
    width: 100%;
    transform-origin: left center;
}

.aflip__face {
    position: absolute;
    inset: 0;
    overflow: hidden;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    background: var(--aflip-paper);
    /* GPU promotion keeps flips crisp */
    transform: translateZ(0);
}
.aflip__face--back {
    transform: rotateY(180deg) translateZ(0.4px);
}
.aflip__face img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

/* Rounded outer corners of the book */
.aflip--spread .aflip__leaf .aflip__face--front { border-radius: 0 10px 10px 0; }
.aflip--spread .aflip__leaf .aflip__face--back  { border-radius: 10px 0 0 10px; }
.aflip--single .aflip__leaf .aflip__face--front,
.aflip--single .aflip__leaf .aflip__face--back  { border-radius: 10px; }

/* Sheen + shade overlays animated by GSAP during a flip */
.aflip__shade {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    border-radius: inherit;
}
.aflip__shade--dark {
    background: linear-gradient(to right, rgba(5, 14, 9, 0.55), rgba(5, 14, 9, 0.08) 55%, rgba(5, 14, 9, 0) 80%);
}
.aflip__shade--light {
    background: linear-gradient(105deg, rgba(255, 255, 255, 0) 30%, rgba(255, 250, 240, 0.28) 48%, rgba(255, 255, 255, 0) 65%);
    mix-blend-mode: screen;
}

/* Inner-gutter shadow near the spine (spread mode) */
.aflip--spread .aflip__face--front::before,
.aflip--spread .aflip__face--back::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 7%;
    pointer-events: none;
    z-index: 2;
}
.aflip--spread .aflip__face--front::before {
    left: 0;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0));
}
.aflip--spread .aflip__face--back::after {
    right: 0;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0));
}

/* Cover leaves get a hard edge highlight */
.aflip__leaf--cover .aflip__face {
    box-shadow: inset 0 0 0 1px rgba(201, 165, 98, 0.35);
}

/* ---- Page-block edges (thickness illusion) ---- */
.aflip__edge {
    position: absolute;
    top: 1.5%;
    bottom: 1.5%;
    width: 0;
    pointer-events: none;
    background:
        repeating-linear-gradient(to right,
            rgba(244, 244, 244, 0.85) 0 1px,
            rgba(190, 186, 178, 0.9) 1px 2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
    transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.aflip__edge--left  { right: 100%; border-radius: 3px 0 0 3px; transform-origin: right center; }
.aflip__edge--right { left: 100%;  border-radius: 0 3px 3px 0; transform-origin: left center; }
.aflip--single .aflip__edge--left { display: none; }

/* Floor shadow under the book */
.aflip__floor {
    position: absolute;
    left: 6%;
    right: 6%;
    bottom: -7%;
    height: 12%;
    background: radial-gradient(50% 100% at 50% 0%, rgba(0, 0, 0, 0.45), transparent 75%);
    filter: blur(6px);
    pointer-events: none;
    transform: translateZ(-60px);
}

/* ---- Hotzones (corner/edge click + peel hint) ---- */
.aflip__hotzone {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 16%;
    z-index: 40;
    cursor: pointer;
    display: flex;
    align-items: center;
    border: 0;
    background: transparent;
    padding: 0;
    color: rgba(255, 255, 255, 0);
    transition: color 0.3s ease;
}
.aflip__hotzone svg { width: 30px; height: 30px; }
.aflip__hotzone--prev { left: 0; justify-content: flex-start; padding-left: 2%; }
.aflip__hotzone--next { right: 0; justify-content: flex-end; padding-right: 2%; }
@media (hover: hover) {
    .aflip__stage:hover .aflip__hotzone:not([disabled]) { color: rgba(201, 165, 98, 0.85); }
    .aflip__hotzone:not([disabled]):hover { color: #fff; }
}
.aflip__hotzone[disabled] { cursor: default; color: transparent !important; }
.aflip--zoomed .aflip__hotzone { display: none; }
.aflip--dragging .aflip__hotzone { color: transparent !important; }

/* ---- Progress bar ---- */
.aflip__progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
    z-index: 41;
}
.aflip__progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(to right, rgba(201, 165, 98, 0.75), #C9A562);
    transform-origin: left center;
}

/* ---- Controls ---- */
.aflip__ui {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.9rem;
    padding: 0.45rem 0.6rem;
    background: var(--aflip-forest-dark);
    border: 1px solid rgba(201, 165, 98, 0.22);
    border-radius: 9999px;
}
.aflip__ui-group {
    display: flex;
    align-items: center;
    gap: 0.15rem;
}
.aflip__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 9999px;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: background-color 0.25s ease, color 0.25s ease, transform 0.2s ease;
}
.aflip__btn svg { width: 19px; height: 19px; }
.aflip__btn:hover:not([disabled]) {
    background: rgba(201, 165, 98, 0.16);
    color: #C9A562;
}
.aflip__btn:active:not([disabled]) { transform: scale(0.92); }
.aflip__btn[disabled] { opacity: 0.3; cursor: default; }
.aflip__btn:focus-visible {
    outline: 2px solid rgba(201, 165, 98, 0.8);
    outline-offset: 2px;
}
.aflip__btn[aria-pressed="true"] {
    background: rgba(201, 165, 98, 0.25);
    color: #C9A562;
}

.aflip__counter {
    min-width: 5.5rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    white-space: nowrap;
    padding: 0 0.4rem;
}
.aflip__counter b { color: #C9A562; font-weight: 700; }

/* ---- Loader ---- */
.aflip__loader {
    position: absolute;
    inset: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: linear-gradient(160deg, #0e2419 0%, #0a1f14 100%);
    border-radius: 1.25rem;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
.aflip__loader.is-hidden { opacity: 0; visibility: hidden; }
.aflip__loader-book {
    width: 46px;
    height: 34px;
    position: relative;
    perspective: 300px;
}
.aflip__loader-book::before,
.aflip__loader-book::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 3px;
    background: rgba(201, 165, 98, 0.85);
}
.aflip__loader-book::after {
    transform-origin: left center;
    background: #F4F4F4;
    animation: aflipLoaderFlip 1.1s cubic-bezier(0.45, 0, 0.2, 1) infinite;
}
@keyframes aflipLoaderFlip {
    0%   { transform: rotateY(0deg); }
    100% { transform: rotateY(-180deg); }
}
.aflip__loader-text {
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.7rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
}

/* ---- Fullscreen ---- */
.aflip--fs {
    position: fixed !important;
    inset: 0;
    z-index: 2147483000;
    background: #081a11;
    padding: clamp(0.5rem, 2vh, 1.5rem);
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.aflip--fs .aflip__stage {
    flex: 1 1 auto;
    min-height: 0;
    border-radius: 0.9rem;
}
.aflip:fullscreen {
    background: #081a11;
    padding: clamp(0.5rem, 2vh, 1.5rem);
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.aflip:fullscreen .aflip__stage {
    flex: 1 1 auto;
    min-height: 0;
}

/* ---- Zoom / pan ---- */
.aflip--zoomed .aflip__stage { cursor: grab; }
.aflip--panning .aflip__stage { cursor: grabbing; }

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    .aflip__loader-book::after { animation: none; transform: rotateY(-100deg); }
    .aflip__edge { transition: none; }
}
