/* ============================================================
   site.css — 全站共享样式（所有页面公用属性集中在此）
   改动此文件会同步影响所有页面。
   页面专属样式请写在各模板的 {% block extra_css %} 里。
   ============================================================ */

/* ===== 全局重置 & 字体 ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4A9EFF;
    --primary-rgb: 74, 158, 255;
    --primary-light: #6BB8FF;
    --primary-dark: #2B7BD9;
    --bg-start: #E8F4FD;
    --bg-end: #D6EAFA;
    --card-bg: rgba(255, 255, 255, 0.72);
    --card-border: rgba(var(--primary-rgb), 0.15);
    --shadow-sm: 0 8px 32px rgba(var(--primary-rgb), 0.10);
    --shadow-hover: 0 14px 44px rgba(var(--primary-rgb), 0.22);
    --text-primary: #1A2A3A;
    --text-secondary: #3A4A5A;
    --icon-gradient: linear-gradient(135deg, #6BB8FF, #4A9EFF);
    --footer-border: rgba(var(--primary-rgb), 0.08);
    --hero-glow: rgba(var(--primary-rgb), 0.13);
    --radius-card: 20px;
    --transition-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="afternoon"] {
    --primary: #F5A623;
    --primary-rgb: 245, 166, 35;
    --primary-light: #FFC857;
    --primary-dark: #D4891A;
    --bg-start: #FFF8ED;
    --bg-end: #FDF0DD;
    --card-bg: rgba(255, 248, 235, 0.78);
    --card-border: rgba(var(--primary-rgb), 0.20);
    --shadow-sm: 0 8px 32px rgba(var(--primary-rgb), 0.12);
    --shadow-hover: 0 14px 44px rgba(var(--primary-rgb), 0.25);
    --text-primary: #3D2B0F;
    --text-secondary: #6B4F2A;
    --icon-gradient: linear-gradient(135deg, #FFC857, #F5A623);
    --footer-border: rgba(var(--primary-rgb), 0.10);
    --hero-glow: rgba(var(--primary-rgb), 0.13);
}

/* Night —— 钴蓝（即原 Mercury 的配色）。
   原先这一块是与 violet.css 同族的紫色，现已整体改名为 violet 并搬到
   static/css/violet.css：那套仍然可以通过 ?theme=violet 访问和预览，
   但不在右上角的切换循环里，也不参与时间自动切换。

   ⚠️ hex 与 triplet 必须同步。 */
[data-theme="night"] {
    --primary: #5266eb; /* Cobalt */
    --primary-rgb: 82, 102, 235;
    --primary-light: #7a8aef;
    --primary-dark: #3d4fd4;
    --bg-start: #171721; /* Onyx，与 bg-end 相同 → 渐变被压成纯色画布 */
    --bg-end: #171721;
    --card-bg: rgba(30, 30, 42, 0.80); /* Graphite */
    --card-border: rgba(var(--primary-rgb), 0.20);
    --shadow-sm: 0 8px 32px rgba(0, 0, 0, 0.30);
    --shadow-hover: 0 14px 44px rgba(var(--primary-rgb), 0.25);
    --text-primary: #ededf3; /* Ivory，不用纯白 */
    --text-secondary: #c3c3cc; /* Ash */
    --icon-gradient: linear-gradient(135deg, #7a8aef, #5266eb);
    --footer-border: rgba(var(--primary-rgb), 0.10);
    --hero-glow: rgba(var(--primary-rgb), 0.13);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    min-height: 100vh;
    background: radial-gradient(ellipse at 50% 20%, var(--bg-start), var(--bg-end));
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 24px 40px;
    color: var(--text-primary);
    /* 页面入场：模糊 → 清晰（0.2s）。
       ⚠️ 这里刻意不写 `opacity: 0` + `animation ... forwards`。
       两个原因：
         1. 基础样式里留 `opacity: 0` 意味着「整页可见性依赖动画跑完」——
            动画被禁用或被打断时（例如下面的 prefers-reduced-motion），
            整页会变成空白。
         2. `forwards` 会把最终帧的属性永久留在 body 上。`filter` 和
            `transform` 一样，只要不是 none，就会让 body 成为
            position:fixed 后代的包含块，悄悄改掉它们的定位基准。
       改成「filter 只出现在关键帧里、不填 forwards」，两个问题都不存在。

       ⚠️ 性能：filter 每帧都要整页重新合成，比纯 opacity 重得多。所以这里
       用短时长（0.2s）+ 小半径（6px）。要再快就调 duration，要更省就调小
       blur 半径 —— 半径越大开销越高。若低端机上感觉掉帧，改回纯淡入即可。 */
    animation: pageFadeIn 0.2s ease-out;
    transition: background 0.8s ease, color 0.5s ease;
}

@keyframes pageFadeIn {
    from { opacity: 0; filter: blur(6px); }
    to   { opacity: 1; filter: blur(0); }
}

/* 尊重系统的「减弱动态效果」（无障碍）。
   上面 body 的基础样式里没有 opacity:0，所以关掉动画不会把页面变空白 ——
   这正是第 1 条注释要防的情况。 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    body { animation: none; }
}

/* ===== 顶部导航栏 ===== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 14px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(0px);
    background: transparent;
    transition: backdrop-filter 0.4s ease, background 0.4s ease, box-shadow 0.3s ease;
    border-radius: 0 0 20px 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.navbar.scrolled {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    background: rgba(255, 255, 255, 0.78);
    box-shadow: 0 2px 20px rgba(var(--primary-rgb), 0.08);
}

[data-theme="night"] .navbar.scrolled {
    background: rgba(23, 23, 33, 0.85);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.30);
}

[data-theme="afternoon"] .navbar.scrolled {
    background: rgba(255, 248, 235, 0.85);
    box-shadow: 0 2px 20px rgba(var(--primary-rgb), 0.08);
}

/* ===== 黑洞 Logo ===== */
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.3px;
    white-space: nowrap;
    transition: color 0.5s ease;
}

