/* ============================================
   ViSiON/3 Sysop Docs — Retro BBS Theme
   Overrides for Docsify dark.css
   ============================================ */

/* ── Color palette — ANSI base + main site palette ─ */
:root {
    /* Backgrounds — same as main site */
    --bg-primary:    #0a0a0a;
    --bg-secondary:  #111118;
    --bg-card:       #15151f;
    --bg-code:       #0d0d1a;    /* code block / pre background */
    --border-color:  #252540;
    --sidebar-width: 300px;

    /* ANSI base text colors */
    --text-primary:  #aaaaaa;   /* ANSI color 7  — light grey  */
    --text-bright:   #ffffff;   /* ANSI color 15 — bright white */
    --text-secondary: #555555;  /* ANSI color 8  — dark grey   */

    /* ANSI accent colors — match main site hue, ANSI saturation */
    --ansi-blue:     #4466ff;   /* ANSI color 9  — bright blue  (main --blue-bright) */
    --ansi-cyan:     #44ccdd;   /* ANSI color 11 — bright cyan  (main --cyan-accent) */
    --ansi-green:    #55ff55;   /* ANSI color 10 — bright green */
    --ansi-yellow:   #ffff55;   /* ANSI color 14 — bright yellow */

    --blue-dark:     #1a1a4e;
    --font-mono:     'IBM Plex Mono', 'Courier New', monospace;
}

/* ── Global reset ────────────────────────── */
* { box-sizing: border-box; }

body {
    font-family: var(--font-mono) !important;
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    font-size: 15px;
    line-height: 1.75;
}

/* Nuke Docsify dark.css defaults that bleed through */
body, .markdown-section, .content, #main {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

/* ── Sidebar ─────────────────────────────── */
.sidebar {
    background-color: var(--bg-secondary) !important;
    border-right: 1px solid var(--border-color) !important;
    padding: 0 !important;
    overflow-x: hidden;
}

/* Scanline effect on sidebar only */
.sidebar::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.08) 2px,
        rgba(0, 0, 0, 0.08) 4px
    );
    z-index: 10;
}

/* Site name / logo area */
.sidebar > h1, .app-name {
    font-family: var(--font-mono) !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    padding: 1.2rem 1rem !important;
    margin: 0 !important;
    border-bottom: 1px solid var(--border-color) !important;
    color: var(--text-bright) !important;
    letter-spacing: 0.05em;
    background-color: var(--bg-secondary) !important;
}

.app-name-link {
    color: var(--text-bright) !important;
    text-decoration: none !important;
}

.app-name-link:hover {
    color: var(--ansi-cyan) !important;
}

/* BBS key style brackets in app name */
.nav-bracket {
    color: var(--text-secondary);
    font-weight: 400;
}
.nav-key {
    color: var(--ansi-cyan);
    font-weight: 700;
}

/* Sidebar nav tree */
.sidebar-nav {
    padding: 0.5rem 0 !important;
}

.sidebar-nav ul {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    /* Never collapse any section regardless of active route */
    display: block !important;
    height: auto !important;
    overflow: visible !important;
}

.sidebar-nav > ul > li {
    margin: 0 !important;
}

/* Section headers — flat structure: * **LABEL** renders as li > p > strong */
.sidebar-nav ul > li > p,
.sidebar-nav ul > li > p > strong,
.sidebar-nav ul > li > strong {
    display: block;
    font-size: 0.7rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ansi-blue) !important;
    padding: 0.85rem 1rem 0.25rem 1rem;
    margin: 0;
    border-top: 1px solid var(--border-color);
}

/* li > p gets the padding/border; strong inside it inherits color but needs no extra padding */
.sidebar-nav ul > li > p > strong {
    padding: 0 !important;
    border: none !important;
}

.sidebar-nav ul > li:first-child > p,
.sidebar-nav ul > li:first-child > strong {
    border-top: none;
}

/* Nav links — all at same level in flat structure */
.sidebar-nav a {
    display: block;
    position: relative;
    font-size: 0.82rem !important;
    color: var(--text-primary) !important;
    text-decoration: none !important;
    padding: 0.2rem 1rem 0.2rem 1.5rem !important;
    transition: color 0.1s, background-color 0.1s;
    white-space: normal;
    overflow-wrap: break-word;
    line-height: 1.4;
}

