/* ============================================================
   KUMBUKUMBU - Kenyan History Platform
   Dark editorial design. Navy + Teal on near-black.
   ============================================================ */

:root {
    --navy: #1E3A8A;
    --teal: #22BFA3;
    --teal-dim: rgba(34, 191, 163, 0.15);
    --bg-dark: #070B14;
    --bg-card: #0D1321;
    --bg-card-hover: #111827;
    --bg-surface: #141B2D;
    --text-primary: #E5E7EB;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-line: rgba(255, 255, 255, 0.1);

    /* Era palette */
    --era-pre-colonial: #8B5CF6;
    --era-coastal-trade: #F59E0B;
    --era-colonial: #EF4444;
    --era-independence: #22BFA3;
    --era-republic: #3B82F6;
    --era-modern: #1E3A8A;

    --font-body: 'Inter', system-ui, -apple-system, sans-serif;
    --max-content: 1200px;
    --transition: 0.25s ease;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.65;
    color: var(--text-primary);
    background-color: var(--bg-dark);
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

a:hover {
    color: #5DDFC8;
}

img {
    max-width: 100%;
    height: auto;
}

::selection {
    background: var(--teal);
    color: var(--bg-dark);
}

/* ---- Navigation ---- */
.kb-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(7, 11, 20, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.75rem 0;
}

.kb-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.kb-nav-logo {
    height: 40px;
    width: auto;
}

.kb-nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.kb-nav-link {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    transition: color var(--transition);
}

.kb-nav-link:hover {
    color: var(--teal);
}

.kb-nav-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
}

/* Mobile menu */
.kb-mobile-menu {
    position: fixed;
    top: 65px;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle);
    z-index: 999;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.kb-mobile-menu.open {
    max-height: 300px;
    padding: 1rem 0;
}

