/*
 * KeyHog docs theme - clean graphite type with restrained signal amber.
 *
 * Loaded by mdBook on top of the default light theme. Overrides
 * colors, typography, and the chrome that makes the default mdBook
 * look... a lot like every other mdBook.
 */

:root {
    /* Neutral reading palette. Greys carry hierarchy; amber carries identity. */
    --ink: #0a0a0a;
    --ink-soft: #1a1a1a;
    --grey-9: #2d2d2d;
    --grey-7: #4a4a4a;
    --grey-5: #767676;
    --grey-3: #b8b8b8;
    --grey-1: #e5e5e5;
    --grey-0: #f4f4f4;
    --paper: #fafafa;
    --paper-pure: #ffffff;

    /* Product identity. The banner and CLI use signal amber against graphite;
     * the docs keep the same cue restrained enough for long-form reading. */
    --brand: #8a6500;
    --brand-bright: #ffd60a;
    --brand-wash: #fff8d6;
    --graphite: #0d1017;
    --elevation-soft: 0 10px 30px rgb(13 16 23 / 8%);

    /* Links stay neutral so the product accent remains meaningful. */
    --rule: #d0d0d0;
    --accent-link: #0a0a0a;
    --accent-link-hover: #555555;

    /* Type. System font stack - fast, native feel. Mono for code. */
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
                 "Helvetica Neue", Helvetica, Arial, sans-serif;
    --font-mono: "JetBrains Mono", "SF Mono", "Menlo", "Monaco",
                 "Consolas", "Liberation Mono", "Courier New", monospace;
}

.keyhog {
    --bg: var(--paper-pure);
    --fg: var(--ink);
    --sidebar-bg: var(--paper);
    --sidebar-fg: var(--grey-7);
    --sidebar-non-existant: var(--grey-3);
    --sidebar-active: var(--ink);
    --sidebar-spacer: var(--rule);
    --scrollbar: var(--grey-3);

    --icons: var(--grey-7);
    --icons-hover: var(--ink);
    --links: var(--accent-link);
    --inline-code-color: var(--ink);
    --theme-popup-bg: var(--paper-pure);
    --theme-popup-border: var(--grey-3);
    --theme-hover: var(--grey-0);
    --quote-bg: var(--paper);
    --quote-border: var(--grey-7);
    --table-border-color: var(--rule);
    --table-header-bg: var(--paper);
    --table-alternate-bg: var(--paper);
    --searchbar-border-color: var(--grey-3);
    --searchbar-bg: var(--paper-pure);
    --searchbar-fg: var(--ink);
    --searchbar-shadow-color: var(--grey-3);
    --searchresults-header-fg: var(--grey-7);
    --searchresults-border-color: var(--grey-1);
    --searchresults-li-bg: var(--paper);
    --search-mark-bg: var(--grey-1);
}

/* Typography */
body, html {
    font-family: var(--font-sans);
    font-feature-settings: "ss01", "cv11";
}

.chapter, .content, .content main {
    line-height: 1.65;
    color: var(--fg);
}

.content h1,
.content h2,
.content h3,
.content h4,
.content h5,
.content h6 {
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.content h1 {
    font-size: 2rem;
    margin-top: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--rule);
}

.content h2 {
    font-size: 1.4rem;
    margin-top: 2.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--grey-1);
}

.content h3 {
    font-size: 1.15rem;
    margin-top: 2rem;
}

/* Links - black with a thin underline. Hover lightens the underline,
 * doesn't change the text. Avoids the typical bright-blue-everywhere
 * look. */
.content a:link,
.content a:visited {
    color: var(--accent-link);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    text-decoration-color: var(--grey-3);
}

.content a:hover,
.content a:focus {
    color: var(--accent-link-hover);
    text-decoration-color: var(--ink);
}

.content a:focus-visible,
.icon-button:focus-visible,
.chapter li > a:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 3px;
    border-radius: 3px;
}

/* Inline code - slightly off-white background, no border. */
.content code {
    background: var(--grey-0);
    color: var(--ink);
    padding: 0.1em 0.35em;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: var(--font-mono);
}

/* Code blocks - no syntax highlighting color riot. Mono + grey only. */
.content pre {
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 4px;
    padding: 1em 1.2em;
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.55;
    box-shadow: 0 1px 0 rgb(13 16 23 / 4%);
    transition: border-color 160ms ease, box-shadow 160ms ease,
                transform 160ms ease;
}

.content pre:hover {
    border-color: var(--grey-3);
    box-shadow: var(--elevation-soft);
    transform: translateY(-1px);
}

.content pre > code {
    background: transparent;
    padding: 0;
    font-family: var(--font-mono);
    color: var(--ink);
}