.logo .name span {
    color: var(--primary);
    transition: color 0.5s ease;
}

.blackhole {
    position: relative;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.blackhole .accretion-disk {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, #ff6b35 0%, #ffd93d 15%, #6bcbff 30%, #a855f7 45%, #ff6b35 60%, #ffd93d 75%, #6bcbff 90%, #a855f7 100%);
    animation: spinDisk 12s linear infinite;
    box-shadow: 0 0 20px rgba(107, 203, 255, 0.3), 0 0 60px rgba(168, 85, 247, 0.15);
    transition: box-shadow 0.5s ease;
}

[data-theme="night"] .blackhole .accretion-disk {
    box-shadow: 0 0 30px rgba(var(--primary-rgb), 0.4), 0 0 80px rgba(var(--primary-rgb), 0.2);
}

[data-theme="afternoon"] .blackhole .accretion-disk {
    box-shadow: 0 0 25px rgba(var(--primary-rgb), 0.3), 0 0 60px rgba(var(--primary-rgb), 0.15);
}

.blackhole .accretion-disk::before {
    content: '';
    position: absolute;
    top: -2px; left: -2px; right: -2px; bottom: -2px;
    border-radius: 50%;
    background: conic-gradient(from 30deg, transparent 0%, rgba(255, 255, 255, 0.15) 10%, transparent 20%, rgba(255, 255, 255, 0.08) 35%, transparent 50%, rgba(255, 255, 255, 0.12) 65%, transparent 80%, rgba(255, 255, 255, 0.06) 90%, transparent 100%);
    animation: spinDisk 8s linear infinite reverse;
    pointer-events: none;
}

.blackhole .event-horizon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #1a1a2e, #000000 80%);
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 0, 0, 0.6), 0 0 60px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

.blackhole .event-horizon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(107, 203, 255, 0.15) 0%, rgba(168, 85, 247, 0.08) 40%, transparent 70%);
    animation: pulseGlow 3s ease-in-out infinite;
    transition: background 0.5s ease;
}

[data-theme="night"] .blackhole .event-horizon::after {
    background: radial-gradient(circle at 30% 30%, rgba(var(--primary-rgb), 0.20) 0%, rgba(var(--primary-rgb), 0.10) 40%, transparent 70%);
}

[data-theme="afternoon"] .blackhole .event-horizon::after {
    background: radial-gradient(circle at 30% 30%, rgba(var(--primary-rgb), 0.15) 0%, rgba(var(--primary-rgb), 0.06) 40%, transparent 70%);
}

