/* ============================================
   AFRICA E-MOBILITY PULSE - MAIN STYLESHEET
   Based on AEP V1 Visual Guides
   Fonts: Fraunces (display), IBM Plex Sans (body), IBM Plex Mono (monospace)
   Colors: AEP Green (#007c3e), Deep Green (#003d1f), Amber (#f19233), etc.
   ============================================ */

/* ========== DESIGN TOKENS ========== */
:root {
    /* AEP Brand Colors */
    --aep-green: #007c3e;
    --aep-green-deep: #003d1f;
    --aep-green-mid: #4cae7f;
    --aep-green-light: #a5d4bb;
    --aep-blue: #0163b6;
    --aep-blue-deep: #084b88;
    --aep-amber: #f19233;
    --aep-amber-deep: #c46d18;
    
    /* Surfaces */
    --bg: #faf7f1;
    --bg-elevated: #ffffff;
    --bg-panel: #f3eee5;
    --bg-secondary: #f0ece0;
    --bg-deep: #1d2520;
    
    /* Ink Colors */
    --ink-primary: #1a201d;
    --ink-secondary: #4a544f;
    --ink-tertiary: #7a847f;
    --ink-faint: #b8c0bb;
    
    /* Borders & Rules */
    --rule: #d8d0c0;
    --rule-faint: #e8e1d2;
    --rule-strong: #2a322d;
    
    /* Typography */
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'IBM Plex Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Monaco, Consolas, monospace;
    
    /* Layout */
    --col-narrow: 680px;
    --col-wide: 980px;
    --gutter: clamp(20px, 4vw, 56px);
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* ========== RESET & BASE ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--ink-primary);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ========== TYPOGRAPHY ========== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 500;
    letter-spacing: -0.02em;
    color: var(--ink-primary);
}

h1 {
    font-size: clamp(40px, 6vw, 78px);
    line-height: 1.02;
    letter-spacing: -0.025em;
}

h2 {
    font-size: clamp(28px, 3.4vw, 40px);
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
}

h3 {
    font-size: 22px;
    line-height: 1.2;
    letter-spacing: -0.01em;
    margin: 2rem 0 0.875rem;
}

p {
    margin-bottom: 1.125rem;
    color: var(--ink-secondary);
    font-size: 16px;
    line-height: 1.65;
}

p strong {
    color: var(--ink-primary);
    font-weight: 600;
}

p em {
    font-style: italic;
    color: var(--ink-primary);
}

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

a:hover {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

/* ========== LINKS ========== */
/* ========== LISTS ========== */
ul, ol {
    margin: 0 0 1rem 1.5rem;
    color: var(--ink-secondary);
}

li {
    margin-bottom: 0.25rem;
}

/* ========== BUTTONS ========== */
button, .btn {
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--border-radius-md);
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--aep-green);
    color: #fff;
    border: none;
    padding: 9px 16px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary:hover {
    background: var(--aep-green-deep);
    text-decoration: none;
}

.btn-secondary {
    background: transparent;
    color: var(--ink-primary);
    border: 0.5px solid var(--rule-strong);
    padding: 9px 16px;
}

.btn-secondary:hover {
    background: var(--ink-primary);
    color: var(--bg);
}

/* ========== NAVIGATION ========== */
.topnav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(250, 247, 241, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--rule-faint);
}

.topnav-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 14px var(--gutter);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 10px;
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink-primary);
}

.brand-mark {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--aep-green);
    transform: translateY(1px);
}

.brand-subtle {
    color: var(--ink-tertiary);
    font-weight: 400;
    font-size: 13px;
    font-family: var(--font-body);
    margin-left: 4px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.nav-links {
    display: flex;
    gap: 28px;
    font-size: 14px;
    font-weight: 500;
}

.nav-links a {
    color: var(--ink-secondary);
    padding-bottom: 4px;
    border-bottom: 2px solid transparent;
}

.nav-links a:hover {
    color: var(--ink-primary);
    text-decoration: none;
    border-bottom-color: var(--aep-green-light);
}

.nav-links a.active {
    color: var(--aep-green);
    border-bottom-color: var(--aep-green);
}

/* Hamburger toggle button */
.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 4px;
}

.nav-toggle-bar {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--ink-primary);
    border-radius: 1px;
    transition: all var(--transition-fast);
}

.nav-toggle.active .nav-toggle-bar:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.nav-toggle.active .nav-toggle-bar:nth-child(2) {
    opacity: 0;
}

