/* ============================================================
   Queer Memory — Design System & Theme
   A vibrant, joyful, LGBTQ+ themed stylesheet
   Supports light and dark color modes
   ============================================================ */

/* --- CSS Custom Properties (Light theme — default) --- */
:root {
    /* Pride-inspired palette */
    --red: #e40303;
    --orange: #ff8c00;
    --yellow: #ffed00;
    --green: #008026;
    --blue: #004dff;
    --violet: #750787;
    --pink: #ff69b4;
    --lavender: #b57edc;
    --cyan: #00d4aa;
    --trans-blue: #55cdfc;
    --trans-pink: #f7a8b8;
    --bi-purple: #9b4f96;
    --bi-pink: #d60270;
    --bi-blue: #0038a8;

    /* Gradients */
    --pride-gradient: linear-gradient(135deg,
            var(--red) 0%,
            var(--orange) 17%,
            var(--yellow) 33%,
            var(--green) 50%,
            var(--blue) 67%,
            var(--violet) 83%,
            var(--pink) 100%);
    --pride-gradient-horizontal: linear-gradient(90deg,
            var(--red),
            var(--orange),
            var(--yellow),
            var(--green),
            var(--blue),
            var(--violet));

    /* Surfaces & backgrounds */
    --bg-primary: #faf8f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f3f0ec;
    --bg-hero: linear-gradient(160deg, #fdf6ff 0%, #f0f4ff 40%, #fef9f0 100%);
    --bg-card: #ffffff;
    --bg-card-hover: #fef6ff;
    --bg-code: #f5f2ff;

    /* Text */
    --text-primary: #1a1136;
    --text-secondary: #4a4160;
    --text-muted: #7b7490;
    --text-inverse: #ffffff;
    --text-link: #6b21a8;
    --text-link-hover: #9333ea;

    /* Accents */
    --accent-primary: #7c3aed;
    --accent-secondary: #db2777;
    --accent-tertiary: #0891b2;
    --accent-warm: #f59e0b;
    --accent-success: #059669;
    --accent-danger: #dc2626;

    /* Borders & dividers */
    --border-subtle: #e8e4f0;
    --border-default: #d4cce0;
    --border-strong: #a89ec0;
    --border-accent: var(--accent-primary);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(26, 17, 54, 0.06);
    --shadow-md: 0 4px 12px rgba(26, 17, 54, 0.08);
    --shadow-lg: 0 8px 30px rgba(26, 17, 54, 0.12);
    --shadow-glow: 0 0 20px rgba(124, 58, 237, 0.15);

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Spacing scale */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;
    --space-4xl: 6rem;

    /* Typography */
    --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-serif: Georgia, 'Times New Roman', serif;
    --font-mono: 'Cascadia Code', 'Fira Code', monospace;

    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    --text-5xl: 3rem;

    --leading-tight: 1.25;
    --leading-normal: 1.6;
    --leading-relaxed: 1.75;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;

    /* Layout */
    --content-max: 72rem;
    --sidebar-w: 18rem;
    --header-h: 3.5rem;

    /* Theme toggle icon */
    --theme-icon: "\263C";
    /* sun */

    /* Status colors for rights maps */
    --status-legal: #059669;
    --status-limited: #f59e0b;
    --status-illegal: #dc2626;
    --status-unknown: #9ca3af;
    --status-progressive: #7c3aed;
}


/* --- Dark theme --- */
[data-theme="dark"] {
    --bg-primary: #0f0a1a;
    --bg-secondary: #1a1230;
    --bg-tertiary: #241a3a;
    --bg-hero: linear-gradient(160deg, #1a0f2e 0%, #0f1629 40%, #1a1020 100%);
    --bg-card: #1e1535;
    --bg-card-hover: #2a1f45;
    --bg-code: #1e1535;

    --text-primary: #f0ecf8;
    --text-secondary: #c4b8db;
    --text-muted: #8b7fa5;
    --text-inverse: #0f0a1a;
    --text-link: #c084fc;
    --text-link-hover: #e9d5ff;

    --accent-primary: #a78bfa;
    --accent-secondary: #f472b6;
    --accent-tertiary: #22d3ee;
    --accent-warm: #fbbf24;
    --accent-success: #34d399;
    --accent-danger: #f87171;

    --border-subtle: #2a2040;
    --border-default: #3d3060;
    --border-strong: #5b4d80;
    --border-accent: var(--accent-primary);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 25px rgba(167, 139, 250, 0.2);

    --theme-icon: "\263E";
    /* moon */

    --status-legal: #34d399;
    --status-limited: #fbbf24;
    --status-illegal: #f87171;
    --status-unknown: #6b7280;
    --status-progressive: #a78bfa;
}


/* ============================================================
   Reset & Base
   ============================================================ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 100%;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: background-color var(--transition-normal),
        color var(--transition-normal);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

img,
svg,
video,
canvas {
    display: block;
    max-width: 100%;
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover,
a:focus-visible {
    color: var(--text-link-hover);
    text-decoration: underline;
    text-underline-offset: 3px;
}

:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

ul,
ol {
    list-style: none;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    line-height: var(--leading-tight);
    color: var(--text-primary);
}


/* ============================================================
   Pride stripe — decorative bar at top of page
   ============================================================ */
body::before {
    content: '';
    display: block;
    height: 4px;
    background: var(--pride-gradient-horizontal);
    position: sticky;
    top: 0;
    z-index: 1000;
}


/* ============================================================
   Site Header
   ============================================================ */
#site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-xl);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 4px;
    /* below pride stripe */
    z-index: 900;
    min-height: var(--header-h);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    transition: background-color var(--transition-normal);
}

.logo a {
    font-size: var(--text-xl);
    font-weight: 800;
    letter-spacing: -0.02em;
    background: var(--pride-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
}

.logo a:hover {
    text-decoration: none;
    filter: brightness(1.15);
}

#site-nav ul {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

#site-nav a {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    transition: background-color var(--transition-fast),
        color var(--transition-fast);
}

#site-nav a:hover,
#site-nav a:focus-visible {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    text-decoration: none;
}

#site-nav a[aria-current="page"] {
    background: var(--accent-primary);
    color: var(--text-inverse);
}

/* Theme toggle (appended by JS) */
.theme-toggle {
    background: none;
    border: 2px solid var(--border-default);
    border-radius: var(--radius-full);
    width: 2.5rem;
    height: 2.5rem;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: var(--text-lg);
    color: var(--text-secondary);
    transition: border-color var(--transition-fast),
        color var(--transition-fast),
        transform var(--transition-fast);
    flex-shrink: 0;
}

.theme-toggle:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: rotate(15deg);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    display: none;
}

:root .theme-toggle .icon-sun {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: none;
}


/* ============================================================
   Language switcher
   ============================================================ */
.lang-switcher {
    display: flex;
    gap: 2px;
    align-items: center;
    flex-shrink: 0;
}

.lang-btn {
    background: none;
    border: 1px solid var(--border-default);
    padding: 0.25rem 0.5rem;
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast),
        color var(--transition-fast),
        border-color var(--transition-fast);
}

.lang-btn:first-child {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.lang-btn:last-child {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.lang-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.lang-btn--active,
.lang-btn--active:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
}


/* ============================================================
   Main content wrapper
   ============================================================ */
#main-content {
    flex: 1;
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--space-2xl) var(--space-xl);
}


/* ============================================================
   Hero (index page)
   ============================================================ */
.hero {
    text-align: center;
    padding: var(--space-3xl) 0;
}

.hero>header {
    margin-bottom: var(--space-2xl);
}

.hero h1 {
    font-size: var(--text-5xl);
    font-weight: 900;
    letter-spacing: -0.03em;
    background: var(--pride-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: var(--space-sm);
}

.hero>header p {
    font-size: var(--text-xl);
    color: var(--text-secondary);
    max-width: 36rem;
    margin: 0 auto;
}


/* Hero Map */
.hero-map {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-2xl);
    box-shadow: var(--shadow-md);
}

.map-controls {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    margin-top: var(--space-md);
    flex-wrap: wrap;
    justify-content: center;
}

.map-controls label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
}

.map-controls input[type="range"] {
    flex: 1;
    max-width: 16rem;
    accent-color: var(--accent-primary);
}

