/* ═══════════════════════════════════════════════════════════════
   GLOVE DOCUMENTATION — Dark Transit Theme
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,300..700&family=DM+Mono:wght@400;500&display=swap');

/* ── Design tokens ── */
:root {
    --glove-bg-deep: #0a0a12;
    --glove-bg-surface: #111119;
    --glove-bg-card: rgba(20, 20, 35, 0.7);
    --glove-border: rgba(255, 255, 255, 0.06);
    --glove-border-mid: rgba(255, 255, 255, 0.09);
    --glove-cyan: #00e5ff;
    --glove-cyan-dim: rgba(0, 229, 255, 0.08);
    --glove-cyan-bright: rgba(0, 229, 255, 0.15);
    --glove-amber: #ffb800;
    --glove-amber-dim: rgba(255, 184, 0, 0.10);
    --glove-text: #e4e2ec;
    --glove-text-secondary: #8b89a0;
    --glove-text-muted: #56546a;
    --content-max-width: 800px;
    --radius: 10px;
    --radius-lg: 14px;
}

/* ── Force dark on every mdBook theme ── */
.navy, .ayu, .coal, .rust, .light {
    --bg: var(--glove-bg-deep) !important;
    --sidebar-bg: var(--glove-bg-surface) !important;
    --sidebar-fg: var(--glove-text) !important;
    --sidebar-active: var(--glove-cyan) !important;
    --fg: var(--glove-text) !important;
    --links: var(--glove-cyan) !important;
}

:root {
    font-size: 15px !important;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--glove-bg-deep) !important;
}

/* Noise overlay */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.02;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 128px 128px;
}

/* ══════════════════════════════════════════════════════════════
   TYPOGRAPHY
   ══════════════════════════════════════════════════════════════ */
body, .sidebar, .content {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif !important;
    -webkit-font-smoothing: antialiased;
    color: var(--glove-text);
}

.content main {
    max-width: var(--content-max-width);
    line-height: 1.8;
    font-size: 1.06rem;
    padding: 1rem 2.5rem;
}

.content main p {
    margin-bottom: 1.1em;
}

/* ── Headings ── */
.content main h1 {
    font-weight: 700;
    font-size: 2rem;
    letter-spacing: -0.03em;
    margin-top: 0;
    margin-bottom: 0.6em;
    padding-bottom: 0.6em;
    border-bottom: 1px solid var(--glove-border-mid);
    color: #fff;
}

.content main h2 {
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.02em;
    margin-top: 2.8rem;
    margin-bottom: 0.5em;
    color: #fff;
}

.content main h3 {
    font-weight: 600;
    font-size: 1.2rem;
    margin-top: 2rem;
    color: var(--glove-text);
}

.content main h4 {
    font-weight: 600;
    font-size: 1.05rem;
    margin-top: 1.5rem;
    color: var(--glove-text-secondary);
}

/* ── Code ── */
code, pre code {
    font-family: 'DM Mono', 'Fira Code', monospace !important;
    font-size: 0.9rem;
}

pre {
    border-radius: var(--radius) !important;
    padding: 1.3em 1.5em !important;
    background: var(--glove-bg-card) !important;
    border: 1px solid var(--glove-border-mid);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.content main p > code,
.content main li > code,
.content main td > code {
    padding: 0.15em 0.45em;
    border-radius: 5px;
    font-size: 0.88em;
    background: rgba(0, 229, 255, 0.07) !important;
    color: var(--glove-cyan) !important;
    border: 1px solid rgba(0, 229, 255, 0.08);
}

pre > code { line-height: 1.6; }

/* ══════════════════════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════════════════════ */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--glove-border-mid);
    margin: 1.8em 0;
    background: var(--glove-bg-card);
}

table thead tr {
    background: rgba(0, 229, 255, 0.06) !important;
}

table thead th {
    padding: 0.85em 1.2em;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border: none;
    border-bottom: 1px solid var(--glove-border-mid);
    color: var(--glove-cyan) !important;
    text-align: left;
}