.nav-toggle.active .nav-toggle-bar:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* ========== SUBNAVIGATION (About tabs) ========== */
.subnav {
    background: var(--bg-panel);
    border-bottom: 1px solid var(--rule);
}

.subnav-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--gutter);
    display: flex;
    align-items: center;
    gap: 32px;
}

.subnav-item {
    padding: 16px 0;
    font-size: 14px;
    color: var(--ink-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all var(--transition-fast);
}

.subnav-item.active {
    color: var(--aep-green);
    border-bottom-color: var(--aep-green);
    font-weight: 500;
}

.subnav-item:hover {
    color: var(--ink-primary);
    text-decoration: none;
}

/* ========== PAGE HEADER ========== */
.page-header {
    border-bottom: 1px solid var(--rule);
    padding: clamp(36px, 6vw, 80px) 0 clamp(28px, 4vw, 56px);
}

.page-header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.breadcrumb {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-tertiary);
    margin-bottom: 24px;
}

.breadcrumb span {
    color: var(--aep-green);
}

.page-title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(40px, 6vw, 78px);
    line-height: 1.02;
    letter-spacing: -0.025em;
    margin: 0 0 24px;
    max-width: 16ch;
}

.page-title em {
    font-style: italic;
    color: var(--aep-green-deep);
}

.page-lede {
    font-family: var(--font-display);
    font-size: clamp(18px, 1.8vw, 22px);
    line-height: 1.45;
    color: var(--ink-secondary);
    max-width: 60ch;
    margin: 0 0 8px;
    font-weight: 400;
}

.meta-strip {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(20px, 4vw, 56px);
    padding-top: 24px;
    border-top: 1px solid var(--rule-faint);
    margin-top: 24px;
}

.meta-item {
    font-size: 13px;
}

.meta-label {
    font-family: var(--font-mono);
    color: var(--ink-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 11px;
    margin-bottom: 4px;
}

.meta-value {
    color: var(--ink-primary);
    font-weight: 500;
}

/* ========== EDITION TAG ========== */
.edition-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #FAEEDA;
    color: #633806;
    font-size: 11px;
    font-weight: 500;
    border-radius: 100px;
    font-family: var(--font-mono);
}

/* ========== CARDS ========== */
.card {
    background: var(--bg-elevated);
    border: 0.5px solid var(--rule);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 0.5px solid var(--rule);
}

.card-body {
    padding: 20px 24px;
}

/* ========== TABLES ========== */
.table-wrapper {
    overflow-x: auto;
    border: 0.5px solid var(--rule);
    border-radius: var(--border-radius-md);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    background: var(--bg-panel);
    text-align: left;
    padding: 12px 16px;
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-secondary);
    font-weight: 500;
    border-bottom: 1px solid var(--rule);
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--rule-faint);
    vertical-align: middle;
    color: var(--ink-secondary);
}

tr:last-child td {
    border-bottom: none;
}

/* ========== CITATION BLOCK ========== */
.citation {
    background: var(--bg-deep);
    color: #e8ebe9;
    padding: clamp(28px, 4vw, 40px);
    border-radius: var(--border-radius-lg);
    margin-top: 32px;
}

.citation-label {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #92a39b;
    margin-bottom: 14px;
}

.citation-text {
    font-family: var(--font-display);
    font-size: 15px;
    line-height: 1.55;
    color: #e8ebe9;
    font-style: italic;
    margin-bottom: 18px;
    font-weight: 400;
}

.citation-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.12);
}

.citation-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.25);
    color: #e8ebe9;
    padding: 7px 14px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-radius: var(--border-radius-md);
}

.citation-btn:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.4);
}

.citation-meta {
    margin-top: 14px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: #92a39b;
    letter-spacing: 0.04em;
}

/* ========== CLASSIFICATION PILLS ========== */
.class-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 100px;
}

.class-pill.leader {
    background: var(--aep-green-deep);
    color: #fff;
}

.class-pill.accelerating {
    background: var(--aep-green);
    color: #fff;
}

.class-pill.emerging {
    background: var(--aep-green-mid);
    color: #fff;
}

.class-pill.nascent {
    background: var(--aep-green-light);
    color: var(--ink-primary);
}

.class-pill-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 8px;
    transform: translateY(0.5px);
}

.class-pill-dot.leader { background: var(--aep-green-deep); }
.class-pill-dot.accelerating { background: var(--aep-green); }
.class-pill-dot.emerging { background: var(--aep-green-mid); }
.class-pill-dot.nascent { background: var(--aep-green-light); }