.map-controls fieldset {
    border: none;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.map-controls legend {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: var(--space-sm);
    float: left;
}

.map-controls input[type="radio"] {
    accent-color: var(--accent-primary);
}


/* Search & Entry points */
.search-and-entries {
    margin-bottom: var(--space-3xl);
}

.site-search {
    display: flex;
    gap: var(--space-sm);
    max-width: 32rem;
    margin: 0 auto var(--space-xl);
}

.site-search label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.site-search input[type="search"] {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    border: 2px solid var(--border-default);
    border-radius: var(--radius-full);
    font-size: var(--text-base);
    font-family: var(--font-sans);
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: border-color var(--transition-fast),
        box-shadow var(--transition-fast);
}

.site-search input[type="search"]:focus {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
    outline: none;
}

.site-search input[type="search"]::placeholder {
    color: var(--text-muted);
}

.site-search button {
    padding: var(--space-sm) var(--space-lg);
    background: var(--accent-primary);
    color: var(--text-inverse);
    border: none;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: var(--text-base);
    cursor: pointer;
    transition: background-color var(--transition-fast),
        transform var(--transition-fast);
}

.site-search button:hover {
    background: var(--text-link-hover);
    transform: translateY(-1px);
}


/* Entry point nav — the browse sections */
.entry-points ul {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: var(--space-sm);
}

.entry-points a {
    display: block;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    text-align: center;
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-primary);
    transition: border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        transform var(--transition-fast),
        background-color var(--transition-fast);
}

.entry-points a:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    background: var(--bg-card-hover);
    text-decoration: none;
    color: var(--accent-primary);
}

/* Rainbow shimmer on entry point hover */
.entry-points a::after {
    content: '';
    display: block;
    height: 3px;
    margin-top: var(--space-sm);
    border-radius: 2px;
    background: var(--pride-gradient-horizontal);
    transform: scaleX(0);
    transition: transform var(--transition-normal);
}

.entry-points a:hover::after {
    transform: scaleX(1);
}


/* Featured sections */
.featured {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
}

.featured article {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-sm);
}

.featured h2 {
    font-size: var(--text-xl);
    margin-bottom: var(--space-md);
    color: var(--accent-primary);
}

.featured article>div {
    min-height: 8rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}


/* ============================================================
   Country / City Page
   ============================================================ */
.country-page {
    max-width: var(--content-max);
}

/* Breadcrumb */
.country-header nav ol {
    display: flex;
    gap: var(--space-sm);
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.country-header nav a {
    color: var(--text-link);
}

.country-header nav li+li::before {
    content: '/';
    margin-right: var(--space-sm);
    color: var(--text-muted);
}

/* Title block */
.country-title-block h1 {
    font-size: var(--text-4xl);
    font-weight: 800;
    margin-bottom: var(--space-xs);
}

.country-title-block .subtitle {
    font-size: var(--text-lg);
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
}

.country-meta {
    display: flex;
    gap: var(--space-md);
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-lg);
}

.country-meta span {
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
}

.country-map {
    margin-bottom: var(--space-2xl);
}

.country-map>div {
    width: 100%;
    height: 16rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}


/* Country sections — shared styles */
.country-page>section,
.country-page>aside {
    margin-bottom: var(--space-3xl);
    padding-bottom: var(--space-3xl);
    border-bottom: 1px solid var(--border-subtle);
    scroll-margin-top: calc(var(--header-h) + 5rem);
}

.country-page>section:last-of-type,
.country-page>aside:last-of-type {
    border-bottom: none;
}

/* Section jump navigation */
.section-jump {
    position: sticky;
    top: calc(var(--header-h) + var(--space-sm));
    z-index: 30;
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    margin: var(--space-xl) 0 var(--space-2xl);
    background: linear-gradient(120deg, rgba(124, 58, 237, 0.12), rgba(8, 145, 178, 0.08));
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.section-jump__label {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    white-space: nowrap;
}

.section-jump__list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-left: auto;
}

.section-jump__link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 0.45rem 0.9rem;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast),
        box-shadow var(--transition-fast),
        border-color var(--transition-fast);
}

.section-jump__link:hover,
.section-jump__link:focus-visible {
    text-decoration: none;
    transform: translateY(-1px);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

@media (max-width: 900px) {
    .section-jump {
        position: static;
        flex-direction: column;
        align-items: flex-start;
        padding: var(--space-md);
    }

    .section-jump__list {
        width: 100%;
        margin-left: 0;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--space-sm);
    }

    .section-jump__link {
        width: 100%;
        min-height: 2.4rem;
        justify-content: center;
    }
}

@media (max-width: 520px) {
    .section-jump__list {
        grid-template-columns: 1fr;
    }
}

.country-page section>header {
    margin-bottom: var(--space-xl);
}

.country-page h2 {
    font-size: var(--text-2xl);
    font-weight: 700;
    margin-bottom: var(--space-sm);
    position: relative;
    padding-left: var(--space-lg);
}

/* Accent bar next to section headings */
.country-page h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.15em;
    width: 4px;
    height: 1.2em;
    border-radius: 2px;
    background: var(--pride-gradient);
}

.narrative-intro {
    font-size: var(--text-lg);
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
    max-width: 56rem;
}


/* Overview section */
.country-overview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
}

.legal-status-summary>div,
.key-milestones>div {
    min-height: 10rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
}

/* Country/city profile section lists */
.profile-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
    gap: var(--space-md);
}

.profile-cards-grid .history-card.card {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding: var(--space-md);
}

.profile-cards-grid .history-card__title {
    font-size: var(--text-base);
}

.profile-cards-grid .history-card__desc {
    margin-bottom: var(--space-sm);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.profile-cards-grid .history-card__links {
    margin-top: auto;
}

/* Legal status grid (populated by JS) */
.legal-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: var(--space-sm);
}


/* Timeline containers */
.country-page [id*="timeline"],
.country-page [id*="key-timeline"] {
    min-height: 8rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
}

/* (Timeline filters defined in timeline section below) */


/* Places layout — map + list side by side */
.places-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
}

.places-map>div {
    height: 20rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.places-list>div {
    min-height: 20rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
}


/* Identity tabs */
.identity-tabs {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
    border-bottom: 2px solid var(--border-subtle);
    padding-bottom: var(--space-xs);
    overflow-x: auto;
}

.identity-tabs button,
.identity-tabs a {
    padding: var(--space-sm) var(--space-md);
    border: none;
    background: none;
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color var(--transition-fast),
        border-color var(--transition-fast);
    white-space: nowrap;
}

.identity-tabs button:hover,
.identity-tabs a:hover {
    color: var(--accent-primary);
}

.identity-tabs button[aria-selected="true"],
.identity-tabs a[aria-current="true"] {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}


/* Data notes aside */
.country-data-notes {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    font-size: var(--text-sm);
    color: var(--text-muted);
    border: 1px dashed var(--border-default);
}


/* ============================================================
   Content grids (culture, media, etc.)
   ============================================================ */
[id*="culture-grid"],
[id*="media-grid"] {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    gap: var(--space-md);
}


/* ============================================================
   Generic card component
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast),
        transform var(--transition-fast),
        border-color var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--accent-primary);
}


/* ============================================================
   Status badges (for rights, legal status)
   ============================================================ */
.status-badge {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-badge--legal {
    background: var(--status-legal);
    color: #fff;
}

.status-badge--limited {
    background: var(--status-limited);
    color: #000;
}

.status-badge--illegal {
    background: var(--status-illegal);
    color: #fff;
}

.status-badge--unknown {
    background: var(--status-unknown);
    color: #fff;
}

.status-badge--progressive {
    background: var(--status-progressive);
    color: #fff;
}


/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: var(--text-sm);
    cursor: pointer;
    transition: background-color var(--transition-fast),
        transform var(--transition-fast),
        box-shadow var(--transition-fast);
    border: none;
}

.btn--primary {
    background: var(--accent-primary);
    color: var(--text-inverse);
}

.btn--primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn--secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
}

.btn--secondary:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn--pride {
    background: var(--pride-gradient);
    color: #fff;
    font-weight: 700;
}

.btn--pride:hover {
    filter: brightness(1.1) saturate(1.1);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}


/* ============================================================
   Homepage — Live Stats Strip
   ============================================================ */
