/* BlogSpace — Notion-inspired Blog Theme */
/* :root variables are injected from ContentUtils/design/tokens.json at build time */

:root {
    --bs-bg: #ffffff;
    --bs-bg-secondary: #f5f6fa;
    --bs-text: #2c3e50;
    --bs-text-light: #6c7a89;
    --bs-accent: #3498db;
    --bs-accent-hover: #2980b9;
    --bs-border: #e1e4e8;
    --bs-header-bg: #2c3e50;
    --bs-header-text: #ffffff;
    --bs-note-tip: #27ae60;
    --bs-note-warning: #e67e22;
    --bs-note-note: #3498db;
    --bs-note-important: #e74c3c;
    --bs-code-bg: #f8f9fa;
    --bs-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --bs-font-mono: "SF Mono", "Fira Code", "JetBrains Mono", monospace;
    --bs-line-height: 1.6;
    --bs-radius: 6px;
    --bs-max-width: 800px;
}

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

body {
    font-family: var(--bs-font-family);
    color: var(--bs-text);
    line-height: var(--bs-line-height);
    background: var(--bs-bg);
}

a {
    color: var(--bs-text);
}

/* ===== Header ===== */
.bs-header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 40px;
    background: var(--bs-bg);
    border-bottom: 1px solid var(--bs-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.bs-home {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}

.bs-logo {
    height: 28px;
    width: auto;
}

.bs-logo-text {
    font-weight: 700;
    font-size: 1em;
    color: var(--bs-text);
}

.bs-nav-main {
    display: flex;
    gap: 4px;
}

.bs-nav-main a {
    color: var(--bs-text-light);
    text-decoration: none;
    font-size: 0.875em;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--bs-radius);
    transition: background 0.15s;
}

.bs-nav-main a:hover {
    background: var(--bs-bg-secondary);
    color: var(--bs-text);
}

/* ===== Search ===== */
.bs-search {
    position: relative;
    flex: 1;
    max-width: 240px;
    margin-left: auto;
}

.bs-search input {
    width: 100%;
    padding: 6px 12px;
    border: 1px solid var(--bs-border);
    border-radius: var(--bs-radius);
    background: var(--bs-bg);
    color: var(--bs-text);
    font-size: 0.875em;
    outline: none;
}

.bs-search input:focus {
    border-color: var(--bs-accent);
    box-shadow: 0 0 0 2px rgba(46, 170, 220, 0.15);
}

.bs-search input::placeholder {
    color: var(--bs-text-light);
}

#bs-search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--bs-bg);
    border: 1px solid var(--bs-border);
    border-radius: var(--bs-radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    max-height: 400px;
    overflow-y: auto;
    z-index: 200;
}

#bs-search-results.bs-search-visible {
    display: block;
}

.bs-search-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    color: var(--bs-text);
    text-decoration: none;
    border-bottom: 1px solid var(--bs-border);
}

.bs-search-item:last-child {
    border-bottom: none;
}

.bs-search-item:hover {
    background: var(--bs-bg-secondary);
}

.bs-search-title {
    font-size: 0.875em;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bs-search-date {
    font-size: 0.75em;
    color: var(--bs-text-light);
    flex-shrink: 0;
    margin-left: 12px;
    white-space: nowrap;
}

.bs-search-empty {
    padding: 14px;
    text-align: center;
    color: var(--bs-text-light);
    font-size: 0.875em;
}

/* ===== Language button ===== */
.bs-lang-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    margin-left: auto;
}

.bs-lang-icon {
    width: 20px;
    height: 20px;
    stroke: var(--bs-text-light);
    fill: none;
    stroke-width: 1.5;
}

.bs-lang-btn:hover .bs-lang-icon {
    stroke: var(--bs-text);
}

/* ===== Offcanvas overlay ===== */
.bs-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 150;
    opacity: 0;
    transition: opacity 0.3s;
}

.bs-overlay.bs-visible {
    display: block;
}

.bs-overlay.bs-shown {
    opacity: 1;
}

/* ===== Offcanvas panel ===== */
.bs-offcanvas {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 300px;
    max-width: 85vw;
    background: var(--bs-bg);
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.bs-offcanvas--right {
    right: 0;
}

.bs-offcanvas.bs-open {
    transform: translateX(0);
}

.bs-offcanvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--bs-border);
    flex-shrink: 0;
}

