/* ============================================================
   Rapaces du Maroc — "Aube sur l'Atlas"
   ============================================================ */

/* === LOCAL FONTS === */
@font-face {
    font-family: 'Tiempos Headline';
    src: url('../assets/fonts/tiempos-headline/tiempos-headline-light.woff2') format('woff2');
    font-weight: 300; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Tiempos Headline';
    src: url('../assets/fonts/tiempos-headline/tiempos-headline-light-italic.woff2') format('woff2');
    font-weight: 300; font-style: italic; font-display: swap;
}
@font-face {
    font-family: 'Tiempos Headline';
    src: url('../assets/fonts/tiempos-headline/tiempos-headline-bold.woff2') format('woff2');
    font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Untitled Sans';
    src: url('../assets/fonts/untitled-sans/untitled-sans-regular.woff2') format('woff2');
    font-weight: 400; font-style: normal; font-display: swap;
}

/* === DESIGN TOKENS === */
:root {
    /* === Primary palette (dark — "Aube sur l'Atlas") === */
    --bg: #0b0e0a;
    --bg-rgb: 11, 14, 10;
    --bg-deep: #05070a;
    --ink: #f2ead8;
    --ink-rgb: 242, 234, 216;
    --surface: #0f1310;

    /* Derived ink tints */
    --ink-muted: rgba(var(--ink-rgb), 0.62);
    --ink-faint: rgba(var(--ink-rgb), 0.28);
    --ink-ghost: rgba(var(--ink-rgb), 0.12);

    /* Borders */
    --border-subtle: rgba(var(--ink-rgb), 0.1);
    --border-medium: rgba(var(--ink-rgb), 0.18);
    --border-strong: rgba(var(--ink-rgb), 0.3);

    /* Button / icon backgrounds */
    --btn-bg: rgba(var(--ink-rgb), 0.05);
    --btn-bg-hover: rgba(var(--ink-rgb), 0.12);

    /* Scrims */
    --badge-scrim: rgba(0, 0, 0, 0.35);
    --modal-scrim: rgba(5, 7, 10, 0.72);
    --end-scrim: rgba(5, 7, 10, 0.82);

    /* Card info overlay gradient stops (use --bg-rgb) */
    --info-overlay-0: rgba(var(--bg-rgb), 0);
    --info-overlay-1: rgba(var(--bg-rgb), 0.7);
    --info-overlay-2: rgba(var(--bg-rgb), 0.92);

    /* Accents */
    --amber: #c8883a;
    --amber-rgb: 200, 136, 58;
    --amber-light: #e8b96a;
    --amber-deep: #a66a20;
    --rust: #8a3a1a;
    --sky-dark: #1a2f4a;

    /* IUCN status dots */
    --lc: #6ba85a;
    --nt: #b89c2f;
    --vu: #c97c32;
    --en: #d65555;
    --cr: #b63838;
    --ex: #8a5a88;

    /* Spotlight + ambient gradients (flip for light) */
    --sky-gradient:
        radial-gradient(ellipse at 70% 0%, rgba(200, 136, 58, 0.10), transparent 55%),
        radial-gradient(ellipse at 20% 100%, rgba(26, 47, 74, 0.30), transparent 60%),
        linear-gradient(180deg, #0b0e0a 0%, #05070a 100%);
    --title-gradient:
        radial-gradient(ellipse 60% 50% at 75% 45%, rgba(200, 136, 58, 0.22), transparent 70%),
        radial-gradient(ellipse 40% 60% at 90% 85%, rgba(138, 58, 26, 0.14), transparent 70%);
    --card-spotlight-gradient: radial-gradient(
        ellipse 55% 60% at 50% 45%,
        rgba(var(--ink-rgb), 0.14) 0%,
        rgba(200, 136, 58, 0.10) 35%,
        transparent 70%
    );

    /* Shadows */
    --illustration-shadow: 0 24px 40px rgba(0, 0, 0, 0.55);
    --shadow-glow: 0 0 40px rgba(200, 136, 58, 0.1);
    --shadow-glow-hover: 0 0 50px rgba(232, 185, 106, 0.22);
    --modal-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    --end-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);

    /* Arrow icon tint (filters a near-black SVG to the current ink color) */
    --arrow-filter: invert(93%) sepia(14%) saturate(280%) hue-rotate(348deg) brightness(98%) contrast(92%);

    /* Grain overlay */
    --grain-blend: screen;
    --grain-opacity: 0.6;

    /* Typography */
    --font-heading: 'Tiempos Headline', Georgia, 'Times New Roman', serif;
    --font-body: 'Untitled Sans', system-ui, -apple-system, sans-serif;

    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* === LIGHT MODE — "Jour sur l'Atlas" === */
[data-theme="light"] {
    --bg: #FBF8EF;
    --bg-rgb: 251, 248, 239;
    --bg-deep: #F3ECDA;
    --ink: #2A2928;
    --ink-rgb: 42, 41, 40;
    --surface: #ffffff;

    /* Ink tints need slightly higher alpha on cream for AA contrast */
    --ink-muted: rgba(var(--ink-rgb), 0.72);
    --ink-faint: rgba(var(--ink-rgb), 0.35);
    --ink-ghost: rgba(var(--ink-rgb), 0.16);

    --border-subtle: rgba(var(--ink-rgb), 0.12);
    --border-medium: rgba(var(--ink-rgb), 0.22);
    --border-strong: rgba(var(--ink-rgb), 0.35);

    --btn-bg: rgba(var(--ink-rgb), 0.04);
    --btn-bg-hover: rgba(var(--ink-rgb), 0.09);

    /* Scrims flip to warm cream */
    --badge-scrim: rgba(255, 255, 255, 0.72);
    --modal-scrim: rgba(251, 248, 239, 0.82);
    --end-scrim: rgba(251, 248, 239, 0.88);

    /* Accents — deepened for AA contrast on cream */
    --amber: #a45e18;
    --amber-rgb: 164, 94, 24;
    --amber-light: #c68730;
    --amber-deep: #723f0e;

    /* IUCN — deepened versions remain legible on cream */
    --lc: #3a6f2a;
    --nt: #7a6a1e;
    --vu: #96531f;
    --en: #a63030;
    --cr: #6e1a1a;
    --ex: #4e2850;

    /* Ambient gradients — cream + dawn-amber wash */
    --sky-gradient:
        radial-gradient(ellipse at 70% 0%, rgba(200, 136, 58, 0.14), transparent 55%),
        radial-gradient(ellipse at 20% 100%, rgba(164, 94, 24, 0.08), transparent 60%),
        linear-gradient(180deg, #FBF8EF 0%, #F3ECDA 100%);
    --title-gradient:
        radial-gradient(ellipse 60% 50% at 75% 45%, rgba(200, 136, 58, 0.24), transparent 70%),
        radial-gradient(ellipse 40% 60% at 90% 85%, rgba(138, 58, 26, 0.10), transparent 70%);
    --card-spotlight-gradient: radial-gradient(
        ellipse 55% 60% at 50% 45%,
        rgba(232, 185, 106, 0.25) 0%,
        rgba(200, 136, 58, 0.10) 35%,
        transparent 70%
    );

    /* Shadows — softer on light */
    --illustration-shadow: 0 18px 32px rgba(0, 0, 0, 0.18);
    --shadow-glow: 0 0 30px rgba(164, 94, 24, 0.14);
    --shadow-glow-hover: 0 0 40px rgba(198, 135, 48, 0.24);
    --modal-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
    --end-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);

    /* Arrow filter → darken to charcoal */
    --arrow-filter: invert(14%) sepia(6%) saturate(300%) hue-rotate(5deg) brightness(92%) contrast(90%);

    /* Grain — multiply is more natural on cream */
    --grain-blend: multiply;
    --grain-opacity: 0.3;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
    overflow: hidden;
    height: 100%;
    height: 100dvh;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    height: 100dvh;
    user-select: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === AMBIENT BACKDROP === */
.sky-layer {
    position: fixed; inset: 0;
    background: var(--sky-gradient);
    z-index: 0;
    pointer-events: none;
    transition: background 0.5s ease;
}

.grain-overlay {
    position: fixed; inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    z-index: 1;
    pointer-events: none;
    mix-blend-mode: var(--grain-blend);
    opacity: var(--grain-opacity);
}

.hidden { display: none !important; }

/* === FOCUS RING (keyboard accessibility) === */
:focus-visible {
    outline: 2px solid var(--amber);
    outline-offset: 3px;
    border-radius: inherit;
}
:focus:not(:focus-visible) { outline: none; }

/* ============================================================
   TITLE CARD
   ============================================================ */
.title-card {
    position: fixed; inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;          /* vertically centred — like Lovable */
    align-items: center;              /* horizontally centred */
    z-index: 1000;
    overflow: hidden;
    isolation: isolate;
    padding: 0 clamp(28px, 7vw, 88px);
    transition: opacity 0.6s ease-out;
}

/* Layer 0: hero photo centred + ambient gradient. */
.title-card::before {
    content: ''; position: absolute; inset: 0;
    background:
        url('../assets/landing-hero.webp?v=2') no-repeat center center / cover,
        var(--title-gradient);
    opacity: 0.02;
    z-index: 0;
}
[data-theme="light"] .title-card::before {
    opacity: 0.30;
    mix-blend-mode: multiply;
}

/* Layer 1: centred vignette — keeps text legible over the full-bleed hero. */
.title-card::after {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(
        ellipse 80% 90% at 50% 50%,
        rgba(var(--bg-rgb), 0.78) 0%,
        rgba(var(--bg-rgb), 0.52) 50%,
        rgba(var(--bg-rgb), 0.20) 100%
    );
    z-index: 1;
    pointer-events: none;
}

.title-card.hidden { opacity: 0; pointer-events: none; }

/* === TOPBAR (brand left, controls right) === */
.title-topbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: clamp(20px, 3vh, 32px) clamp(28px, 7vw, 88px);
    z-index: 12;
}

.title-topbar-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.title-brand {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 300;
    letter-spacing: 0.02em;
    color: var(--ink);
    opacity: 0.52;
}

.title-ctrl-btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px;
    background: var(--btn-bg);
    border: 1px solid var(--border-medium);
    border-radius: 9999px;
    padding: 10px 16px;
    min-height: 44px;
    min-width: 44px;
    font-family: var(--font-body);
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink);
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.2s, background 0.2s;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.title-ctrl-btn:hover { opacity: 1; background: var(--btn-bg-hover); }