.blackhole .einstein-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1.5px solid rgba(107, 203, 255, 0.15);
    box-shadow: 0 0 15px rgba(107, 203, 255, 0.05), inset 0 0 15px rgba(107, 203, 255, 0.03);
    animation: ringPulse 4s ease-in-out infinite;
    z-index: 1;
    transition: border-color 0.5s ease, box-shadow 0.5s ease;
}

[data-theme="night"] .blackhole .einstein-ring {
    border-color: rgba(var(--primary-rgb), 0.20);
    box-shadow: 0 0 20px rgba(var(--primary-rgb), 0.08), inset 0 0 20px rgba(var(--primary-rgb), 0.05);
}

[data-theme="afternoon"] .blackhole .einstein-ring {
    border-color: rgba(var(--primary-rgb), 0.20);
    box-shadow: 0 0 15px rgba(var(--primary-rgb), 0.06), inset 0 0 15px rgba(var(--primary-rgb), 0.04);
}

.blackhole .highlight-glow {
    position: absolute;
    top: 15%;
    left: 25%;
    width: 8px;
    height: 6px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.6) 0%, transparent 100%);
    z-index: 3;
    filter: blur(1px);
}

@keyframes spinDisk {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes pulseGlow {
    0%, 100% { opacity: 0.6; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
}

@keyframes ringPulse {
    0%, 100% { opacity: 0.4; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 0.9; transform: translate(-50%, -50%) scale(1.08); }
}

/* ===== 导航菜单 ===== */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.nav-menu a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 450;
    padding: 6px 16px;
    border-radius: 20px;
    transition: all 0.3s ease;
    letter-spacing: 0.2px;
}

.nav-menu a:hover {
    color: var(--primary);
    background: rgba(var(--primary-rgb), 0.08);
}

[data-theme="night"] .nav-menu a:hover {
    background: rgba(var(--primary-rgb), 0.15);
}

[data-theme="afternoon"] .nav-menu a:hover {
    background: rgba(var(--primary-rgb), 0.10);
}

.nav-menu a.active {
    color: var(--primary);
    background: rgba(var(--primary-rgb), 0.12);
    /* 刻意不加大字重：选中项字重一旦与常态（450）不同，它就会变宽，
       整排导航跟着位移。选中态靠颜色 + 底色区分已经足够。 */
}

[data-theme="night"] .nav-menu a.active {
    background: rgba(var(--primary-rgb), 0.15);
}

[data-theme="afternoon"] .nav-menu a.active {
    background: rgba(var(--primary-rgb), 0.12);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-toggle {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 30px;
    padding: 5px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    font-family: inherit;
    white-space: nowrap;
    /* 固定宽度 —— 关键。
       按钮文字随主题变长变短（🌤 Morning / ☀️ Afternoon / 🌙 Night，
       隐藏主题还会显示 ◐ Violet），而 .navbar 是 space-between，中间
       .nav-menu 的位置由两侧宽度决定。宽度不锁死，切主题时导航词条就会
       被推着左右移动。
       宽度取最长的「☀️ Afternoon」并留出余量。 */
    width: 120px;
    text-align: center;
}

.mode-toggle:hover {
    background: rgba(var(--primary-rgb), 0.12);
    border-color: var(--primary-light);
    transform: scale(1.02);
}

[data-theme="night"] .mode-toggle:hover {
    background: rgba(var(--primary-rgb), 0.15);
}

[data-theme="afternoon"] .mode-toggle:hover {
    background: rgba(var(--primary-rgb), 0.10);
}

/* ===== Page Hero（子页共用） ===== */
.page-hero {
    width: 100%;
    max-width: 880px;
    padding: 30px 0 20px;
    text-align: center;
    position: relative;
    transition: color 0.5s ease;
}

.page-hero::before {
    content: '';
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--hero-glow) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    transition: background 0.8s ease;
}

.page-hero h1 {
    font-size: clamp(36px, 6vw, 52px);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.2;
    margin-bottom: 8px;
    color: var(--text-primary);
    transition: color 0.5s ease;
}

.page-hero h1 .highlight {
    color: var(--primary);
    transition: color 0.5s ease;
}

.page-hero .subtitle {
    font-size: clamp(16px, 2vw, 20px);
    font-weight: 400;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
    opacity: 0.7;
    transition: color 0.5s ease;
}

/* ===== Content Card（Research/Talks 共用） ===== */
.content-grid {
    width: 100%;
    max-width: 880px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin: 16px 0 20px;
}

.content-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-card);
    padding: 24px 28px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.35s var(--transition-spring), box-shadow 0.4s ease, background 0.5s ease, border-color 0.5s ease, color 0.5s ease;
    opacity: 0;
    transform: translateY(24px);
}

