/* PDF flipbook modal — package: flipbook/v1
   ----------------------------------------------------------
   Namespace: .slip-flipbook-*

   Renders a full-screen overlay containing the PDF viewer + a
   title bar with "Open in new tab" and close affordances.
   The shell is style-guide-token-aware so it inherits the active
   skin's surface + accent. Falls back to safe defaults for
   installs without a configured style guide.

   Body class .slip-flipbook-locked is added while a modal is
   open to suppress background scrolling.

   The inner viewer is a plain <iframe> in v1 (browser's PDF
   viewer renders inside). A future revision swaps the iframe
   for the forked DearFlip-Lite renderer without changing this
   shell.
   ---------------------------------------------------------- */

.slip-flipbook-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    opacity: 0;
    transition: opacity 200ms ease;
    font-family: var(--font-body, system-ui, -apple-system, sans-serif);
}
.slip-flipbook-modal.is-open { display: block; opacity: 1; }

body.slip-flipbook-locked { overflow: hidden; }

.slip-flipbook-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(9, 12, 22, 0.78);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.slip-flipbook-shell {
    position: absolute;
    inset: 1.5rem;
    display: flex;
    flex-direction: column;
    background: var(--bg-page, #fdfbf6);
    color: var(--text-on-page, #0b2545);
    border-radius: var(--radius-lg, 14px);
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
    transform: translateY(8px) scale(0.99);
    transition: transform 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.slip-flipbook-modal.is-open .slip-flipbook-shell { transform: none; }

/* On phones — drop the inset so the viewer goes corner-to-corner */
@media (max-width: 640px) {
    .slip-flipbook-shell { inset: 0; border-radius: 0; }
}

/* ----- Floating close X (top-right corner) ----------------------- */
/* No title bar — design decision is "menu speaks for itself + the
 * dflip toolbar carries download/page-nav, an extra row would just
 * eat vertical space." The X floats above the flipbook canvas
 * and inherits white-on-dark contrast from the inverse surface. */
/* "× Close" pill — icon + word so beginner users immediately know
   how to dismiss the viewer. Round-icon-only was too cryptic per
   user feedback. */
.slip-flipbook-close {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    z-index: 5;
    appearance: none;
    height: 2.25rem;
    padding: 0 0.95rem 0 0.8rem;
    border: 0;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text-on-inverse, #fdfbf6) 14%, transparent);
    color: var(--text-on-inverse, #fdfbf6);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font: 600 0.875rem / 1 var(--font-body, system-ui, -apple-system, sans-serif);
    letter-spacing: 0.01em;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background 160ms ease, transform 160ms ease;
}
.slip-flipbook-close:hover {
    background: color-mix(in srgb, var(--text-on-inverse, #fdfbf6) 24%, transparent);
    transform: translateY(-1px);
}
.slip-flipbook-close:focus-visible {
    outline: 2px solid var(--brand-secondary-accent, var(--brand-primary-accent, #e6a822));
    outline-offset: 2px;
}
.slip-flipbook-close-label { line-height: 1; }
@media (max-width: 640px) {
    .slip-flipbook-close { top: 0.6rem; right: 0.6rem; padding: 0 0.85rem 0 0.7rem; }
}

/* ----- Body / viewer --------------------------------------------- */
/* Hosts the vendored DearFlip renderer (or, before vendor JS lands,
 * the loading panel). The dark backdrop is owned by the body — the
 * dflip container itself is forced transparent via the overrides
 * stylesheet so the surface stays cohesive with the rest of the
 * modal chrome. */
.slip-flipbook-body {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    background: var(--bg-inverse, #0b2545);
    color: var(--text-on-inverse, #fdfbf6);
    overflow: hidden;
}

/* Loading state — shown while the ~2.4MB DearFlip vendor JS is
 * fetched on first open. Subsequent opens skip this entirely
 * (vendor is cached + DFLIP global already exists). */
.slip-flipbook-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    background: var(--bg-inverse, #0b2545);
    color: color-mix(in srgb, var(--text-on-inverse, #fdfbf6) 75%, transparent);
    font-size: 0.9rem;
    z-index: 1;
}
.slip-flipbook-loading p { margin: 0; }
.slip-flipbook-loading[hidden] { display: none; }

.slip-flipbook-spinner {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 2px solid color-mix(in srgb, currentColor 22%, transparent);
    border-top-color: var(--brand-secondary-accent, var(--brand-primary-accent, #e6a822));
    animation: slip-flipbook-spin 0.85s linear infinite;
}
@keyframes slip-flipbook-spin {
    to { transform: rotate(360deg); }
}

.slip-flipbook-error {
    text-align: center;
    color: color-mix(in srgb, var(--text-on-inverse, #fdfbf6) 85%, transparent);
    max-width: 28rem;
    margin: 0 auto;
    padding: 0 1rem;
    line-height: 1.5;
}
.slip-flipbook-error a {
    color: var(--brand-secondary-accent, var(--brand-primary-accent, #e6a822));
}

@media (prefers-reduced-motion: reduce) {
    .slip-flipbook-modal,
    .slip-flipbook-shell { transition: none; }
    .slip-flipbook-spinner { animation: none; border-top-color: currentColor; }
}
