/* ═══════════════════════════════════════════════════════════════
   MIMIC Documentation Theme
   A clean, dark monospace theme for mdBook.
   ═══════════════════════════════════════════════════════════════ */

:root {
    --bg: #0a0a0a;
    --bg-surface: #111111;
    --fg: #e0e0e0;
    --accent: #fb7b5a;
    --accent-dim: #c96244;
    --heading: #ffffff;
    --border: #2a2a2a;
    --border-light: #333333;
    --sidebar-width: 280px;
    --top-bar-height: 72px;
    --content-max: 860px;
    --code-bg: #161616;
    --code-border: #2a2a2a;
    --text-muted: #888888;
    --link: #fb7b5a;
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg);
    color: var(--fg);
    font-family: 'Space Mono', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.7;
    overflow-x: hidden;
    display: flex;
    min-height: 100vh;
}

#container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────── */
#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    scrollbar-width: thin;
    scrollbar-color: var(--border-light) transparent;
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }

.sidebar-header {
    padding: 32px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    font-size: 2.2rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--heading) !important;
    text-decoration: none !important;
    letter-spacing: -1px;
}

.sidebar-logo span {
    color: var(--accent);
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.sidebar-header img {
    display: none;
}

.sidebar-scrollbox {
    padding: 16px 0;
}

/* TOC Chapter Styling */
.chapter, .chapter .section {
    list-style: none;
    margin: 0;
    padding: 0;
}

.chapter li {
    margin: 0;
}

.chapter li.chapter-item a {
    color: var(--text-muted) !important;
    text-decoration: none;
    text-transform: uppercase;
    font-size: 0.82rem;
    letter-spacing: 0.5px;
    display: flex;
    align-items: flex-start;
    padding: 8px 20px;
    border-left: 2px solid transparent;
    transition: all 0.15s ease;
}

.chapter li.chapter-item a strong {
    color: var(--border-light);
    margin-right: 12px;
    font-weight: 400;
    flex-shrink: 0;
    min-width: 32px;
}

.chapter li.chapter-item a:hover {
    color: var(--fg) !important;
    background: rgba(255,255,255,0.03);
    border-left-color: var(--border-light);
}

/* Indentation for sub-sections */
.chapter .section li.chapter-item a {
    padding-left: 40px;
}

.chapter .section li.chapter-item a strong {
    min-width: 42px;
}

/* Indentation for nested sub-sections (3rd level) */
.chapter .section .section li.chapter-item a {
    padding-left: 60px;
}

.chapter .section .section li.chapter-item a strong {
    min-width: 52px;
}

.chapter li.chapter-item a.active {
    color: #ffffff !important;
    border-left-color: var(--accent);
    background: rgba(251, 123, 90, 0.06);
}

.chapter li.chapter-item a.active strong {
    color: var(--accent);
}

/* Section separators in TOC */
.chapter li.part-title {
    padding: 24px 20px 8px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent);
    font-weight: 700;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

.chapter li.part-title:first-child {
    border-top: none;
    margin-top: 0;
}

/* ── Main Content Area ────────────────────────────── */
#main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: calc(100% - var(--sidebar-width));
}

/* ── Top Bar ───────────────────────────────────────── */
.top-bar {
    height: var(--top-bar-height);
    background: rgba(10, 10, 10, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 500;
    flex-shrink: 0;
}

.top-bar-title {
    color: var(--heading);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

.icon-button {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--fg);
    padding: 6px 14px;
    text-transform: uppercase;
    font-size: 0.7rem;
    font-family: 'Space Mono', monospace;
    cursor: pointer;
    letter-spacing: 1px;
    transition: all 0.15s ease;
    text-decoration: none !important;
}

.icon-button:hover {
    border-color: var(--accent);
    color: var(--accent) !important;
    background: rgba(251, 123, 90, 0.06);
}

/* ── Content Styling ──────────────────────────────── */
#content {
    max-width: var(--content-max);
    width: 100%;
    margin: 0 auto;
    padding: 48px 40px 80px;
    flex: 1;
    overflow-x: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    color: var(--heading);
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

h1 {
    font-size: 2.2rem;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--accent);
    line-height: 1.2;
}

h1 .header {
    color: var(--heading) !important;
}

h2 {
    font-size: 1.3rem;
    margin-top: 48px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--accent);
}

h3 {
    font-size: 1.05rem;
    margin-top: 32px;
    margin-bottom: 12px;
    color: var(--fg);
}

h4 {
    font-size: 0.9rem;
    margin-top: 24px;
    margin-bottom: 8px;
    color: var(--text-muted);
}

/* Paragraphs */
p {
    margin-bottom: 16px;
    color: var(--fg);
    line-height: 1.8;
}

/* Links */
a {
    color: var(--link) !important;
    text-decoration: none;
    transition: opacity 0.15s ease;
}

