/**
 * Fearann Alba — history.css
 *
 * Styles for the shared History page (templates/page-history.php),
 * used by every History page (e.g. the 'castle-haven' and
 * 'ardstinchar' slugs). Reuses the theme's tokens, .btn and
 * .container, plus a ported copy of the .tt-compare comparison-slider
 * frame so the page never depends on the Time Travel or Historic Site
 * stylesheets being loaded.
 *
 * PROGRESSIVE ENHANCEMENT
 *   Everything is fully visible by DEFAULT. history.js adds a
 *   .js-ready class to each scroll-driven section, which switches its
 *   animated parts into their hidden "before" state; the script then
 *   reveals them with .is-* classes as the visitor scrolls. So with
 *   JavaScript off (or before it runs) the page shows all its copy,
 *   cards and buttons — nothing is ever stranded hidden.
 *
 * SECTION MAP
 *   0. Page shell
 *   1. Hero — pinned scroll-scrubbed video
 *   2. The History — text + (desktop) image
 *   3. Slider Image — full-screen before/after (.tt-compare*)
 *   4. How It Works — sticky card stack
 *   5. Responsive (mobile)
 *   6. Reduced motion
 *
 * The fixed site header is 70px tall; pinned/full-screen areas use
 * calc(100vh - 70px) (with 100svh fallbacks for mobile browser
 * chrome) so nothing hides behind the nav.
 */


/* ============================================================
 * 0. PAGE SHELL
 * ============================================================ */
.fah-page {
    position: relative;
    background: var(--color-bg);
    /* No overflow here on purpose: position: sticky children are
       bounded by their own sections, and an overflow context on an
       ancestor is the classic way to silently break sticky. */
}


/* ============================================================
 * 1. HERO — pinned scroll-scrubbed video
 * ============================================================ */
.fah-hero {
    position: relative;
    height: 260vh;      /* scroll distance for the scrub + reveals */
}

.fah-hero__pin {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    background: #000;
}
@supports (height: 100svh) { .fah-hero__pin { height: 100svh; } }

.fah-hero__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    background: #000;
}

.fah-hero__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom,
        rgba(0,0,0,0.55) 0%,
        rgba(0,0,0,0.15) 28%,
        rgba(0,0,0,0.15) 60%,
        rgba(0,0,0,0.70) 100%);
}

.fah-hero__content {
    position: absolute;
    left: 0; right: 0;
    top: calc(70px + 8vh);
    padding: 0 var(--container-padding);
    text-align: center;
    z-index: 2;
}

.fah-hero__title {
    margin: 0;
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    line-height: 1.02;
    font-size: clamp(2.4rem, 7vw, 5.5rem);
    color: var(--color-text);
    text-shadow: 0 2px 24px rgba(0,0,0,0.5);
    transition: opacity 0.7s ease, transform 0.7s cubic-bezier(.2,.7,.2,1);
}

.fah-hero__subtitle {
    margin: 0.9rem 0 0;
    font-weight: var(--weight-light);
    letter-spacing: 0.04em;
    font-size: clamp(0.95rem, 2.2vw, 1.4rem);
    color: rgba(255,255,255,0.85);
    text-shadow: 0 2px 16px rgba(0,0,0,0.5);
    transition: opacity 0.7s ease 0.12s, transform 0.7s ease 0.12s;
}

.fah-hero__cta {
    position: absolute;
    left: 0; right: 0;
    bottom: clamp(4.5rem, 12vh, 8rem);
    display: flex;
    justify-content: center;
    z-index: 2;
}
.fah-hero__btn { transition: opacity 0.6s ease, transform 0.6s ease; }

.fah-hero__scroll {
    position: absolute;
    left: 50%;
    bottom: 1.4rem;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    color: rgba(255,255,255,0.7);
    font-size: 0.62rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    z-index: 2;
    transition: opacity 0.4s ease;
}
.fah-hero__scroll svg { width: 18px; height: 18px; animation: fah-bob 1.8s ease-in-out infinite; }

@keyframes fah-bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(4px); }
}

/* --- JS-on initial (hidden) states --- */
.fah-hero.js-ready .fah-hero__title    { opacity: 0; transform: translateX(-3.5rem); }
.fah-hero.js-ready .fah-hero__subtitle { opacity: 0; transform: translateY(0.75rem); }
.fah-hero.js-ready .fah-hero__btn      { opacity: 0; transform: translateY(1rem); pointer-events: none; }

/* --- scroll-revealed states (override the hidden ones) --- */
.fah-hero.is-title .fah-hero__title    { opacity: 1; transform: translateX(0); }
.fah-hero.is-title .fah-hero__subtitle { opacity: 1; transform: translateY(0); }
.fah-hero.is-cta   .fah-hero__btn      { opacity: 1; transform: translateY(0); pointer-events: auto; }
.fah-hero.is-cta   .fah-hero__scroll   { opacity: 0; pointer-events: none; }


/* ============================================================
 * 2. THE HISTORY
 * ============================================================ */
.fah-history { position: relative; background: var(--color-bg); }

.fah-history__inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(2rem, 5vw, 5rem);
    align-items: center;
}

.fah-history__title {
    margin: 0 0 1.4rem;
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: clamp(1.6rem, 3.4vw, 2.6rem);
    color: var(--color-text);
}

.fah-history__text p {
    margin: 0 0 1.1rem;
    color: var(--color-text-muted);
    line-height: 1.8;
    font-size: 1rem;
}

