/* ==========================================================================
   Quicksave Magazine – Premium Flipbook Styles  v3.0
   Dark luxury cinema aesthetic.
   Three states: loading → cover-intro → flipbook reader
   ========================================================================== */

/* --------------------------------------------------------------------------
   OUTER WRAP
-------------------------------------------------------------------------- */
.qs-mag-wrap {
    max-width: 1280px;
    margin: 0 auto 48px;
    font-family: inherit;
    user-select: none;
    position: relative;
}

/* Title above viewer */
.qs-mag-title {
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    color: #b0b0b0;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-bottom: 14px;
}

/* --------------------------------------------------------------------------
   ①  LOADING SCREEN
-------------------------------------------------------------------------- */
.qs-mag-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    background: #0c0c0c;
    border-radius: 10px;
    gap: 22px;
    color: #666;
    font-size: 0.82rem;
    letter-spacing: .08em;
    text-transform: uppercase;
}

/* Animated ring */
.qs-mag-loading::before {
    content: '';
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255,255,255,.06);
    border-top-color: #e85d04;
    border-radius: 50%;
    animation: qsMagSpin .9s linear infinite;
}

@keyframes qsMagSpin { to { transform: rotate(360deg); } }

.qs-mag-progress { display: block; }

.qs-mag-error { color: #e05030; text-transform: none; font-size: 0.9rem; }

/* --------------------------------------------------------------------------
   ②  COVER INTRO STAGE
-------------------------------------------------------------------------- */
.qs-mag-cover-stage {
    display: none;              /* shown by JS after load */
    position: relative;
    min-height: 80vh;
    background: #080808;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0;
}

/* Radial dark vignette around edges */
.qs-mag-vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 45%,
        transparent 30%,
        rgba(0,0,0,.65) 80%,
        rgba(0,0,0,.88) 100%);
    pointer-events: none;
    z-index: 2;
}

/* Warm ambient glow behind the cover */
.qs-mag-cover-glow {
    position: absolute;
    width: 70%;
    height: 70%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -58%);
    background: radial-gradient(ellipse at center,
        rgba(232,93,4,.13) 0%,
        rgba(180,60,0,.06) 40%,
        transparent 70%);
    pointer-events: none;
    z-index: 1;
}

/* Floating magazine cover */
.qs-mag-cover-float {
    position: relative;
    z-index: 3;
    animation: qsMagFloat 5s ease-in-out infinite;
    /* Deep cinematic shadow */
    filter:
        drop-shadow(0 60px 80px rgba(0,0,0,.95))
        drop-shadow(0 20px 30px rgba(0,0,0,.80))
        drop-shadow(0  6px 12px rgba(0,0,0,.60));
}

@keyframes qsMagFloat {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    30%       { transform: translateY(-14px) rotate(-.3deg); }
    70%       { transform: translateY(-8px)  rotate(.2deg); }
}

/* The high-res cover canvas */
.qs-mag-cover-canvas {
    display: block;
    border-radius: 2px 6px 6px 2px; /* slight right-side spine curve */
}

/* Subtle ground reflection below the cover */
.qs-mag-cover-reflection {
    position: absolute;
    bottom: -40px;
    left: 5%;
    right: 5%;
    height: 50px;
    background: linear-gradient(to bottom, rgba(255,255,255,.04), transparent);
    filter: blur(8px);
    transform: scaleY(-1);
    pointer-events: none;
    border-radius: 50%;
}

/* "Click to open" hint at bottom of stage */
.qs-mag-cover-cta {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,.55);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: .14em;
    text-transform: uppercase;
    white-space: nowrap;
    animation: qsCtaFade 2s ease-in-out .8s both;
}