.home-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: var(--space-md);
    margin-top: var(--space-xl);
}

.home-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-lg) var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast),
        transform var(--transition-fast),
        border-color var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.home-stat-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--pride-gradient-horizontal);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.home-stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
    border-color: var(--accent-primary);
}

.home-stat-card:hover::after {
    opacity: 1;
}

.home-stat-card__icon {
    font-size: var(--text-3xl);
    line-height: 1;
}

.home-stat-card__number {
    font-size: var(--text-3xl);
    font-weight: 900;
    line-height: 1;
    background: var(--pride-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    min-height: 1.2em;
}

.home-stat-card__label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}


/* ============================================================
   Homepage — Browse Section
   ============================================================ */
.home-browse {
    margin-top: var(--space-3xl);
    margin-bottom: var(--space-3xl);
}

.home-browse .site-search {
    margin-bottom: var(--space-2xl);
}

/* Entry point icon and label */
.entry-points a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-lg);
}

.entry-icon {
    font-size: var(--text-3xl);
    line-height: 1;
    transition: transform var(--transition-normal);
}

.entry-points a:hover .entry-icon {
    transform: scale(1.15) rotate(-5deg);
}

.entry-label {
    font-size: var(--text-sm);
    font-weight: 600;
}


/* ============================================================
   Homepage — Featured Content (two-column)
   ============================================================ */
.home-featured {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2xl);
    margin-bottom: var(--space-3xl);
}

.home-featured__col>h2 {
    font-size: var(--text-2xl);
    font-weight: 700;
    margin-bottom: var(--space-lg);
    position: relative;
    padding-left: var(--space-lg);
}

.home-featured__col>h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.15em;
    width: 4px;
    height: 1.2em;
    border-radius: 2px;
    background: var(--pride-gradient);
}

/* "Born in Month" label */
.featured-month-label {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--accent-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: var(--space-md);
}

/* Featured people grid (3 columns, compact) */
.featured-people-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
    gap: var(--space-md);
}

.featured-person-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    color: inherit;
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast),
        transform var(--transition-fast);
}

.featured-person-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    text-decoration: none;
}

.featured-person-card__photo {
    width: 5rem;
    height: 5rem;
    border-radius: var(--radius-full);
    object-fit: cover;
    margin-bottom: var(--space-sm);
    border: 3px solid var(--border-subtle);
    transition: border-color var(--transition-fast);
    background: var(--bg-tertiary);
}

.featured-person-card:hover .featured-person-card__photo {
    border-color: var(--accent-primary);
}

.featured-person-card__photo--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 5rem;
    height: 5rem;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    margin-bottom: var(--space-sm);
    border: 3px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: var(--text-xl);
}

.featured-person-card__name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    line-height: var(--leading-tight);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.featured-person-card__dates {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 2px;
}


/* ============================================================
   Homepage — Discover Grid (vertical, matches featured)
   ============================================================ */
.discover-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
    gap: var(--space-md);
}

.discover-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    color: inherit;
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast),
        transform var(--transition-fast);
}

.discover-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    text-decoration: none;
}

.discover-card__photo {
    width: 5rem;
    height: 5rem;
    border-radius: var(--radius-full);
    object-fit: cover;
    margin-bottom: var(--space-sm);
    border: 3px solid var(--border-subtle);
    transition: border-color var(--transition-fast);
    background: var(--bg-tertiary);
}

.discover-card:hover .discover-card__photo {
    border-color: var(--accent-secondary);
}

.discover-card__photo--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 5rem;
    height: 5rem;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    margin-bottom: var(--space-sm);
    border: 3px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: var(--text-xl);
}

.discover-card__name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    line-height: var(--leading-tight);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.discover-card__desc {
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: var(--leading-normal);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 2px;
}


/* ============================================================
   Homepage — Section (Pride Events, Flags, etc.)
   ============================================================ */
.home-section {
    margin-bottom: var(--space-3xl);
}

.home-section>header {
    margin-bottom: var(--space-xl);
}

.home-section>header h2 {
    font-size: var(--text-2xl);
    font-weight: 700;
    margin-bottom: var(--space-xs);
    position: relative;
    padding-left: var(--space-lg);
}

.home-section>header h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.15em;
    width: 4px;
    height: 1.2em;
    border-radius: 2px;
    background: var(--pride-gradient);
}

/* On This Day — card list */
.otd-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
    gap: var(--space-md);
}

.otd-card {
    display: flex;
    gap: var(--space-md);
    align-items: flex-start;
    text-decoration: none;
    color: inherit;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.otd-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-primary);
}

.otd-card__photo {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-tertiary);
}

.otd-card__photo--empty {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.otd-card__info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.otd-card__name {
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.otd-card:hover .otd-card__name {
    color: var(--accent-primary);
}

.otd-card__dates {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.otd-card__badge {
    display: inline-block;
    font-size: var(--text-xs);
    font-weight: 700;
    padding: 1px var(--space-sm);
    border-radius: var(--radius-full);
    align-self: flex-start;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.otd-card__badge--born {
    background: color-mix(in srgb, var(--accent-success) 15%, transparent);
    color: var(--accent-success);
}

.otd-card__badge--died {
    background: color-mix(in srgb, var(--accent-secondary) 15%, transparent);
    color: var(--accent-secondary);
}

.otd-card__desc {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    line-height: var(--leading-normal);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


/* Pride events grid */
.pride-events-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: var(--space-lg);
}

.pride-event-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    padding: 0;
}

.pride-event-card:hover {
    text-decoration: none;
}

.pride-event-card__image {
    width: 100%;
    height: 10rem;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.pride-event-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-normal);
}

.pride-event-card:hover .pride-event-card__image img {
    transform: scale(1.05);
}

.pride-event-card__title {
    font-size: var(--text-base);
    font-weight: 700;
    padding: var(--space-md) var(--space-lg) var(--space-xs);
    color: var(--accent-primary);
}

.pride-event-card__meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
    padding: 0 var(--space-lg);
}

.pride-event-card__participants {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--accent-secondary);
    padding: var(--space-xs) var(--space-lg) var(--space-md);
}


/* ============================================================
   Homepage — Flag Strip
   ============================================================ */
.home-section--flags {
    background: var(--bg-secondary);
    margin-left: calc(-1 * var(--space-xl));
    margin-right: calc(-1 * var(--space-xl));
    padding: var(--space-2xl) var(--space-xl);
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}

.flag-strip {
    display: flex;
    gap: var(--space-md);
    overflow-x: auto;
    padding-bottom: var(--space-sm);
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.flag-strip::-webkit-scrollbar {
    height: 6px;
}

.flag-strip::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.flag-strip::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 3px;
}

.flag-strip::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

.flag-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    min-width: 8rem;
    max-width: 8rem;
    scroll-snap-align: start;
    flex-shrink: 0;
    text-decoration: none;
    color: inherit;
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    transition: transform var(--transition-fast),
        background-color var(--transition-fast);
}

.flag-card:hover {
    transform: translateY(-3px);
    background: var(--bg-card-hover);
    text-decoration: none;
}

.flag-card img {
    width: 6rem;
    height: 4rem;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast);
}

.flag-card:hover img {
    box-shadow: var(--shadow-md);
}

.flag-card__label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    line-height: var(--leading-tight);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


/* ============================================================
   Homepage — About / CTA Section
   ============================================================ */
.home-about {
    background: var(--bg-hero);
    margin-left: calc(-1 * var(--space-xl));
    margin-right: calc(-1 * var(--space-xl));
    padding: var(--space-3xl) var(--space-xl);
    text-align: center;
}

.home-about__text {
    max-width: 42rem;
    margin: 0 auto;
}

.home-about__text h2 {
    font-size: var(--text-2xl);
    font-weight: 800;
    margin-bottom: var(--space-md);
    background: var(--pride-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.home-about__text p {
    font-size: var(--text-base);
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
    margin-bottom: var(--space-md);
}

.home-about__links {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    flex-wrap: wrap;
    margin-top: var(--space-xl);
}

.home-about__links .btn {
    padding: var(--space-md) var(--space-xl);
    font-size: var(--text-base);
}


/* ============================================================
   Site Footer
   ============================================================ */
#site-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    padding: var(--space-xl);
    text-align: center;
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-top: auto;
    transition: background-color var(--transition-normal);
}

/* Pride stripe at the bottom too */
#site-footer::after {
    content: '';
    display: block;
    height: 3px;
    background: var(--pride-gradient-horizontal);
    border-radius: 2px;
    margin-top: var(--space-md);
    max-width: 12rem;
    margin-left: auto;
    margin-right: auto;
}


