/* ============================================================
   ECHOES FROM THE ANCESTORS — Master Stylesheet
   Shared by the index page and all Igbo story HTML files.
   Now with automatic light/dark theme support.
   ============================================================ */

/* ---------- THEME TOKENS (LIGHT DEFAULT) ---------- */

:root {
    /* Surfaces */
    --bg: #ffffff;
    --bg-card: #faf8f6;
    --bg-card-hover: #ffffff;
    --bg-code: rgba(241, 245, 249, 0.9);
    --bg-pre: #f8fafc;
    --bg-quote: #faf8f6;
    --bg-note: #f7f3ef;
    --bg-table-header: #faf8f6;
    --bg-table-stripe: #fdfcfb;

    /* Text */
    --text: #374151;
    --text-strong: #1f2937;
    --text-heading: #111827;
    --text-h2: #4b3e35;
    --text-muted: #6b5e57;
    --text-faint: #9a8b7f;
    --text-code: #111827;

    /* Borders & lines */
    --border: #e5d9cf;
    --border-light: #efe6dd;
    --border-card: #efe6dd;
    --border-card-hover: #d4b8a3;
    --border-code: #e5e7eb;
    --border-pre: #d1d5db;
    --border-badge: #d6c9bd;
    --border-badge-subtle: #cbb9ab;
    --border-dashed: #e0cfc0;

    /* Accent */
    --accent: #b45309;
    --accent-hover: #92400e;
    --accent-contrast: #ffffff;

    /* Badge */
    --badge-bg: #e7dfd7;
    --badge-text: #4b3e35;
    --badge-bg-subtle: #eae2da;
    --badge-text-subtle: #3f332a;

    /* Link */
    --link: #1e3a5f;
    --link-hover: #b45309;

    /* Shadows */
    --shadow-img: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.03), 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-card-hover: 0 12px 24px -6px rgba(80, 60, 40, 0.12);
    --shadow-fixed-link: 0 4px 12px rgba(0, 0, 0, 0.25);

    /* Fixed back-to-index button */
    --fab-bg: #222222;
    --fab-text: #ffffff;
    --fab-bg-hover: #f4a026;
    --fab-text-hover: #000000;
}

/* ---------- THEME TOKENS (DARK) ---------- */

@media (prefers-color-scheme: dark) {
    :root {
        /* Surfaces */
        --bg: #121212;
        --bg-card: #1e1e1e;
        --bg-card-hover: #2a2a2a;
        --bg-code: rgba(30, 41, 59, 0.6);
        --bg-pre: #1e1e1e;
        --bg-quote: #1c1a18;
        --bg-note: #1e1b18;
        --bg-table-header: #1e1e1e;
        --bg-table-stripe: #181818;

        /* Text */
        --text: #d1d5db;
        --text-strong: #f3f4f6;
        --text-heading: #f9fafb;
        --text-h2: #d6c9bd;
        --text-muted: #a89b92;
        --text-faint: #7a6e64;
        --text-code: #e5e7eb;

        /* Borders & lines */
        --border: #3a3330;
        --border-light: #2e2a27;
        --border-card: #2e2a27;
        --border-card-hover: #5a4a3c;
        --border-code: #374151;
        --border-pre: #374151;
        --border-badge: #4a4038;
        --border-badge-subtle: #3a322c;
        --border-dashed: #4a4038;

        /* Accent */
        --accent: #f59e0b;
        --accent-hover: #fbbf24;
        --accent-contrast: #1a1a1a;

        /* Badge */
        --badge-bg: #3a322c;
        --badge-text: #d6c9bd;
        --badge-bg-subtle: #2e2823;
        --badge-text-subtle: #c4b5a5;

        /* Link */
        --link: #93c5fd;
        --link-hover: #fbbf24;

        /* Shadows */
        --shadow-img: 0 4px 12px rgba(0, 0, 0, 0.4);
        --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.3);
        --shadow-card-hover: 0 12px 24px -6px rgba(0, 0, 0, 0.5);
        --shadow-fixed-link: 0 4px 12px rgba(0, 0, 0, 0.5);

        /* Fixed back-to-index button */
        --fab-bg: #f59e0b;
        --fab-text: #1a1a1a;
        --fab-bg-hover: #fbbf24;
        --fab-text-hover: #000000;
    }
}

