/* === Amazon Shareholder Letters Knowledge Base === */
/* Inspired by learnbuffett.com — Dark sidebar + Light content */

:root {
    --sidebar-bg: #0f1923;
    --sidebar-text: #a8b9cb;
    --sidebar-hover: #ffffff;
    --sidebar-active: #ff9900;
    --sidebar-width: 280px;
    --content-bg: #fafbfc;
    --card-bg: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --accent: #ff9900;
    --accent-dark: #e68a00;
    --border: #e2e8f0;
    --quote-bg: #fffbeb;
    --quote-border: #f59e0b;
    --note-bg: #eff6ff;
    --note-border: #3b82f6;
    --tip-bg: #ecfdf5;
    --tip-border: #10b981;
    --success-bg: #ecfdf5;
    --fail-bg: #fef2f2;
    --code-bg: #1e293b;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-hover: 0 4px 12px rgba(0,0,0,0.12);
    --radius: 8px;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-mono: "JetBrains Mono", "Fira Code", "Consolas", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--content-bg);
    line-height: 1.7;
    display: flex;
    min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
}

.logo-icon { font-size: 28px; }

.logo-text {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
}

.logo-text small {
    font-size: 11px;
    font-weight: 400;
    color: var(--sidebar-text);
}

.sidebar-search {
    padding: 12px 16px;
}

.sidebar-search input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.sidebar-search input::placeholder { color: rgba(255,255,255,0.4); }
.sidebar-search input:focus { border-color: var(--accent); }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.nav-section { border-bottom: 1px solid rgba(255,255,255,0.05); }

.nav-section-title {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--sidebar-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    transition: color 0.2s;
}

.nav-section-title:hover { color: #fff; }

.nav-section-title .count {
    margin-left: auto;
    background: rgba(255,255,255,0.1);
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
}

.nav-items {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-section.active .nav-items { max-height: 2000px; }

.nav-items li a {
    display: block;
    padding: 5px 16px 5px 36px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.nav-items li a:hover {
    color: #fff;
    background: rgba(255,255,255,0.05);
}

.nav-items li.active a {
    color: var(--accent);
    border-left-color: var(--accent);
    background: rgba(255,153,0,0.08);
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 11px;
    color: rgba(255,255,255,0.4);
}

.sidebar-footer .stats { line-height: 1.8; }

.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    background: var(--sidebar-bg);
    color: #fff;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
}

/* === Main Content === */
.content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    padding: 0;
}

.content-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 40px 60px;
}

/* === Homepage === */
.hero {
    text-align: center;
    padding: 60px 0 40px;
}

.hero h1 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.hero-subtitle {
    font-size: 1rem;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 12px;
}

.hero-desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    max-width: 640px;
    margin: 0 auto 24px;
    line-height: 1.7;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-top: 24px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-num {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.section {
    margin-top: 48px;
}

.section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--accent);
}

.section h3 {
    font-size: 1.15rem;
    margin-top: 24px;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.section-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* === Card Grid === */
.card-grid {
    display: grid;
    gap: 12px;
}

.letter-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.concept-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.biz-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.people-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.card {
    display: block;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
    border-color: var(--accent);
}

.letter-card {
    text-align: center;
    padding: 20px 12px;
}

.card-year {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent);
}