/* ============================================================
   Forms & inputs (general)
   ============================================================ */
input,
select,
textarea {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--bg-secondary);
}

/* Accessibility helpers */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}


/* ============================================================
   Search page
   ============================================================ */
.search-page-form {
    margin-bottom: var(--space-2xl);
}

.search-bar {
    display: flex;
    gap: var(--space-sm);
    max-width: 40rem;
}

.search-bar input[type="search"] {
    flex: 1;
    padding: var(--space-md) var(--space-lg);
    border: 2px solid var(--border-default);
    border-radius: var(--radius-full);
    font-size: var(--text-lg);
    font-family: var(--font-sans);
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: border-color var(--transition-fast),
        box-shadow var(--transition-fast);
}

.search-bar input[type="search"]:focus {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
    outline: none;
}

.search-bar input[type="search"]::placeholder {
    color: var(--text-muted);
}

.search-bar button {
    padding: var(--space-md) var(--space-xl);
    background: var(--accent-primary);
    color: var(--text-inverse);
    border: none;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: var(--text-base);
    cursor: pointer;
    transition: background-color var(--transition-fast),
        transform var(--transition-fast);
}

.search-bar button:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.search-status {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
}

.search-progress {
    margin-bottom: var(--space-lg);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.search-progress__bar {
    width: 100%;
    height: 0.4rem;
    background: color-mix(in srgb, var(--accent-primary) 12%, var(--bg-secondary));
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--space-sm);
}

.search-progress__fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-tertiary));
    transition: width var(--transition-normal);
}

.search-progress__chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.search-progress__chip {
    font-size: var(--text-xs);
    font-weight: 700;
    padding: 2px var(--space-sm);
    border-radius: var(--radius-full);
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform var(--transition-fast), opacity var(--transition-fast), box-shadow var(--transition-fast);
}

.search-progress__chip:hover {
    transform: translateY(-1px);
}

.search-progress__chip:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 1px;
}

.search-progress__chip--pending {
    background: var(--bg-secondary);
    color: var(--text-muted);
    border-color: var(--border-subtle);
}

.search-progress__chip--done {
    background: color-mix(in srgb, var(--accent-success) 18%, var(--bg-secondary));
    color: var(--accent-success);
    border-color: color-mix(in srgb, var(--accent-success) 35%, var(--bg-secondary));
}

.search-progress__chip--error {
    background: color-mix(in srgb, var(--accent-danger) 18%, var(--bg-secondary));
    color: var(--accent-danger);
    border-color: color-mix(in srgb, var(--accent-danger) 35%, var(--bg-secondary));
}

.search-progress__chip--off {
    opacity: 0.45;
    box-shadow: none;
}

.search-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
    gap: var(--space-lg);
}

.search-result-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    padding: 0;
}

.search-result-card:hover {
    text-decoration: none;
}

.search-result-card__image {
    width: 100%;
    height: 10rem;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.search-result-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-normal);
}

.search-result-card:hover .search-result-card__image img {
    transform: scale(1.05);
}

.search-result-card__content {
    padding: var(--space-md) var(--space-lg) var(--space-lg);
}

.search-result-card__title {
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: var(--space-xs);
}

.search-result-card__title-link {
    color: inherit;
    text-decoration: none;
}

.search-result-card__title-link:hover,
.search-result-card__title-link:focus-visible {
    color: inherit;
    text-decoration: underline;
}

.search-result-card__type {
    display: inline-block;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 2px var(--space-sm);
    border-radius: var(--radius-full);
    margin-bottom: var(--space-sm);
    text-transform: capitalize;
}

.search-result-card__desc {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: var(--leading-normal);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    #site-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto;
        align-items: center;
        column-gap: var(--space-xs);
        row-gap: 0.35rem;
        padding: 0.35rem var(--space-sm);
        min-height: auto;
    }

    .logo a {
        font-size: var(--text-lg);
    }

    #site-nav {
        grid-column: 1 / -1;
        position: relative;
        overflow: hidden;
    }

    #site-nav.is-scrollable::after {
        content: '\203A';
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 2rem;
        display: grid;
        place-items: center;
        font-size: 1.2rem;
        font-weight: 900;
        color: var(--text-primary);
        text-shadow: 0 0 1px var(--bg-primary);
        background: linear-gradient(to right, transparent 0%, var(--bg-secondary) 45%, var(--bg-secondary) 100%);
        border-left: 1px solid var(--border-default);
        pointer-events: none;
        opacity: 1;
        z-index: 2;
    }

    #site-nav.is-scrollable.is-scrolled::before {
        content: '\2039';
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 1.8rem;
        display: grid;
        place-items: center;
        font-size: 1.1rem;
        font-weight: 900;
        color: var(--text-primary);
        text-shadow: 0 0 1px var(--bg-primary);
        background: linear-gradient(to left, transparent 0%, var(--bg-secondary) 45%, var(--bg-secondary) 100%);
        border-right: 1px solid var(--border-default);
        pointer-events: none;
        opacity: 1;
        z-index: 2;
    }

    #site-nav.is-scrollable.is-at-end::after {
        opacity: 0;
    }

    #site-nav ul {
        display: flex;
        justify-content: flex-start;
        flex-wrap: nowrap;
        width: auto;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 2px;
    }

    #site-nav li {
        flex: 0 0 auto;
    }

    #site-nav a {
        padding: 0.2rem 0.5rem;
        font-size: var(--text-xs);
    }

    .theme-toggle {
        width: 2rem;
        height: 2rem;
        border-width: 1px;
        font-size: var(--text-base);
    }

    .lang-switcher {
        gap: 1px;
    }

    .lang-btn {
        padding: 0.2rem 0.4rem;
    }

    .hero h1 {
        font-size: var(--text-3xl);
    }

    .hero>header p {
        font-size: var(--text-base);
    }

    .featured {
        grid-template-columns: 1fr;
    }

    .country-overview {
        grid-template-columns: 1fr;
    }

    .profile-cards-grid {
        grid-template-columns: 1fr;
    }

    .places-layout {
        grid-template-columns: 1fr;
    }

    #main-content {
        padding: var(--space-lg) var(--space-md);
    }

    .country-title-block h1 {
        font-size: var(--text-2xl);
    }

    .page-header h1 {
        font-size: var(--text-2xl);
    }

    .identities-grid {
        grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
    }

    .counts-grid {
        grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
    }

    .rights-topics-grid {
        grid-template-columns: 1fr;
    }

    .rights-countries-grid {
        grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    }

    .rights-discrimination-grid {
        grid-template-columns: 1fr;
    }

    /* Homepage responsive */
    .home-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-sm);
    }

    .home-stat-card {
        padding: var(--space-md) var(--space-sm);
    }

    .home-stat-card__number {
        font-size: var(--text-2xl);
    }

    .home-featured {
        grid-template-columns: 1fr;
        gap: var(--space-xl);
    }

    .featured-people-grid,
    .discover-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .search-bar {
        flex-direction: column;
        max-width: 100%;
    }

    .search-bar button {
        width: 100%;
    }

    .search-results-grid {
        grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    }

    .pride-events-grid {
        grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
    }

    .home-section--flags {
        margin-left: calc(-1 * var(--space-md));
        margin-right: calc(-1 * var(--space-md));
        padding: var(--space-xl) var(--space-md);
    }

    .home-about {
        margin-left: calc(-1 * var(--space-md));
        margin-right: calc(-1 * var(--space-md));
        padding: var(--space-2xl) var(--space-md);
    }
}

@media (max-width: 480px) {
    .entry-points ul {
        grid-template-columns: 1fr 1fr;
    }

    .site-search {
        flex-direction: column;
    }

    .site-search button {
        width: 100%;
    }

    .map-controls {
        flex-direction: column;
    }

    /* Homepage responsive (small) */
    .home-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .home-stat-card__icon {
        font-size: var(--text-xl);
    }

    .home-stat-card__number {
        font-size: var(--text-xl);
    }

    .featured-people-grid,
    .discover-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .search-results-grid {
        grid-template-columns: 1fr;
    }

    .pride-events-grid {
        grid-template-columns: 1fr;
    }

    .home-about__links {
        flex-direction: column;
        align-items: stretch;
    }

    .home-about__links .btn {
        text-align: center;
    }
}