.bs-offcanvas-title {
    font-weight: 600;
    font-size: 0.95em;
}

.bs-offcanvas-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: var(--bs-text-light);
    font-size: 1.4em;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.bs-offcanvas-close:hover {
    color: var(--bs-text);
}

.bs-offcanvas-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* ===== Language list in offcanvas ===== */
.bs-lang-list {
    list-style: none;
    padding: 0;
}

.bs-lang-list li {
    margin: 2px 0;
}

.bs-lang-list a,
.bs-lang-list .bs-lang-list-current {
    display: block;
    padding: 12px 16px;
    border-radius: var(--bs-radius);
    text-decoration: none;
    font-size: 0.95em;
    transition: background 0.15s;
}

.bs-lang-list a {
    color: var(--bs-text);
}

.bs-lang-list a:hover {
    background: var(--bs-bg-secondary);
}

.bs-lang-list .bs-lang-list-current {
    background: var(--bs-accent);
    color: #ffffff;
    font-weight: 600;
}

/* ===== Main ===== */
.bs-main {
    max-width: var(--bs-max-width);
    margin: 0 auto;
    padding: 48px 40px;
}

/* ===== Blog index ===== */
.bs-index h1 {
    font-size: 2.5em;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 8px;
}

.bs-tagline {
    font-size: 1.15em;
    color: var(--bs-text-light);
    margin-bottom: 48px;
}

/* Article grid */
.bs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 32px;
}

.bs-card {
    background: none;
    border: none;
    border-radius: 0;
    overflow: hidden;
    transition: opacity 0.15s;
}

.bs-card:hover {
    opacity: 0.85;
}

.bs-card-image {
    display: block;
    overflow: hidden;
    border-radius: var(--bs-radius);
    margin-bottom: 12px;
}

.bs-card-image img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
}

.bs-card-body {
    padding: 0;
}

.bs-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8em;
    color: var(--bs-text-light);
    margin-bottom: 6px;
}

.bs-card h2 {
    font-size: 1.1em;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 6px;
}

.bs-card h2 a {
    color: var(--bs-text);
    text-decoration: none;
}

.bs-card h2 a:hover {
    text-decoration: underline;
}

.bs-card-excerpt {
    color: var(--bs-text-light);
    font-size: 0.9em;
    line-height: 1.5;
    margin-bottom: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bs-read-more {
    display: none;
}

/* Badges & Tags */
.bs-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bs-bg-secondary);
    color: var(--bs-text-light);
    border-radius: var(--bs-radius);
    font-size: 0.75em;
    text-decoration: none;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.bs-badge:hover {
    background: var(--bs-border);
    color: var(--bs-text);
}

.bs-tag {
    display: inline-block;
    padding: 2px 10px;
    background: var(--bs-bg-secondary);
    color: var(--bs-text-light);
    border-radius: var(--bs-radius);
    font-size: 0.8em;
    text-decoration: none;
    margin: 2px;
}

.bs-tag:hover {
    background: var(--bs-border);
    color: var(--bs-text);
}

/* Pagination */
.bs-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 48px;
    padding-top: 24px;
}

.bs-pagination a {
    color: var(--bs-text);
    text-decoration: none;
    font-size: 0.875em;
    padding: 6px 14px;
    border: 1px solid var(--bs-border);
    border-radius: var(--bs-radius);
}

.bs-pagination a:hover {
    background: var(--bs-bg-secondary);
}

.bs-pagination-info {
    color: var(--bs-text-light);
    font-size: 0.8em;
}

/* ===== Article page ===== */
.bs-article {
    max-width: 720px;
    margin: 0 auto;
}

.bs-draft-banner {
    background: #fef3cd;
    color: #856404;
    border: 1px solid #ffc107;
    border-radius: var(--bs-radius);
    padding: 10px 16px;
    margin-bottom: 20px;
    font-size: 0.875em;
    font-weight: 600;
    text-align: center;
}

.bs-hero img {
    width: 100%;
    height: auto;
    max-height: 520px;
    object-fit: contain;
    border-radius: var(--bs-radius);
    margin-bottom: 8px;
}

