/* ==========================================================================
   Bibelskolan — Modern Editorial Reader Stylesheet
   mickelsson.net/bibelskolan
   ========================================================================== */

:root {
    /* Fonts */
    --font-heading: 'Source Serif 4', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-scripture: 'Source Serif 4', Georgia, serif;

    /* Spacing & Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --sidebar-width: 320px;
    --content-max-w: 760px;

    /* Light Theme (Warm Paper & Golden Amber) */
    --bg-canvas: #fcfbf9;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-card-subtle: #f7f5f0;
    --bg-sidebar: #f5f3ec;
    --border-subtle: #ebe7de;
    --border-strong: #dcd7cc;
    --text-primary: #1c1917;
    --text-secondary: #57534e;
    --text-muted: #8c857b;
    --brand-accent: #b45309;
    --brand-accent-hover: #92400e;
    --brand-accent-subtle: rgba(180, 83, 9, 0.08);
    --scripture-border: #b45309;
    --reflection-border: #0284c7;
    --reflection-bg: #f0f9ff;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --topbar-blur: rgba(252, 251, 249, 0.85);
}

[data-theme="dark"] {
    /* Dark Theme (Deep Midnight & Warm Gold) */
    --bg-canvas: #0c0e12;
    --bg-surface: #141720;
    --bg-card: #181c27;
    --bg-card-subtle: #1e2331;
    --bg-sidebar: #11141c;
    --border-subtle: #242938;
    --border-strong: #333a4f;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --brand-accent: #f59e0b;
    --brand-accent-hover: #fbbf24;
    --brand-accent-subtle: rgba(245, 158, 11, 0.12);
    --scripture-border: #f59e0b;
    --reflection-border: #38bdf8;
    --reflection-bg: #0c2033;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --topbar-blur: rgba(12, 14, 18, 0.85);
}

/* Base Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-canvas);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Layout Grid */
.site-layout {
    display: flex;
    min-height: 100vh;
}