/* === MAIN CONTENT === */
.title-card-inner {
    text-align: center;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: min(820px, 90%);
    animation: titleReveal 0.85s var(--ease-out) 0.1s both;
}

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

/* Kicker: ─── Aube sur l'Atlas ─── */
.title-kicker {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-body);
    font-size: 10px;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--amber-light);
    margin-bottom: 22px;
}
.kicker-rule {
    display: block;
    width: 28px;
    height: 1px;
    background: var(--amber-light);
    opacity: 0.55;
    flex-shrink: 0;
}

/* Giant two-line display title */
.title {
    font-family: var(--font-heading);
    font-weight: 300;
    font-size: clamp(62px, 10vw, 144px);
    color: var(--ink);
    letter-spacing: -0.04em;
    line-height: 0.93;
    margin-bottom: 26px;
}
/* "du Maroc" / "of Morocco" — amber italic second line */
.title-amber {
    color: var(--amber);
    font-style: italic;
    display: block;
}
[data-theme="light"] .title-amber { color: var(--amber-deep); }

.subtitle {
    font-family: var(--font-heading);
    font-style: italic;
    font-weight: 300;
    font-size: clamp(14px, 1.8vw, 17px);
    color: var(--ink);
    opacity: 0.72;
    margin-bottom: 0;
    letter-spacing: 0.005em;
    line-height: 1.55;
    max-width: 520px;
}

/* Intro description paragraph */
.landing-intro {
    font-family: var(--font-body);
    font-size: clamp(12px, 1.3vw, 14px);
    color: var(--ink-muted);
    opacity: 0.80;
    margin-top: 18px;
    margin-bottom: 0;
    letter-spacing: 0.02em;
    line-height: 1.7;
    max-width: 540px;
}

/* === STATS GRID (border-l columns) === */
.title-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, auto);
    gap: 0;
    margin: 32px auto 40px;
    width: fit-content;
}
.title-stat-col {
    display: flex;
    flex-direction: column;
    padding: 0 28px 0 20px;
    border-left: 1px solid var(--ink-faint);
}
.title-stat-col:first-child {
    padding-left: 0;
    border-left: none;
}
.title-stat-num {
    font-family: var(--font-heading);
    font-weight: 300;
    font-size: clamp(26px, 3vw, 38px);
    color: var(--ink);
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: 5px;
}
.title-stat-dim .title-stat-num  { opacity: 0.35; }
.title-stat-accent .title-stat-num { color: var(--amber-light); }
[data-theme="light"] .title-stat-accent .title-stat-num { color: var(--amber-deep); }
.title-stat-label {
    font-family: var(--font-body);
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-muted);
    line-height: 1.4;
    white-space: nowrap;
}