/* ========== CHOROPLETH LEGEND ========== */
.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 16px;
    font-size: 11px;
    color: var(--ink-tertiary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-swatch {
    width: 14px;
    height: 14px;
    border: 1px solid rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.legend-swatch.leader { background: var(--aep-green-deep); }
.legend-swatch.accel { background: var(--aep-green); }
.legend-swatch.emerg { background: var(--aep-green-mid); }
.legend-swatch.nasc { background: var(--aep-green-light); }
.legend-swatch.unas { background: #d8d8d8; }

/* ========== INFO CALLOUT ========== */
.info-callout {
    margin-top: 16px;
    padding: 12px 14px;
    background: #E6F1FB;
    border-radius: var(--border-radius-md);
    font-size: 13px;
    color: #0C447C;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.55;
}

.info-callout i {
    flex-shrink: 0;
    margin-top: 1px;
}

/* ========== FOOTER ========== */
footer {
    border-top: 1px solid var(--rule);
    padding: 40px var(--gutter) 56px;
    background: var(--bg);
    margin-top: 48px;
}

.footer-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: space-between;
    align-items: baseline;
    font-size: 12px;
    color: var(--ink-tertiary);
}

.footer-links {
    display: flex;
    gap: 20px;
}

.footer-links a {
    color: var(--ink-secondary);
    font-size: 13px;
}

.footer-links a:hover {
    color: var(--aep-green);
}

/* ========== CONTAINERS & LAYOUT ========== */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: clamp(48px, 6vw, 80px) var(--gutter);
}

.container-narrow {
    max-width: 880px;
    margin: 0 auto;
    padding: clamp(48px, 6vw, 80px) var(--gutter);
}

/* ========== GRID ========== */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
}

@media (min-width: 640px) {
    .grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

@media (min-width: 880px) {
    .grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 640px) {
    .topnav-inner {
        flex-direction: column;
        gap: 12px;
    }
    
    .nav-links {
        gap: 20px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .subnav-inner {
        overflow-x: auto;
        gap: 20px;
    }
    
    .footer-inner {
        flex-direction: column;
        text-align: center;
    }
    
    .footer-links {
        justify-content: center;
        flex-wrap: wrap;
    }
}

/* ========== RESPONSIVE (Mobile: 768px) ========== */
@media (max-width: 768px) {
    .topnav-inner {
        flex-wrap: wrap;
    }

    .nav-toggle {
        display: flex;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        gap: 0;
        padding: 12px 0 8px;
        border-top: 1px solid var(--rule-faint);
    }

    .nav-links.visible {
        display: flex;
    }

    .nav-links a {
        padding: 10px 0;
        border-bottom: none;
        font-size: 15px;
    }

    .nav-links a.active {
        border-bottom: none;
        color: var(--aep-green);
    }

    h1 {
        font-size: clamp(28px, 8vw, 40px);
    }

    h2 {
        font-size: clamp(22px, 6vw, 30px);
    }

    .page-title {
        font-size: clamp(28px, 8vw, 40px);
    }

    .page-lede {
        font-size: 16px;
    }

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr !important;
    }

    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-wrapper table {
        min-width: 520px;
    }

    footer {
        padding: 28px var(--gutter) 40px;
    }

    .footer-inner {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }

    .footer-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 14px;
    }

    .subnav-inner {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 20px;
    }

    .subnav-item {
        white-space: nowrap;
        padding: 14px 0;
        font-size: 13px;
    }

    .meta-strip {
        flex-direction: column;
        gap: 16px;
    }

    .citation-actions {
        flex-direction: column;
    }

    .citation-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ========== PRINT STYLES (for PDF export) ========== */
@media print {
    .topnav, .subnav, footer, .citation-actions, .action-buttons, .nav-toggle, .nav-links {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
        font-size: 12pt;
    }
    
    .citation {
        background: #f5f5f5;
        color: black;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
    
    a {
        text-decoration: none;
        color: black;
    }

    .page-header {
        border-bottom: 1px solid #ccc;
        padding: 20px 0;
    }

    .issue-masthead {
        background: #1a1a1a !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .issue-masthead * {
        color: #fff !important;
    }

    .watch-section {
        background: #1a1a1a !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .watch-section * {
        color: #fff !important;
    }

    .section-number, .chapter-num, .issue-tag {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    @page {
        margin: 20mm 15mm;
    }
}