/* ============================================================
   Accessibility: reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}


/* ============================================================
   Page header (shared by section pages)
   ============================================================ */
.page-header {
    margin-bottom: var(--space-3xl);
}

.page-header h1 {
    font-size: var(--text-4xl);
    font-weight: 800;
    margin-bottom: var(--space-sm);
    background: var(--pride-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.page-intro {
    font-size: var(--text-lg);
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
    max-width: 52rem;
}


/* ============================================================
   Identities page
   ============================================================ */

/* Section spacing */
.identities-section {
    margin-bottom: var(--space-3xl);
    padding-bottom: var(--space-3xl);
    border-bottom: 1px solid var(--border-subtle);
}

.identities-section:last-of-type {
    border-bottom: none;
}

.identities-section>header {
    margin-bottom: var(--space-xl);
}

.identities-section h2 {
    font-size: var(--text-2xl);
    font-weight: 700;
    margin-bottom: var(--space-sm);
    position: relative;
    padding-left: var(--space-lg);
}

.identities-section h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.15em;
    width: 4px;
    height: 1.2em;
    border-radius: 2px;
    background: var(--pride-gradient);
}

.section-desc {
    font-size: var(--text-base);
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
    max-width: 56rem;
}

/* Identity cards grid */
.identities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: var(--space-lg);
}

/* Individual identity card */
.identity-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.identity-card__image {
    width: 100%;
    height: 10rem;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.identity-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-normal);
}

.identity-card:hover .identity-card__image img {
    transform: scale(1.05);
}

.identity-card__title {
    font-size: var(--text-lg);
    font-weight: 700;
    padding: var(--space-md) var(--space-lg) var(--space-xs);
    color: var(--accent-primary);
}

.identity-card__desc {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    padding: 0 var(--space-lg);
    line-height: var(--leading-normal);
    flex: 1;
    /* Clamp to 3 lines */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.identity-card__links {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    flex-wrap: wrap;
    align-items: center;
}

.identity-card__link {
    font-size: var(--text-xs);
    font-weight: 600;
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    color: var(--text-link);
    text-decoration: none;
    transition: background-color var(--transition-fast);
}

.identity-card__link[href*="wikipedia.org"] {
    color: var(--accent-success);
    background: color-mix(in srgb, var(--accent-success) 14%, var(--bg-tertiary));
}

.identity-card__link[href*="wikidata.org"] {
    color: var(--accent-tertiary);
    background: color-mix(in srgb, var(--accent-tertiary) 14%, var(--bg-tertiary));
}

.identity-card__link:hover {
    background: var(--accent-primary);
    color: var(--text-inverse);
    text-decoration: none;
}

.identity-card__link[href*="wikipedia.org"]:hover,
.identity-card__link[href*="wikipedia.org"]:focus-visible {
    background: var(--accent-success);
    color: var(--text-inverse);
}

.identity-card__link[href*="wikidata.org"]:hover,
.identity-card__link[href*="wikidata.org"]:focus-visible {
    background: var(--accent-tertiary);
    color: var(--text-inverse);
}

.identity-card__people-btn {
    margin-left: auto;
    font-size: var(--text-xs) !important;
    padding: var(--space-xs) var(--space-sm) !important;
}

/* Expanded people list inside card */
.identity-card__people {
    padding: 0 var(--space-lg) var(--space-lg);
}

/* People list */
.people-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.people-list__item {
    display: flex;
    gap: var(--space-sm);
    align-items: flex-start;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    transition: background-color var(--transition-fast);
}

.people-list__item:hover {
    background: var(--bg-card-hover);
}

.people-list__photo {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-full);
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--border-subtle);
}

.people-list__info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.people-list__name {
    font-weight: 600;
    font-size: var(--text-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.people-list__name[href*="wikipedia.org"] {
    color: var(--accent-success);
}

.people-list__name[href*="wikidata.org"] {
    color: var(--accent-tertiary);
}

.people-list__dates {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.people-list__desc {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Counts grid (Wikidata coverage section) */
.counts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: var(--space-sm);
}

.count-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    text-align: center;
    transition: box-shadow var(--transition-fast),
        transform var(--transition-fast);
}

.count-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.count-card__number {
    font-size: var(--text-2xl);
    font-weight: 800;
    color: var(--accent-primary);
    line-height: 1;
    margin-bottom: var(--space-xs);
}

.count-card__label {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: capitalize;
}

/* Data provenance aside */
.identities-data-note {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    font-size: var(--text-sm);
    color: var(--text-muted);
    border: 1px dashed var(--border-default);
    margin-top: var(--space-2xl);
}

.identities-data-note h2 {
    font-size: var(--text-lg);
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.identities-data-note p {
    margin-bottom: var(--space-sm);
    line-height: var(--leading-relaxed);
}

.identities-data-note p:last-child {
    margin-bottom: 0;
}


/* ============================================================
   History & Timelines page
   ============================================================ */

/* Section spacing (reuses identities pattern) */
.history-section {
    margin-bottom: var(--space-3xl);
    padding-bottom: var(--space-3xl);
    border-bottom: 1px solid var(--border-subtle);
}

.history-section:last-of-type {
    border-bottom: none;
}

.history-section>header {
    margin-bottom: var(--space-xl);
}

.history-section h2 {
    font-size: var(--text-2xl);
    font-weight: 700;
    margin-bottom: var(--space-sm);
    position: relative;
    padding-left: var(--space-lg);
}

.history-section h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.15em;
    width: 4px;
    height: 1.2em;
    border-radius: 2px;
    background: var(--pride-gradient);
}

.history-eras-grid,
.history-movements-grid,
.history-people-grid,
.history-hotspots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: var(--space-lg);
}

/* History cards */
.history-card__title {
    font-size: var(--text-lg);
    font-weight: 700;
    margin-bottom: var(--space-xs);
    color: var(--accent-primary);
}

.history-card__meta {
    display: inline-block;
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.history-card__tag {
    display: inline-block;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 2px var(--space-sm);
    border-radius: var(--radius-full);
    margin-bottom: var(--space-sm);
}

.history-card__desc {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: var(--leading-normal);
    margin-bottom: var(--space-md);
}

.history-card__count {
    display: inline-block;
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.history-card__links {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
    align-items: center;
}

.history-card--thumb {
    overflow: hidden;
}

.history-card__thumb {
    width: calc(100% + (var(--space-lg) * 2));
    height: 10rem;
    margin: calc(var(--space-lg) * -1) calc(var(--space-lg) * -1) var(--space-md);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-subtle);
    overflow: hidden;
}

.history-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-normal);
}

.history-card--thumb:hover .history-card__thumb img {
    transform: scale(1.04);
}

.history-person-card__image {
    width: 100%;
    height: 10rem;
    overflow: hidden;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
}

.history-person-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-normal);
}

.history-person-card:hover .history-person-card__image img {
    transform: scale(1.05);
}

/* Data provenance aside */
.history-data-note {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    font-size: var(--text-sm);
    color: var(--text-muted);
    border: 1px dashed var(--border-default);
    margin-top: var(--space-2xl);
}

.history-data-note h2 {
    font-size: var(--text-lg);
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.history-data-note p {
    margin-bottom: var(--space-sm);
    line-height: var(--leading-relaxed);
}

.history-data-note p:last-child {
    margin-bottom: 0;
}


/* ============================================================
   Activism page
   ============================================================ */

/* Section spacing */
.activism-section {
    margin-bottom: var(--space-3xl);
    padding-bottom: var(--space-3xl);
    border-bottom: 1px solid var(--border-subtle);
}

.activism-section:last-of-type {
    border-bottom: none;
}

.activism-section>header {
    margin-bottom: var(--space-xl);
}

.activism-section h2 {
    font-size: var(--text-2xl);
    font-weight: 700;
    margin-bottom: var(--space-sm);
    position: relative;
    padding-left: var(--space-lg);
}

.activism-section h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.15em;
    width: 4px;
    height: 1.2em;
    border-radius: 2px;
    background: var(--pride-gradient);
}

