/* ── Cellular Cosmology — Design System v2 ── */
/* Warm, luminous, scholarly — no black */

:root {
    --gold: #b8962e;
    --gold-light: #d4b044;
    --gold-pale: rgba(184, 150, 46, 0.1);
    --cream: #faf8f5;
    --cream-dark: #f0ece4;
    --warm-dark: #3d352a;
    --warm-mid: #5c5040;
    --warm-light: #7a6e5e;
    --text: #3d352a;
    --text-soft: #6b5f50;
    --border: #e8e0d0;
    --border-dark: #d0c8b8;
    --blue-soft: #4a7fa5;
    --blue-pale: #e8f0f6;
    --hero-bg: #2c3e50;
    --hero-dark: #1e2d3d;
    --shadow: rgba(60, 52, 40, 0.06);
    --shadow-md: rgba(60, 52, 40, 0.1);
    --radius: 8px;
    --max-width: 1100px;
    --content-width: 780px;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: Georgia, 'Times New Roman', serif;
    color: var(--text);
    background: var(--cream);
    line-height: 1.75;
    font-size: 17px;
}

/* ── Typography ── */

h1, h2, h3, h4 {
    font-family: 'Nunito Sans', 'Segoe UI', sans-serif;
    font-weight: 700;
    line-height: 1.3;
    color: var(--warm-dark);
}

h1 { font-size: 2.4rem; margin-bottom: 1rem; }
h2 { font-size: 1.8rem; margin: 2rem 0 0.8rem; }
h3 { font-size: 1.3rem; margin: 1.5rem 0 0.6rem; }

p { margin-bottom: 1rem; }

a {
    color: var(--gold);
    text-decoration: none;
    transition: color 0.2s;
}
a:hover { color: var(--gold-light); }

blockquote {
    border-left: 3px solid var(--gold);
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    background: var(--cream-dark);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-style: italic;
}

/* ── Layout ── */

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 2rem;
}

.content-narrow {
    max-width: var(--content-width);
    margin: 0 auto;
}

/* ── Header / Navigation ── */

header {
    background: var(--cream);
    color: var(--text);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 6px var(--shadow-md);
    border-bottom: 1px solid var(--border);
}

header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--warm-dark);
    letter-spacing: 0.3px;
}
.logo:hover { color: var(--gold); }

.logo img {
    width: 36px;
    height: 36px;
}

nav { display: flex; gap: 1.5rem; align-items: center; }

nav a {
    color: var(--warm-mid);
    font-family: 'Nunito Sans', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.2s;
}
nav a:hover { color: var(--gold); }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--warm-mid);
    font-size: 1.5rem;
    cursor: pointer;
}

/* ── Language Switcher ── */

.lang-switcher {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-left: 0.5rem;
    padding-left: 1rem;
    border-left: 1px solid var(--border);
}

.lang-option {
    font-family: 'Nunito Sans', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--warm-light);
    text-decoration: none;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    transition: all 0.2s;
}

.lang-option:hover {
    color: var(--gold);
}

.lang-option.active {
    color: var(--gold);
    background: var(--gold-pale);
}

.lang-divider {
    color: var(--border-dark);
    font-size: 0.75rem;
}

/* ── Hero Section ── */

.hero {
    background: linear-gradient(145deg, #34495e 0%, var(--hero-bg) 40%, var(--hero-dark) 100%);
    color: #eef2f5;
    padding: 6rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 500px;
    border-radius: 50%;
    border: 1px solid rgba(184, 150, 46, 0.12);
    pointer-events: none;
}

.hero::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    border-radius: 50%;
    border: 1px solid rgba(139, 184, 220, 0.1);
    pointer-events: none;
}

.hero h1 {
    font-size: 3rem;
    color: var(--gold);
    margin-bottom: 0.5rem;
    position: relative;
}

.hero .subtitle {
    font-size: 1.3rem;
    opacity: 0.85;
    font-style: italic;
    margin-bottom: 2rem;
    position: relative;
}