/* === ACTIONS ROW (CTA + hint) === */
.title-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
}
.title-hint {
    font-family: var(--font-body);
    font-size: 10px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink-muted);
    opacity: 0.55;
    margin: 0;
}

/* CTA button — amber pill */
.btn-enter {
    background: var(--amber);
    border: 1px solid var(--amber);
    border-radius: 9999px;
    padding: 14px 30px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--bg);
    display: inline-flex; align-items: center; gap: 10px;
    transition: background 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
    touch-action: manipulation;
    box-shadow: var(--shadow-glow);
}
.btn-enter:hover {
    background: var(--amber-light);
    border-color: var(--amber-light);
    box-shadow: var(--shadow-glow-hover);
}
.btn-enter:active { transform: translateY(1px); }
.btn-enter .arrow-icon { color: var(--bg); filter: none; }

.arrow-icon { width: 14px; transition: transform 0.2s ease; flex-shrink: 0; }
.btn-enter:hover .arrow-icon { transform: translateX(3px); }
.arrow-icon.inverted { transform: rotate(180deg); }

/* ============================================================
   MAIN APP UI
   ============================================================ */
.app-ui {
    position: fixed; inset: 0;
    overflow: hidden;
    z-index: 5;
    opacity: 1;
    transition: opacity 0.5s ease-in;
}
.app-ui.hidden { opacity: 0; pointer-events: none; }

/* Logo hidden during card experience — badges occupy top-left.
   Esc key returns to the title card. */
.logo { display: none; }

/* === TOP RIGHT UI === */
.top-right-ui {
    position: fixed; top: 24px; right: 32px;
    display: flex; gap: 8px;
    /* Above about-panel (1002) and end-card (1001) so theme/lang stay
       reachable even while modals are open. */
    z-index: 1003;
    transition: opacity 0.2s, visibility 0.2s;
}
/* Hide nav controls while species detail modal is open */
body.modal-open .top-right-ui {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
/* Raise close button above everything */
.modal-close-btn {
    z-index: 1010;
}

.icon-btn {
    width: 44px; height: 44px; border-radius: 50%;
    min-width: 44px; min-height: 44px;
    background: var(--btn-bg);
    border: 1px solid var(--border-medium);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-body);
    color: var(--ink);
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    touch-action: manipulation;
}
.icon-btn:hover {
    background: var(--btn-bg-hover);
    border-color: var(--border-strong);
}

/* Theme icon: show sun in dark mode (switches to light), moon in light mode */
#btn-theme .icon-sun, #title-btn-theme .icon-sun { display: block; }
#btn-theme .icon-moon, #title-btn-theme .icon-moon { display: none; }
[data-theme="light"] #btn-theme .icon-sun,
[data-theme="light"] #title-btn-theme .icon-sun { display: none; }
[data-theme="light"] #btn-theme .icon-moon,
[data-theme="light"] #title-btn-theme .icon-moon { display: block; }
.icon-btn:active { transform: translateY(1px); }

/* ============================================================
   SPECIES CARD STAGE
   ============================================================ */
.card-stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

/* Radial spotlight — creates the "light on the bird" effect */
.card-spotlight {
    position: absolute;
    inset: 0;
    background: var(--card-spotlight-gradient);
    transition: background 0.5s ease;
    pointer-events: none;
    z-index: -1;
}

/* === BADGES (top-left overlay) === */
.card-badges {
    position: absolute;
    top: clamp(24px, 4vh, 40px);
    left: clamp(24px, 5vw, 56px);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    z-index: 12;
    pointer-events: none;
}

.iucn-badge {
    font-family: var(--font-body);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.14em;
    padding: 5px 12px;
    border-radius: 9999px;
    text-transform: uppercase;
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--badge-scrim);
    border: 1px solid var(--border-medium);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.iucn-badge::before {
    content: '';
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--badge-color, var(--ink-muted));
    flex-shrink: 0;
}
.iucn-badge[data-iucn="LC"] { --badge-color: var(--lc); }
.iucn-badge[data-iucn="NT"] { --badge-color: var(--nt); }
.iucn-badge[data-iucn="VU"] { --badge-color: var(--vu); }
.iucn-badge[data-iucn="EN"] { --badge-color: var(--en); }
.iucn-badge[data-iucn="CR"] { --badge-color: var(--cr); }
.iucn-badge[data-iucn="EX"] { --badge-color: var(--ex); }

