/* PenguinWatch — Emperor Penguin Design System */
/* Dark mode default, ice/ocean palette, yellow accent like the emperor's patch */

/* ========== FONTS ========== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Lora:ital,wght@0,400;0,600;0,700;1,400&display=swap');

/* OpenDyslexic — loaded from jsDelivr CDN */
@font-face {
    font-family: 'OpenDyslexic';
    src: url('https://cdn.jsdelivr.net/npm/@fontsource/opendyslexic@5.2.5/files/opendyslexic-latin-400-normal.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'OpenDyslexic';
    src: url('https://cdn.jsdelivr.net/npm/@fontsource/opendyslexic@5.2.5/files/opendyslexic-latin-700-normal.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Dark mode (default): Emperor penguin inspired — deep navy, ice blue, golden yellow */
    --bg: #0b1220;
    --bg-deep: #070d18;
    --bg-card: #111b2e;
    --bg-hover: #162240;
    --bg-accent: #132240;
    --text: #d8dce6;
    --text-bright: #eef1f6;
    --text-muted: #8892a4;
    --text-muted2: #5a6478;
    --accent: #f0c040;          /* Emperor penguin golden patch */
    --accent-light: #2a2210;
    --accent-hover: #f5d060;
    --teal: #5cc0d0;            /* Antarctic ice blue */
    --teal-light: #0d2a30;
    --danger: #e05050;
    --danger-light: #2a1010;
    --warning: #e8a830;
    --warning-light: #2a1e10;
    --success: #40c070;
    --success-light: #0a2a1a;
    --border: #1e2a40;
    --border-light: #162240;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 24px rgba(0,0,0,0.5);
    --max-width: 1120px;
    --font-base: 1rem;
    --radius: 8px;
}

/* Light mode (toggled via accessibility panel) */
body.light-mode {
    --bg: #f5f8fc;
    --bg-deep: #eef2f8;
    --bg-card: #ffffff;
    --bg-hover: #e8edf5;
    --bg-accent: #e3ecf7;
    --text: #1a2332;
    --text-bright: #0f1825;
    --text-muted: #5a6577;
    --text-muted2: #8893a5;
    --accent: #1b6b93;
    --accent-light: #e3f0f8;
    --accent-hover: #15557a;
    --teal: #0e8a7d;
    --teal-light: #e0f5f3;
    --danger: #b83232;
    --danger-light: #fde8e8;
    --warning: #c48a19;
    --warning-light: #fef5e0;
    --success: #2d8a4e;
    --success-light: #e4f6ec;
    --border: #d4dbe6;
    --border-light: #e8edf5;
    --shadow: 0 2px 8px rgba(26, 35, 50, 0.08);
    --shadow-lg: 0 4px 24px rgba(26, 35, 50, 0.12);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.65;
    font-size: var(--font-base);
    -webkit-font-smoothing: antialiased;
    transition: background 0.3s, color 0.3s;
}

h1, h2, h3, h4 {
    font-family: 'Lora', Georgia, 'Times New Roman', serif;
    color: var(--text-bright);
    line-height: 1.3;
}

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--accent); text-decoration: underline; }

/* ========== SKIP LINK ========== */
.skip-link {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: var(--bg);
    padding: 0.5rem 1rem;
    border-radius: 0 0 4px 4px;
    font-weight: 600;
    z-index: 10001;
    transition: top 0.2s;
}
.skip-link:focus { top: 0; }

/* ========== NAVIGATION ========== */
nav {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Lora', Georgia, serif;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text-bright);
    text-decoration: none;
}
.nav-brand svg { width: 28px; height: 28px; }
.nav-brand span { color: var(--accent); }
.nav-brand:hover { text-decoration: none; color: var(--text-bright); }

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
}
.nav-links a {
    display: block;
    padding: 0.4rem 0.75rem;
    color: var(--text-muted);
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s;
}
.nav-links a:hover { color: var(--teal); background: var(--bg-hover); text-decoration: none; }
.nav-links a[aria-current="page"] { color: var(--accent); background: var(--accent-light); }

