/* =========================================================
   LEDIA — Animations
   Motion is restrained-to-moderate, editorial in feel.
   Honors prefers-reduced-motion at the bottom of the file.
   ========================================================= */

/* =========================================================
   KEYFRAMES
   ========================================================= */
@keyframes ledia-fade-up {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes ledia-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes ledia-draw-line {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}

@keyframes ledia-gold-sweep {
    from { background-size: 0 2px; }
    to   { background-size: 100% 2px; }
}

@keyframes ledia-pulse-soft {
    0%, 100% { opacity: 0.55; transform: scale(1); }
    50%      { opacity: 1;   transform: scale(1.08); }
}

@keyframes ledia-ambient-drift {
    0%   { transform: translate(0, 0) scale(1); opacity: 0.06; }
    50%  { transform: translate(-3%, 2%) scale(1.05); opacity: 0.10; }
    100% { transform: translate(0, 0) scale(1); opacity: 0.06; }
}

@keyframes ledia-rise-stagger {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   SCROLL-REVEAL — applied via IntersectionObserver in JS
   Initial state hides; .is-visible reveals.
   ========================================================= */
.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
    will-change: opacity, transform;
}

.reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered children */
.reveal-stagger > * {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}

.reveal-stagger.is-visible > *:nth-child(1) { transition-delay: 0.00s; }
.reveal-stagger.is-visible > *:nth-child(2) { transition-delay: 0.10s; }
.reveal-stagger.is-visible > *:nth-child(3) { transition-delay: 0.20s; }
.reveal-stagger.is-visible > *:nth-child(4) { transition-delay: 0.30s; }
.reveal-stagger.is-visible > *:nth-child(5) { transition-delay: 0.40s; }
.reveal-stagger.is-visible > *:nth-child(6) { transition-delay: 0.50s; }

.reveal-stagger.is-visible > * {
    opacity: 1;
    transform: translateY(0);
}

/* Divider lines that "draw" in */
.draw-line {
    transform-origin: left center;
    transform: scaleX(0);
    transition: transform 1s var(--ease) 0.2s;
}

.draw-line.is-visible { transform: scaleX(1); }

/* =========================================================
   HERO ENHANCEMENTS — homepage
   ========================================================= */

/* Ambient gold glow behind the hero */
.hero__glow {
    position: absolute;
    top: -10%;
    right: -10%;
    width: 60%;
    height: 80%;
    background: radial-gradient(circle, rgba(180, 31, 39, 0.16), transparent 65%);
    pointer-events: none;
    animation: ledia-ambient-drift 14s ease-in-out infinite;
    z-index: 0;
}

/* Typed hero headline — words appear one at a time */
.hero__title .word {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    animation: ledia-rise-stagger 0.7s var(--ease) forwards;
}

.hero__title .word--em {
    color: var(--steel-accent);
    font-style: italic;
}

/* Words are animated via inline animation-delay set in JS for arbitrary text */

/* When a heading inside .rise also has .typed-words, the .rise animation
   on the heading itself is suppressed — the word-level animation handles it. */
.rise > .typed-words {
    opacity: 1;
    animation: none;
}

/* Underline beneath the em word, drawn after the words appear */
.hero__title .word--em {
    background-image: linear-gradient(var(--steel-accent), var(--steel-accent));
    background-position: 0 100%;
    background-repeat: no-repeat;
    background-size: 0 2px;
    padding-bottom: 4px;
    animation: ledia-rise-stagger 0.7s var(--ease) forwards,
               ledia-gold-sweep 1.2s var(--ease) forwards;
    animation-delay: var(--word-delay, 0s), calc(var(--word-delay, 0s) + 0.7s);
}

/* =========================================================
   DOTTED ARROW LOGO MARK — from cover slide
   Interactive: clickable scroll affordance with build-up hover
   ========================================================= */
.arrow-mark {
    position: absolute;
    bottom: clamp(28px, 5vw, 56px);
    right: clamp(24px, 5vw, 48px);
    width: 80px;
    height: 116px;
    z-index: 2;
    opacity: 0;
    animation: ledia-fade-in 1.2s var(--ease) 1.6s forwards;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: transform 0.4s var(--ease);
}

.arrow-mark:hover { transform: translateY(-2px); }

.arrow-mark:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 8px;
}

/* Pressed state — when clicked, arrow nudges down briefly */
.arrow-mark.is-pressed {
    animation: ledia-arrow-press 0.6s var(--ease);
}