.phenology-badge {
    font-family: var(--font-body);
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.12em;
    padding: 5px 12px;
    border-radius: 9999px;
    text-transform: uppercase;
    color: var(--ink);
    background: var(--badge-scrim);
    border: 1px solid var(--border-medium);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* === ILLUSTRATION === */
.card-illustration {
    position: absolute;
    top: 42%; left: 50%;
    transform: translate(-50%, -50%);
    width: min(68vw, 720px);
    height: min(58vh, 560px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.card-illustration img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(var(--illustration-shadow));
    animation: illustrationEntry 0.9s var(--ease-out) both;
}

.illustration-placeholder {
    width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border: 1px dashed var(--ink-faint);
    border-radius: 18px;
    background: rgba(var(--ink-rgb), 0.03);
    color: var(--ink-muted);
    animation: illustrationEntry 0.9s var(--ease-out) both;
}
.placeholder-label {
    font-family: var(--font-body);
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    opacity: 0.55;
}
.placeholder-id {
    font-family: var(--font-heading);
    font-size: clamp(90px, 16vw, 180px);
    font-weight: 300;
    color: var(--amber);
    opacity: 0.25;
    line-height: 1;
    letter-spacing: -0.04em;
}

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

/* ============================================================
   ALTITUDE GAUGE (right side)
   ============================================================ */
/* ============================================================
   ALTITUDE COLUMN — atmospheric, editorial
   Reads as an air column with the bird's altitude glowing within,
   not as a technical meter.
   ============================================================ */
.altitude-gauge {
    position: absolute;
    top: 50%;
    right: clamp(24px, 5vw, 64px);
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 14px;
    z-index: 12;
    transition: opacity 0.35s var(--ease-out);
    pointer-events: none;
}
.card-stage.is-expanded .altitude-gauge {
    opacity: 0;
    pointer-events: none;
}

.gauge-label,
.gauge-zero {
    font-family: var(--font-heading);
    font-style: italic;
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 0.02em;
    color: var(--ink-muted);
    padding-right: 12px;
}

.gauge-track {
    position: relative;
    width: 64px;
    height: 260px;
}

/* Atmospheric amber mist — replaces the hard tick line.
   Soft vertical bloom, densest near the midrange where most raptors fly. */
.gauge-mist {
    position: absolute;
    top: 0; bottom: 0;
    right: 0;
    width: 1px;
    background: linear-gradient(to top,
        rgba(var(--amber-rgb), 0) 0%,
        rgba(var(--amber-rgb), 0.12) 18%,
        rgba(var(--amber-rgb), 0.18) 35%,
        rgba(var(--amber-rgb), 0.06) 75%,
        rgba(var(--amber-rgb), 0) 100%);
}

/* Soft filled column from ground to the bird's typical altitude */
.gauge-fill {
    position: absolute;
    right: -2px;
    bottom: 0;
    width: 3px;
    border-radius: 2px;
    background: linear-gradient(to top,
        rgba(var(--amber-rgb), 0.5) 0%,
        rgba(var(--amber-rgb), 0.25) 100%);
    height: 0;
    transition: height 1.1s var(--ease-out);
    filter: blur(0.5px);
}

/* Reference ticks become floating italic numbers — no hard lines */
.gauge-tick {
    position: absolute;
    right: 12px;
    width: 0;
    height: 0;
    border: none;
    pointer-events: none;
}
.gauge-tick-label {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-heading);
    font-style: italic;
    font-weight: 300;
    font-size: 10px;
    letter-spacing: 0.02em;
    color: var(--ink-faint);
    white-space: nowrap;
}

/* Typical altitude — breathing amber orb with radial bloom.
   This is the narrative focal point: where this species flies. */
.gauge-marker {
    position: absolute;
    right: -3px;
    transition: bottom 1.1s var(--ease-out) 0.25s,
                opacity 0.5s ease;
    opacity: 0;
}
.gauge-marker.typical {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: radial-gradient(circle,
        var(--amber-light) 0%,
        var(--amber) 45%,
        rgba(var(--amber-rgb), 0) 90%);
    transform: translateX(50%);
    box-shadow:
        0 0 12px rgba(var(--amber-rgb), 0.6),
        0 0 28px rgba(var(--amber-rgb), 0.3);
    right: 0;
}
.gauge-marker.typical .gauge-typical-ring {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 1px solid rgba(var(--amber-rgb), 0.45);
    animation: gaugePulse 3.2s ease-in-out infinite;
}

@keyframes gaugePulse {
    0%, 100% { transform: scale(1); opacity: 0.55; }
    50%      { transform: scale(1.35); opacity: 0; }
}

/* Max altitude — subtle amber-light dashed "ceiling" with italic label */
.gauge-marker.max {
    right: 0;
    height: 0;
    width: 28px;
    border-top: 1px dashed rgba(var(--amber-rgb), 0.55);
    transform: translateX(0);
}
.gauge-max-label {
    position: absolute;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-heading);
    font-style: italic;
    font-weight: 300;
    font-size: 10px;
    letter-spacing: 0.02em;
    color: rgba(var(--amber-rgb), 0.85);
    white-space: nowrap;
}

.gauge-marker.visible { opacity: 1; }

/* ============================================================
   INFO OVERLAY (bottom)
   ============================================================ */
.card-info {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    background: linear-gradient(180deg,
        var(--info-overlay-0) 0%,
        var(--info-overlay-1) 22%,
        var(--info-overlay-2) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-subtle);
    padding: 22px clamp(24px, 6vw, 72px) 72px;
    z-index: 10;
    max-height: 38vh;
    overflow: hidden;
    transition: max-height 0.5s var(--ease-out);
}
.card-info.expanded {
    position: fixed;
    inset: 0;
    z-index: 200;
    max-height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg);
    border-top: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: clamp(56px, 8vh, 96px) clamp(20px, 6vw, 88px) 80px;
    animation: modalSlideUp 0.38s var(--ease-out) both;
}

@keyframes modalSlideUp {
    from { transform: translateY(60px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
@keyframes modalSlideDown {
    from { transform: translateY(0);    opacity: 1; }
    to   { transform: translateY(60px); opacity: 0; }
}
/* Collapsing state plays the exit animation then JS removes .expanded */
.card-info.collapsing {
    animation: modalSlideDown 0.32s var(--ease-out) both !important;
    pointer-events: none;
}

.card-info-summary {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 900px;
    margin: 0 auto;
}

.card-scientific {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 13px;
    letter-spacing: 0.01em;
    color: var(--ink-muted);
    margin: 0;
}

.card-name {
    font-family: var(--font-heading);
    font-weight: 300;
    font-size: clamp(26px, 3.8vw, 42px);
    color: var(--ink);
    letter-spacing: -0.02em;
    line-height: 1.02;
    margin: 0;
}

/* Arabic name — right-aligned, light, authentic naming layer */
.card-arabic {
    font-family: var(--font-body);
    font-size: clamp(12px, 1.2vw, 14px);
    color: var(--ink-muted);
    opacity: 0.60;
    text-align: right;
    letter-spacing: 0.02em;
    line-height: 1.5;
    margin: -2px 0 4px;
}
.card-arabic:empty { display: none; }

.card-tagline {
    font-family: var(--font-heading);
    font-style: italic;
    font-weight: 300;
    font-size: clamp(15px, 1.6vw, 18px);
    color: var(--amber-light);
    line-height: 1.4;
    margin: 4px 0 8px;
    max-width: 620px;
}

.card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin-top: 2px;
    border-top: 1px solid var(--border-subtle);
    padding-top: 10px;
}
.card-stat {
    flex: 1 1 auto;
    min-width: 120px;
    padding: 4px 18px 4px 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.card-stat-label {
    font-family: var(--font-body);
    font-size: 9px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-muted);
}
.card-stat-value {
    font-family: var(--font-heading);
    font-weight: 300;
    font-size: 16px;
    color: var(--ink);
    letter-spacing: -0.01em;
}
/* Habitat value: full text, smaller size so it wraps gracefully */
.card-stat--wrap .card-stat-value {
    font-size: 13px;
    line-height: 1.3;
    word-break: break-word;
}

/* Read more / Réduire button */
.card-read-more {
    align-self: flex-start;
    margin-top: 12px;
    background: var(--btn-bg);
    border: 1px solid var(--border-medium);
    border-radius: 9999px;
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px 9px 16px;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.card-read-more:hover {
    background: var(--btn-bg-hover);
    border-color: var(--amber-light);
    color: var(--amber-light);
}
/* In modal mode the ✕ button handles closing — hide the LIRE PLUS pill */
.card-info.expanded .card-read-more {
    display: none;
}
.card-read-more svg {
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

/* Expanded content — collapsed to 0 height when summary is shown so the
   overlay shrinks to summary content only (no phantom dead zone). */
.card-info-expanded {
    max-width: 900px;
    margin: 0 auto;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transform: translateY(12px);
    transition: max-height 0.5s var(--ease-out),
                margin 0.5s var(--ease-out),
                opacity 0.35s ease 0.1s,
                transform 0.35s var(--ease-out) 0.1s;
    pointer-events: none;
}
.card-info.expanded .card-info-expanded {
    max-height: 3000px;
    margin-top: 22px;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.card-short, .card-long {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.7;
    color: var(--ink);
    opacity: 0.82;
    margin-bottom: 14px;
    max-width: 720px;
}
.card-short { font-weight: 400; }
.card-long { opacity: 0.72; }

.card-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px 28px;
    margin-top: 18px;
    padding: 18px 0;
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}
.card-meta-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.card-meta-label {
    font-family: var(--font-body);
    font-size: 9px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-muted);
}
.card-meta-value {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--ink);
    opacity: 0.9;
    line-height: 1.5;
}

.card-fact {
    margin-top: 22px;
    padding: 16px 20px;
    border-left: 2px solid var(--amber);
    background: rgba(200, 136, 58, 0.04);
    border-radius: 0 6px 6px 0;
}
.card-fact-label {
    font-family: var(--font-body);
    font-size: 9px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--amber-light);
    display: block;
    margin-bottom: 6px;
}
.card-fact-text {
    font-family: var(--font-heading);
    font-style: italic;
    font-weight: 300;
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink);
    opacity: 0.92;
}