/* ---------- GLOBAL RESET ---------- */

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

html {
    scroll-behavior: smooth;
    color-scheme: light dark;
}

/* ---------- BODY (default = story pages) ---------- */

body {
    font-family: 'Calibri', 'Arial', 'Microsoft YaHei', 'Hei', 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.7;
    padding: 2.5rem 1.5rem 4rem 1.5rem;
    max-width: 860px;
    margin: 0 auto;
    font-size: 1.05rem;
}

/* Index page override — wider layout */
body.index-page {
    line-height: 1.6;
    padding: 2rem 1.5rem;
    max-width: 1200px;
    font-size: 1rem;
}

/* ============================================================
   HEADINGS
   ============================================================ */

h1 {
    font-family: 'Calibri', 'Arial', 'Microsoft YaHei', 'Hei', 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
    font-size: 2.4rem;
    font-weight: 800;
    color: var(--text-heading);
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-top: 3rem;
    margin-bottom: 0.6rem;
    padding-left: 1.25rem;
    border-left: 8px solid var(--accent);
}

/* Index page h1 — larger and airier */
body.index-page h1 {
    font-size: 2.8rem;
    margin-bottom: 0.25rem;
    padding-left: 1.5rem;
}

/* First h1 on a story page — tighter top spacing */
body > h1:first-of-type {
    margin-top: 0.5rem;
}

h2 {
    font-family: 'Calibri', 'Arial', 'Microsoft YaHei', 'Hei', 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--text-h2);
    font-style: italic;
    margin-top: 0.5rem;
    margin-bottom: 1.75rem;
    padding-left: 1.25rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
}

h3 {
    font-family: 'Calibri', 'Arial', 'Microsoft YaHei', 'Hei', 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-heading);
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

h4 {
    font-family: 'Calibri', 'Arial', 'Microsoft YaHei', 'Hei', 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
    margin-top: 2rem;
    margin-bottom: 0.65rem;
}

h5,
h6 {
    font-family: 'Calibri', 'Arial', 'Microsoft YaHei', 'Hei', 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-h2);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

/* ============================================================
   PARAGRAPHS & TEXT
   ============================================================ */

p {
    margin-top: 1em;
    margin-bottom: 1em;
    line-height: 1.75;
}

/* First letter of the very first paragraph on a story page */
body > p:first-of-type::first-letter {
    font-size: 1.05em;
    font-weight: 600;
    color: var(--accent);
}

strong,
b {
    font-weight: 700;
    color: var(--text-strong);
}

em,
i {
    font-style: italic;
}

a {
    color: var(--link);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

a:hover {
    color: var(--link-hover);
    border-bottom-color: var(--link-hover);
}

/* ============================================================
   LISTS
   ============================================================ */

ul,
ol {
    margin-top: 1em;
    margin-bottom: 1em;
    padding-left: 2rem;
}

ul {
    list-style-type: disc;
}

ol {
    list-style-type: decimal;
}

li {
    margin-bottom: 0.5em;
    line-height: 1.7;
}

li::marker {
    color: var(--accent);
}

/* ============================================================
   BLOCKQUOTE
   ============================================================ */

blockquote {
    margin: 1.5em 0;
    margin-left: 1rem;
    margin-right: 0.5rem;
    border-left: 5px solid var(--accent);
    background-color: var(--bg-quote);
    padding: 1rem 1.5rem;
    color: var(--text-h2);
    font-style: italic;
    border-radius: 0 12px 12px 0;
}

blockquote p {
    margin: 0.5em 0;
}

/* ============================================================
   CODE
   ============================================================ */

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    background-color: var(--bg-code);
    color: var(--text-code);
    font-size: 0.92em;
    padding: 0.14em 0.4em;
    border-radius: 6px;
    border: 1px solid var(--border-code);
}

pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    background-color: var(--bg-pre);
    color: var(--text-code);
    font-size: 13px;
    line-height: 1.5;
    padding: 1rem 1.25rem;
    margin: 1.5em 0;
    overflow: auto;
    border: 1px solid var(--border-pre);
    border-radius: 12px;
}

pre code {
    background-color: transparent;
    color: inherit;
    display: block;
    font-size: inherit;
    padding: 0;
    border: none;
    border-radius: 0;
}

/* ============================================================
   HORIZONTAL RULE (story dividers)
   ============================================================ */

hr {
    border: 0;
    border-top: 2px solid var(--border-light);
    margin: 3rem 0 2rem 0;
    position: relative;
}

hr::after {
    content: "✦";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg);
    padding: 0 0.75rem;
    color: var(--accent);
    font-size: 1rem;
}

/* Index page hr — simpler, no ornament */
body.index-page hr {
    border-top: 2px solid var(--border-light);
    margin: 3rem 0 1.5rem;
}

body.index-page hr::after {
    content: "";
    display: none;
}

/* ============================================================
   TABLES
   ============================================================ */

table {
    border-collapse: collapse;
    width: 100%;
    margin: 1.5em 0;
    page-break-inside: avoid;
    font-size: 0.98em;
}

th,
td {
    border: 1px solid var(--border);
    padding: 0.65rem 0.9rem;
    text-align: left;
    vertical-align: top;
    word-break: break-word;
}

th {
    background-color: var(--bg-table-header);
    color: var(--text-heading);
    font-weight: 600;
}

tr:nth-child(even) td {
    background-color: var(--bg-table-stripe);
}

/* ============================================================
   IMAGES
   ============================================================ */

img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.5rem auto;
    border-radius: 12px;
    box-shadow: var(--shadow-img);
}

/* ============================================================
   DELETED / STRIKETHROUGH
   ============================================================ */

del,
s {
    text-decoration: line-through;
    color: var(--text-faint);
}

/* ============================================================
   "THE LESSON" — special treatment for bold lead-ins
   ============================================================ */

p strong:first-child {
    color: var(--accent);
}

/* ============================================================
   BACK-TO-INDEX LINK
   ============================================================ */

.back-to-index {
    display: inline-block;
    margin-top: 3rem;
    padding: 0.65rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 40px;
    color: var(--text-h2);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    transition: all 0.2s ease;
}

.back-to-index:hover {
    background: var(--accent);
    color: var(--accent-contrast);
    border-color: var(--accent);
}

/* ============================================================
   INDEX PAGE — SUBHEAD, GRID, CARDS, NOTES, FOOTER
   ============================================================ */

.subhead {
    font-size: 1.25rem;
    color: var(--text-muted);
    margin-bottom: 2.5rem;
    font-style: italic;
    padding-left: 2rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.collection-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 1.8rem 1.8rem 2rem 1.8rem;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-card);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.collection-card:hover {
    border-color: var(--border-card-hover);
    box-shadow: var(--shadow-card-hover);
    background: var(--bg-card-hover);
}

.collection-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-heading);
    font-style: normal;
    margin-bottom: 1.25rem;
    padding: 0 0 0.65rem 0;
    border-bottom: 2px dashed var(--border-dashed);
    border-left: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.collection-card h2 span {
    font-size: 1.6rem;
}

.story-list {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
}

.story-list li {
    margin-bottom: 0.7rem;
    font-size: 1.02rem;
    line-height: 1.4;
    padding-left: 0.2rem;
}

.story-list a {
    color: var(--link);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s, color 0.15s;
    font-weight: 500;
    display: inline-block;
}

