/*
 * Fearann Alba — viewer-360.css
 *
 * 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: Back (left), era toggle
 * (centre), Fullscreen (right).
 *
 * 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. */
.fa360__fs.is-unsupported {
    display: none;
}


/*
 * ============================================================
 * SOUND TOGGLE (top-left)
 * ============================================================
 * 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-left 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));
    left: max(1.25rem, env(safe-area-inset-left));
}

.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));
}


/*
 * ============================================================
 * ERA TOGGLE
 * ============================================================
 * A pill split into 2 (or 3) labelled segments. The active
 * era gets the only bold colour on the screen: a dark fill
 * lifted by a gold glow, mirroring the prototype's look.
 *
 * Built with flex so 2 or 3 segments both lay out correctly
 * with no markup changes.
 * ============================================================
 */
.fa360__era {
    pointer-events: auto;

    display: inline-flex;
    align-items: center;
    gap: 0.25rem;

    padding: 0.3rem;
    border-radius: 999px;
    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);

    /* Sit centred even though the row uses space-between */
    margin: 0 auto;
}

.fa360__era-seg {
    appearance: none;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;

    padding: 0.5rem 1.1rem;
    border-radius: 999px;

    font-family: var(--font-primary, 'Inter', sans-serif);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    white-space: nowrap;

    color: rgba(255, 255, 255, 0.65);

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

.fa360__era-seg:hover {
    color: #fff;
}

.fa360__era-seg:focus-visible {
    outline: none;
    color: #fff;
    border-color: var(--color-gold, #B8960C);
}

.fa360__era-seg.is-active {
    color: #fff;
    background-color: var(--color-surface, #0b0b0b);
    border-color: rgba(184, 150, 12, 0.55);
    box-shadow: 0 0 16px var(--color-gold-glow, rgba(184,150,12,0.8));
}

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


/*
 * ============================================================
 * 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-seg {
        padding: 0.45rem 0.8rem;
        font-size: 0.72rem;
        letter-spacing: 0.08em;
    }
}


/*
 * ============================================================
 * 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-seg,
    .fa360__loader,
    .fa360__modal,
    .fa360__modal-panel,
    .fa360__continue,
    .fa360__hint {
        transition: none;
    }
}