/* === MODAL CLOSE BUTTON (✕) — fixed top-right when card-info is in modal mode === */
.modal-close-btn {
    display: none;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 210;
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-medium);
    background: var(--btn-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--ink);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.modal-close-btn.visible {
    display: flex;
}
.modal-close-btn:hover {
    background: var(--btn-bg-hover);
    border-color: var(--amber-light);
    color: var(--amber-light);
}

/* === WINGSPAN COMPARISON ("taille de vie") === */
.wingspan-compare {
    margin: 24px 0 18px;
    padding: 16px 20px;
    background: rgba(var(--ink-rgb, 0,0,0), 0.025);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    overflow: hidden;
}
[data-theme="dark"] .wingspan-compare {
    background: rgba(255,255,255, 0.03);
}

/* === ZONE CHIPS === */
.card-meta-value--chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 2px;
}
.zone-tag {
    display: inline-block;
    font-family: var(--font-body);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-muted);
    background: rgba(var(--ink-rgb, 0,0,0), 0.06);
    border: 1px solid var(--border-subtle);
    border-radius: 99px;
    padding: 2px 9px;
    white-space: nowrap;
}
[data-theme="dark"] .zone-tag {
    background: rgba(255,255,255, 0.07);
}

/* ============================================================
   NAVIGATION (arrows + dots + counter)
   ============================================================ */
.arrow-nav {
    position: fixed; bottom: 34px;
    z-index: 25;
}
.prev-arrow { left: 28px; }
.next-arrow { right: 28px; }

.control-button {
    width: 44px; height: 44px;
    min-width: 44px; min-height: 44px;
    border-radius: 50%;
    background: var(--btn-bg);
    border: 1px solid var(--border-medium);
    outline: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.18s, border-color 0.18s, transform 0.15s;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    touch-action: manipulation;
}
.control-button:hover:not(:disabled) {
    background: var(--btn-bg-hover);
    border-color: var(--border-strong);
}
.control-button:active:not(:disabled) { transform: translateY(1px); }
.control-button:disabled { opacity: 0.25; cursor: not-allowed; }

.arrow-icon {
    width: 16px;
    filter: var(--arrow-filter);
}

/* Progress counter + dots */
.progress-counter {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}
.progress-dots {
    display: flex;
    gap: 6px;
    align-items: center;
    pointer-events: auto;
}
.progress-dot {
    position: relative;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--ink-faint);
    cursor: pointer;
    transition: width 0.3s var(--ease-out), background-color 0.3s;
    border: none;
    padding: 0;
}
/* Invisible 28px tap target around each 5px dot — doesn't affect layout. */
.progress-dot::before {
    content: '';
    position: absolute;
    inset: -12px -4px;
}
.progress-dot.active {
    width: 22px;
    border-radius: 3px;
    background: var(--amber);
}
.progress-dot:hover:not(.active) {
    background: var(--ink-muted);
}
#counter-text {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 11px;
    color: var(--ink-muted);
    letter-spacing: 0.04em;
}

/* ============================================================
   ABOUT PANEL — full-screen editorial page
   ============================================================ */
.about-panel {
    position: fixed; inset: 0;
    background: var(--bg);
    z-index: 1002;
    overflow-y: auto;
    overflow-x: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(60px);
    transition: opacity 0.38s var(--ease-out), transform 0.38s var(--ease-out);
}
.about-panel.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* Ambient spotlight — mirrors end card atmosphere */
.about-spotlight {
    position: fixed; inset: 0;
    background: var(--card-spotlight-gradient);
    opacity: 0.6;
    pointer-events: none;
    z-index: 0;
}

/* Close button — identical pill-circle as species detail modal */
.about-close-btn {
    position: fixed;
    top: 20px; right: 20px;
    z-index: 10;
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-medium);
    background: var(--btn-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.about-close-btn:hover {
    background: var(--btn-bg-hover);
    border-color: var(--amber-light);
    color: var(--amber-light);
}

/* Scrollable inner column */
.about-inner {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
    padding: clamp(56px, 8vh, 96px) clamp(20px, 6vw, 56px) 80px;
    color: var(--ink);
}

/* Editorial header */
.about-header {
    margin-bottom: 48px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border-subtle);
}
.about-overline {
    font-family: var(--font-body);
    font-size: 10px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--amber);
    opacity: 0.8;
    margin-bottom: 16px;
}
.about-title {
    font-family: var(--font-heading);
    font-weight: 300;
    font-size: clamp(36px, 7vw, 64px);
    letter-spacing: -0.03em;
    line-height: 1;
    color: var(--ink);
    margin: 0;
}
.about-title em {
    font-style: italic;
    color: var(--amber-light);
}