.content-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.content-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: rgba(var(--primary-rgb), 0.25);
}

[data-theme="night"] .content-card:hover {
    border-color: rgba(var(--primary-rgb), 0.30);
}

[data-theme="afternoon"] .content-card:hover {
    border-color: rgba(var(--primary-rgb), 0.25);
}

.content-card .card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    transition: color 0.5s ease;
}

.content-card .card-title .emoji {
    margin-right: 10px;
}

.content-card .card-meta {
    font-size: 13px;
    color: var(--text-secondary);
    opacity: 0.6;
    margin-bottom: 8px;
    transition: color 0.5s ease;
}

.content-card .card-desc {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    opacity: 0.85;
    transition: color 0.5s ease;
}

.content-card .card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.content-card .card-tags span {
    background: var(--card-border);
    color: var(--text-secondary);
    font-size: 12px;
    padding: 2px 12px;
    border-radius: 12px;
    transition: background 0.3s ease, color 0.3s ease;
}

[data-theme="night"] .content-card .card-tags span {
    background: rgba(var(--primary-rgb), 0.15);
}

[data-theme="afternoon"] .content-card .card-tags span {
    background: rgba(var(--primary-rgb), 0.12);
}

/* ===== Footer ===== */
.footer {
    width: 100%;
    max-width: 880px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--footer-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-secondary);
    opacity: 0.7;
    flex-wrap: wrap;
    gap: 12px;
    transition: border-color 0.5s ease, color 0.5s ease;
}

.back-top {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 30px;
    padding: 6px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--primary-dark);
    cursor: pointer;
    transition: all 0.3s ease, background 0.5s ease, border-color 0.5s ease, color 0.5s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    font-family: inherit;
}

.back-top:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 4px 14px rgba(var(--primary-rgb), 0.25);
    transform: translateY(-2px);
}

[data-theme="night"] .back-top:hover {
    background: var(--primary);
    box-shadow: 0 4px 14px rgba(var(--primary-rgb), 0.25);
}

[data-theme="afternoon"] .back-top:hover {
    background: var(--primary);
    box-shadow: 0 4px 14px rgba(var(--primary-rgb), 0.25);
}

/* ===== 响应式 ===== */
@media (max-width: 820px) {
    .navbar {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        padding: 12px 0;
    }
    .logo { justify-content: center; font-size: 17px; }
    .nav-menu { justify-content: center; gap: 2px; }
    .nav-menu a { font-size: 13px; padding: 5px 12px; }
    .nav-actions { justify-content: center; margin-top: 2px; }
}

@media (max-width: 600px) {
    body { padding: 0 16px 32px; }
    .content-card { padding: 18px 18px; }
    .page-hero { padding: 16px 0 10px; }
    .page-hero::before { width: 220px; height: 220px; top: -20px; }
    .nav-menu a { font-size: 12px; padding: 4px 10px; }
    .footer { flex-direction: column; text-align: center; gap: 8px; }
    .blackhole { width: 30px; height: 30px; }
    .blackhole .accretion-disk { width: 30px; height: 30px; }
    .blackhole .event-horizon { width: 15px; height: 15px; }
    .blackhole .einstein-ring { width: 23px; height: 23px; }
    .blackhole .event-horizon::after { width: 22px; height: 22px; }
}

@media (max-width: 400px) {
    .nav-menu a { font-size: 11px; padding: 3px 8px; }
}

/* ============================================================
   Wiki
   ------------------------------------------------------------
   These classes are shared by several pages under /wiki/ (index, category,
   all-pages, search results), so per the project rule that cross-page styling
   belongs in site.css, they live here rather than in each page's extra_css.
   Article body typography (.wiki-article) is used by one page only and stays
   in wiki_page.html's extra_css.
   ============================================================ */

.wiki-grid {
    width: 100%;
    max-width: 880px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 18px;
    margin: 16px 0 20px;
}