/* Override the default syntax highlighting palette - everything stays
 * in grey-scale. Comments lighter, strings italic, keywords bold. */
.hljs {
    background: transparent !important;
    color: var(--ink) !important;
}
.hljs-comment, .hljs-quote {
    color: var(--grey-5);
    font-style: italic;
}
.hljs-keyword, .hljs-built_in, .hljs-type {
    color: var(--ink);
    font-weight: 600;
}
.hljs-string, .hljs-symbol, .hljs-attr {
    color: var(--grey-7);
    font-style: italic;
}
.hljs-number, .hljs-literal {
    color: var(--ink);
}
.hljs-function .hljs-title, .hljs-title.function_ {
    color: var(--ink);
    font-weight: 500;
}

/* Sidebar - minimal, sans-serif, no bullets, no clutter. */
.sidebar {
    background: var(--sidebar-bg);
    border-right: 1px solid var(--rule);
}

.sidebar .sidebar-scrollbox {
    padding: 1.5em 1em;
}

.chapter li > a {
    color: var(--sidebar-fg);
    padding: 0.3em 0.5em;
    border-radius: 3px;
    text-decoration: none;
}

.chapter li > a:hover {
    color: var(--ink);
    background: var(--grey-0);
}

.chapter li.chapter-item {
    line-height: 1.5;
    margin: 0.15em 0;
}

.chapter li.active > a {
    color: var(--sidebar-active);
    font-weight: 500;
    background: linear-gradient(90deg, var(--brand-wash), transparent 88%);
    box-shadow: inset 2px 0 0 var(--brand);
}

.sidebar .sidebar-resize-handle {
    background: var(--rule);
}

/* Top nav - flatten the icon row. */
.menu-title {
    position: relative;
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    color: var(--graphite);
    letter-spacing: 0.01em;
    overflow: hidden;
}

.menu-title::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--brand), transparent);
    transform: translateX(-125%);
    animation: keyhog-scanline 4.8s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}

#menu-bar {
    background: linear-gradient(90deg, var(--paper-pure), var(--paper) 55%, var(--paper-pure));
    border-bottom: 1px solid var(--rule);
    box-shadow: 0 1px 10px rgb(13 16 23 / 4%);
}

.icon-button {
    color: var(--icons);
}
.icon-button:hover {
    color: var(--icons-hover);
}

/* Tables - borderless inside, single rule above and below. */
.content table {
    border-collapse: collapse;
    margin: 1.5em 0;
    width: 100%;
    font-size: 0.95em;
}

.content table th,
.content table td {
    border: none;
    padding: 0.5em 0.8em;
    text-align: left;
    vertical-align: top;
}

.content table thead th {
    border-bottom: 2px solid var(--ink);
    font-weight: 600;
}

.content table tbody tr {
    border-bottom: 1px solid var(--grey-1);
    transition: background-color 140ms ease;
}

.content table tbody tr:hover {
    background: var(--brand-wash);
}

.content table tbody tr:last-child {
    border-bottom: 1px solid var(--rule);
}

/* Blockquotes - left rule, no italics, just inset prose. */
.content blockquote {
    border-left: 3px solid var(--brand);
    padding: 0.6em 1em;
    margin: 1.2em 0;
    background: var(--paper);
    color: var(--grey-9);
}

.content blockquote p:first-child {
    margin-top: 0;
}
.content blockquote p:last-child {
    margin-bottom: 0;
}

/* Horizontal rule - almost invisible. */
.content hr {
    border: none;
    border-top: 1px solid var(--rule);
    margin: 2.5em 0;
}

/* Page nav (prev/next chapter) */
.nav-chapters {
    color: var(--icons);
    border-color: var(--rule);
}
.nav-chapters:hover {
    color: var(--ink);
    background: var(--grey-0);
}

/* Search */
#searchresults a {
    border-bottom: 1px solid var(--grey-1);
}
#searchresults a:hover {
    background: var(--grey-0);
}

mark {
    background: var(--brand-wash);
    color: var(--ink);
    padding: 0 2px;
    border-radius: 2px;
}

@keyframes keyhog-scanline {
    0%, 68% { transform: translateX(-125%); opacity: 0; }
    74% { opacity: 0.8; }
    92%, 100% { transform: translateX(125%); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .menu-title::after { animation: none; }
    .content pre,
    .content table tbody tr { transition: none; }
    .content pre:hover { transform: none; }
}

/* Print - clean white with full-bleed text. */
@media print {
    .sidebar, #menu-bar, .nav-chapters { display: none; }
    .page-wrapper { margin-left: 0; }
}