/* Sections */
.about-section {
    margin-bottom: 36px;
    padding-bottom: 36px;
    border-bottom: 1px solid var(--border-subtle);
}
.about-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.about-section-label {
    font-family: var(--font-body);
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--amber);
    margin-bottom: 14px;
    opacity: 0.9;
}

.about-creator-block {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.about-desc,
.about-creator-bio {
    font-family: var(--font-body);
    font-size: clamp(13px, 1.5vw, 15px);
    line-height: 1.75;
    color: var(--ink);
    opacity: 0.78;
    margin-bottom: 12px;
}

.about-creator-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-body);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--amber-light);
    text-decoration: none;
    border-bottom: 1px solid rgba(var(--amber-rgb), 0.4);
    padding-bottom: 2px;
    transition: color 0.2s, border-color 0.2s;
}
.about-creator-link:hover {
    color: var(--ink);
    border-bottom-color: var(--border-strong);
}

.about-contact-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}
.about-contact-link {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--ink-secondary);
    text-decoration: none;
    transition: color 0.2s;
}
.about-contact-link svg {
    flex-shrink: 0;
    color: var(--amber);
}
.about-contact-link:hover {
    color: var(--amber-light);
}

/* Hide top-right nav when about panel is open */
body.about-open .top-right-ui {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal-sources-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.modal-sources-list li {
    font-family: var(--font-body);
    font-size: 12px;
    line-height: 1.6;
    padding: 6px 0;
    color: var(--ink-muted);
    border-bottom: 1px solid var(--border-subtle);
}
.modal-sources-list li:last-child { border-bottom: none; }
.modal-sources-list a {
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px dashed var(--border-strong);
    transition: border-color 0.2s, color 0.2s;
}
.modal-sources-list a:hover {
    color: var(--amber-light);
    border-bottom-color: var(--amber);
}

/* ============================================================
   END CARD — full-page closing chapter (not a modal)
   ============================================================ */
.end-card {
    position: fixed; inset: 0;
    background: var(--bg);
    z-index: 1001;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 0 0 80px;
    overflow-y: auto;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}
.end-card.open {
    opacity: 1;
    pointer-events: auto;
}

/* Hero image at top of end card */
.end-hero {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 52vh;
    z-index: 0;
    pointer-events: none;
}
.end-hero img {
    width: 100%; height: 100%;
    object-fit: cover;
    object-position: center 40%;
    opacity: 0.55;
}
.end-hero-fade {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 30%, var(--bg) 100%);
}

/* Ambient amber spotlight — mirrors the species card language */
.end-spotlight {
    position: fixed; inset: 0;
    background: var(--card-spotlight-gradient);
    opacity: 0.7;
    pointer-events: none;
    z-index: 0;
}

.end-card-inner {
    background: transparent;
    border: none;
    padding: clamp(56px, 8vh, 96px) clamp(20px, 5vw, 56px) 0;
    width: 100%;
    max-width: 720px;
    position: relative;
    color: var(--ink);
    text-align: left;
    z-index: 1;
}

.end-card-close {
    position: fixed;
    top: 24px; left: 24px;
    background: var(--btn-bg);
    border: 1px solid var(--border-medium);
    color: var(--ink);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.8;
    min-width: 44px; min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 50%;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.2s, background 0.2s;
    z-index: 10;
}
.end-card-close:hover { opacity: 1; background: var(--btn-bg-hover); }

.end-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-body);
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--amber);
    border: 1px solid rgba(var(--amber-rgb), 0.45);
    border-radius: 9999px;
    padding: 6px 14px;
    margin-bottom: 20px;
}

.end-title {
    font-family: var(--font-heading);
    font-weight: 300;
    font-size: clamp(44px, 7vw, 80px);
    color: var(--ink);
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: 16px;
}
/* Italic amber word inside the title */
.end-title em {
    font-style: italic;
    color: var(--amber-light);
}

.end-subtitle {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: clamp(15px, 1.8vw, 19px);
    line-height: 1.6;
    color: var(--ink);
    opacity: 0.75;
    margin-bottom: 36px;
    max-width: 580px;
}

/* ============================================================
   END CARD THUMBNAILS — horizontal retrospective of all 12 birds
   ============================================================ */
.end-thumbs {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 32px;
    padding: 20px 0;
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}
@media (max-width: 640px) {
    .end-thumbs { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
}
.end-thumb {
    position: relative;
    aspect-ratio: 1;
    border-radius: 10px;
    background: rgba(var(--ink-rgb), 0.04);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
    cursor: pointer;
    padding: 0;
    transition: transform 0.25s var(--ease-out), border-color 0.2s, background 0.2s;
    min-width: 0;
    min-height: 0;
}
.end-thumb:hover {
    transform: translateY(-3px);
    border-color: var(--amber);
    background: rgba(var(--amber-rgb), 0.08);
}
.end-thumb img {
    position: absolute;
    inset: 4px;
    width: calc(100% - 8px);
    height: calc(100% - 8px);
    object-fit: contain;
    filter: grayscale(0.8) brightness(0.95);
    transition: filter 0.25s var(--ease-out);
}
.end-thumb:hover img {
    filter: grayscale(0) brightness(1);
}
.end-thumb-number {
    position: absolute;
    top: 4px; right: 6px;
    font-family: var(--font-heading);
    font-size: 9px;
    font-weight: 300;
    color: var(--ink-muted);
    letter-spacing: 0.02em;
    pointer-events: none;
}
.end-thumb:hover .end-thumb-number {
    color: var(--amber);
}

.end-stats {
    display: flex;
    align-items: stretch;
    width: 100%;
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    margin-bottom: 28px;
    overflow: hidden;
    background: rgba(var(--ink-rgb), 0.02);
}
.end-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 18px 8px;
    gap: 6px;
}
.end-stat-num {
    font-family: var(--font-heading);
    font-size: clamp(22px, 3.5vw, 32px);
    font-weight: 300;
    color: var(--amber);
    letter-spacing: -0.02em;
    line-height: 1;
}
.end-stat-label {
    font-family: var(--font-body);
    font-size: 9px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-muted);
    line-height: 1.4;
}
.end-stat-divider {
    width: 1px;
    background: var(--border-subtle);
    align-self: stretch;
}
@media (max-width: 480px) {
    .end-stats {
        flex-wrap: wrap;
    }
    .end-stat { flex: 0 0 50%; min-width: 0; }
    .end-stat-divider { display: none; }
    .end-stat:nth-child(odd) { border-right: 1px solid var(--border-subtle); }
    .end-stat:nth-child(1),
    .end-stat:nth-child(2) { border-bottom: 1px solid var(--border-subtle); }
}