.activism-movements-grid,
.activism-protests-grid,
.activism-pride-grid,
.activism-people-grid,
.activism-orgs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: var(--space-lg);
}

/* Data provenance aside */
.activism-data-note {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    font-size: var(--text-sm);
    color: var(--text-muted);
    border: 1px dashed var(--border-default);
    margin-top: var(--space-2xl);
}

.activism-data-note h2 {
    font-size: var(--text-lg);
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.activism-data-note p {
    margin-bottom: var(--space-sm);
    line-height: var(--leading-relaxed);
}

.activism-data-note p:last-child {
    margin-bottom: 0;
}


/* ============================================================
   Places page
   ============================================================ */

/* Section spacing */
.places-section {
    margin-bottom: var(--space-3xl);
    padding-bottom: var(--space-3xl);
    border-bottom: 1px solid var(--border-subtle);
}

.places-section:last-of-type {
    border-bottom: none;
}

.places-section>header {
    margin-bottom: var(--space-xl);
}

.places-section h2 {
    font-size: var(--text-2xl);
    font-weight: 700;
    margin-bottom: var(--space-sm);
    position: relative;
    padding-left: var(--space-lg);
}

.places-section h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.15em;
    width: 4px;
    height: 1.2em;
    border-radius: 2px;
    background: var(--pride-gradient);
}

.places-centers-grid,
.places-museums-grid,
.places-archives-grid,
.places-memorials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: var(--space-lg);
}

/* Data provenance aside */
.places-data-note {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    font-size: var(--text-sm);
    color: var(--text-muted);
    border: 1px dashed var(--border-default);
    margin-top: var(--space-2xl);
}

.places-data-note h2 {
    font-size: var(--text-lg);
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.places-data-note p {
    margin-bottom: var(--space-sm);
    line-height: var(--leading-relaxed);
}

.places-data-note p:last-child {
    margin-bottom: 0;
}


/* ============================================================
   Culture page
   ============================================================ */

/* Section spacing */
.culture-section {
    margin-bottom: var(--space-3xl);
    padding-bottom: var(--space-3xl);
    border-bottom: 1px solid var(--border-subtle);
}

.culture-section:last-of-type {
    border-bottom: none;
}

.culture-section>header {
    margin-bottom: var(--space-xl);
}

.culture-section h2 {
    font-size: var(--text-2xl);
    font-weight: 700;
    margin-bottom: var(--space-sm);
    position: relative;
    padding-left: var(--space-lg);
}

.culture-section h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.15em;
    width: 4px;
    height: 1.2em;
    border-radius: 2px;
    background: var(--pride-gradient);
}

.culture-performing-grid,
.culture-screen-grid,
.culture-literature-grid,
.culture-media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: var(--space-lg);
}

/* Data provenance aside */
.culture-data-note {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    font-size: var(--text-sm);
    color: var(--text-muted);
    border: 1px dashed var(--border-default);
    margin-top: var(--space-2xl);
}

.culture-data-note h2 {
    font-size: var(--text-lg);
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.culture-data-note p {
    margin-bottom: var(--space-sm);
    line-height: var(--leading-relaxed);
}

.culture-data-note p:last-child {
    margin-bottom: 0;
}


/* ============================================================
   Country & City listing pages
   ============================================================ */

.locations-section {
    margin-bottom: var(--space-3xl);
    padding-bottom: var(--space-3xl);
    border-bottom: 1px solid var(--border-subtle);
}

.locations-section:last-of-type {
    border-bottom: none;
}

.location-controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    align-items: center;
    margin-bottom: var(--space-lg);
}

.location-search {
    min-width: min(24rem, 100%);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-default);
    background: var(--bg-secondary);
}

.location-count {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--accent-primary);
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
}

.location-count--updating {
    color: var(--text-primary);
    background: color-mix(in srgb, var(--accent-primary) 16%, var(--bg-tertiary));
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent-primary) 35%, transparent);
    animation: location-count-pulse 1s ease-in-out infinite alternate;
}

@keyframes location-count-pulse {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(-1px);
    }
}

.location-help {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
    max-width: 56rem;
}

.inline-code {
    font-family: var(--font-mono);
    font-size: 0.95em;
    background: var(--bg-tertiary);
    padding: 0 6px;
    border-radius: var(--radius-full);
}

.location-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    gap: var(--space-md);
}

.location-card {
    text-decoration: none;
    color: inherit;
}

.location-card__name {
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.location-card__meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.location-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.location-tag {
    font-size: var(--text-xs);
    font-weight: 700;
    padding: 2px var(--space-sm);
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.locations-data-note {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    font-size: var(--text-sm);
    color: var(--text-muted);
    border: 1px dashed var(--border-default);
    margin-top: var(--space-2xl);
}

.locations-data-note h2 {
    font-size: var(--text-lg);
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.locations-data-note p {
    margin-bottom: var(--space-sm);
    line-height: var(--leading-relaxed);
}

.locations-data-note p:last-child {
    margin-bottom: 0;
}


/* ============================================================
   Data & Methodology page
   ============================================================ */

.data-section {
    margin-bottom: var(--space-3xl);
    padding-bottom: var(--space-3xl);
    border-bottom: 1px solid var(--border-subtle);
}

.data-section:last-of-type {
    border-bottom: none;
}

.data-section>header {
    margin-bottom: var(--space-xl);
}

.data-section h2 {
    font-size: var(--text-2xl);
    font-weight: 700;
    margin-bottom: var(--space-sm);
    position: relative;
    padding-left: var(--space-lg);
}

.data-section h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.15em;
    width: 4px;
    height: 1.2em;
    border-radius: 2px;
    background: var(--pride-gradient);
}

.data-list {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
}

.data-list li {
    margin-bottom: var(--space-sm);
}

.data-note {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    font-size: var(--text-sm);
    color: var(--text-muted);
    border: 1px dashed var(--border-default);
    margin-top: var(--space-2xl);
}

.data-note h2 {
    font-size: var(--text-lg);
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.data-note p {
    margin-bottom: 0;
    line-height: var(--leading-relaxed);
}


/* ============================================================
   Loading spinner & error states (shared)
   ============================================================ */
.qm-loading {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xl);
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.qm-spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 3px solid var(--border-default);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: qm-spin 0.7s linear infinite;
}

@keyframes qm-spin {
    to {
        transform: rotate(360deg);
    }
}

.qm-error {
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-danger);
    border-radius: var(--radius-md);
    color: var(--accent-danger);
    font-size: var(--text-sm);
}

.qm-empty {
    padding: var(--space-md);
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-style: italic;
}


/* ============================================================
   Rights & Law page
   ============================================================ */

/* Section spacing (reuses identities pattern) */
.rights-section {
    margin-bottom: var(--space-3xl);
    padding-bottom: var(--space-3xl);
    border-bottom: 1px solid var(--border-subtle);
}

.rights-section:last-of-type {
    border-bottom: none;
}

.rights-section>header {
    margin-bottom: var(--space-xl);
}

.rights-section h2 {
    font-size: var(--text-2xl);
    font-weight: 700;
    margin-bottom: var(--space-sm);
    position: relative;
    padding-left: var(--space-lg);
}

.rights-section h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.15em;
    width: 4px;
    height: 1.2em;
    border-radius: 2px;
    background: var(--pride-gradient);
}


/* Rights topics grid */
.rights-topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
    gap: var(--space-lg);
}

/* Rights topic card */
.rights-topic-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.rights-topic-card__icon {
    font-size: var(--text-3xl);
    line-height: 1;
}

.rights-topic-card__title {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.rights-topic-card__desc {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: var(--leading-normal);
    flex: 1;
}

.rights-topic-card__count {
    display: inline-block;
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--accent-primary);
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    align-self: flex-start;
}

.rights-topic-card__links {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
    align-items: center;
    padding-top: var(--space-xs);
}

.rights-topic-card__expand-btn {
    font-size: var(--text-xs) !important;
    padding: var(--space-xs) var(--space-sm) !important;
}

/* Expandable region list inside topic card */
.rights-topic-card__regions {
    margin-top: var(--space-sm);
}

.region-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 20rem;
    overflow-y: auto;
    padding-right: var(--space-sm);
}