/* CP437 code 16 — ► — BBS cursor/selector.
   Always present in the left gutter (invisible by default) so text
   position never shifts when a link becomes active. */
.sidebar-nav a::before {
    content: '►';
    position: absolute;
    left: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.6rem;
    line-height: 1;
    color: transparent;
    pointer-events: none;
    transition: color 0.1s;
}

.sidebar-nav a:hover {
    color: var(--ansi-cyan) !important;
    background-color: rgba(68, 204, 221, 0.06) !important;
}

.sidebar-nav a:hover::before {
    color: rgba(68, 204, 221, 0.35);
}

.sidebar-nav a.active {
    color: var(--ansi-cyan) !important;
    font-weight: 600 !important;
    background-color: rgba(68, 204, 221, 0.08) !important;
}

.sidebar-nav a.active::before {
    color: var(--ansi-cyan);
}

/* ── Search box ──────────────────────────── */
.search {
    border-bottom: 1px solid var(--border-color) !important;
    padding: 0.6rem 0.8rem !important;
    background-color: var(--bg-secondary) !important;
}

.search input {
    font-family: var(--font-mono) !important;
    font-size: 0.78rem !important;
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 0 !important;
    padding: 0.35rem 0.6rem !important;
    outline: none !important;
    width: 100% !important;
    transition: border-color 0.15s;
}

.search input:focus {
    border-color: var(--ansi-cyan) !important;
}

.search input::placeholder {
    color: var(--text-secondary) !important;
}

/* ── Main content area ───────────────────── */
.content {
    background-color: var(--bg-primary) !important;
    max-width: 860px;
}

section.cover, .markdown-section {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    padding: 2rem 2.5rem !important;
    max-width: 860px;
}

/* ── Typography ──────────────────────────── */
.markdown-section h1,
.markdown-section h2,
.markdown-section h3,
.markdown-section h4 {
    font-family: var(--font-mono) !important;
    color: var(--text-bright) !important;
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    border: none;
}

.markdown-section h1 {
    font-size: 1.5rem !important;
    color: var(--ansi-cyan) !important;   /* ANSI bright cyan */
    border-bottom: 1px solid var(--border-color) !important;
    padding-bottom: 0.5rem;
}

.markdown-section h2 {
    font-size: 1.15rem !important;
    color: var(--ansi-blue) !important;   /* ANSI bright blue */
    border-bottom: 1px solid var(--border-color) !important;
    padding-bottom: 0.3rem;
}

.markdown-section h3 {
    font-size: 1rem !important;
    color: var(--text-bright) !important; /* ANSI bright white */
}

.markdown-section p {
    color: var(--text-primary) !important;
    margin-bottom: 1rem;
    line-height: 1.8;
}

.markdown-section strong {
    color: var(--text-bright) !important;
    font-weight: 700;
}

.markdown-section a {
    color: var(--ansi-cyan) !important;   /* ANSI bright cyan for links */
    text-decoration: none !important;
    border-bottom: 1px solid rgba(68, 204, 221, 0.3);
    transition: color 0.1s, border-color 0.1s;
}

.markdown-section a:hover {
    color: var(--text-bright) !important;
    border-bottom-color: var(--text-bright);
}

/* ── Code blocks ─────────────────────────── */
.markdown-section code {
    font-family: var(--font-mono) !important;
    font-size: 0.85em;
    background-color: var(--bg-card) !important;
    color: var(--ansi-green) !important;  /* ANSI bright green — classic terminal */
    padding: 0.15em 0.4em;
    border: 1px solid var(--border-color);
    border-radius: 0;
}

.markdown-section pre {
    background-color: var(--bg-code) !important;
    border: 1px solid var(--border-color) !important;
    border-left: 3px solid var(--ansi-cyan) !important;
    border-radius: 0 !important;
    padding: 1rem 1.25rem !important;
    overflow-x: auto;
    margin: 1.25rem 0;
}

.markdown-section pre code {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    color: var(--ansi-green) !important;  /* ANSI bright green for code blocks */
    font-size: 0.85rem;
    line-height: 1.6;
}