.bs-hero-caption {
    text-align: center;
    font-size: 0.875em;
    color: var(--bs-muted, #6b7280);
    font-style: italic;
    margin: 0 0 32px;
}

.bs-article-header {
    margin-bottom: 32px;
}

.bs-article-header h1 {
    font-size: 2.5em;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
    margin-bottom: 16px;
}

.bs-article-meta {
    color: var(--bs-text-light);
    font-size: 0.875em;
    margin-bottom: 12px;
}

.bs-article-categories {
    display: flex;
    gap: 6px;
}

.bs-article-body {
    font-size: 1.05em;
    line-height: 1.75;
}

.bs-article-body p {
    margin: 16px 0;
}

.bs-article-body h2 {
    font-size: 1.4em;
    font-weight: 600;
    margin: 40px 0 16px;
    padding: 0;
    border: none;
}

.bs-article-body h3 {
    font-size: 1.15em;
    font-weight: 600;
    margin: 32px 0 12px;
}

.bs-article-body ul,
.bs-article-body ol {
    margin: 14px 0;
    padding-left: 28px;
}

.bs-article-body li {
    margin: 6px 0;
}

.bs-article-footer {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--bs-border);
}

.bs-article-tags {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.bs-article-tags span {
    color: var(--bs-text-light);
    font-size: 0.875em;
}

/* ===== Breadcrumb ===== */
.bs-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.8em;
    color: var(--bs-text-light);
    margin-bottom: 20px;
}

.bs-breadcrumb a {
    color: var(--bs-text-light);
    text-decoration: none;
}

.bs-breadcrumb a:hover {
    color: var(--bs-text);
}

.bs-breadcrumb-sep {
    margin: 0 6px;
    color: var(--bs-border);
}

/* Reading time */
.bs-reading-time {
    color: var(--bs-text-light);
}

/* ===== Table of contents ===== */
.bs-toc {
    background: var(--bs-bg-secondary);
    border-radius: var(--bs-radius);
    padding: 20px 24px;
    margin-bottom: 32px;
}

.bs-toc h2 {
    font-size: 0.8em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--bs-text-light);
    margin: 0 0 12px;
    border: none;
    padding: 0;
}

.bs-toc ol {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: toc;
}

.bs-toc li {
    counter-increment: toc;
    margin: 4px 0;
}

.bs-toc li::before {
    content: counters(toc, ".") ". ";
    color: var(--bs-text-light);
    font-size: 0.85em;
}

.bs-toc li a {
    color: var(--bs-text);
    text-decoration: none;
    font-size: 0.9em;
}

.bs-toc li a:hover {
    color: var(--bs-accent);
}

.bs-toc .bs-toc-h3 {
    padding-left: 20px;
}

/* ===== Related articles ===== */
.bs-related {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--bs-border);
}

.bs-related h2 {
    font-size: 1em;
    font-weight: 600;
    margin-bottom: 16px;
    border: none;
    padding: 0;
}

.bs-related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.bs-related-card {
    display: flex;
    flex-direction: column;
    padding: 16px;
    background: var(--bs-bg-secondary);
    border-radius: var(--bs-radius);
    text-decoration: none;
    transition: background 0.15s;
}

.bs-related-card:hover {
    background: var(--bs-border);
}

.bs-related-title {
    color: var(--bs-text);
    font-size: 0.875em;
    font-weight: 500;
    line-height: 1.4;
}

.bs-related-date {
    color: var(--bs-text-light);
    font-size: 0.75em;
    margin-top: 6px;
}

/* ===== Figures ===== */
.bs-figure {
    margin: 24px 0;
}

.bs-figure img {
    max-width: 100%;
    height: auto;
    border-radius: var(--bs-radius);
}

/* ===== Notes ===== */
.bs-note {
    margin: 20px 0;
    padding: 16px 20px;
    border-radius: var(--bs-radius);
    border-left: 3px solid;
    background: var(--bs-bg-secondary);
}