/* The card itself is a link. The wrapping <a> becomes the grid cell, so it has
   to fill the height on its own — otherwise the card's height:100% has nothing
   to resolve against and a row ends up ragged.
   text-decoration / color are cleared so the link does not alter the card. */
.wiki-link {
    display: block;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.wiki-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-card);
    padding: 28px 24px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.35s var(--transition-spring), box-shadow 0.4s ease,
        background 0.5s ease, border-color 0.5s ease, color 0.5s ease;
    opacity: 0;
    transform: translateY(24px);
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wiki-card.visible { opacity: 1; transform: translateY(0); }

.wiki-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-hover);
    border-color: rgba(var(--primary-rgb), 0.30);
}

[data-theme="night"] .wiki-card:hover { border-color: rgba(var(--primary-rgb), 0.35); }

.wiki-card .name {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    transition: color 0.5s ease;
}

.wiki-card .brief {
    font-size: 13px;
    color: var(--text-secondary);
    opacity: 0.65;
    line-height: 1.5;
    flex: 1;
    transition: color 0.5s ease;
}

.wiki-card .tag,
.wiki-card-tags .tag {
    display: inline-block;
    background: var(--card-border);
    color: var(--text-secondary);
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 10px;
    transition: background 0.3s ease, color 0.3s ease;
}

.wiki-card > .tag { margin-top: 4px; align-self: flex-start; }

[data-theme="night"] .wiki-card .tag,
[data-theme="night"] .wiki-card-tags .tag { background: rgba(var(--primary-rgb), 0.15); }

[data-theme="afternoon"] .wiki-card .tag,
[data-theme="afternoon"] .wiki-card-tags .tag { background: rgba(var(--primary-rgb), 0.12); }

/* The group of category chips at the foot of a card */
.wiki-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

/* ===== Search box ===== */

.wiki-search {
    width: 100%;
    max-width: 880px;
    margin: 4px 0 16px;
    display: flex;
    gap: 10px;
}

.wiki-search input {
    flex: 1;
    min-width: 0;
    padding: 12px 20px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 30px;
    transition: border-color 0.3s ease, background 0.5s ease, color 0.5s ease;
}

.wiki-search input::placeholder { color: var(--text-secondary); opacity: 0.6; }
.wiki-search input:focus { outline: none; border-color: rgba(var(--primary-rgb), 0.55); }

.wiki-search button {
    padding: 12px 26px;
    font-size: 15px;
    font-family: inherit;
    font-weight: 500;
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.3s ease, background 0.5s ease;
}

.wiki-search button:hover { opacity: 0.88; }

/* ===== Category chip bar (shared by the index, category and all-pages views) ===== */

.wiki-cats {
    width: 100%;
    max-width: 880px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 18px;
}

.wiki-cat {
    display: inline-block;
    padding: 5px 14px;
    font-size: 13px;
    text-decoration: none;
    color: var(--text-secondary);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    transition: color 0.3s ease, border-color 0.3s ease, background 0.5s ease;
}

.wiki-cat:hover { color: var(--primary); border-color: rgba(var(--primary-rgb), 0.45); }
.wiki-cat.active { color: #fff; background: var(--primary); border-color: var(--primary); }
.wiki-cat .count { opacity: 0.55; margin-left: 5px; }

/* Section heading — the "All pages", "Categories" style dividers */
.wiki-section-title {
    width: 100%;
    max-width: 880px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 6px 0 10px;
    transition: color 0.5s ease;
}

/* Compact list used by the all-pages index */
.wiki-index {
    width: 100%;
    max-width: 880px;
    list-style: none;
    padding: 0;
    margin: 0 0 22px;
}

.wiki-index li {
    padding: 9px 0;
    border-bottom: 1px solid var(--card-border);
    font-size: 15px;
}

.wiki-index li:last-child { border-bottom: none; }

.wiki-index a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.5s ease;
}
.wiki-index a:hover { text-decoration: underline; }

.wiki-index .desc {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    opacity: 0.7;
    margin-top: 3px;
    line-height: 1.5;
}

/* Search results */
.wiki-hits {
    width: 100%;
    max-width: 880px;
    list-style: none;
    padding: 0;
    margin: 0 0 20px;
}