table tbody td {
    padding: 0.8em 1.2em;
    border-bottom: 1px solid var(--glove-border);
    font-size: 0.98rem;
    line-height: 1.6;
}

table tbody tr:last-child td { border-bottom: none; }
table tbody tr:hover { background: rgba(0, 229, 255, 0.03); }
table tbody td:first-child { font-weight: 600; }

/* ══════════════════════════════════════════════════════════════
   SIDEBAR — mdBook uses a flat <ol> with .part-title dividers.
   All <li> are siblings. We use CSS to create visual hierarchy.
   ══════════════════════════════════════════════════════════════ */
.sidebar {
    background: var(--glove-bg-surface) !important;
    border-right: 1px solid var(--glove-border) !important;
}

.sidebar .sidebar-scrollbox {
    padding: 0.6rem 0.7rem 2rem 0.7rem;
    background: transparent !important;
}

.sidebar ol.chapter {
    padding: 0;
    list-style: none;
}

/* ── Section headings (GETTING STARTED, ARCHITECTURE, etc.) ── */
.sidebar .chapter li.part-title {
    font-weight: 700;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--glove-amber);
    margin: 1.4em 0 0.3em 0;
    padding: 0.55em 0.8em;
    border-radius: 0;
    background: var(--glove-amber-dim);
}

/* ── Empty spacer <li> before each section ── */
.sidebar .chapter li.chapter-item.expanded.affix {
    height: 0;
    margin: 0;
    padding: 0;
    line-height: 0;
}

/* ── Collapsible section wrapper ── */
.sidebar-section-items {
    overflow: hidden;
    max-height: 800px;
    transition: max-height 0.25s ease, opacity 0.2s ease;
    opacity: 1;
}

.sidebar-section-items.collapsed {
    max-height: 0;
    opacity: 0;
}

/* ── Chevron on section titles ── */
.section-chevron {
    display: inline-block;
    margin-right: 0.5em;
    font-size: 0.55rem;
    vertical-align: middle;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.sidebar .chapter li.part-title:hover .section-chevron {
    opacity: 1;
}

/* ── Section icon ── */
.section-icon {
    display: inline-flex;
    align-items: center;
    margin-right: 0.5em;
    vertical-align: middle;
    opacity: 0.7;
}

.section-icon svg {
    display: block;
}

/* ── All nav links ── */
.sidebar ol.chapter li.chapter-item a {
    display: block;
    padding: 0.45em 0.7em 0.45em 1.4em;
    margin: 1px 0.4em;
    border-radius: 7px;
    color: var(--glove-text-secondary) !important;
    font-size: 0.88rem;
    font-weight: 450;
    text-decoration: none;
    transition: all 0.15s ease;
    position: relative;
}

/* Hide the chapter numbers (1. 2. 3. etc.) */
.sidebar ol.chapter li.chapter-item a strong {
    display: none;
}

/* Left accent line on each item */
.sidebar ol.chapter li.chapter-item a::before {
    content: '';
    position: absolute;
    left: 0.35em;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    border-radius: 2px;
    background: var(--glove-cyan);
    opacity: 0;
    transition: all 0.2s ease;
}

/* Hover */
.sidebar ol.chapter li.chapter-item a:hover {
    background: var(--glove-cyan-dim);
    color: var(--glove-text) !important;
}

.sidebar ol.chapter li.chapter-item a:hover::before {
    height: 50%;
    opacity: 0.4;
}

/* Active page */
.sidebar ol.chapter li.chapter-item a.active {
    color: var(--glove-cyan) !important;
    font-weight: 600;
    background: var(--glove-cyan-bright);
}

.sidebar ol.chapter li.chapter-item a.active::before {
    height: 60%;
    opacity: 1;
    box-shadow: 0 0 6px rgba(0, 229, 255, 0.4);
}

/* ── Introduction (special: no number, affix) ── */
.sidebar ol.chapter li.affix:first-child a {
    font-weight: 600;
    color: var(--glove-text) !important;
    font-size: 0.92rem;
    padding-left: 0.7em;
    margin-bottom: 0.3em;
}

.sidebar ol.chapter li.affix:first-child a::before {
    display: none;
}

/* ── Blockquotes ── */
blockquote {
    border-left: 3px solid var(--glove-cyan);
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--glove-cyan-dim);
    padding: 0.9em 1.3em;
    margin: 1.5em 0;
}