@keyframes ledia-arrow-press {
    0%   { transform: translateY(0); }
    30%  { transform: translateY(6px); }
    100% { transform: translateY(0); }
}

/* Scroll affordance label */
.arrow-mark__label {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    font-family: var(--font-display);
    font-style: italic;
    font-size: 10px;
    color: var(--gold);
    letter-spacing: 2px;
    text-transform: uppercase;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
    pointer-events: none;
}

.arrow-mark:hover .arrow-mark__label,
.arrow-mark:focus-visible .arrow-mark__label {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Dots */
.arrow-mark__dot {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gold);
    transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

/* Arrow tip — single dot at top */
.arrow-mark__dot--1 { top: 0;   left: 36px; }
/* Row 2 — 2 dots */
.arrow-mark__dot--2 { top: 14px; left: 28px; }
.arrow-mark__dot--3 { top: 14px; left: 44px; }
/* Row 3 — 3 dots */
.arrow-mark__dot--4 { top: 28px; left: 20px; }
.arrow-mark__dot--5 { top: 28px; left: 36px; }
.arrow-mark__dot--6 { top: 28px; left: 52px; }
/* Row 4 — 4 dots (widest row) */
.arrow-mark__dot--7  { top: 42px; left: 12px; }
.arrow-mark__dot--8  { top: 42px; left: 28px; }
.arrow-mark__dot--9  { top: 42px; left: 44px; }
.arrow-mark__dot--10 { top: 42px; left: 60px; }
/* Stem dots — middle column */
.arrow-mark__dot--11 { top: 60px; left: 36px; }
.arrow-mark__dot--12 { top: 78px; left: 36px; opacity: 0.55; }
.arrow-mark__dot--13 { top: 96px; left: 36px; opacity: 0.25; }

/* Default ambient pulse on the tip three dots */
.arrow-mark__dot--1 { animation: ledia-pulse-soft 3.2s ease-in-out infinite; }
.arrow-mark__dot--2 { animation: ledia-pulse-soft 3.2s ease-in-out infinite 0.25s; }
.arrow-mark__dot--3 { animation: ledia-pulse-soft 3.2s ease-in-out infinite 0.5s; }

/* ---------- BUILD-UP HOVER ---------- */
/* On hover: all dots fade out, then reassemble from base upward.
   Stem-base dots first (faintest), then stem, then widest row, narrowing to the tip.
   Each dot's :hover transition handles the fade-in; staggered delays via :nth-child-like rules. */

.arrow-mark:hover .arrow-mark__dot {
    /* Suppress the ambient pulse during the build-up */
    animation: none;
}

/* Out-state — dots vanish first, then reappear in order */
.arrow-mark:hover .arrow-mark__dot {
    opacity: 0;
    transform: scale(0.4);
    transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
}

/* Build order — base of the stem upward to the tip.
   Total sequence ~1.4s, each dot ~0.08s after the last. */
.arrow-mark:hover .arrow-mark__dot--13 { transition-delay: 0.05s; opacity: 0.25; transform: scale(1); }
.arrow-mark:hover .arrow-mark__dot--12 { transition-delay: 0.15s; opacity: 0.55; transform: scale(1); }
.arrow-mark:hover .arrow-mark__dot--11 { transition-delay: 0.25s; opacity: 1;    transform: scale(1); }

/* Widest row — 4 dots */
.arrow-mark:hover .arrow-mark__dot--7  { transition-delay: 0.40s; opacity: 1; transform: scale(1); }
.arrow-mark:hover .arrow-mark__dot--8  { transition-delay: 0.45s; opacity: 1; transform: scale(1); }
.arrow-mark:hover .arrow-mark__dot--9  { transition-delay: 0.50s; opacity: 1; transform: scale(1); }
.arrow-mark:hover .arrow-mark__dot--10 { transition-delay: 0.55s; opacity: 1; transform: scale(1); }

/* Row 3 — 3 dots */
.arrow-mark:hover .arrow-mark__dot--4 { transition-delay: 0.70s; opacity: 1; transform: scale(1); }
.arrow-mark:hover .arrow-mark__dot--5 { transition-delay: 0.75s; opacity: 1; transform: scale(1); }
.arrow-mark:hover .arrow-mark__dot--6 { transition-delay: 0.80s; opacity: 1; transform: scale(1); }

/* Row 2 — 2 dots */
.arrow-mark:hover .arrow-mark__dot--2 { transition-delay: 0.95s; opacity: 1; transform: scale(1); }
.arrow-mark:hover .arrow-mark__dot--3 { transition-delay: 1.00s; opacity: 1; transform: scale(1); }

/* Tip — final dot lands with a brief overshoot */
.arrow-mark:hover .arrow-mark__dot--1 {
    transition-delay: 1.15s;
    transition: opacity 0.4s var(--ease), transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 1;
    transform: scale(1.15);
}

/* When the build completes, scale the tip back to normal */
.arrow-mark:hover .arrow-mark__dot--1 {
    animation: ledia-arrow-tip-settle 0.4s var(--ease) 1.55s forwards;
}

@keyframes ledia-arrow-tip-settle {
    from { transform: scale(1.15); }
    to   { transform: scale(1); }
}

@media (max-width: 700px) {
    .arrow-mark {
        bottom: 24px;
        right: 6%;
        transform: scale(0.7);
        transform-origin: bottom right;
    }
}

/* =========================================================
   ANIMATED COUNTERS
   ========================================================= */
.counter {
    display: inline-block;
    font-variant-numeric: tabular-nums;
}

/* When counter is mid-animation it shows zero — keep the rendered value smooth */
.counter[data-counting="true"] {
    color: var(--burgundy);
}

/* =========================================================
   VIDEO TILE HOVER — Ken Burns
   ========================================================= */
.video {
    overflow: hidden;
}

.video::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.25) 100%);
    transition: transform 6s var(--ease), opacity 0.4s var(--ease);
    z-index: 0;
}