.region-list__item {
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    transition: background-color var(--transition-fast);
}

.region-list__item:hover {
    background: var(--bg-tertiary);
}

.region-list__link {
    font-weight: 600;
}

.region-list__link--wikipedia {
    color: var(--accent-success);
}

.region-list__link--wikidata {
    color: var(--accent-tertiary);
}

.region-list__desc {
    color: var(--text-muted);
    font-size: var(--text-xs);
}


/* Country rights grid */
.rights-countries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    gap: var(--space-sm);
}

.rights-stat {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: var(--space-md);
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    display: inline-block;
}

.rights-country-card {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        transform var(--transition-fast);
}

.rights-country-card--wikipedia {
    border-left: 3px solid color-mix(in srgb, var(--accent-success) 70%, transparent);
}

.rights-country-card--wikidata {
    border-left: 3px solid color-mix(in srgb, var(--accent-tertiary) 70%, transparent);
}

.rights-country-card:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
    text-decoration: none;
}

.rights-country-card__name {
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-primary);
}

.rights-country-card:hover .rights-country-card__name {
    color: var(--accent-primary);
}

.rights-country-card--wikipedia .rights-country-card__name {
    color: var(--accent-success);
}

.rights-country-card--wikidata .rights-country-card__name {
    color: var(--accent-tertiary);
}

.rights-country-card__desc {
    font-size: var(--text-xs);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* Discrimination grid */
.rights-discrimination-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: var(--space-lg);
}

.discrimination-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    border-left: 4px solid var(--accent-danger);
}

.discrimination-card__title {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.discrimination-card__desc {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: var(--leading-normal);
    flex: 1;
}

.discrimination-card__count {
    display: inline-block;
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--accent-danger);
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    align-self: flex-start;
}

.discrimination-card__links {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
    align-items: center;
}


/* Heatmap section */
.heatmap-section {
    margin-bottom: var(--space-3xl);
}

.heatmap-section>header {
    margin-bottom: var(--space-xl);
}

.heatmap-section>header h2 {
    font-size: var(--text-2xl);
    font-weight: 700;
    margin-bottom: var(--space-xs);
}

.heatmap-controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
}

.heatmap-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    padding: var(--space-xs) var(--space-md);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.heatmap-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.heatmap-btn--active,
.heatmap-btn--active:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
}

.heatmap-container {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    overflow: hidden;
}

#heatmap-map svg {
    width: 100%;
    height: auto;
    display: block;
}

.heatmap-tooltip {
    position: absolute;
    z-index: 10;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    line-height: var(--leading-normal);
    pointer-events: none;
    box-shadow: var(--shadow-md);
    max-width: 18rem;
}

.heatmap-tooltip[hidden] {
    display: none;
}

.heatmap-tooltip strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 2px;
}

.heatmap-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-subtle);
}

.heatmap-legend__item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.heatmap-legend__swatch {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    border: 1px solid var(--border-default);
    flex-shrink: 0;
}

.heatmap-legend__label {
    font-size: var(--text-xs);
    color: var(--text-muted);
}


/* Data provenance aside (rights page) */
.rights-data-note {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    font-size: var(--text-sm);
    color: var(--text-muted);
    border: 1px dashed var(--border-default);
    margin-top: var(--space-2xl);
}

.rights-data-note h2 {
    font-size: var(--text-lg);
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.rights-data-note p {
    margin-bottom: var(--space-sm);
    line-height: var(--leading-relaxed);
}

.rights-data-note p:last-child {
    margin-bottom: 0;
}


/* ============================================================
   Memorial page — solemn, restrained design
   ============================================================ */

/* Content warning overlay */
.memorial-warning {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.memorial-warning[hidden] {
    display: none;
}

.memorial-warning__inner {
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    max-width: 28rem;
    text-align: center;
}

.memorial-warning__inner h2 {
    font-size: var(--text-lg);
    margin-bottom: var(--space-sm);
}

.memorial-warning__inner p {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
    margin-bottom: var(--space-lg);
}

.memorial-warning__btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    padding: var(--space-sm) var(--space-xl);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.memorial-warning__btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-strong);
}

/* Memorial page overrides — solemn tone */
.memorial-page .page-header h1 {
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
    -webkit-text-fill-color: var(--text-primary);
    color: var(--text-primary);
}

.memorial-intro {
    font-family: Georgia, 'Times New Roman', Times, serif;
    font-size: var(--text-lg);
    line-height: var(--leading-relaxed);
    color: var(--text-secondary);
    max-width: 48rem;
}

.memorial-header {
    margin-bottom: var(--space-2xl);
}

/* Memorial sections */
.memorial-section {
    margin-bottom: var(--space-3xl);
}

.memorial-section>header {
    margin-bottom: var(--space-xl);
}

.memorial-section>header h2 {
    font-size: var(--text-2xl);
    font-weight: 700;
    margin-bottom: var(--space-xs);
    color: var(--text-primary);
}

/* Person cards — circular grayscale photos */
.memorial-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: var(--space-md);
}

.memorial-person-card {
    display: flex;
    gap: var(--space-md);
    align-items: flex-start;
    text-decoration: none;
    color: inherit;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.memorial-person-card:hover {
    border-color: var(--border-default);
    box-shadow: var(--shadow-sm);
}

.memorial-person-card__photo {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    object-fit: cover;
    flex-shrink: 0;
    filter: grayscale(80%);
    transition: filter 0.3s ease;
}

.memorial-person-card:hover .memorial-person-card__photo {
    filter: grayscale(20%);
}

.memorial-person-card__photo--empty {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.memorial-person-card__info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.memorial-person-card__name {
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.memorial-person-card__dates {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.memorial-person-card__desc {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    line-height: var(--leading-normal);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Region cards for persecution section */
.memorial-region-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
    gap: var(--space-md);
}

.memorial-region-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    text-decoration: none;
    color: inherit;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--accent-danger);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.memorial-region-card:hover {
    border-color: var(--accent-danger);
    box-shadow: var(--shadow-sm);
}

.memorial-region-card__title {
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--text-primary);
}

.memorial-region-card__desc {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: var(--leading-normal);
}

/* Data note — memorial-specific */
.memorial-data-note {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    font-size: var(--text-sm);
    color: var(--text-muted);
    border: 1px dashed var(--border-default);
    margin-top: var(--space-2xl);
}

.memorial-data-note h2 {
    font-size: var(--text-lg);
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.memorial-data-note p {
    margin-bottom: var(--space-sm);
    line-height: var(--leading-relaxed);
}

.memorial-data-note p:last-child {
    margin-bottom: 0;
}


/* ============================================================
   Timeline page
   ============================================================ */

/* Timeline controls */
.timeline-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.timeline-filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.timeline-filter-btn {
    background: var(--cat-color, var(--accent-primary));
    border: 2px solid var(--cat-color, var(--accent-primary));
    border-radius: var(--radius-full);
    padding: var(--space-xs) var(--space-md);
    font-size: var(--text-xs);
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.timeline-filter-btn--off {
    opacity: 0.3;
}

.timeline-filter-btn:hover {
    opacity: 0.85;
}

/* Expand / Collapse all */
.timeline-bulk-actions {
    display: flex;
    gap: var(--space-xs);
}

.timeline-bulk-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.timeline-bulk-btn:hover {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
}

/* ---- Vertical Timeline Container ---- */
.vtl-container {
    position: relative;
    padding-left: 0;
}

/* Vertical spine line */
.vtl-container::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-default);
    transform: translateX(-1px);
    border-radius: 1px;
}

/* ---- Decade (collapsible) ---- */
.vtl-decade {
    position: relative;
    margin-bottom: var(--space-md);
}

.vtl-decade__summary {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    list-style: none;
    position: relative;
    -webkit-user-select: none;
    user-select: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.vtl-decade__summary::-webkit-details-marker {
    display: none;
}

/* Chevron indicator */
.vtl-decade__summary::before {
    content: '\25B6';
    font-size: var(--text-xs);
    color: var(--text-muted);
    transition: transform 0.2s ease;
    flex-shrink: 0;
    width: 1em;
    text-align: center;
}

.vtl-decade[open]>.vtl-decade__summary::before {
    transform: rotate(90deg);
}

.vtl-decade__summary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-default);
}

.vtl-decade__title {
    font-size: var(--text-lg);
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.vtl-decade__count {
    font-size: var(--text-xs);
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    padding: 2px var(--space-sm);
}

.vtl-decade__dots {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.vtl-decade__dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

/* Years wrapper */
.vtl-decade__years {
    padding: var(--space-sm) 0 0 var(--space-md);
}

/* ---- Year (collapsible) ---- */
.vtl-year {
    position: relative;
    margin-bottom: var(--space-sm);
}

.vtl-year__summary {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    cursor: pointer;
    list-style: none;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease;
    -webkit-user-select: none;
    user-select: none;
}

.vtl-year__summary::-webkit-details-marker {
    display: none;
}

/* Chevron */
.vtl-year__summary::before {
    content: '\25B6';
    font-size: 0.6em;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    flex-shrink: 0;
    width: 1em;
    text-align: center;
}

.vtl-year[open]>.vtl-year__summary::before {
    transform: rotate(90deg);
}

.vtl-year__summary:hover {
    background: var(--bg-tertiary);
}

.vtl-year__label {
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--accent-primary);
}

.vtl-year__count {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* Event list inside a year */
.vtl-year__events {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: calc(var(--space-xl) + var(--space-md));
    row-gap: var(--space-sm);
    padding: var(--space-sm) 0 0;
}

.vtl-year__events::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-default);
    transform: translateX(-1px);
}

/* ---- Event card ---- */
.vtl-event {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.vtl-event--left {
    grid-column: 1;
    margin-right: var(--space-md);
}

.vtl-event--right {
    grid-column: 2;
    margin-left: var(--space-md);
    flex-direction: row-reverse;
}

.vtl-event--left::before,
.vtl-event--right::before {
    content: '';
    position: absolute;
    top: 50%;
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    background: var(--bg-primary);
    border: 2px solid var(--accent-primary);
    transform: translateY(-50%);
    z-index: 2;
}

.vtl-event--left::before {
    right: calc((var(--space-xl) + var(--space-md)) / -2 - 5px);
}

.vtl-event--right::before {
    left: calc((var(--space-xl) + var(--space-md)) / -2 - 5px);
}

.vtl-event:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-default);
    box-shadow: var(--shadow-sm);
}

