/*
 * Lost Sites 360 — viewer-360.css (inherited from Fearann Alba)
 *
 * Styles for the full-screen 360° experience template
 * (templates/page-360.php). Loaded only on that template
 * via the conditional block in inc/enqueue.php.
 *
 * Design notes:
 *   - Reuses the brand tokens from main.css (gold accent,
 *     Inter, surface colours) so it sits inside the same
 *     visual language as the rest of the site.
 *   - The Back and Fullscreen buttons are a matched pair:
 *     white outline on a dark scrim, with a gold glow on
 *     hover / focus / press — the same gold-glow gesture the
 *     .btn--gold class uses elsewhere. (This replaces the
 *     blue Back button from the prototype, per the brand
 *     gold/white palette decision.)
 *   - All bold colour is spent in ONE place: the active era
 *     segment. Everything else stays quiet.
 *
 * STEP 1 SCOPE: layout, controls, loader, and a single
 * panorama with drag-to-look + the working era cross-fade.
 * The opening modal and device-motion control arrive next.
 */


/*
 * ============================================================
 * ROOT STAGE
 * ============================================================
 * Fills the viewport. body.no-header (set by the template via
 * $hide_header) removes the site chrome, so this can own the
 * whole screen.
 *
 * 100dvh tracks the *dynamic* viewport so the mobile browser
 * chrome shrinking/growing never crops the experience. A plain
 * 100vh fallback is listed first for older browsers.
 * ============================================================
 */