.story-list a:hover {
    color: var(--link-hover);
    border-bottom-color: var(--link-hover);
}

.file-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    background: var(--badge-bg);
    color: var(--badge-text);
    padding: 0.15rem 0.6rem;
    border-radius: 30px;
    margin-left: 0.5rem;
    vertical-align: middle;
    border: 1px solid var(--border-badge);
}

.collection-card .story-list a .file-badge {
    font-size: 0.65rem;
    background: var(--badge-bg-subtle);
    color: var(--badge-text-subtle);
    border-color: var(--border-badge-subtle);
    margin-left: 0.4rem;
}

.note {
    margin-top: 3.5rem;
    padding: 1.5rem 2rem;
    background: var(--bg-note);
    border-left: 8px solid var(--accent);
    border-radius: 0 16px 16px 0;
    color: var(--text-strong);
    font-size: 1.05rem;
}

.note strong {
    color: var(--accent);
}

.footer {
    font-size: 0.9rem;
    color: var(--text-faint);
    text-align: center;
    margin-top: 2rem;
}

/* ============================================================
   AUTHOR CREDIT
   ============================================================ */

.author-credit {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.author-credit a {
    color: var(--accent);
    font-weight: 600;
    border-bottom: 1px solid var(--accent);
    text-decoration: none;
    transition: color 0.15s ease;
}

.author-credit a:hover {
    color: var(--accent-hover);
    border-bottom-color: var(--accent-hover);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 600px) {
    body {
        padding: 1.5rem 1rem 3rem 1rem;
        font-size: 1rem;
    }

    h1 {
        font-size: 1.75rem;
        padding-left: 0.85rem;
        border-left-width: 6px;
        margin-top: 2.25rem;
    }

    h2 {
        font-size: 1.2rem;
        padding-left: 0.85rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    blockquote {
        margin-left: 0.5rem;
        padding: 0.85rem 1rem;
    }

    hr {
        margin: 2rem 0 1.5rem 0;
    }

    /* Index page mobile tweaks */
    body.index-page h1 {
        font-size: 2rem;
        padding-left: 1rem;
    }

    .subhead {
        font-size: 1rem;
        padding-left: 1rem;
    }

    .collection-card {
        padding: 1.4rem;
    }

    .collection-card h2 {
        font-size: 1.3rem;
    }
}

/* ============================================================
   PRINT
   ============================================================ */

@media print {
    body {
        padding: 0;
        max-width: 100%;
        font-size: 11pt;
        color: #000;
        background: #fff;
    }

    h1 {
        border-left: 6px solid #b45309;
        page-break-after: avoid;
    }

    h2,
    h3,
    h4 {
        page-break-after: avoid;
    }

    hr {
        border-top: 1px solid #ccc;
    }

    hr::after {
        content: "";
    }

    a {
        color: #000;
        text-decoration: none;
    }
}

/* ============================================================
   FIXED BOTTOM-LEFT BACK-TO-INDEX BUTTON
   ============================================================ */

a.back-to-index {
    position: fixed;
    left: 1rem;
    bottom: 1rem;
    z-index: 1000;
    padding: 0.5rem 0.9rem;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    background: var(--fab-bg);
    color: var(--fab-text);
    border-radius: 999px;
    box-shadow: var(--shadow-fixed-link);
}

a.back-to-index:hover {
    background: var(--fab-bg-hover);
    color: var(--fab-text-hover);
}

/* Hide it on the index page */
body.index-page a.back-to-index {
    display: none;
}



.footer {
  text-align: center;
}

.contribute-btn {
  display: inline-block;
  margin-left: 8px;
  padding: 6px 14px;
  background-color: #25d366; /* WhatsApp green */
  color: #fff;
  text-decoration: none;
  border-radius: 20px;
  font-size: 0.9em;
  transition: background-color 0.2s ease;
}

.contribute-btn:hover {
  background-color: #1ebe5b;
}
