/* Simple 1031 — Animated Explainer Player
 *
 * Shared styles for SVG+CSS keyframe explainer pages embedded as iframes
 * on service pages (forward, reverse, improvement, DST). Pure CSS animation
 * triggered by adding `.is-active` to the current scene; respects
 * `prefers-reduced-motion` by freezing scenes in their final state.
 */

:root {
    --brand-navy: #1B2B4B;
    --brand-emerald: #047857;
    --brand-emerald-light: #10B981;
    --brand-gold: #C7A54B;
    --brand-gray: #F8FAFB;
    --brand-white: #FFFFFF;
    --text-light: #E2E8F0;
    --text-muted: #94A3B8;
    --scene-bg: #0F1A33;
    --vault-fill: #0E3B2D;
    --danger: #DC2626;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--brand-navy);
    color: var(--brand-white);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ---------- Skip-nav (visually hidden until focused) ---------- */

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--brand-gold);
    color: var(--brand-navy);
    padding: 0.5rem 1rem;
    font-weight: 700;
    border-radius: 0 0 8px 0;
    text-decoration: none;
    z-index: 100;
}

.skip-link:focus,
.skip-link:focus-visible {
    left: 0;
    outline: 3px solid var(--brand-emerald-light);
    outline-offset: 2px;
}

/* ---------- Header ---------- */

.explainer-header {
    flex: 0 0 auto;
    padding: 0.75rem 1.25rem;
    background: rgba(0, 0, 0, 0.25);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.explainer-header .brand-link {
    color: var(--brand-white);
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
    letter-spacing: 0.5px;
}

.explainer-header .brand-link .emerald {
    color: var(--brand-emerald-light);
}

.explainer-header h1 {
    margin: 0;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-light);
}

@media (min-width: 768px) {
    .explainer-header h1 {
        font-size: 1.15rem;
    }
}

/* ---------- Stage ---------- */

.explainer-stage {
    flex: 1 1 auto;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, var(--brand-navy) 0%, var(--scene-bg) 100%);
}

.scene {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 1.5rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 320ms ease-out, visibility 0s linear 320ms;
    pointer-events: none;
}

.scene.is-active {
    opacity: 1;
    visibility: visible;
    transition: opacity 320ms ease-in, visibility 0s linear 0s;
    pointer-events: auto;
}

.scene-svg {
    width: 100%;
    max-width: 800px;
    height: auto;
    max-height: 60%;
    flex: 1 1 auto;
}

.caption {
    flex: 0 0 auto;
    text-align: center;
    max-width: 720px;
    margin-top: 0.75rem;
    padding: 0 0.5rem;
}

.caption h2 {
    margin: 0 0 0.4rem 0;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--brand-white);
    line-height: 1.25;
}

.caption p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-light);
}

@media (min-width: 768px) {
    .caption h2 {
        font-size: 1.5rem;
    }

    .caption p {
        font-size: 1.05rem;
    }
}

/* ---------- Controls ---------- */

.explainer-controls {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    background: rgba(0, 0, 0, 0.45);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-wrap: wrap;
}

.explainer-controls button {
    font-family: inherit;
    font-size: 0.9rem;
    background: var(--brand-emerald);
    color: var(--brand-white);
    border: none;
    border-radius: 8px;
    padding: 0.5rem 0.9rem;
    min-height: 44px;
    cursor: pointer;
    transition: background 160ms ease;
    font-weight: 600;
}

.explainer-controls button:hover,
.explainer-controls button:focus-visible {
    background: #036647;
    outline: 2px solid var(--brand-emerald-light);
    outline-offset: 2px;
}

.explainer-controls #scrubber {
    flex: 1 1 200px;
    min-width: 100px;
    accent-color: var(--brand-emerald-light);
    cursor: pointer;
}

.explainer-controls #timeLabel {
    font-variant-numeric: tabular-nums;
    font-size: 0.85rem;
    color: var(--text-light);
    min-width: 80px;
    text-align: center;
}

.explainer-controls .cta {
    background: var(--brand-gold);
    color: var(--brand-navy);
    text-decoration: none;
    padding: 0.55rem 1rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    transition: background 160ms ease;
}

.explainer-controls .cta:hover,
.explainer-controls .cta:focus-visible {
    background: #d8b75c;
    outline: 2px solid var(--brand-gold);
    outline-offset: 2px;
}

@media (max-width: 600px) {
    .explainer-controls {
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .explainer-controls button,
    .explainer-controls .cta {
        font-size: 0.8rem;
        padding: 0.45rem 0.7rem;
    }

    .explainer-controls #timeLabel {
        font-size: 0.75rem;
        min-width: 64px;
    }
}

/* ---------- End-of-video overlay ---------- */

.end-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 26, 51, 0.85);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 240ms ease-in;
    z-index: 10;
}

.end-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.end-overlay h2 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.6rem;
    margin: 0 0 0.5rem 0;
    color: var(--brand-white);
}

.end-overlay p {
    color: var(--text-light);
    margin: 0 0 1.25rem 0;
    max-width: 520px;
}

.end-overlay .cta {
    display: inline-block;
    background: var(--brand-gold);
    color: var(--brand-navy);
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-weight: 700;
    text-decoration: none;
    font-size: 1rem;
    min-height: 44px;
}

/* ---------- Shared SVG element styling ---------- */

.scene-svg text {
    font-family: 'DM Sans', system-ui, sans-serif;
    fill: var(--brand-white);
}

.scene-svg .label {
    font-size: 14px;
    font-weight: 600;
}

.scene-svg .sub-label {
    font-size: 11px;
    fill: var(--text-muted);
    font-weight: 400;
}

.scene-svg .stroke-emerald {
    stroke: var(--brand-emerald-light);
}

.scene-svg .fill-emerald {
    fill: var(--brand-emerald-light);
}

.scene-svg .fill-gold {
    fill: var(--brand-gold);
}

.scene-svg .fill-navy-dark {
    fill: var(--scene-bg);
}

.scene-svg .stroke-gold {
    stroke: var(--brand-gold);
}

.scene-svg .fill-danger {
    fill: var(--danger);
}

/* Reusable animation primitives — keyed by class names that scenes apply
 * with `.is-active .target { animation: ... ; }` rules in inline <style>
 * blocks. Defining keyframes here keeps each explainer page small. */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes drawLine {
    from { stroke-dashoffset: var(--dash-len, 1000); }
    to { stroke-dashoffset: 0; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

@keyframes flowDown {
    from { transform: translateY(-40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes flowRight {
    from { transform: translateX(-40px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes rise {
    from { transform: scaleY(0); }
    to { transform: scaleY(1); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes coinDrop {
    0% { transform: translateY(-40px); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translateY(0); opacity: 1; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    .scene {
        transition: none;
    }

    .scene-svg *,
    .scene-svg {
        animation: none !important;
        transition: none !important;
    }

    /* Show scene content in its final state when motion is reduced. */
    .scene-svg [data-anim] {
        opacity: 1 !important;
        transform: none !important;
        stroke-dashoffset: 0 !important;
    }
}