.card-author {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.card-tags {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.4;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.card-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.card-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.biz-success { border-left: 3px solid #10b981; }
.biz-fail { border-left: 3px solid #ef4444; }

/* === Article === */
.article-header {
    margin-bottom: 32px;
}

.breadcrumb {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.breadcrumb a {
    color: var(--accent);
    text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }

.article-header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.3;
    margin-bottom: 12px;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    display: inline-block;
    padding: 2px 10px;
    background: rgba(255,153,0,0.1);
    color: var(--accent-dark);
    border-radius: 12px;
    font-size: 0.75rem;
}

/* === Article Body Typography === */
.article-body h1 { font-size: 1.6rem; margin: 40px 0 16px; font-weight: 800; }
.article-body h2 { font-size: 1.35rem; margin: 36px 0 14px; font-weight: 700; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.article-body h3 { font-size: 1.1rem; margin: 28px 0 10px; font-weight: 600; color: var(--text-primary); }
.article-body h4 { font-size: 1rem; margin: 20px 0 8px; font-weight: 600; }

.article-body p { margin-bottom: 14px; }

.article-body a, .wikilink {
    color: var(--accent-dark);
    text-decoration: none;
    border-bottom: 1px solid rgba(255,153,0,0.3);
    transition: border-color 0.2s;
}

.article-body a:hover, .wikilink:hover {
    border-bottom-color: var(--accent);
}

.wikilink-broken {
    color: var(--text-muted);
    border-bottom: 1px dashed var(--border);
}

.article-body strong { font-weight: 700; }

.article-body ul, .article-body ol {
    margin: 8px 0 14px 24px;
}

.article-body li { margin-bottom: 4px; }

/* Tables */
.article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.9rem;
}

.article-body th {
    background: #f1f5f9;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    border: 1px solid var(--border);
}

.article-body td {
    padding: 8px 12px;
    border: 1px solid var(--border);
}

.article-body tr:nth-child(even) { background: #f8fafc; }

/* Code blocks */
.article-body code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85em;
}

.article-body pre {
    background: var(--code-bg);
    color: #e2e8f0;
    padding: 16px 20px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 16px 0;
    font-size: 0.85rem;
    line-height: 1.5;
}

.article-body pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* Blockquotes */
.article-body blockquote {
    border-left: 3px solid var(--quote-border);
    background: var(--quote-bg);
    padding: 12px 16px;
    margin: 14px 0;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-style: italic;
    color: var(--text-secondary);
}

/* Callouts */
.callout {
    border-radius: var(--radius);
    padding: 16px;
    margin: 16px 0;
    border-left: 4px solid;
}

.callout-title {
    font-weight: 700;
    margin-bottom: 8px;
    font-style: normal;
}

.callout-quote {
    background: var(--quote-bg);
    border-color: var(--quote-border);
}

.callout-note {
    background: var(--note-bg);
    border-color: var(--note-border);
}

.callout-tip {
    background: var(--tip-bg);
    border-color: var(--tip-border);
}

/* Horizontal rules */
.article-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 32px 0;
}

/* === Responsive === */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: block;
    }

    .content {
        margin-left: 0;
    }

    .content-inner {
        padding: 20px 16px 40px;
    }

    .hero h1 { font-size: 1.6rem; }
    .hero-stats { gap: 16px; }
    .stat-num { font-size: 1.5rem; }

    .letter-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
    .concept-grid, .biz-grid, .people-grid {
        grid-template-columns: 1fr;
    }

    .article-header h1 { font-size: 1.4rem; }
}

@media (max-width: 480px) {
    .hero-stats { flex-wrap: wrap; }
}

/* === Scrollbar === */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* === Search highlight === */
.search-highlight { background: rgba(255,153,0,0.3); border-radius: 2px; }

/* 补充:abstract callout 样式 */
.callout-abstract {
    background: var(--note-bg, #f4f1e8);
    border-color: var(--accent, #c9a876);
    border-left: 4px solid var(--accent, #c9a876);
}

/* ===== Full-Text Search Results Panel ===== */
.sidebar-search { position: relative; }
.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 8px;
    right: 8px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.18);
    max-height: 70vh;
    overflow-y: auto;
    z-index: 1000;
    color: #222;
}
.search-meta {
    padding: 8px 12px;
    background: #f5f5f5;
    color: #666;
    font-size: 11px;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
}
.search-result-item {
    display: block;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    text-decoration: none;
    color: #222;
    cursor: pointer;
    transition: background 0.1s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item.active {
    background: #fdf3ec;
    border-left: 3px solid #c9a876;
    padding-left: 9px;
}
.search-result-title {
    font-size: 13px;
    font-weight: 600;
    color: #8b1a1a;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.search-icon { font-size: 14px; flex-shrink: 0; }
.search-cat {
    margin-left: auto;
    background: #ede0c5;
    color: #6b4423;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 500;
    flex-shrink: 0;
}
.search-result-snippet {
    font-size: 12px;
    color: #555;
    line-height: 1.5;
    margin-left: 20px;
}
.search-result-snippet mark, .search-result-title mark {
    background: #fff3a0;
    color: #8b1a1a;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 600;
}
.search-empty, .search-loading {
    padding: 16px;
    text-align: center;
    color: #888;
    font-size: 13px;
}

/* ===== Visitor Counter ===== */
.visitor-counter {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed rgba(255,255,255,0.2);
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    letter-spacing: 0.5px;
}
.visitor-counter strong {
    color: var(--accent, #c9a876);
    font-weight: 700;
    letter-spacing: 1px;
}