.wiki-hit {
    display: block;
    padding: 14px 16px;
    margin-bottom: 10px;
    text-decoration: none;
    color: inherit;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    transition: border-color 0.3s ease, background 0.5s ease;
}
.wiki-hit:hover { border-color: rgba(var(--primary-rgb), 0.4); }

.wiki-hit .hit-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    transition: color 0.5s ease;
}

.wiki-hit .hit-where {
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.55;
    margin-left: 8px;
    font-weight: 400;
}

.wiki-hit .hit-snippet {
    font-size: 13px;
    color: var(--text-secondary);
    opacity: 0.8;
    line-height: 1.6;
    margin-top: 5px;
}

/* ===== Two-column wiki layout (sticky left sidebar) =====
   Wikipedia's Vector layout: a left column that stays put while the article
   scrolls, and the article beside it. On an article page the sidebar carries
   that article's Contents; on every page it also carries the article and
   category lists, so you can navigate without going back to the index. */

.wiki-layout {
    width: 100%;
    max-width: 1080px;
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 30px;
    align-items: start;
}

.wiki-sidebar {
    position: sticky;
    /* clears the sticky navbar (which is roughly 70px tall when scrolled) */
    top: 88px;
    /* long sidebars scroll internally rather than running off the viewport */
    max-height: calc(100vh - 110px);
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.5;
    /* the scrollbar in a narrow column is noise */
    scrollbar-width: thin;
    transition: color 0.5s ease;
}

.wiki-main { min-width: 0; }   /* without this, wide tables stretch the grid */

.wiki-side-block { margin-bottom: 22px; }

.wiki-side-title {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
    opacity: 0.6;
    margin-bottom: 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--card-border);
    transition: color 0.5s ease, border-color 0.5s ease;
}

.wiki-side-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.wiki-side-list li { margin: 2px 0; }

.wiki-side-list a {
    display: block;
    padding: 4px 9px;
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease, background 0.3s ease;
}

.wiki-side-list a:hover {
    color: var(--primary);
    background: rgba(var(--primary-rgb), 0.08);
}

/* The current page, marked the way Wikipedia marks it */
.wiki-side-list a.here {
    color: var(--primary);
    background: rgba(var(--primary-rgb), 0.12);
    font-weight: 500;
}

.wiki-side-list .n {
    float: right;
    opacity: 0.45;
    font-size: 12px;
}

/* ===== Contents box, now living in the sidebar ===== */

.wiki-toc .toc ul {
    margin: 0;
    padding-left: 1.1em;
    list-style: none;
}
.wiki-toc .toc > ul { padding-left: 0; }
.wiki-toc li { margin: 3px 0; }

.wiki-toc a {
    display: block;
    padding: 3px 8px;
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease, background 0.3s ease;
}
.wiki-toc a:hover { color: var(--primary); background: rgba(var(--primary-rgb), 0.08); }

/* Section numbers (1 / 1.1 / 2 …) from CSS counters, so the Markdown source
   stays free of them and renumbering after an edit is automatic.
   Scoped to .wiki-toc so the article and category lists are not numbered. */
.wiki-toc ul { counter-reset: toc-num; }
.wiki-toc li { counter-increment: toc-num; }
.wiki-toc li > a::before {
    content: counters(toc-num, ".") "  ";
    opacity: 0.5;
    font-size: 12px;
}

@media (max-width: 900px) {
    /* One column: the sidebar collapses above the content, scrolls normally */
    .wiki-layout { grid-template-columns: 1fr; gap: 20px; }
    .wiki-sidebar { position: static; max-height: none; overflow: visible; }
}

/* Generic notice card */
.notice-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-card);
    padding: 20px 28px;
    box-shadow: var(--shadow-sm);
    font-size: 13px;
    color: var(--text-secondary);
    opacity: 0.7;
    text-align: center;
    transition: background 0.5s ease, border-color 0.5s ease, color 0.5s ease;
}

.notice-card code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: rgba(var(--primary-rgb), 0.12);
    padding: 0.1em 0.4em;
    border-radius: 4px;
}

@media (max-width: 600px) {
    .wiki-grid { grid-template-columns: 1fr; gap: 12px; }
    .wiki-card { padding: 20px 18px; }
    .wiki-search { flex-direction: column; }
    .wiki-search button { width: 100%; }
}