.hero .tagline {
    max-width: 650px;
    margin: 0 auto 2.5rem;
    font-size: 1.05rem;
    line-height: 1.8;
    opacity: 0.88;
    position: relative;
}

.cta-group {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    position: relative;
}

.btn {
    display: inline-block;
    padding: 0.75rem 2rem;
    border-radius: var(--radius);
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.btn-primary {
    background: var(--gold);
    color: white;
}
.btn-primary:hover {
    background: var(--gold-light);
    color: white;
}

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

/* ── Chapter Cards Grid ── */

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

.chapter-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.8rem;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
}

.chapter-card:hover {
    box-shadow: 0 4px 20px var(--shadow-md);
    border-color: var(--gold);
    transform: translateY(-2px);
}

.chapter-card .icon {
    font-size: 2rem;
    margin-bottom: 0.8rem;
}

.chapter-card h3 {
    font-size: 1.15rem;
    margin-bottom: 0.5rem;
}
.chapter-card h3 a { color: var(--warm-dark); }
.chapter-card h3 a:hover { color: var(--gold); }

.chapter-card .chapter-num {
    font-family: 'Nunito Sans', sans-serif;
    font-size: 0.8rem;
    color: var(--gold);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.3rem;
}

/* ── Chapter Content ── */

.chapter-header {
    background: linear-gradient(145deg, #34495e 0%, var(--hero-bg) 100%);
    color: #eef2f5;
    padding: 3rem 2rem;
    text-align: center;
}

.chapter-header .chapter-num {
    font-family: 'Nunito Sans', sans-serif;
    font-size: 0.85rem;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
}

.chapter-header h1 { color: var(--gold); font-size: 2.2rem; }

.lang-badge {
    display: inline-block;
    font-family: 'Nunito Sans', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.2rem 0.6rem;
    border-radius: 3px;
    background: var(--gold-pale);
    color: var(--gold);
    margin-left: 0.5rem;
    vertical-align: middle;
}

.chapter-body {
    padding: 3rem 2rem;
}

.chapter-body .content-narrow img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    margin: 1.5rem 0;
}

.chapter-nav {
    display: flex;
    justify-content: space-between;
    padding: 2rem 0;
    margin-top: 3rem;
    border-top: 1px solid var(--border);
}

.chapter-nav a {
    font-family: 'Nunito Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
}

/* ── Sidebar TOC (compendium) ── */

.compendium-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 3rem;
    padding: 3rem 2rem;
    max-width: var(--max-width);
    margin: 0 auto;
}

.sidebar {
    position: sticky;
    top: 88px;
    align-self: start;
}

.sidebar h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--gold);
    margin-bottom: 1rem;
}

.sidebar ul {
    list-style: none;
}

.sidebar li {
    margin-bottom: 0.4rem;
}

.sidebar li a {
    display: block;
    padding: 0.4rem 0.8rem;
    color: var(--text-soft);
    font-size: 0.9rem;
    border-left: 2px solid transparent;
    border-radius: 0 var(--radius) var(--radius) 0;
    transition: all 0.15s;
}

.sidebar li a:hover,
.sidebar li a.active {
    border-left-color: var(--gold);
    color: var(--warm-dark);
    background: var(--cream-dark);
}

/* ── Section Dividers ── */

.section {
    padding: 4rem 2rem;
}

.section-alt {
    background: var(--cream-dark);
}

.section h2 {
    text-align: center;
    margin-bottom: 0.5rem;
}

.section .section-subtitle {
    text-align: center;
    font-style: italic;
    color: var(--text-soft);
    margin-bottom: 2.5rem;
}

/* ── Quotes / Epigraph ── */

.epigraph {
    text-align: center;
    padding: 3rem 2rem;
    max-width: 600px;
    margin: 0 auto;
    font-style: italic;
    font-size: 1.15rem;
    color: var(--text-soft);
}