/* ==========================================================================
   Sidebar Navigation
   ========================================================================== */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-header {
    padding: 1.25rem 1.25rem 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-branding {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
}

.brand-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: var(--brand-accent-subtle);
    color: var(--brand-accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-titles {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.brand-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.btn-close-sidebar {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
}

/* Sidebar Search */
.sidebar-search {
    padding: 0.5rem 1.25rem 0.75rem 1.25rem;
    position: relative;
}

.sidebar-search input {
    width: 100%;
    padding: 0.6rem 0.75rem 0.6rem 2.25rem;
    border: 1px solid var(--border-subtle);
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.15s ease;
}

.sidebar-search input:focus {
    border-color: var(--brand-accent);
}

.sidebar-search .search-icon {
    position: absolute;
    left: 1.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* Course Navigation */
.course-nav {
    flex: 1;
    padding: 0 0.75rem 1.5rem 0.75rem;
}

.nav-section-title {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.5rem 0.5rem 0.35rem 0.5rem;
}

.course-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.course-item {
    border-radius: var(--radius-md);
    overflow: hidden;
}

.course-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.75rem;
    background: none;
    border: none;
    text-align: left;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background 0.15s ease;
}

.course-toggle:hover {
    background-color: var(--border-subtle);
}

.course-item.is-active > .course-toggle {
    background-color: var(--brand-accent-subtle);
    color: var(--brand-accent);
    font-weight: 600;
}

.course-number {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--brand-accent);
    background: var(--bg-surface);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.course-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.course-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.chevron-icon {
    color: var(--text-muted);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.course-item.is-expanded .chevron-icon {
    transform: rotate(180deg);
}

/* Chapter List inside course */
.chapter-list {
    list-style: none;
    padding-left: 2rem;
    padding-right: 0.5rem;
    display: none;
    flex-direction: column;
    gap: 0.15rem;
    margin-top: 0.15rem;
    margin-bottom: 0.5rem;
}

.chapter-list.is-open {
    display: flex;
}

.chapter-item {
    border-radius: var(--radius-sm);
}

.chapter-link {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.chapter-link:hover {
    color: var(--brand-accent);
    background-color: var(--border-subtle);
}

.chapter-item.is-active .chapter-link {
    color: var(--brand-accent);
    font-weight: 600;
    background-color: var(--brand-accent-subtle);
}

.chapter-badge {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}

.chapter-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ==========================================================================
   Main Content & Topbar
   ========================================================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background-color: var(--topbar-blur);
    border-bottom: 1px solid var(--border-subtle);
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.btn-sidebar-toggle {
    display: none;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.4rem 0.75rem;
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
}

.topbar-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crumb-study {
    font-weight: 600;
    color: var(--text-primary);
}

.crumb-sep {
    color: var(--text-muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-theme-toggle {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.btn-theme-toggle:hover {
    border-color: var(--brand-accent);
}

.icon-sun { display: none; }
.icon-moon { display: block; }

[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* ==========================================================================
   Reader Canvas & Article Typography
   ========================================================================== */
.reader-container {
    max-width: var(--content-max-w);
    margin: 0 auto;
    padding: 2.75rem 1.5rem 5rem 1.5rem;
    width: 100%;
}

.reader-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.kicker-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.kicker-pill {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--brand-accent);
    background: var(--brand-accent-subtle);
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-sm);
}

.kicker-study {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.chapter-headline {
    font-family: var(--font-heading);
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    text-wrap: balance;
}

.study-intro-card {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background-color: var(--bg-card-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.intro-tag {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--brand-accent);
    margin-bottom: 0.5rem;
}

.intro-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Scripture Quote Card */
.scripture-card {
    background-color: var(--bg-card);
    border-left: 4px solid var(--scripture-border);
    border-top: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    padding: 1.25rem 1.5rem;
    margin-bottom: 2.25rem;
    box-shadow: var(--shadow-sm);
}

.scripture-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.scripture-icon {
    color: var(--brand-accent);
    display: flex;
}

.scripture-tag {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--brand-accent);
}

.scripture-body {
    font-family: var(--font-scripture);
    font-size: 1.15rem;
    font-style: italic;
    line-height: 1.65;
    color: var(--text-primary);
}

/* Main Teaching Prose */
.teaching-body {
    font-size: 1.08rem;
    line-height: 1.8;
    color: var(--text-primary);
    margin-bottom: 3rem;
}

.teaching-body p {
    margin-bottom: 1.4rem;
}

/* Reflection / Application Card */
.reflection-card {
    background-color: var(--reflection-bg);
    border: 1px solid var(--reflection-border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 3rem;
}

.reflection-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.reflection-icon {
    color: var(--reflection-border);
    display: flex;
}

.reflection-title {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
}

.reflection-body {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

.reflection-body p {
    margin-bottom: 0.85rem;
}

/* ==========================================================================
   Bottom Pager Navigation
   ========================================================================== */
.reader-pager {
    display: flex;
    gap: 1rem;
    margin-bottom: 3rem;
}

.pager-col {
    flex: 1;
}

.pager-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1.1rem 1.25rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-sm);
    height: 100%;
}

.pager-card:hover {
    border-color: var(--brand-accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.pager-card-next {
    align-items: flex-end;
    text-align: right;
}

.pager-dir {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--brand-accent);
}

.pager-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

/* Footer */
.reader-footer {
    padding-top: 2rem;
    border-top: 1px solid var(--border-subtle);
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.back-to-top {
    color: var(--brand-accent);
    text-decoration: none;
}

.back-to-top:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        box-shadow: var(--shadow-md);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .btn-close-sidebar {
        display: block;
    }

    .btn-sidebar-toggle {
        display: inline-flex;
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background-color: rgba(0, 0, 0, 0.45);
        backdrop-filter: blur(3px);
        z-index: 90;
    }

    .sidebar-backdrop.is-active {
        display: block;
    }

    .reader-container {
        padding: 2rem 1.25rem 4rem 1.25rem;
    }

    .chapter-headline {
        font-size: 1.85rem;
    }

    .reader-pager {
        flex-direction: column;
    }

    .pager-card-next {
        align-items: flex-start;
        text-align: left;
    }
}