.fa360 {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;

    background-color: var(--color-bg, #000);
    color: var(--color-text, #fff);
    font-family: var(--font-primary, 'Inter', sans-serif);

    overflow: hidden;

    /* Stop the browser hijacking drags as page scroll / pinch.
       Looking around must feel like grabbing the world. */
    touch-action: none;
    overscroll-behavior: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* The WebGL canvas is injected in here by viewer-360.js */
.fa360__stage {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.fa360__stage canvas {
    display: block;
    width: 100%;
    height: 100%;
}


/*
 * ============================================================
 * CONTROL BAR
 * ============================================================
 * A row pinned to the bottom: the alignment toggle (left), the
 * era navigator — earlier / date / later — filling the middle,
 * and Fullscreen (right). The Back (home) button lives
 * separately in the top-left corner.
 *
 * The bar itself ignores pointer events so dragging works
 * right up to the edges; only the actual controls inside it
 * are interactive (pointer-events re-enabled on each).
 *
 * Padding uses max(fixed, safe-area-inset) so the controls
 * clear notches and home indicators on modern phones, while
 * still having a sensible gap on devices that report 0.
 * ============================================================
 */
.fa360__controls {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;

    padding-left:   max(1.25rem, env(safe-area-inset-left));
    padding-right:  max(1.25rem, env(safe-area-inset-right));
    padding-bottom: max(1.5rem,  env(safe-area-inset-bottom));
    padding-top: 1.5rem;

    /* Soft bottom fade so white controls stay legible over a
       bright sky or pale ground without a hard bar. */
    background: linear-gradient(to top, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.18) 55%, transparent 100%);

    pointer-events: none;
}


/*
 * ============================================================
 * ICON BUTTONS — Back + Fullscreen (matched pair)
 * ============================================================
 */
.fa360__icon-btn {
    pointer-events: auto;

    flex: 0 0 auto;
    width: 3.25rem;
    height: 3.25rem;
    display: grid;
    place-items: center;

    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.85);
    background-color: rgba(0, 0, 0, 0.35);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);

    color: #fff;
    cursor: pointer;

    transition: border-color 0.25s ease,
                box-shadow 0.25s ease,
                background-color 0.25s ease,
                transform 0.1s ease;
}

.fa360__icon-btn svg {
    width: 1.5rem;
    height: 1.5rem;
    display: block;
}

/* Gold-glow gesture — same language as .btn--gold elsewhere */
.fa360__icon-btn:hover,
.fa360__icon-btn:focus-visible {
    border-color: var(--color-gold, #B8960C);
    box-shadow: 0 0 20px var(--color-gold-glow, rgba(184,150,12,0.8));
    outline: none;
}

.fa360__icon-btn:active {
    transform: scale(0.94);
}

/* Fullscreen button hides itself where the Fullscreen API is
   unavailable (e.g. iPhone Safari). viewer-360.js adds this
   class after a capability check. margin-left:auto keeps it
   pinned to the right even on a single-era page, where the
   alignment toggle and era navigator are not rendered. */
.fa360__fs {
    margin-left: auto;
}

.fa360__fs.is-unsupported {
    display: none;
}


/*
 * ============================================================
 * 360° VIDEO PROGRESS LINE
 * ============================================================
 * Shown only while a video segment is the live one. A thin
 * gold progress line in the same quiet glass language as the
 * controls, sitting just above the control bar, with the whole
 * strip acting as a tap-to-replay target.
 *
 * Ported from the app build, where these rules lived in an
 * inline <style> block in viewer.html. They belong here now
 * that the viewer is served by a page template rather than a
 * standalone HTML file.
 *
 * The 22px height is a deliberate tap target — the visible
 * line is only 2px, which no thumb could reliably hit.
 * ============================================================
 */
.fa360__vprogress {
    position: absolute;
    left:  max(1.25rem, env(safe-area-inset-left));
    right: max(1.25rem, env(safe-area-inset-right));
    bottom: calc(max(1.5rem, env(safe-area-inset-bottom)) + 4.75rem);
    z-index: 3;

    height: 22px;
    display: none;
    align-items: center;

    cursor: pointer;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
}

.fa360__vprogress.is-visible {
    display: flex;
}

.fa360__vprogress-track {
    position: relative;
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 1px;
    overflow: hidden;
}

.fa360__vprogress-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0%;
    background: var(--color-gold, #B8960C);
    box-shadow: 0 0 8px var(--color-gold-glow, rgba(184, 150, 12, 0.8));
    border-radius: 1px;
}


/*
 * ============================================================
 * BACK (HOME) BUTTON — top-left
 * ============================================================
 * A home-style icon pinned to the top-left corner, matching
 * the app UI. Same .fa360__icon-btn styling as every other
 * control; still a plain link to the per-page fa360_back_url.
 * ============================================================
 */
.fa360__back {
    position: absolute;
    z-index: 3;
    top:  max(1.25rem, env(safe-area-inset-top));
    left: max(1.25rem, env(safe-area-inset-left));
}


/*
 * ============================================================
 * ALIGNMENT TOGGLE — bottom-left
 * ============================================================
 * Sits at the left end of the bottom control bar. Tapping it
 * cross-fades to the present-day era so the visitor can line
 * the panorama up with where they are standing; tapping again
 * returns to the era they were viewing. While active it holds
 * the gold glow (same language as the sound button's
 * .is-playing) and the era arrows are disabled.
 * ============================================================
 */
.fa360__align.is-active {
    border-color: var(--color-gold, #B8960C);
    box-shadow: 0 0 16px var(--color-gold-glow, rgba(184,150,12,0.8));
}


/*
 * ============================================================
 * SOUND TOGGLE (top-right)
 * ============================================================
 * Only present in the DOM when the page has an audio file set
 * (the template renders it conditionally). It reuses the
 * .fa360__icon-btn pair styling — white outline on a dark
 * scrim with the gold-glow gesture — but lives on its own in
 * the top-right corner rather than in the bottom control bar.
 *
 * Insets use max(fixed, safe-area-inset) so the button clears
 * notches / status bars on modern phones while still sitting a
 * sensible distance from the edge on devices that report 0.
 *
 * .is-playing keeps the gold glow ON for the whole time audio
 * is playing (added/removed by viewer-360.js), so the visitor
 * can see at a glance that sound is active and tap to pause.
 * ============================================================
 */
.fa360__sound {
    position: absolute;
    z-index: 3;
    top:   max(1.25rem, env(safe-area-inset-top));
    right: max(1.25rem, env(safe-area-inset-right));
}

.fa360__sound.is-playing {
    border-color: var(--color-gold, #B8960C);
    box-shadow: 0 0 16px var(--color-gold-glow, rgba(184,150,12,0.8));
}


/*
 * ============================================================
 * INFO TOGGLE (top-right, below the sound button) + LABELS
 * ============================================================
 * The info button shares the .fa360__icon-btn pair styling and
 * safe-area-aware inset and is pinned to the top-RIGHT corner.
 * When the page also has audio, the template adds .is-stacked
 * so it sits vertically BELOW the sound button; without audio
 * it takes the corner itself. Only present in the DOM when the
 * page has labels set (the template renders it conditionally),
 * so a page without labels never shows it.
 *
 * .is-active keeps the gold glow ON while the labels are
 * showing (added/removed by viewer-360.js), matching the
 * sound button's .is-playing language.
 *
 * The labels layer sits between the canvas (z1) and the
 * controls (z3). It ignores pointer events entirely, so
 * drag-to-look keeps working right through the labels. Each
 * .fa360__label is positioned by viewer-360.js every frame —
 * projected through the same camera as the panorama — so the
 * boxes stay pinned to their features in both gyro and drag
 * modes, and stay put when the era changes.
 * ============================================================
 */
.fa360__info {
    position: absolute;
    z-index: 3;
    top:   max(1.25rem, env(safe-area-inset-top));
    right: max(1.25rem, env(safe-area-inset-right));
}

/* Page has audio too → sit below the sound button
   (button height 3.25rem + a 0.75rem gap). */
.fa360__info.is-stacked {
    top: calc(max(1.25rem, env(safe-area-inset-top)) + 4rem);
}

.fa360__info.is-active {
    border-color: var(--color-gold, #B8960C);
    box-shadow: 0 0 16px var(--color-gold-glow, rgba(184,150,12,0.8));
}

.fa360__labels {
    position: absolute;
    inset: 0;
    z-index: 2;

    pointer-events: none;

    /* Hidden until the visitor taps the info button. The
       visibility delay keeps the layer untabbable/invisible
       until the fade has actually started. */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}

.fa360__labels.is-visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.25s ease;
}

/* The label box itself: a thin white outline with the scene
   showing through — the same quiet white-on-scrim language as
   the icon buttons, per the reference design. transform is set
   by viewer-360.js (translate(-50%,-50%) + the projected pixel
   position), so left/top stay at 0. */
.fa360__label {
    position: absolute;
    left: 0;
    top: 0;
    will-change: transform;

    max-width: 70vw;
    padding: 0.6rem 1.4rem;

    border: 1.5px solid rgba(255, 255, 255, 0.92);
    background-color: rgba(0, 0, 0, 0.18);

    color: #fff;
    font-family: var(--font-primary, 'Inter', sans-serif);
    font-size: 1.05rem;
    font-weight: 400;
    letter-spacing: 0.01em;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
}


/*
 * ============================================================
 * ERA NAVIGATOR
 * ============================================================
 * Earlier / current era label / later, matching the app UI.
 * The eras are stepped through IN ORDER (era_a, era_b, …), so
 * this layout handles anything from 2 to 5 eras with no markup
 * changes. On the first era the earlier arrow is greyed out;
 * on the last, the later arrow is. viewer-360.js keeps the
 * label text and disabled states in sync via syncEraButtons().
 * ============================================================
 */
.fa360__era {
    /* Only the buttons inside are interactive, so dragging the
       panorama keeps working across the gaps. */
    pointer-events: none;

    flex: 1 1 auto;
    min-width: 0;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.fa360__era-label {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;

    text-align: center;
    font-family: var(--font-primary, 'Inter', sans-serif);
    font-size: 1.4rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);

    padding-bottom: 0.6rem;
}

/* The short underline beneath the date, per the app UI. */
.fa360__era-label::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 2.75rem;
    height: 2px;
    border-radius: 1px;
    background: rgba(255, 255, 255, 0.9);
}

/* Greyed-out end-of-timeline (and during alignment) state. */
.fa360__era-nav:disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
    box-shadow: none;
    transform: none;
}

/* While a cross-fade is mid-flight, the navigator is
   non-interactive to avoid stacking transitions. */
.fa360__era.is-busy {
    opacity: 0.85;
}
.fa360__era.is-busy .fa360__era-nav {
    pointer-events: none;
}


/*
 * ============================================================
 * LOADER
 * ============================================================
 * Covers the screen until every panorama texture is decoded,
 * so the experience never starts mid-download. A simple gold
 * ring on the brand-black surface.
 * ============================================================
 */
.fa360__loader {
    position: absolute;
    inset: 0;
    z-index: 4;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;

    background-color: var(--color-bg, #000);

    transition: opacity 0.5s ease;
}

.fa360__loader.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.fa360__spinner {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--color-gold, #B8960C);
    animation: fa360-spin 0.9s linear infinite;
}

.fa360__loading-text {
    font-size: 0.7rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--color-text-muted, rgba(255,255,255,0.6));
}

@keyframes fa360-spin {
    to { transform: rotate(360deg); }
}


/*
 * ============================================================
 * FALLBACK
 * ============================================================
 * Shown if WebGL is unavailable or a panorama fails to load.
 * An empty screen is never acceptable on site — give the
 * visitor the first image flat, plus a plain explanation.
 * ============================================================
 */
.fa360__fallback {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: none;

    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 1rem;
    padding: 2rem;

    background-color: var(--color-bg, #000);
    background-size: cover;
    background-position: center;
}

.fa360__fallback.is-visible {
    display: flex;
}

.fa360__fallback p {
    max-width: 32ch;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #fff;
    background-color: rgba(0, 0, 0, 0.55);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
}


/*
 * ============================================================
 * OPENING MODAL — "Position Your Phone"
 * ============================================================
 * Sits above everything once the loader clears. The scrim
 * blurs the live panorama behind it (matching the prototype),
 * and the Continue button uses the brand gold-on-press gesture.
 * ============================================================
 */
.fa360__modal {
    position: absolute;
    inset: 0;
    z-index: 6;

    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;

    background-color: rgba(0, 0, 0, 0.45);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);

    opacity: 1;
    transition: opacity 0.4s ease;
}

.fa360__modal.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.fa360__modal-panel {
    width: min(92vw, 22rem);
    padding: 2rem 1.75rem;
    text-align: center;

    background-color: rgba(8, 8, 8, 0.94);
    border: 1px solid var(--color-border, rgba(255,255,255,0.08));
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);

    transition: transform 0.4s ease, opacity 0.4s ease;
}

.fa360__modal.is-hidden .fa360__modal-panel {
    transform: translateY(10px) scale(0.98);
}

.fa360__modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #fff;
    margin-bottom: 1.5rem;
}