.nav-right { display: flex; align-items: center; gap: 0.5rem; }

.a11y-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s;
}
.a11y-toggle:hover { color: var(--accent); border-color: var(--accent); }

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
}

/* Accessibility panel */
.a11y-panel {
    display: none;
    position: absolute;
    top: 100%;
    right: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    z-index: 1001;
    min-width: 240px;
    box-shadow: var(--shadow-lg);
}
.a11y-panel.open { display: block; }
.a11y-panel h3 { font-size: 0.9rem; margin-bottom: 0.75rem; color: var(--accent); }
.a11y-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.85rem;
}
.a11y-option:last-child { border-bottom: none; }
.a11y-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}
.a11y-btn:hover { color: var(--accent); border-color: var(--accent); }
.a11y-btn.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* OpenDyslexic label — always shown in OpenDyslexic so users can preview */
.font-preview {
    font-family: 'OpenDyslexic', 'Inter', sans-serif;
    letter-spacing: 0.02em;
}
/* ========== HIGH CONTRAST ========== */
body.high-contrast {
    --bg: #000000;
    --bg-deep: #0a0a0a;
    --bg-card: #111111;
    --bg-hover: #1a1a1a;
    --bg-accent: #1a1a1a;
    --text: #ffffff;
    --text-bright: #ffffff;
    --text-muted: #cccccc;
    --text-muted2: #aaaaaa;
    --accent: #ffdd00;
    --accent-light: #2a2200;
    --accent-hover: #ffee44;
    --teal: #00dddd;
    --teal-light: #002a2a;
    --border: #555555;
    --border-light: #333333;
}

/* ========== OPENDYSLEXIC ========== */
body.opendyslexic,
body.opendyslexic h1,
body.opendyslexic h2,
body.opendyslexic h3,
body.opendyslexic h4,
body.opendyslexic .nav-brand {
    font-family: 'OpenDyslexic', 'Inter', sans-serif !important;
}
body.opendyslexic {
    line-height: 1.85;
    letter-spacing: 0.02em;
}
body.opendyslexic .species-card,
body.opendyslexic .fact,
body.opendyslexic .colony-row {
    letter-spacing: 0.03em;
}

/* ========== HERO ========== */
.hero {
    text-align: center;
    padding: 5rem 1.5rem 3.5rem;
    position: relative;
    background: linear-gradient(180deg, var(--bg-deep) 0%, var(--bg) 100%);
}
.hero::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.hero-icon { width: 80px; height: 80px; margin: 0 auto 1.25rem; opacity: 0.9; }
.hero h1 { font-size: 2.75rem; font-weight: 700; margin-bottom: 0.5rem; }
.hero h1 .accent { color: var(--accent); }
.hero .subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    font-style: italic;
    font-family: 'Lora', Georgia, serif;
    margin-bottom: 2rem;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}
.hero-stat { text-align: center; }
.hero-stat .number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    font-family: 'Lora', Georgia, serif;
}
.hero-stat .label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.15rem;
}

.hero-ctas { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; }

.btn {
    display: inline-block;
    padding: 0.65rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.15s;
    border: 2px solid transparent;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }

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

.btn-secondary {
    background: transparent;
    color: var(--teal);
    border-color: var(--teal);
}
.btn-secondary:hover { background: var(--teal-light); }

/* ========== LAYOUT ========== */
.container { max-width: var(--max-width); margin: 0 auto; padding: 2rem 1.5rem; }

.page-header { margin-bottom: 2rem; padding-bottom: 1rem; border-bottom: 2px solid var(--accent); }
.page-header h1 { font-size: 2rem; margin-bottom: 0.25rem; }
.page-header .subtitle { color: var(--text-muted); font-size: 1rem; font-style: italic; font-family: 'Lora', Georgia, serif; }