.kb-mobile-link {
    display: block;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.kb-mobile-link:hover {
    color: var(--teal);
    background: var(--bg-surface);
}

/* ---- Hero ---- */
.kb-hero {
    padding: 8rem 0 4rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.kb-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(34, 191, 163, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

.kb-hero-logo {
    width: 120px;
    height: auto;
    margin-bottom: 1.5rem;
    opacity: 0.95;
}

.kb-hero h1 {
    font-size: clamp(2.25rem, 5vw, 3.5rem);
    font-weight: 800;
    color: #fff;
    margin: 0 0 0.75rem;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.kb-hero-sub {
    font-size: clamp(1rem, 2vw, 1.25rem);
    color: var(--text-secondary);
    max-width: 540px;
    margin: 0 auto 2rem;
    font-weight: 300;
    line-height: 1.6;
}

.kb-hero-stat {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    border: 1px solid var(--border-line);
    border-radius: 100px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.kb-hero-stat strong {
    color: var(--teal);
    font-weight: 700;
}

/* ---- Section Headers ---- */
.kb-section {
    padding: 5rem 0;
}

.kb-section-header {
    margin-bottom: 2.5rem;
}

.kb-section-header h2 {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 700;
    color: #fff;
    margin: 0 0 0.5rem;
    letter-spacing: -0.01em;
}

.kb-section-header p {
    color: var(--text-secondary);
    font-size: 1rem;
    margin: 0;
    max-width: 600px;
}

/* ---- Era Filter Pills ---- */
.kb-era-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
}

.kb-era-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.875rem;
    border-radius: 100px;
    border: 1px solid var(--border-line);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.kb-era-pill::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--pill-color);
    flex-shrink: 0;
}

.kb-era-pill:hover,
.kb-era-pill.active {
    background: var(--pill-color);
    color: #fff;
    border-color: var(--pill-color);
}

.kb-era-pill.active::before,
.kb-era-pill:hover::before {
    background: #fff;
}

.kb-era-pill-all {
    padding: 0.375rem 0.875rem;
    border-radius: 100px;
    border: 1px solid var(--border-line);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.kb-era-pill-all:hover,
.kb-era-pill-all.active {
    background: var(--teal);
    color: #fff;
    border-color: var(--teal);
}

/* ============================================================
   VISUAL TIMELINE
   ============================================================ */
.kb-timeline-section {
    padding: 3rem 0 5rem;
    position: relative;
}

.kb-timeline-wrap {
    position: relative;
    overflow-x: auto;
    overflow-y: visible;
    padding: 2rem 0 3rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--teal) var(--bg-card);
}

.kb-timeline-wrap::-webkit-scrollbar {
    height: 6px;
}

.kb-timeline-wrap::-webkit-scrollbar-track {
    background: var(--bg-card);
    border-radius: 3px;
}

.kb-timeline-wrap::-webkit-scrollbar-thumb {
    background: var(--navy);
    border-radius: 3px;
}

.kb-timeline-wrap::-webkit-scrollbar-thumb:hover {
    background: var(--teal);
}

.kb-timeline-track {
    display: flex;
    align-items: flex-start;
    position: relative;
    min-width: max-content;
    padding: 0 2rem;
}

/* The flowing line */
.kb-timeline-track::before {
    content: '';
    position: absolute;
    top: 52px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(
        90deg,
        var(--era-pre-colonial) 0%,
        var(--era-pre-colonial) 7%,
        var(--era-coastal-trade) 12%,
        var(--era-colonial) 25%,
        var(--era-independence) 35%,
        var(--era-republic) 50%,
        var(--era-modern) 70%,
        var(--era-modern) 100%
    );
    opacity: 0.5;
}

/* Era label markers on the line */
.kb-timeline-era-label {
    position: absolute;
    top: 62px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    white-space: nowrap;
    transform: translateX(-50%);
    padding-top: 0.5rem;
    border-top: 2px solid;
}

/* Individual timeline nodes */
.kb-tl-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 140px;
    flex-shrink: 0;
    cursor: pointer;
    position: relative;
    padding-top: 0;
    transition: transform var(--transition);
}

.kb-tl-node:hover {
    transform: translateY(-4px);
}

.kb-tl-date {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-align: center;
    font-weight: 500;
    line-height: 1.3;
    min-height: 28px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.kb-tl-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid;
    background: var(--bg-dark);
    position: relative;
    z-index: 2;
    transition: all var(--transition);
    flex-shrink: 0;
}

.kb-tl-node:hover .kb-tl-dot {
    transform: scale(1.4);
    background: var(--node-color);
    box-shadow: 0 0 12px var(--node-color);
}

.kb-tl-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    margin-top: 0.75rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 130px;
}

.kb-tl-category {
    font-size: 0.625rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-align: center;
}

/* Story popup card on timeline hover */
.kb-tl-popup {
    position: absolute;
    top: calc(100% + 1rem);
    left: 50%;
    transform: translateX(-50%);
    width: 280px;
    background: var(--bg-card);
    border: 1px solid var(--border-line);
    border-radius: 8px;
    padding: 1.25rem;
    z-index: 100;
    display: none;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.kb-tl-node:hover .kb-tl-popup {
    display: block;
}

.kb-tl-popup-era {
    font-size: 0.6875rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.06);
}

.kb-tl-popup-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.5rem;
    line-height: 1.35;
}

.kb-tl-popup-text {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 0.75rem;
}

.kb-tl-popup-link {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--teal);
}

/* Timeline scroll hint */
.kb-tl-scroll-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8125rem;
    padding-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.kb-tl-scroll-hint i {
    animation: scrollHint 1.5s ease-in-out infinite;
}

@keyframes scrollHint {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(6px); }
}

/* ============================================================
   ON THIS DAY SECTION (Homepage teaser)
   ============================================================ */
.kb-otd-section {
    padding: 5rem 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}

.kb-otd-date-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.kb-otd-today {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--teal-dim);
    border: 1px solid rgba(34, 191, 163, 0.25);
    border-radius: 6px;
    color: var(--teal);
    font-weight: 600;
    font-size: 0.9375rem;
}

.kb-otd-browse {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Story cards */
.kb-story-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 1.5rem;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.kb-story-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-line);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.kb-story-card-era {
    font-size: 0.6875rem;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 0.5rem;
    padding: 0.125rem 0.5rem;
    border-radius: 100px;
}