.fah-history__btn { margin-top: 1.2rem; }

.fah-history__media { position: relative; width: 100%; }

.fah-history__img {
    display: block;
    width: 100%;
    height: 100%;
    max-height: 70vh;
    object-fit: cover;
    border: 1px solid var(--color-border);
}


/* ============================================================
 * 3. SLIDER IMAGE — full-screen before / after
 * ============================================================ */
.fah-slider { position: relative; background: #000; line-height: 0; }
.fah-pic { display: contents; }

/* --- ported comparison slider frame (.tt-compare*) --- */
.tt-compare__slider {
    --tt-pos: 50%;
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 2;
    overflow: hidden;
    cursor: ew-resize;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}

.tt-compare__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    pointer-events: none;
}

.tt-compare__over {
    position: absolute;
    inset: 0;
    clip-path: inset(0 calc(100% - var(--tt-pos)) 0 0);
    pointer-events: none;
}

.tt-compare__divider {
    position: absolute;
    top: 0; bottom: 0;
    left: var(--tt-pos);
    transform: translateX(-50%);
    width: 2px;
    background: #ffffff;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.55);
    cursor: ew-resize;
    outline: none;
}

.tt-compare__divider:focus-visible .tt-compare__grip { box-shadow: 0 0 0 3px var(--color-gold-glow); }

.tt-compare__handle {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: #ffffff;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
    pointer-events: none;
}

.tt-compare__grip {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px; height: 46px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.tt-compare__hand { width: 22px; height: 22px; }
.tt-compare__chevron { width: 14px; height: 14px; opacity: 0.9; }
.tt-compare__slider.is-dragging .tt-compare__grip { background: #ffffff; color: #111111; }
.tt-compare__slider.is-dragging { cursor: grabbing; }

/* --- full-screen override --- */
.fah-compare {
    aspect-ratio: auto;
    height: calc(100vh - 70px);
    line-height: normal;
}
@supports (height: 100svh) { .fah-compare { height: calc(100svh - 70px); } }


/* ============================================================
 * 4. HOW IT WORKS — sticky card stack
 * ============================================================ */
.fah-how {
    position: relative;
    background: var(--color-bg);
    height: 760vh;      /* room to reveal 5 cards + the button */
}

.fah-how__stage {
    position: sticky;
    top: 70px;
    height: calc(100vh - 70px);
    display: flex;
    align-items: center;
    overflow: hidden;
}
@supports (height: 100svh) { .fah-how__stage { height: calc(100svh - 70px); } }

.fah-how__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.fah-how__title {
    margin: 0 0 1.8rem;
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: clamp(1.5rem, 3.4vw, 2.4rem);
    color: var(--color-text);
}

.fah-how__stack {
    width: 100%;
    max-width: 560px;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.fah-how-card {
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    padding: 0.85rem 1.1rem;
    text-align: center;
    transition:
        opacity 0.45s ease,
        transform 0.45s cubic-bezier(.2,.7,.2,1),
        border-color 0.3s ease,
        background-color 0.3s ease;
}

.fah-how-card__title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: var(--weight-bold);
    letter-spacing: 0.02em;
    color: var(--color-gold);
}
.fah-how-card__num { opacity: 0.85; }

.fah-how-card__body {
    /* Default: open (so no-JS shows the text). JS collapses inactive
       cards. Uses the 0fr→1fr grid trick for height animation. */
    display: grid;
    grid-template-rows: 1fr;
    overflow: hidden;
    margin-top: 0.55rem;
    opacity: 1;
    transition: grid-template-rows 0.4s ease, margin-top 0.4s ease, opacity 0.3s ease;
}
.fah-how-card__body > p {
    min-height: 0;
    margin: 0;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    line-height: 1.6;
}

.fah-how__cta {
    margin-top: 1.6rem;
    display: flex;
    justify-content: center;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

/* --- JS-on states --- */
/* Before reveal: cards sit below, faded; bodies collapsed. */
.fah-how.js-ready .fah-how-card {
    opacity: 0;
    transform: translateY(28px);
}
.fah-how.js-ready .fah-how-card__body {
    grid-template-rows: 0fr;
    margin-top: 0;
    opacity: 0;
}
.fah-how.js-ready .fah-how__cta {
    opacity: 0;
    transform: translateY(1rem);
    pointer-events: none;
}

/* Revealed card slides into place. */
.fah-how .fah-how-card.is-shown {
    opacity: 1;
    transform: translateY(0);
}
/* The active (latest) card: brighter frame + open body. */
.fah-how .fah-how-card.is-active {
    border-color: rgba(184, 150, 12, 0.5);
    background: var(--color-surface-alt);
}
.fah-how .fah-how-card.is-active .fah-how-card__body {
    grid-template-rows: 1fr;
    margin-top: 0.55rem;
    opacity: 1;
}
/* Button appears on the final step. */
.fah-how.is-complete .fah-how__cta {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}


/* ============================================================
 * 5. RESPONSIVE (mobile)
 * ============================================================ */
@media (max-width: 768px) {
    .fah-hero__content { top: calc(70px + 6vh); }

    .fah-history__inner { grid-template-columns: 1fr; }
    .fah-history__media { display: none; }   /* image is desktop-only */

    .fah-how__stack { max-width: 420px; }
    .fah-how-card__title { font-size: 0.9rem; }
}


/* ============================================================
 * 6. REDUCED MOTION
 * ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .fah-hero__scroll svg { animation: none; }
}