.epigraph cite {
    display: block;
    margin-top: 0.8rem;
    font-size: 0.9rem;
    color: var(--gold);
    font-style: normal;
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 700;
}

/* ── Footer ── */

footer {
    background: var(--cream-dark);
    color: var(--text-soft);
    padding: 2.5rem 2rem;
    margin-top: 4rem;
    border-top: 1px solid var(--border);
}

footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

footer .copyright {
    font-size: 0.85rem;
}

footer nav a {
    color: var(--text-soft);
    font-size: 0.85rem;
}
footer nav a:hover { color: var(--gold); }

/* ── Placeholder / Coming Soon ── */

.placeholder {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-soft);
}

.placeholder .icon { font-size: 3rem; margin-bottom: 1rem; }

/* ── Responsive ── */

@media (max-width: 768px) {
    .hero h1 { font-size: 2rem; }
    .hero .subtitle { font-size: 1.1rem; }
    .hero { padding: 4rem 1.5rem; }

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

    .compendium-layout {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: static;
        border-bottom: 1px solid var(--border);
        padding-bottom: 1.5rem;
        margin-bottom: 2rem;
    }

    .nav-toggle { display: block; }

    nav {
        display: none;
        position: absolute;
        top: 68px;
        left: 0;
        right: 0;
        background: var(--cream);
        flex-direction: column;
        padding: 1rem 2rem;
        gap: 0.8rem;
        box-shadow: 0 4px 12px var(--shadow-md);
        border-bottom: 1px solid var(--border);
    }
    nav.open { display: flex; }

    header .container { position: relative; }
}

@media (max-width: 480px) {
    body { font-size: 16px; }
    .hero h1 { font-size: 1.7rem; }
    .cta-group { flex-direction: column; align-items: center; }
}

/* ── Chat Widget ── */

#cc-chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gold);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    z-index: 1000;
}
#cc-chat-toggle:hover {
    background: var(--gold-light);
    transform: scale(1.05);
}

#cc-chat-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1001;
    border: 1px solid var(--border);
}

#cc-chat-header {
    background: var(--hero-bg);
    color: white;
    padding: 0.8rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Nunito Sans', sans-serif;
    font-size: 0.9rem;
}

#cc-chat-header strong { color: var(--gold-light); }

#cc-chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}
#cc-chat-close:hover { opacity: 1; }

#cc-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.cc-msg {
    padding: 0.6rem 0.9rem;
    border-radius: 12px;
    font-size: 0.88rem;
    line-height: 1.5;
    max-width: 85%;
    word-wrap: break-word;
}

.cc-bot {
    background: var(--cream-dark);
    color: var(--text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.cc-user {
    background: var(--gold);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.cc-typing {
    display: flex;
    gap: 4px;
    padding: 0.8rem 1rem;
}
.cc-typing span {
    width: 8px;
    height: 8px;
    background: var(--border-dark);
    border-radius: 50%;
    animation: cc-bounce 1.2s infinite;
}
.cc-typing span:nth-child(2) { animation-delay: 0.15s; }
.cc-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes cc-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

#cc-chat-form {
    display: flex;
    border-top: 1px solid var(--border);
    padding: 0.5rem;
    gap: 0.4rem;
}

#cc-chat-input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.8rem;
    font-size: 0.88rem;
    font-family: Georgia, serif;
    outline: none;
    transition: border-color 0.2s;
}
#cc-chat-input:focus { border-color: var(--gold); }

#cc-chat-send {
    background: var(--gold);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 0.8rem;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}
#cc-chat-send:hover { background: var(--gold-light); }

#cc-chat-turnstile {
    padding: 0.5rem;
    display: flex;
    justify-content: center;
}

@media (max-width: 480px) {
    #cc-chat-window {
        width: calc(100vw - 16px);
        height: calc(100vh - 80px);
        bottom: 8px;
        right: 8px;
        border-radius: 8px;
    }
}