.kb-story-card-date {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
    font-weight: 500;
}

.kb-story-card h3 {
    font-size: 1.0625rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 0.5rem;
    line-height: 1.35;
}

.kb-story-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.55;
    flex-grow: 1;
}

.kb-story-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-subtle);
}

.kb-story-card-cat {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.kb-story-card-cat i {
    margin-right: 0.25rem;
}

.kb-story-card-read {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--teal);
}

/* ============================================================
   STORY PAGE
   ============================================================ */
.kb-story-hero {
    padding: 7rem 0 3rem;
    border-bottom: 1px solid var(--border-subtle);
}

.kb-story-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.kb-story-era-tag {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    color: #fff;
}

.kb-story-date-tag {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.kb-story-hero h1 {
    font-size: clamp(1.75rem, 4vw, 2.75rem);
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
    letter-spacing: -0.02em;
    max-width: 750px;
    margin: 0;
}

.kb-story-body {
    padding: 3rem 0;
    max-width: 720px;
}

.kb-story-body .story-text {
    font-size: 1.125rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.kb-story-body .story-text p {
    margin-bottom: 1.5rem;
}

.kb-story-sidebar-box {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.kb-story-sidebar-box h4 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    margin: 0 0 0.75rem;
    text-transform: uppercase;
}

.kb-story-sidebar-box p {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0;
}

/* Story navigation */
.kb-story-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 2rem 0;
    border-top: 1px solid var(--border-subtle);
    flex-wrap: wrap;
}

.kb-story-nav a {
    display: block;
    color: var(--text-secondary);
    font-size: 0.875rem;
    max-width: 45%;
}

.kb-story-nav a:hover {
    color: var(--teal);
}

.kb-story-nav a span {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

/* ============================================================
   ON THIS DAY PAGE
   ============================================================ */
.kb-otd-page {
    padding: 7rem 0 3rem;
}

.kb-date-picker-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.kb-date-input {
    background: var(--bg-card);
    border: 1px solid var(--border-line);
    color: var(--text-primary);
    padding: 0.625rem 1rem;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.9375rem;
}

.kb-date-input:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-dim);
}

.kb-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9375rem;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-body);
}

.kb-btn-teal {
    background: var(--teal);
    color: var(--bg-dark);
}

.kb-btn-teal:hover {
    background: #5DDFC8;
    color: var(--bg-dark);
}

.kb-btn-outline {
    background: transparent;
    color: var(--teal);
    border: 1px solid var(--teal);
}

.kb-btn-outline:hover {
    background: var(--teal);
    color: var(--bg-dark);
}

/* ---- Footer ---- */
.kb-footer {
    padding: 3rem 0;
    border-top: 1px solid var(--border-subtle);
}

.kb-footer-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    text-align: center;
}

.kb-footer-logo {
    height: 48px;
    width: auto;
    opacity: 0.7;
}

.kb-footer-tagline {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0.5rem 0 0;
}

.kb-footer-links {
    display: flex;
    gap: 1.5rem;
}

.kb-footer-links a {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.kb-footer-links a:hover {
    color: var(--teal);
}

.kb-footer-copy {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.kb-footer-copy p {
    margin: 0;
}

/* ---- Utilities ---- */
.text-teal { color: var(--teal); }

.kb-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.kb-empty-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: block;
    opacity: 0.4;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .kb-hero {
        padding: 6rem 0 3rem;
    }

    .kb-section {
        padding: 3rem 0;
    }

    .kb-tl-node {
        width: 110px;
    }

    .kb-tl-popup {
        width: 240px;
    }

    .kb-story-body {
        padding: 2rem 0;
    }

    .kb-story-nav a {
        max-width: 100%;
    }

    .kb-story-nav {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .kb-tl-node {
        width: 95px;
    }

    .kb-tl-title {
        font-size: 0.6875rem;
    }

    .kb-tl-date {
        font-size: 0.625rem;
    }
}

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

    html {
        scroll-behavior: auto;
    }
}