/* ── Tables ──────────────────────────────── */
.markdown-section table {
    border-collapse: collapse !important;
    width: 100%;
    margin: 1.25rem 0;
    font-size: 0.85rem;
}

/* Kill Docsify's zebra striping on tr — it makes text unreadable */
.markdown-section table tr,
.markdown-section table tr:nth-child(odd),
.markdown-section table tr:nth-child(even),
.markdown-section table tr:nth-child(2n) {
    background-color: transparent !important;
    color: var(--text-primary) !important;
}

.markdown-section th {
    background-color: var(--bg-card) !important;
    color: var(--ansi-blue) !important;   /* ANSI bright blue for column headers */
    font-weight: 700;
    text-align: left;
    padding: 0.5rem 0.75rem !important;
    border: 1px solid var(--border-color) !important;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-size: 0.75rem;
}

.markdown-section td {
    padding: 0.45rem 0.75rem !important;
    border: 1px solid var(--border-color) !important;
    background-color: transparent !important;
    color: var(--text-primary) !important;
    vertical-align: top;
}

/* Subtle alternate row tinting — dark only, never light */
.markdown-section tbody tr:nth-child(even) td {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

/* ── Blockquotes ─────────────────────────── */
.markdown-section blockquote {
    background-color: var(--bg-card) !important;
    border-left: 3px solid var(--ansi-yellow) !important;  /* ANSI bright yellow */
    margin: 1.25rem 0 !important;
    padding: 0.75rem 1rem !important;
    color: var(--text-primary) !important;
}

.markdown-section blockquote p {
    color: var(--text-primary) !important;
    margin: 0 !important;
}

/* ── Lists ───────────────────────────────── */
.markdown-section ul,
.markdown-section ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.markdown-section li {
    margin-bottom: 0.25rem;
    line-height: 1.75;
}

/* ── Horizontal rule ─────────────────────── */
.markdown-section hr {
    border: none !important;
    border-top: 1px solid var(--border-color) !important;
    margin: 2rem 0;
}

/* ── Navbar (top) ────────────────────────── */
.app-nav {
    background-color: var(--bg-secondary) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.app-nav a {
    font-family: var(--font-mono) !important;
    font-size: 0.8rem !important;
    color: var(--text-primary) !important;
}

.app-nav a:hover {
    color: var(--ansi-cyan) !important;
}

/* ── GitHub corner ───────────────────────── */
.github-corner svg {
    fill: var(--blue-dark) !important;
    color: var(--bg-secondary) !important;
}

.github-corner:hover svg {
    fill: var(--ansi-blue) !important;
}

/* ── Prev/Next page nav ──────────────────── */
.docsify-pagination-container {
    border-top: 1px solid var(--border-color) !important;
    margin-top: 3rem;
    padding-top: 1.5rem;
    display: flex;
    justify-content: space-between;
}

.pagination-item a {
    font-family: var(--font-mono) !important;
    font-size: 0.82rem;
    color: var(--ansi-cyan) !important;
    text-decoration: none !important;
}

.pagination-item a:hover {
    color: var(--text-bright) !important;
}

/* ── Sidebar toggle button (mobile) ──────── */
.sidebar-toggle {
    background-color: var(--bg-secondary) !important;
    border-right: 1px solid var(--border-color) !important;
}

.sidebar-toggle span {
    background-color: var(--text-secondary) !important;
}

/* ── Scrollbar ───────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--blue-dark);
}

/* ── Discord link ────────────────────────── */
.discord-link {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 1rem;
    background-color: #5865F2;
    color: #ffffff !important;
    font-family: var(--font-mono) !important;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none !important;
    border: none !important;
    border-radius: 0;
    transition: background-color 0.15s;
}

.discord-link:hover {
    background-color: #4752c4;
    color: #ffffff !important;
    border: none !important;
}

/* ── Back-to-top link ────────────────────── */
.back-to-top {
    background-color: var(--ansi-blue) !important;
    color: var(--text-bright) !important;
    border-radius: 0 !important;
}

/* ── Mobile responsive ───────────────────── */
@media (max-width: 768px) {
    .markdown-section {
        padding: 1.25rem 1rem !important;
    }

    .sidebar::after {
        width: 100vw;
    }
}