.end-quote {
    border: none;
    border-left: 3px solid var(--amber);
    border-radius: 0;
    padding: clamp(12px, 2vw, 20px) clamp(20px, 4vw, 36px);
    margin-bottom: 36px;
    background: transparent;
    position: relative;
}
.end-quote::before {
    content: '"';
    position: absolute;
    top: -14px;
    left: clamp(20px, 4vw, 36px);
    font-family: var(--font-heading);
    font-size: 56px;
    line-height: 1;
    color: var(--amber);
    opacity: 0.45;
}
.end-quote p {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: clamp(17px, 2.2vw, 24px);
    line-height: 1.6;
    color: var(--ink);
    opacity: 0.88;
    margin-bottom: 14px;
}
.end-quote cite {
    font-family: var(--font-body);
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--amber);
    font-style: normal;
    opacity: 0.75;
}

/* Conservation CTA */
.end-cta {
    border: 1px solid rgba(var(--amber-rgb), 0.3);
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 28px;
    background: rgba(var(--amber-rgb), 0.04);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.end-cta-text {
    font-family: var(--font-body);
    font-size: 13px;
    line-height: 1.5;
    color: var(--ink-secondary);
    flex: 1;
}
.end-cta-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-body);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--amber-light);
    text-decoration: none;
    border: 1px solid rgba(var(--amber-rgb), 0.5);
    border-radius: 9999px;
    padding: 8px 18px;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}
.end-cta-link:hover {
    background: rgba(var(--amber-rgb), 0.12);
    color: var(--amber);
}

/* Sources — collapsible */
.end-sources-details {
    margin-bottom: 28px;
}
.end-sources-summary {
    font-family: var(--font-body);
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--amber);
    opacity: 0.75;
    cursor: pointer;
    list-style: none;
    padding: 8px 0;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.2s;
}
.end-sources-summary::-webkit-details-marker { display: none; }
.end-sources-summary::after {
    content: '+';
    margin-left: auto;
    font-size: 14px;
    font-weight: 300;
    color: var(--ink-muted);
}
details[open] .end-sources-summary::after { content: '−'; }
.end-sources-summary:hover { opacity: 1; }
.end-sources-list {
    list-style: none;
    padding: 8px 0 0;
    margin: 0;
}
.end-sources-list li {
    font-family: var(--font-body);
    font-size: 11px;
    line-height: 1.6;
    padding: 5px 0;
    color: var(--ink-muted);
    border-bottom: 1px solid var(--border-subtle);
}
.end-sources-list li:last-child { border-bottom: none; }
.end-sources-list a {
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px dashed var(--border-strong);
    transition: border-color 0.2s, color 0.2s;
}
.end-sources-list a:hover {
    color: var(--amber-light);
    border-bottom-color: var(--amber);
}

.end-actions {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.btn-share {
    background: transparent;
    border: none;
    padding: 0;
    font-family: var(--font-body);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: color 0.2s;
    position: relative;
}
.btn-share::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 1px;
    background: currentColor;
    opacity: 0;
    transition: opacity 0.2s;
}
.btn-share:hover {
    color: var(--ink);
}
.btn-share:hover::after {
    opacity: 0.4;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .logo { display: none; }

    .card-illustration {
        width: 90vw;
        height: 48vh;
        top: 38%;
    }

    .card-badges {
        top: 16px;
        left: 16px;
        flex-direction: row;
        gap: 6px;
        flex-wrap: wrap;
    }

    .iucn-badge,
    .phenology-badge {
        font-size: 9px;
        padding: 4px 10px;
        letter-spacing: 0.1em;
    }

    .altitude-gauge {
        right: 14px;
    }
    .gauge-track {
        height: 200px;
        width: 52px;
    }
}

/* On very narrow phones, drop the reference numbers so the gauge keeps breathing room. */
@media (max-width: 540px) {
    .gauge-tick-label { display: none; }
    .gauge-max-label  { font-size: 9px; }
    .gauge-track { width: 28px; }

    .card-info {
        padding: 22px 20px 80px;
        max-height: 52vh;
    }
    .card-name {
        font-size: clamp(22px, 6vw, 32px);
    }

    .card-tagline {
        font-size: 14px;
    }

    .card-stat { min-width: 90px; padding-right: 10px; }
    .card-stat-value { font-size: 14px; }

    .arrow-nav { bottom: max(16px, env(safe-area-inset-bottom, 0px) + 8px); }
    .prev-arrow { left: 14px; }
    .next-arrow { right: 14px; }

    .control-button { width: 44px; height: 44px; }

    .progress-counter {
        bottom: max(22px, env(safe-area-inset-bottom, 0px) + 14px);
    }

    .top-right-ui {
        top: max(14px, env(safe-area-inset-top, 0px) + 8px);
        right: 14px;
        gap: 6px;
    }
    .icon-btn { width: 44px; height: 44px; }

    .title-card {
        padding-top: 0;
        padding-bottom: clamp(48px, 10vh, 90px);
        padding-left: 24px;
        padding-right: 24px;
    }
    .title-card-inner { max-width: 100%; }
    .title { font-size: clamp(52px, 14vw, 96px); }
    .title-stats-grid { grid-template-columns: repeat(2, auto); row-gap: 20px; }
    .title-stat-col:nth-child(3) { border-left: none; padding-left: 0; }
    .title-stats-grid .title-stat-col:nth-child(odd) { padding-left: 0; border-left: none; }
    .title-stats-grid .title-stat-col:nth-child(even) { padding-left: 20px; border-left: 1px solid var(--ink-faint); }
    .title-hint { display: none; }
    .title-topbar { padding: 18px 24px; }

    .end-card-inner { padding: 32px 24px 28px; }
}

/* ============================================================
   320 px — absolute minimum (iPhone SE 1st gen, Galaxy A series)
   ============================================================ */