.bs-note strong {
    display: block;
    margin-bottom: 4px;
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.bs-note--tip { border-color: var(--bs-note-tip); }
.bs-note--warning { border-color: var(--bs-note-warning); }
.bs-note--note { border-color: var(--bs-note-note); }
.bs-note--important { border-color: var(--bs-note-important); }

/* ===== Code ===== */
.bs-code {
    background: var(--bs-code-bg);
    border-radius: var(--bs-radius);
    padding: 16px 20px;
    margin: 16px 0;
    overflow-x: auto;
    font-family: var(--bs-font-mono);
    font-size: 0.875em;
    line-height: 1.5;
}

/* ===== Tables ===== */
.bs-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.bs-table th, .bs-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--bs-border);
}

.bs-table th {
    font-weight: 600;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--bs-text-light);
}

/* ===== Callout / CTA ===== */
.bs-callout {
    margin: 24px 0;
    padding: 24px;
    background: var(--bs-bg-secondary);
    border-radius: var(--bs-radius);
    text-align: center;
}

.bs-callout-btn {
    display: inline-block;
    margin-top: 12px;
    padding: 10px 24px;
    background: var(--bs-accent);
    color: #ffffff;
    text-decoration: none;
    border-radius: var(--bs-radius);
    font-weight: 600;
    font-size: 0.875em;
    transition: background 0.15s;
}

.bs-callout-btn:hover {
    background: var(--bs-accent-hover);
}

/* ===== Embed ===== */
.bs-embed {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    margin: 24px 0;
    border-radius: var(--bs-radius);
}

.bs-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.bs-embed-caption {
    text-align: center;
    color: var(--bs-text-light);
    font-size: 0.8em;
    margin-top: 8px;
}

/* ===== Quote ===== */
.bs-quote {
    margin: 24px 0;
    padding: 20px 24px;
    border-left: 3px solid var(--bs-text);
}

.bs-quote p {
    font-style: italic;
    font-size: 1.1em;
    line-height: 1.6;
}

.bs-quote footer {
    margin-top: 8px;
    color: var(--bs-text-light);
    font-size: 0.875em;
    font-style: normal;
}

/* ===== Links ===== */
.bs-link a {
    color: var(--bs-accent);
    text-decoration: underline;
}

.bs-link a:hover {
    opacity: 0.8;
}

/* ===== Listing pages (category, tag) ===== */
.bs-listing {
    max-width: var(--bs-max-width);
}

.bs-listing h1 {
    font-size: 2em;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.bs-listing-desc {
    color: var(--bs-text-light);
    margin-bottom: 32px;
}

.bs-card--compact {
    background: none;
    border: none;
    border-bottom: 1px solid var(--bs-border);
    border-radius: 0;
    margin-bottom: 0;
}

.bs-card--compact .bs-card-body {
    padding: 20px 0;
}

.bs-card--compact h2 {
    font-size: 1.05em;
    margin-bottom: 4px;
}

.bs-card--compact .bs-card-excerpt {
    font-size: 0.875em;
    margin-bottom: 0;
}

/* ===== Static page ===== */
.bs-page {
    max-width: 720px;
    margin: 0 auto;
}

.bs-page h1 {
    font-size: 2.5em;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 24px;
}

.bs-page p {
    margin: 14px 0;
    font-size: 1.05em;
    line-height: 1.75;
}

.bs-page h2 {
    font-size: 1.4em;
    font-weight: 600;
    margin: 36px 0 16px;
}

/* Steps */
.bs-steps {
    margin: 16px 0;
    padding-left: 24px;
}

.bs-steps li {
    margin: 8px 0;
    padding-left: 8px;
}

/* ===== Footer ===== */
.bs-footer {
    padding: 32px 40px;
    text-align: center;
    font-size: 0.8em;
    color: var(--bs-text-light);
    border-top: 1px solid var(--bs-border);
}

.bs-footer a {
    color: var(--bs-text-light);
    text-decoration: underline;
}

.bs-footer a:hover {
    color: var(--bs-text);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .bs-header {
        flex-wrap: wrap;
        padding: 10px 16px;
        gap: 10px;
    }

    .bs-nav-main {
        display: none;
    }

    .bs-search {
        max-width: none;
        order: 10;
        flex-basis: 100%;
    }

    .bs-main {
        padding: 24px 16px;
    }

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

    .bs-index h1,
    .bs-article-header h1,
    .bs-page h1 {
        font-size: 1.8em;
    }

    .bs-lang-dropdown {
        margin-left: auto;
    }

    .bs-related-grid {
        grid-template-columns: 1fr;
    }
}