/* ========== SPECIES GRID ========== */
.species-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.species-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.species-card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.species-card .card-emoji { font-size: 2.25rem; margin-bottom: 0.5rem; display: block; }
.species-card .card-name {
    font-family: 'Lora', Georgia, serif;
    font-size: 1.2rem;
    color: var(--text-bright);
    margin-bottom: 0.15rem;
}
.species-card .card-sci-name { font-size: 0.82rem; font-style: italic; color: var(--text-muted); margin-bottom: 0.5rem; }
.species-card .card-range { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.species-card .card-link { font-size: 0.85rem; color: var(--teal); font-weight: 500; }

/* ========== IUCN BADGES — stamp style ========== */
.iucn-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 2px solid;
    margin-bottom: 0.5rem;
    font-family: 'Inter', sans-serif;
    line-height: 1.3;
}
.iucn-badge.lc  { color: #40c070; border-color: #40c070; background: rgba(64,192,112,0.12); }
.iucn-badge.nt  { color: #a8b840; border-color: #a8b840; background: rgba(168,184,64,0.12); }
.iucn-badge.vu  { color: #e8a830; border-color: #e8a830; background: rgba(232,168,48,0.12); }
.iucn-badge.en  { color: #e05050; border-color: #e05050; background: rgba(224,80,80,0.12); }
.iucn-badge.cr  { color: #cc2020; border-color: #cc2020; background: rgba(204,32,32,0.12); }

.favorite-badge {
    display: inline-block;
    background: var(--accent);
    color: var(--bg);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* ========== SPECIES DETAIL PAGE ========== */
.species-hero {
    position: relative;
    padding: 2.5rem 0;
    border-bottom: 2px solid var(--accent);
    margin-bottom: 2rem;
}

.species-hero-inner { display: flex; gap: 2.5rem; align-items: flex-start; flex-wrap: wrap; }

.species-hero-photo { flex: 0 0 360px; max-width: 100%; }
.species-hero-photo img {
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}
.species-hero-photo .photo-credit { font-size: 0.72rem; color: var(--text-muted2); margin-top: 0.4rem; }

.species-hero-info { flex: 1; min-width: 280px; }
.species-hero-info h1 { font-size: 2.25rem; margin-bottom: 0.15rem; }
.species-hero-info .sci-name {
    font-size: 1.1rem;
    font-style: italic;
    color: var(--text-muted);
    font-family: 'Lora', Georgia, serif;
    margin-bottom: 0.75rem;
}
.species-hero-info .iucn-badge { font-size: 0.8rem; padding: 0.3rem 0.7rem; }

/* Quick facts */
.quick-facts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}
.fact {
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem;
}
.fact .fact-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}
.fact .fact-value { font-size: 0.95rem; color: var(--text-bright); font-weight: 500; }

/* Content sections */
.content-section { margin-bottom: 2.25rem; }
.content-section h2 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 3px solid var(--accent);
    display: inline-block;
}
.content-section p { margin-bottom: 0.85rem; max-width: 72ch; }
.content-section ul { margin: 0.5rem 0 0.85rem 1.5rem; }
.content-section li { margin-bottom: 0.35rem; }

/* Sources list */
.sources-list { list-style: none; padding: 0; }
.sources-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--border-light); font-size: 0.9rem; }
.sources-list li:last-child { border-bottom: none; }

/* No data notice */
.no-data-notice {
    background: var(--warning-light);
    border: 1px solid var(--warning);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    margin: 1.5rem 0;
}
.no-data-notice .notice-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.no-data-notice p { color: var(--text-muted); margin-bottom: 0.5rem; }
.no-data-notice a { color: var(--teal); font-weight: 500; }

/* Prev/Next nav */
.species-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}
.species-nav a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    transition: all 0.15s;
    box-shadow: var(--shadow);
}
.species-nav a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ========== COLONY DATA ========== */
.colony-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 1.5rem 0;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.colony-panel-header {
    padding: 0.85rem 1.25rem;
    background: var(--bg-deep);
    border-bottom: 1px solid var(--border);
    font-family: 'Lora', Georgia, serif;
    font-size: 0.95rem;
    color: var(--text-bright);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.colony-panel-header .count {
    font-family: 'Inter', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

.colony-list { max-height: 400px; overflow-y: auto; }
.colony-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.85rem;
    align-items: center;
    transition: background 0.1s;
}
.colony-row:hover { background: var(--bg-hover); }
.colony-row .name { color: var(--text-bright); }
.colony-row .year { color: var(--text-muted); font-family: 'Inter', monospace; font-size: 0.82rem; }
.colony-row .count-val { color: var(--teal); font-family: 'Inter', monospace; font-weight: 600; }

.trend-badge {
    display: inline-block;
    padding: 0.12rem 0.45rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-radius: 3px;
}
.trend-badge.stable   { background: var(--success-light); color: var(--success); }
.trend-badge.declining { background: var(--warning-light); color: var(--warning); }
.trend-badge.critical  { background: var(--danger-light); color: var(--danger); }
.trend-badge.unknown   { background: var(--bg-hover); color: var(--text-muted); }

/* ========== MAP ========== */
#map-container {
    height: 70vh;
    min-height: 400px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.map-filters { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.map-filters select, .map-filters button {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    cursor: pointer;
}
.map-filters select:focus, .map-filters button:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.map-legend { margin-top: 1rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 0.35rem; font-size: 0.82rem; color: var(--text-muted); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ========== FILTERS ========== */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    align-items: center;
}
.filter-bar select, .filter-bar button {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    cursor: pointer;
}
.filter-bar select:focus, .filter-bar button:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ========== ABOUT/SOURCES/LEARN ========== */
.prose-page { max-width: 800px; }
.prose-page h2 {
    font-size: 1.5rem;
    margin-top: 2.25rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 3px solid var(--accent);
    display: inline-block;
}
.prose-page h2:first-child { margin-top: 0; }
.prose-page p { margin-bottom: 1rem; max-width: 72ch; }
.prose-page ul, .prose-page ol { margin-bottom: 1rem; padding-left: 1.5rem; }
.prose-page li { margin-bottom: 0.35rem; }

.tech-stack {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}
.tech-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}
.tech-item .tech-name { font-weight: 600; color: var(--accent); margin-bottom: 0.25rem; }
.tech-item .tech-desc { font-size: 0.82rem; color: var(--text-muted); }

/* Glossary */
.glossary dt { font-weight: 600; color: var(--text-bright); margin-top: 0.75rem; }
.glossary dd { color: var(--text-muted); margin-bottom: 0.5rem; margin-left: 0; }

/* ========== FOOTER ========== */
footer {
    background: var(--bg-card);
    border-top: 2px solid var(--accent);
    padding: 1.5rem;
    margin-top: 4rem;
}
.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}
.footer-links { display: flex; gap: 1rem; flex-wrap: wrap; }
.footer-links a { color: var(--text-muted); transition: color 0.15s; }
.footer-links a:hover { color: var(--accent); }

/* Focus indicators */
*:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .hamburger { display: block; }
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0; right: 0;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        padding: 0.5rem;
        z-index: 999;
        box-shadow: var(--shadow-lg);
    }
    .nav-links.open { display: flex; }
    .nav-links a { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-light); }
    .hero h1 { font-size: 2rem; }
    .hero { padding: 3rem 1rem 2rem; }
    .hero-stats { gap: 1.5rem; }
    .species-hero-inner { flex-direction: column; }
    .species-hero-photo { flex: 1 1 100%; }
    .species-grid { grid-template-columns: 1fr; }
    .quick-facts { grid-template-columns: repeat(2, 1fr); }
    .colony-row { grid-template-columns: 1fr auto auto; }
    .colony-row .year { display: none; }
    .species-nav { flex-direction: column; gap: 0.5rem; }
}

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========== PRINT ========== */
@media print {
    body { background: #fff; color: #000; }
    nav, .a11y-toggle, .hamburger, .a11y-panel { display: none; }
    .species-card { break-inside: avoid; }
    .hero { background: none; }
}