/* Left color indicator */
.vtl-event__indicator {
    width: 4px;
    flex-shrink: 0;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.vtl-event--right .vtl-event__indicator {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* Content area */
.vtl-event__content {
    padding: var(--space-sm) var(--space-md);
    min-width: 0;
    flex: 1;
}

.vtl-event__header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.vtl-event__badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    padding: 1px var(--space-xs);
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    line-height: 1.4;
}

.vtl-event__title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
}

.vtl-event__desc {
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: var(--leading-relaxed);
    margin-top: var(--space-xs);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Data note */
.timeline-data-note {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    font-size: var(--text-sm);
    color: var(--text-muted);
    border: 1px dashed var(--border-default);
    margin-top: var(--space-2xl);
}

.timeline-data-note h2 {
    font-size: var(--text-lg);
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.timeline-data-note p {
    margin-bottom: var(--space-sm);
    line-height: var(--leading-relaxed);
}

.timeline-data-note p:last-child {
    margin-bottom: 0;
}

/* Responsive adjustments for vertical timeline */
@media (max-width: 768px) {
    .vtl-container {
        padding-left: var(--space-md);
    }

    .vtl-container::before {
        left: 6px;
    }

    .vtl-decade__summary {
        padding: var(--space-xs) var(--space-sm);
    }

    .vtl-decade__title {
        font-size: var(--text-base);
    }

    .vtl-year__events {
        display: flex;
        flex-direction: column;
        row-gap: var(--space-xs);
        padding-left: var(--space-sm);
    }

    .vtl-year__events::before {
        content: none;
    }

    .vtl-event--left,
    .vtl-event--right {
        margin-left: 0;
        margin-right: 0;
        flex-direction: row;
    }

    .vtl-event--left::before,
    .vtl-event--right::before {
        content: none;
    }

    .vtl-event__content {
        padding: var(--space-xs) var(--space-sm);
    }

    .timeline-bulk-actions {
        width: 100%;
        justify-content: flex-end;
    }
}


/* ============================================================
   Respect OS theme preference as initial state
   ============================================================ */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-primary: #0f0a1a;
        --bg-secondary: #1a1230;
        --bg-tertiary: #241a3a;
        --bg-hero: linear-gradient(160deg, #1a0f2e 0%, #0f1629 40%, #1a1020 100%);
        --bg-card: #1e1535;
        --bg-card-hover: #2a1f45;
        --bg-code: #1e1535;

        --text-primary: #f0ecf8;
        --text-secondary: #c4b8db;
        --text-muted: #8b7fa5;
        --text-inverse: #0f0a1a;
        --text-link: #c084fc;
        --text-link-hover: #e9d5ff;

        --accent-primary: #a78bfa;
        --accent-secondary: #f472b6;
        --accent-tertiary: #22d3ee;
        --accent-warm: #fbbf24;
        --accent-success: #34d399;
        --accent-danger: #f87171;

        --border-subtle: #2a2040;
        --border-default: #3d3060;
        --border-strong: #5b4d80;
        --border-accent: var(--accent-primary);

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
        --shadow-glow: 0 0 25px rgba(167, 139, 250, 0.2);

        --theme-icon: "\263E";

        --status-legal: #34d399;
        --status-limited: #fbbf24;
        --status-illegal: #f87171;
        --status-unknown: #6b7280;
        --status-progressive: #a78bfa;
    }
}

/* ============================================================
   Rights matrix table (heatmap replacement)
   ============================================================ */
#heatmap-map {
    min-height: 0;
}

.heatmap-table-toolbar {
    display: flex;
    gap: var(--space-sm);
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: var(--space-sm);
}

.heatmap-table-search {
    min-width: 16rem;
    max-width: 24rem;
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-sm);
}

.heatmap-table-search:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 20%, transparent);
}

.heatmap-table-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-weight: 600;
}

.heatmap-table-wrap {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: auto;
    background: var(--bg-card);
}

.heatmap-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 56rem;
}

.heatmap-table thead th {
    position: sticky;
    top: 0;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: var(--text-xs);
    font-weight: 700;
    text-align: left;
    padding: var(--space-sm);
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
}

.heatmap-table tbody td {
    border-bottom: 1px solid var(--border-subtle);
    padding: var(--space-sm);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.heatmap-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.heatmap-table__sortable {
    padding: 0 !important;
}

.heatmap-table__sortbtn {
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    color: inherit;
    padding: var(--space-sm);
    font-size: inherit;
    font-weight: inherit;
    cursor: pointer;
}

.heatmap-table__sortbtn[data-dir="asc"]::after {
    content: ' ↑';
}

.heatmap-table__sortbtn[data-dir="desc"]::after {
    content: ' ↓';
}

.heatmap-table__country strong {
    display: block;
    color: var(--text-primary);
}

.heatmap-table__country span {
    display: block;
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.heatmap-table__score {
    font-weight: 700;
    color: var(--accent-primary);
}

.heatmap-table__status {
    text-align: center;
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.heatmap-table__status--no {
    color: var(--text-muted);
}

.heatmap-table__status-link {
    text-decoration: none;
    border-bottom: 1px dashed transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.heatmap-table__status-link--wikipedia {
    color: var(--accent-success);
}

.heatmap-table__status-link--wikidata {
    color: var(--accent-tertiary);
}

.heatmap-table__status-link:hover {
    border-color: currentColor;
}

.heatmap-table__article-badge {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    font-size: 0.62rem;
    line-height: 1.25;
    letter-spacing: 0.05em;
    font-weight: 800;
    color: var(--text-primary);
    background: color-mix(in srgb, var(--accent-warm) 28%, var(--bg-tertiary));
    border: 1px solid color-mix(in srgb, var(--accent-warm) 55%, transparent);
    vertical-align: middle;
}

.heatmap-table__empty {
    text-align: center;
    color: var(--text-muted);
}

.heatmap-legend__swatch--yes {
    background: color-mix(in srgb, var(--accent-success) 70%, white 30%);
}

.heatmap-legend__swatch--no {
    background: var(--bg-tertiary);
}