@keyframes qsCtaFade {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Pulsing orange dot */
.qs-mag-cover-pulse {
    width: 8px;
    height: 8px;
    background: #e85d04;
    border-radius: 50%;
    flex-shrink: 0;
    animation: qsPulse 1.6s ease-in-out infinite;
}

@keyframes qsPulse {
    0%, 100% { transform: scale(1);   opacity: 1; box-shadow: 0 0 0 0 rgba(232,93,4,.5); }
    50%       { transform: scale(1.4); opacity: .8; box-shadow: 0 0 0 6px rgba(232,93,4,0); }
}

/* Opening transition (JS adds .qs-mag-opening) */
.qs-mag-cover-stage.qs-mag-opening {
    animation: qsStageOpen .7s cubic-bezier(.4,0,.2,1) forwards;
}

@keyframes qsStageOpen {
    0%   { opacity: 1; transform: scale(1); }
    40%  { opacity: 1; transform: scale(1.015); }
    100% { opacity: 0; transform: scale(.97); }
}

/* --------------------------------------------------------------------------
   ③  FLIPBOOK READER
-------------------------------------------------------------------------- */
.qs-mag-reader {
    /* Shown by JS: starts display:block opacity:0, transitions to opacity:1 */
    transition: opacity .5s ease;
}

/* ---- Cinema viewer bar ---- */
.qs-mag-viewer {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #0c0c0c;
    padding: 40px 20px;
    border-radius: 10px 10px 0 0;
    overflow: hidden;
    /* Rich dark shadow */
    box-shadow:
        0 0 0 1px rgba(255,255,255,.04) inset,
        0 30px 80px rgba(0,0,0,.80),
        0  8px 20px rgba(0,0,0,.55);
}

/* Subtle warm ambient behind the open book */
.qs-mag-viewer-glow {
    position: absolute;
    width: 70%;
    height: 60%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(ellipse at center,
        rgba(232,93,4,.06) 0%,
        transparent 65%);
    pointer-events: none;
}

/* ---- Flipbook container (shrinks to exact book size) ---- */
.qs-mag-flipbook-container {
    position: relative;
    display: inline-block;
    line-height: 0;
    /* Deep book shadow */
    filter:
        drop-shadow(0 10px 40px rgba(0,0,0,.95))
        drop-shadow(0  3px 10px rgba(0,0,0,.70));
}

/* StPageFlip renders here (dimensions set by JS) */
.qs-mag-flipbook { display: block; }

/* ---- Side arrow buttons ---- */
.qs-mag-arrow {
    position: absolute;
    top: 50%;
    z-index: 300;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 1.5px solid rgba(255,255,255,.18);
    background: rgba(12,12,12,.72);
    color: #ddd;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;

    /* Glassmorphism */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);

    /* Normally subtle; hover-reveal managed by JS (.qs-visible) */
    opacity: 0;
    transition: opacity .25s ease, border-color .2s ease,
                background .2s ease, color .2s ease, transform .2s ease;
}

/* Centre of the left-hand page */
.qs-mag-prev {
    left: 25%;
    transform: translate(-50%, -50%);
}

/* Centre of the right-hand page */
.qs-mag-next {
    right: 25%;
    transform: translate(50%, -50%);
}

/* Revealed on viewer hover (JS toggles .qs-visible) */
.qs-mag-arrow.qs-visible {
    opacity: 1;
}

.qs-mag-arrow:hover:not(:disabled) {
    border-color: #e85d04;
    background: rgba(232,93,4,.20);
    color: #fff;
    opacity: 1;
}

/* Disabled state (first/last page) */
.qs-mag-arrow:disabled {
    opacity: 0 !important;
    pointer-events: none;
}

/* ---- Bottom control bar ---- */
.qs-mag-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 22px;
    background: #080808;
    border-radius: 0 0 10px 10px;
    border-top: 1px solid rgba(255,255,255,.05);
    gap: 16px;
    flex-wrap: wrap;
}

.qs-mag-info {
    color: #606060;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    flex: 1;
    text-align: center;
    min-width: 120px;
}

.qs-mag-ctrl-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* Fullscreen toggle button */
.qs-mag-fullscreen-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 6px;
    color: #888;
    font-size: 0.95rem;
    line-height: 1;
    padding: 5px 8px;
    cursor: pointer;
    transition: border-color .18s, color .18s;
}

.qs-mag-fullscreen-btn:hover {
    border-color: rgba(255,255,255,.35);
    color: #ccc;
}

/* Download PDF link */
.qs-mag-download {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 14px;
    border: 1px solid rgba(232,93,4,.40);
    border-radius: 50px;
    color: #e85d04 !important;
    font-size: 0.70rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    text-decoration: none !important;
    transition: background .18s, border-color .18s;
    line-height: 1;
    white-space: nowrap;
}

.qs-mag-download:hover {
    background: rgba(232,93,4,.12);
    border-color: #e85d04;
    text-decoration: none !important;
}

/* --------------------------------------------------------------------------
   FULLSCREEN MODE
-------------------------------------------------------------------------- */
.qs-mag-wrap.qs-mag-fullscreen {
    max-width: 100vw;
    width: 100vw;
    height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    border-radius: 0;
}

.qs-mag-wrap.qs-mag-fullscreen .qs-mag-reader {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.qs-mag-wrap.qs-mag-fullscreen .qs-mag-viewer {
    flex: 1;
    border-radius: 0;
    padding: 24px 16px;
}

.qs-mag-wrap.qs-mag-fullscreen .qs-mag-controls {
    border-radius: 0;
}

/* --------------------------------------------------------------------------
   MOBILE  (< 768 px)
-------------------------------------------------------------------------- */
@media (max-width: 767px) {
    .qs-mag-loading,
    .qs-mag-cover-stage { min-height: 60vh; }

    .qs-mag-viewer { padding: 20px 8px; }

    .qs-mag-arrow {
        width: 38px;
        height: 38px;
        font-size: 0.9rem;
    }

    .qs-mag-controls { padding: 9px 12px; gap: 10px; }
    .qs-mag-info     { font-size: 0.65rem; min-width: 80px; }
    .qs-mag-download { font-size: 0.65rem; padding: 5px 10px; }
}
