/* ================================================================
   FlowScroll – Sequence Scroller — Front-end Styles
================================================================ */

.fs-section { position: relative; width: 100%; }

.fs-sticky {
    position: sticky;
    top: 0; width: 100%; height: 100vh;
    overflow: hidden; background: #000;
}

/* Canvas fills the sticky viewport for frame rendering.
   Using canvas instead of CSS background-image prevents the black-flash
   that occurs when GPU textures are evicted while the tab is hidden. */
.fs-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: block;
}

/* Progress bar */
.fs-progress {
    position: absolute; bottom: 0; left: 0;
    width: 100%; height: 2px;
    background: rgba(255,255,255,0.12); z-index: 10;
}
.fs-progress-bar { height: 100%; width: 0%; background: #fff; will-change: width; }

/* Loader */
.fs-loader {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 12px;
    background: #000; z-index: 20; transition: opacity 0.5s ease;
}
.fs-loader--done { opacity: 0; pointer-events: none; }
.fs-loader-track {
    width: min(280px, 55%); height: 2px;
    background: rgba(255,255,255,0.12); border-radius: 2px; overflow: hidden;
}
.fs-loader-fill {
    height: 100%; width: 0%; background: #fff;
    border-radius: 2px; transition: width 0.12s linear;
}
.fs-loader-label {
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.7rem; letter-spacing: 0.1em;
    text-transform: uppercase; color: rgba(255,255,255,0.35);
}

/* ================================================================
   COLOUR OVERLAY — sits between frames and text overlays
   background set inline by PHP (gradient or solid colour)
================================================================ */
.fs-bg-layer {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    will-change: transform;
    z-index: 0;
}

.fs-color-overlay {
    position: absolute;
    inset: 0;
    z-index: 6;           /* topmost layer — above overlays (z:5), so gradients sit on top */
    pointer-events: none;
}

/* ================================================================
   OVERLAYS
   .fs-overlays fills the sticky viewport completely.
   Each .fs-overlay is position:absolute with top/left % set by JS.
================================================================ */
.fs-overlays {
    position: absolute;
    inset: 0;               /* full sticky area — overlays reference this */
    pointer-events: none;
    z-index: 5;
    overflow: visible;      /* allow overlays to extend beyond the frame edge */
    clip-path: inset(0);    /* clips overflow without breaking position:sticky —
                               prevents scale-animated overlays from temporarily
                               widening the iOS Safari scroll area and causing shake */
}

.fs-overlay {
    /* position, top, left, transform set by JS */
    position: absolute;
    opacity: 0;
    will-change: opacity;
    pointer-events: none;
}

/* Font sizes — defaults only.
   Overridden per-breakpoint by px values from Settings → FlowScroll – Sequence Scroller.
   The admin page outputs a <style> block in wp_head with !important rules. */
.fs-overlay--size-small  .fs-overlay-text { font-size: 18px; }
.fs-overlay--size-medium .fs-overlay-text { font-size: 28px; }
.fs-overlay--size-large  .fs-overlay-text { font-size: 44px; }
.fs-overlay--size-xl     .fs-overlay-text { font-size: 72px; }

.fs-overlay-inner {
    display: flex; flex-direction: column;
    align-items: center; gap: 20px;
}

.fs-overlay-text {
    font-family: inherit; /* inherits active theme font — no override */
    font-weight: 400; line-height: 1.15;
    text-shadow: 0 2px 32px rgba(0,0,0,0.6), 0 0 80px rgba(0,0,0,0.3);
    white-space: nowrap; /* prevents wrapping on desktop */
    /* Beat any theme word-break:break-word rule — words must never split mid-character */
    word-break: normal !important;
    overflow-wrap: normal !important;
}
/* Default line-heights per tag — overridden by JS inline style when user sets a value */
p.fs-overlay-text                                                        { line-height: 1.5; }
h1.fs-overlay-text, h2.fs-overlay-text, h3.fs-overlay-text,
h4.fs-overlay-text, h5.fs-overlay-text, h6.fs-overlay-text              { line-height: 1.15; }

/* On mobile: allow wrapping, constrain width */
@media (max-width: 767px) {
    .fs-overlay-text {
        white-space: normal;
    }
    .fs-overlay {
        max-width: 80vw; /* no !important — JS inline styles must be able to override */
    }
    /* Fullscreen parallax layers must not be capped — they fill the sticky viewport */
    .fs-overlay[data-ov-fullscreen="1"],
    .fs-overlay[data-ov-fullscreen-mobile="1"] {
        max-width: none !important;
    }
}

/* Word/letter/typewriter spans */
.fs-word {
    display: inline-block;
    margin-right: 0.28em;
    /* will-change intentionally omitted — per-word GPU layers cause jitter on mobile */
}
.fs-space {
    display: inline-block;
    width: 0.28em;
}
.fs-letter {
    display: inline-block;
    /* will-change intentionally omitted — per-letter GPU layers cause jitter on mobile */
}
.fs-tw-cursor {
    display: inline-block;
    margin-left: 2px;
    animation: fs-blink 0.7s step-end infinite;
}
@keyframes fs-blink { 50% { opacity: 0; } }

/* ================================================================
   CTA BUTTON
================================================================ */
.fs-cta {
    display: inline-block;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.95rem; font-weight: 500; letter-spacing: 0.02em;
    text-decoration: none; padding: 12px 28px; border-radius: 4px;
    cursor: pointer; opacity: 0; will-change: opacity, transform;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    white-space: nowrap;
}
.fs-cta--solid   { background: #fff; color: #000; border: 2px solid #fff; }
.fs-cta--solid:hover { background: transparent; color: #fff; }
.fs-cta--outline { background: transparent; color: #fff; border: 2px solid #fff; }
.fs-cta--outline:hover { background: #fff; color: #000; }
.fs-cta--ghost   { background: rgba(255,255,255,0.15); color: #fff; border: 1px solid rgba(255,255,255,0.3); backdrop-filter: blur(8px); }
.fs-cta--ghost:hover { background: rgba(255,255,255,0.28); }

/* ================================================================
   MODAL
================================================================ */
.fs-modal {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.fs-modal--open { opacity: 1; pointer-events: auto; }
.fs-modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
}
.fs-modal-box {
    position: relative; background: #fff; border-radius: 12px;
    padding: 48px; max-width: 520px; width: 90%;
    box-shadow: 0 24px 80px rgba(0,0,0,0.3);
    transform: translateY(16px);
    transition: transform 0.3s cubic-bezier(0.22,1,0.36,1);
}
.fs-modal--open .fs-modal-box { transform: translateY(0); }
.fs-modal-close {
    position: absolute; top: 16px; right: 16px;
    background: none; border: none; font-size: 1.1rem; cursor: pointer; color: #999;
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; transition: background 0.15s, color 0.15s;
}
.fs-modal-close:hover { background: #f0f0f0; color: #333; }
.fs-modal-content { font-family: Georgia, serif; font-size: 1.1rem; line-height: 1.6; color: #222; }

/* Empty state */
.fs-empty {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 12px;
    height: 200px; background: #f5f5f5;
    border: 2px dashed #ddd; border-radius: 4px;
    color: #aaa; font-family: sans-serif; font-size: 0.875rem;
}
.fs-empty p { margin: 0; }

/* ----------------------------------------------------------------
   Disable on mobile — show a static 16:9 placeholder instead
---------------------------------------------------------------- */
@media (max-width: 767px) {
    .fs-section--no-mobile {
        height: auto !important;
    }
    .fs-section--no-mobile .fs-sticky {
        position: relative;
        height: min( 56.25vw, 100vw );  /* 16:9 ratio */
        background-color: #000;
        background-size: cover;
        background-position: center;
    }
    .fs-section--no-mobile .fs-loader,
    .fs-section--no-mobile .fs-overlays,
    .fs-section--no-mobile .fs-progress,
    .fs-section--no-mobile .fs-color-overlay {
        display: none;
    }
    /* Show a subtle "view on desktop" hint */
    .fs-section--no-mobile .fs-sticky::after {
        content: 'Best viewed on desktop';
        position: absolute;
        bottom: 12px;
        left: 50%;
        transform: translateX(-50%);
        font-family: -apple-system, BlinkMacSystemFont, sans-serif;
        font-size: 0.7rem;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: rgba(255,255,255,0.4);
        white-space: nowrap;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fs-section  { height: auto !important; }
    .fs-sticky   { position: relative; height: min(56.25vw, 90vh); }
    .fs-loader, .fs-overlays { display: none; }
}


/* Use theme heading font via WP preset or inherit fallback */
.fs-overlay-text {
    font-family: var(--wp--preset--font-family--primary, inherit) !important;
}