.fa360__modal-icon {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1.5rem;
    color: #fff;
}

.fa360__modal-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.fa360__modal-body {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--color-text-muted, rgba(255,255,255,0.6));
}

.fa360__modal-body p + p {
    margin-top: 0.9rem;
}

/* The site-specific aiming line reads a touch brighter than
   the standard permission line beneath it. */
.fa360__modal-instruction {
    color: #fff;
}

.fa360__continue {
    appearance: none;
    margin-top: 1.75rem;
    min-width: 12rem;
    padding: 0.85rem 2rem;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: 0.5rem;
    background: transparent;
    color: #fff;
    cursor: pointer;

    font-family: var(--font-primary, 'Inter', sans-serif);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;

    transition: background-color 0.2s ease,
                color 0.2s ease,
                border-color 0.2s ease,
                box-shadow 0.2s ease,
                transform 0.1s ease;
}

/* Brand gold on hover / focus / press — the same gesture as
   .btn--gold elsewhere, matching the prototype's Continue. */
.fa360__continue:hover,
.fa360__continue:focus-visible,
.fa360__continue:active {
    background-color: var(--color-gold, #B8960C);
    border-color: var(--color-gold, #B8960C);
    color: #000;
    box-shadow: 0 0 20px var(--color-gold-glow, rgba(184,150,12,0.8));
    outline: none;
}

.fa360__continue:active {
    transform: scale(0.97);
}


/*
 * ============================================================
 * HINT (transient)
 * ============================================================
 * Brief message shown when motion is declined or unavailable,
 * so a no-gyro visitor knows they can still drag to look.
 * ============================================================
 */
.fa360__hint {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(max(1.5rem, env(safe-area-inset-bottom)) + 5rem);
    z-index: 5;

    max-width: 80vw;
    padding: 0.6rem 1rem;
    border-radius: 999px;

    background-color: rgba(0, 0, 0, 0.7);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);

    color: #fff;
    font-size: 0.8rem;
    text-align: center;

    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.fa360__hint.is-visible {
    opacity: 1;
}


/*
 * ============================================================
 * SMALL SCREENS
 * ============================================================
 */
@media (max-width: 380px) {
    .fa360__icon-btn {
        width: 2.9rem;
        height: 2.9rem;
    }
    .fa360__era-label {
        font-size: 1.15rem;
        letter-spacing: 0.04em;
    }
    .fa360__label {
        padding: 0.5rem 1rem;
        font-size: 0.92rem;
    }
}


/*
 * ============================================================
 * REDUCED MOTION
 * ============================================================
 * viewer-360.js also reads prefers-reduced-motion to shorten
 * the cross-fade and disable drag inertia; here we calm the
 * spinner for the same audience.
 * ============================================================
 */
@media (prefers-reduced-motion: reduce) {
    .fa360__spinner {
        animation-duration: 1.8s;
    }
    .fa360__icon-btn,
    .fa360__era-nav,
    .fa360__loader,
    .fa360__modal,
    .fa360__modal-panel,
    .fa360__continue,
    .fa360__hint,
    .fa360__labels {
        transition: none;
    }
}