.video:hover::before {
    transform: scale(1.08);
}

.video > * { position: relative; z-index: 1; }

/* =========================================================
   FEATURED ARTICLE — gentle hover lift
   ========================================================= */
.featured__art {
    transition: transform 0.6s var(--ease);
}

.featured__art:hover {
    transform: scale(1.015);
}

/* Article cards already have hover lift in pages.css — add cover image drift */
.article__cover {
    overflow: hidden;
    position: relative;
}

.article__cover::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(107,158,189,0.10), transparent);
    transform: translateX(-100%);
    transition: transform 0.8s var(--ease);
}

.article:hover .article__cover::after {
    transform: translateX(0);
}

/* =========================================================
   TESTIMONIAL — gentle quote mark animation on reveal
   ========================================================= */
.reveal .testimonial__mark {
    transform: scale(0.8) translateY(8px);
    opacity: 0;
    transition: opacity 0.6s var(--ease) 0.3s, transform 0.6s var(--ease) 0.3s;
}

.reveal.is-visible .testimonial__mark {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* =========================================================
   NAV LINK UNDERLINE — slide in on hover
   ========================================================= */
.nav__link {
    position: relative;
}

.nav__link::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--gold);
    transform: scaleX(0);
    transform-origin: right center;
    transition: transform 0.35s var(--ease);
}

.nav__link:hover::after {
    transform: scaleX(1);
    transform-origin: left center;
}

/* Active page already has the underline — disable the slide */
.nav__link[aria-current="page"]::after {
    transform: scaleX(1);
}

/* =========================================================
   BUTTON ARROW — already in styles.css, extend with subtle entrance
   ========================================================= */
.btn--gold {
    background-size: 200% 100%;
    background-image: linear-gradient(90deg, var(--gold) 50%, var(--gold-light) 50%);
    background-position: 0% 0;
    transition: background-position 0.4s var(--ease), transform 0.25s var(--ease);
}

.btn--gold:hover {
    background-position: -100% 0;
    transform: translateY(-1px);
}

/* =========================================================
   REDUCED MOTION
   Respect user preference — disable everything decorative
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
    .reveal,
    .reveal-stagger > *,
    .draw-line {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }

    .hero__title .word,
    .arrow-mark,
    .hero__glow {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }

    .hero__title .word--em {
        background-size: 100% 2px !important;
    }

    .arrow-mark__dot--1,
    .arrow-mark__dot--2,
    .arrow-mark__dot--3 {
        animation: none !important;
    }

    /* Arrow remains clickable but skips the build-up choreography */
    .arrow-mark:hover .arrow-mark__dot {
        opacity: 1 !important;
        transform: scale(1) !important;
        transition: none !important;
        transition-delay: 0s !important;
    }
    .arrow-mark__dot--12 { opacity: 0.55 !important; }
    .arrow-mark__dot--13 { opacity: 0.25 !important; }
    .arrow-mark.is-pressed { animation: none !important; }

    .video::before,
    .article__cover::after,
    .featured__art {
        transition: none !important;
        transform: none !important;
    }
}