a:hover {
    opacity: 0.8;
}

/* Header anchor links */
a.header {
    color: inherit !important;
}

a.header:hover {
    opacity: 1;
}

/* ── Lists ─────────────────────────────────────────── */
ul, ol {
    margin: 0 0 20px 24px;
    padding: 0;
}

li {
    margin-bottom: 6px;
    line-height: 1.7;
    color: var(--fg);
}

li p {
    margin-bottom: 4px;
}

ul li {
    list-style-type: "▸ ";
}

ul li::marker {
    color: var(--accent);
}

ol li::marker {
    color: var(--accent);
    font-weight: 700;
}

/* Nested lists */
li > ul, li > ol {
    margin-top: 4px;
    margin-bottom: 4px;
}

/* ── Code ──────────────────────────────────────────── */
code {
    font-family: 'Space Mono', monospace;
    font-size: 0.85em;
    background: var(--code-bg);
    color: var(--accent);
    padding: 2px 6px;
    border: 1px solid var(--code-border);
}

pre {
    margin: 20px 0;
    overflow-x: auto;
    max-width: 100%;
}

pre code {
    display: block;
    background: var(--code-bg);
    color: #ebdbb2;
    padding: 16px 20px;
    border: 1px solid var(--code-border);
    font-size: 0.82rem;
    line-height: 1.6;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

pre code.language-bash,
pre code.language-text,
pre code.language-shell {
    background: var(--code-bg);
    color: #ebdbb2;
}

/* ── Blockquotes ───────────────────────────────────── */
blockquote {
    border-left: 3px solid var(--accent);
    background: rgba(251, 123, 90, 0.04);
    padding: 12px 20px;
    margin: 20px 0;
}

blockquote p {
    margin-bottom: 0;
    color: var(--fg);
}

/* ── Tables ────────────────────────────────────────── */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    font-size: 0.85rem;
    overflow-x: auto;
    display: block;
}

thead {
    display: table;
    width: 100%;
    table-layout: fixed;
}

tbody {
    display: table;
    width: 100%;
    table-layout: fixed;
}

th {
    background: var(--bg-surface);
    color: var(--accent);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 1px;
    padding: 10px 16px;
    text-align: left;
    border-bottom: 2px solid var(--border-light);
    font-weight: 700;
}

td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--fg);
    vertical-align: top;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* ── Strong / Bold ─────────────────────────────────── */
strong {
    color: #ffffff;
    font-weight: 700;
}

/* ── Emphasis ──────────────────────────────────────── */
em {
    color: var(--text-muted);
    font-style: italic;
}

/* ── Horizontal Rule ───────────────────────────────── */
hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 40px 0;
}

/* ── Mermaid Diagrams ──────────────────────────────── */
.mermaid {
    text-align: center;
    margin: 32px 0;
    padding: 24px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    overflow-x: auto;
    overflow-y: hidden;
}

.mermaid svg {
    max-width: 100%;
    height: auto;
    display: inline-block;
}

/* ── Navigation Arrows ─────────────────────────────── */
.nav-wrapper {
    padding: 32px 40px;
    display: flex;
    justify-content: space-between;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.nav-chapters {
    font-size: 1.4rem;
    color: var(--border-light) !important;
    text-decoration: none;
    padding: 8px 16px;
    border: 1px solid var(--border);
    transition: all 0.15s ease;
    line-height: 1;
}

.nav-chapters:hover {
    color: var(--accent) !important;
    border-color: var(--accent);
    background: rgba(251, 123, 90, 0.06);
}

/* ── Sidebar Toggle ────────────────────────────────── */
body.sidebar-hidden #sidebar {
    transform: translateX(-100%);
}

body.sidebar-hidden #main {
    margin-left: 0;
    width: 100%;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 1080px) {
    #sidebar {
        z-index: 2000;
        transform: translateX(-100%);
    }

    #main {
        margin-left: 0 !important;
        width: 100% !important;
    }

    body.sidebar-visible #sidebar,
    body:not(.sidebar-hidden) #sidebar {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.8);
    }

    #content {
        padding: 32px 24px 60px;
    }

    .nav-wrapper {
        padding: 24px;
    }
}

@media (max-width: 600px) {
    h1 { font-size: 1.6rem; }
    h2 { font-size: 1.1rem; }

    .top-bar-title {
        display: none;
    }

    #content {
        padding: 24px 16px 48px;
    }

    pre code {
        font-size: 0.75rem;
        padding: 12px;
    }

    table {
        font-size: 0.75rem;
    }

    th, td {
        padding: 6px 10px;
    }
}

/* ── Print ─────────────────────────────────────────── */
@media print {
    #sidebar, .top-bar, .nav-wrapper { display: none; }
    #main { margin-left: 0; }
    body { background: white; color: black; }
}