blockquote p { margin: 0.3em 0; }

/* ── Links ── */
.content a {
    color: var(--glove-cyan) !important;
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 229, 255, 0.15);
    transition: border-color 0.15s ease;
}

.content a:hover {
    border-bottom-color: var(--glove-cyan);
}

/* ── Nav (previous/next) ── */
.nav-chapters {
    font-size: 0.95rem;
    opacity: 0.3;
    transition: opacity 0.2s ease;
}

.nav-chapters:hover {
    opacity: 1;
    color: var(--glove-cyan) !important;
}

/* ── Badges ── */
.content main img[src*="badge"],
.content main img[src*="shields"] {
    display: inline-block;
    margin: 0 4px 6px 0;
    vertical-align: middle;
}

/* ── Images ── */
.content main img:not([src*="badge"]):not([src*="shields"]) {
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glove-border-mid);
    margin: 1.5em 0;
    max-width: 100%;
}

/* ── Menu bar ── */
#menu-bar {
    background: var(--glove-bg-surface) !important;
    border-bottom: 1px solid var(--glove-border);
}

#menu-bar .icon-button {
    border-radius: 6px;
    color: var(--glove-text-muted) !important;
    transition: all 0.15s ease;
}

#menu-bar .icon-button:hover {
    background: var(--glove-cyan-dim);
    color: var(--glove-cyan) !important;
}

/* ── Theme selector ── */
#theme-list {
    background: var(--glove-bg-surface) !important;
    border: 1px solid var(--glove-border-mid) !important;
    border-radius: 8px;
}

/* ── Search ── */
#searchbar {
    background: var(--glove-bg-card) !important;
    border: 1px solid var(--glove-border) !important;
    border-radius: 8px !important;
    color: var(--glove-text) !important;
    font-size: 0.95rem;
    padding: 0.5em 0.9em !important;
}

#searchbar:focus {
    border-color: var(--glove-cyan) !important;
    box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.1) !important;
}

.search-results {
    background: var(--glove-bg-surface) !important;
    border: 1px solid var(--glove-border-mid) !important;
    border-radius: var(--radius) !important;
}

.search-results .search-results-item {
    border-bottom-color: var(--glove-border) !important;
}

/* ── Footer ── */
.content .page-footer {
    margin-top: 4em;
    padding-top: 1.5em;
    border-top: 1px solid var(--glove-border);
    opacity: 0.35;
    font-size: 0.8rem;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.07); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.14); }

/* ── Transitions ── */
* {
    transition-property: background-color, border-color, color, opacity;
    transition-duration: 0.15s;
    transition-timing-function: ease;
}

pre, pre *, code, .hljs, .hljs * {
    transition: none !important;
}

/* ── Admonish ── */
.admonition {
    border-radius: var(--radius) !important;
    border: 1px solid var(--glove-border-mid) !important;
    background: var(--glove-bg-card) !important;
    font-size: 1rem;
}

.admonition .admonition-title {
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
}

/* ── Bold ── */
strong {
    color: var(--glove-text);
    font-weight: 700;
}

/* ── Lists ── */
.content main ul, .content main ol { padding-left: 1.5em; }
.content main li { margin-bottom: 0.4em; line-height: 1.75; }
.content main li strong { color: var(--glove-cyan); }

/* ── HR ── */
.content main hr {
    border: none;
    height: 1px;
    background: var(--glove-border-mid);
    margin: 2.5em 0;
}

/* ── Focus ── */
*:focus-visible {
    outline: 2px solid var(--glove-cyan);
    outline-offset: 2px;
}