@media (max-width: 340px) {
    .card-info {
        padding: 16px 14px 72px;
    }
    .card-stat { min-width: 72px; padding-right: 8px; }
    .card-stat-label { font-size: 8px; }
    .card-stat-value { font-size: 13px; }
    .card-read-more { padding: 7px 13px; font-size: 10px; }
    .card-name { font-size: 22px; }
    .title { font-size: clamp(44px, 14vw, 64px); }
    .title-stats-grid { gap: 12px; }
    .end-card-inner { max-width: 100%; }
    .end-quote { padding: 16px; }
    .wingspan-compare svg { height: 60px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================
   DOSSIER PANEL — enriched species detail
   Ported from Trees of Morocco — adapted to raptor palette
   ============================================================ */

/* Container */
.card-dossier {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* ── Trend pill ── */
.dossier-trend-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dossier-trend-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 9999px;
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid currentColor;
}
.dossier-trend-pill[data-trend="declining-fast"] {
    color: var(--cr);
    background: rgba(182, 56, 56, 0.10);
    border-color: rgba(182, 56, 56, 0.30);
}
.dossier-trend-pill[data-trend="declining"] {
    color: var(--en);
    background: rgba(214, 85, 85, 0.10);
    border-color: rgba(214, 85, 85, 0.25);
}
.dossier-trend-pill[data-trend="stable"] {
    color: var(--nt);
    background: rgba(184, 156, 47, 0.10);
    border-color: rgba(184, 156, 47, 0.25);
}
.dossier-trend-pill[data-trend="recovering"] {
    color: var(--lc);
    background: rgba(107, 168, 90, 0.12);
    border-color: rgba(107, 168, 90, 0.28);
}

/* ── The Number quote ── */
.dossier-number {
    margin: 0;
    padding: 18px 20px;
    background: rgba(var(--amber-rgb), 0.06);
    border-left: 3px solid var(--amber);
    border-radius: 0 6px 6px 0;
    font-family: var(--font-heading);
    font-style: italic;
    font-weight: 300;
    font-size: clamp(14px, 1.6vw, 17px);
    line-height: 1.5;
    color: var(--amber-light);
    letter-spacing: -0.01em;
}

/* ── Section structure ── */
.dossier-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dossier-section-label {
    font-family: var(--font-body);
    font-size: 9px;
    font-weight: 400;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin: 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}

/* ── Distribution block ── */
.dossier-dist-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}
.dossier-dist-label {
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--ink-muted);
    flex-shrink: 0;
}
.dossier-dist-value {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 300;
    color: var(--ink);
    text-align: right;
}

/* Elevation track */
.elevation-wrap {
    margin: 4px 0 6px;
}
.elevation-track-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.elevation-edge-label {
    font-family: var(--font-body);
    font-size: 9px;
    color: var(--ink-faint);
    flex-shrink: 0;
    min-width: 28px;
}
.elevation-edge-label:last-child { text-align: right; }
.elevation-track {
    flex: 1;
    height: 6px;
    background: var(--ink-ghost);
    border-radius: 3px;
    position: relative;
    overflow: hidden;
}
.elevation-zone {
    position: absolute;
    top: 0;
    height: 100%;
    background: var(--amber);
    opacity: 0.55;
    border-radius: 3px;
}

.dossier-threat-text {
    font-family: var(--font-body);
    font-size: 12px;
    line-height: 1.55;
    color: var(--ink-muted);
    margin: 4px 0 0;
    padding: 10px 12px;
    background: var(--ink-ghost);
    border-radius: 6px;
}

/* ── Companion chips ── */
.companions-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.companion-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--btn-bg);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    transition: background 0.15s;
}
.companion-chip:hover {
    background: var(--btn-bg-hover);
}

.companion-icon {
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.companion-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.companion-name {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.companion-scientific {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 11px;
    color: var(--ink-muted);
}

.companion-iucn {
    flex-shrink: 0;
    font-size: 9px !important;
    padding: 2px 5px !important;
}

/* ── Timeline bar chart ── */
#dossier-timeline {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.timeline-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.timeline-year {
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--ink-muted);
    width: 36px;
    flex-shrink: 0;
    text-align: right;
}
.timeline-year.projected {
    color: var(--ink-faint);
    font-style: italic;
}

.timeline-bar-track {
    flex: 1;
    height: 8px;
    background: var(--ink-ghost);
    border-radius: 4px;
    overflow: hidden;
}

.timeline-bar {
    height: 100%;
    background: var(--amber);
    border-radius: 4px;
    transition: width 0.6s var(--ease-out);
}
.timeline-bar.projected {
    background: var(--amber-deep);
    opacity: 0.5;
}

.timeline-ha {
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--ink-muted);
    min-width: 52px;
    flex-shrink: 0;
    text-align: right;
}
.timeline-ha.projected {
    color: var(--ink-faint);
    font-style: italic;
}

.timeline-unknown {
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--ink-faint);
    margin: 0;
    font-style: italic;
}

/* ── Conservation actions ── */
.dossier-actions-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dossier-action-item {
    font-family: var(--font-body);
    font-size: 12px;
    line-height: 1.6;
    color: var(--ink-muted);
    padding: 10px 14px 10px 28px;
    background: var(--btn-bg);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    position: relative;
}
.dossier-action-item::before {
    content: '→';
    position: absolute;
    left: 12px;
    top: 10px;
    color: var(--amber);
    font-size: 11px;
    line-height: 1.6;
}

/* IUCN badges inside companion chips */
.iucn-badge[data-iucn="LC"] { background: rgba(107, 168, 90, 0.15); color: var(--lc); border: 1px solid rgba(107,168,90,0.3); }
.iucn-badge[data-iucn="NT"] { background: rgba(184, 156, 47, 0.15); color: var(--nt); border: 1px solid rgba(184,156,47,0.3); }
.iucn-badge[data-iucn="VU"] { background: rgba(201, 124, 50, 0.15); color: var(--vu); border: 1px solid rgba(201,124,50,0.3); }
.iucn-badge[data-iucn="EN"] { background: rgba(214, 85, 85, 0.15); color: var(--en); border: 1px solid rgba(214,85,85,0.3); }
.iucn-badge[data-iucn="CR"] { background: rgba(182, 56, 56, 0.18); color: var(--cr); border: 1px solid rgba(182,56,56,0.3); }
.iucn-badge[data-iucn="EX"] { background: rgba(138, 90, 136, 0.15); color: var(--ex); border: 1px solid rgba(138,90,136,0.3); }

.companion-iucn.iucn-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: var(--font-body);
    font-size: 9px;
    letter-spacing: 0.06em;
    font-weight: 400;
    line-height: 1;
}
