/*
 * Refined theme for agentkit book.
 * Inspired by bfl.ai, linear.app/ai, and lumalabs.ai.
 * Dark-first, layered opacity text hierarchy, sage accent, generous spacing.
 */

/* ──────────────────────────────────────────────
   Google Fonts: Inter
   ────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ──────────────────────────────────────────────
   Root / global overrides
   ────────────────────────────────────────────── */

:root {
    --content-max-width: 820px;
    --code-font-size: 0.9em;
    --menu-bar-height: 52px;
    --page-padding: 20px;
    --mono-font: "Source Code Pro", "JetBrains Mono", "Fira Code", ui-monospace, Consolas, monospace;

    /* Accent palette — sage green */
    --accent: #7c9a82;
    --accent-dim: #556659;
    --accent-bright: #9ab8a0;
    --accent-subtle: rgba(124, 154, 130, 0.08);
    --accent-border: rgba(124, 154, 130, 0.15);
}

/* ──────────────────────────────────────────────
   Ayu theme overrides — refined dark palette
   ────────────────────────────────────────────── */

.ayu {
    --bg: #08090a;
    --fg: rgba(255, 255, 255, 0.85);

    --sidebar-bg: #0d0e10;
    --sidebar-fg: rgba(255, 255, 255, 0.55);
    --sidebar-non-existant: rgba(255, 255, 255, 0.25);
    --sidebar-active: var(--accent-bright);
    --sidebar-spacer: rgba(255, 255, 255, 0.06);

    --scrollbar: rgba(255, 255, 255, 0.12);

    --icons: rgba(255, 255, 255, 0.30);
    --icons-hover: rgba(255, 255, 255, 0.70);

    --links: var(--accent);

    --inline-code-color: rgba(255, 255, 255, 0.80);

    --theme-popup-bg: #111214;
    --theme-popup-border: rgba(255, 255, 255, 0.08);
    --theme-hover: rgba(255, 255, 255, 0.04);

    --quote-bg: rgba(255, 255, 255, 0.03);
    --quote-border: rgba(255, 255, 255, 0.06);

    --warning-border: #d4a447;

    --table-border-color: rgba(255, 255, 255, 0.06);
    --table-header-bg: rgba(255, 255, 255, 0.04);
    --table-alternate-bg: rgba(255, 255, 255, 0.02);

    --searchbar-border-color: rgba(255, 255, 255, 0.12);
    --searchbar-bg: #111214;
    --searchbar-fg: rgba(255, 255, 255, 0.85);
    --searchbar-shadow-color: rgba(124, 154, 130, 0.15);
    --searchresults-header-fg: rgba(255, 255, 255, 0.40);
    --searchresults-border-color: rgba(255, 255, 255, 0.08);
    --searchresults-li-bg: rgba(255, 255, 255, 0.04);
    --search-mark-bg: rgba(124, 154, 130, 0.25);

    --color-scheme: dark;

    --copy-button-filter: invert(100%) sepia(0%) saturate(0%) brightness(100%) opacity(0.3);
    --copy-button-filter-hover: invert(100%) sepia(0%) saturate(0%) brightness(100%) opacity(0.7);

    --footnote-highlight: var(--accent);
    --overlay-bg: rgba(0, 0, 0, 0.6);

    --blockquote-note-color: #6ba3d6;
    --blockquote-tip-color: var(--accent);
    --blockquote-important-color: #b8a0d6;
    --blockquote-warning-color: #d4a447;
    --blockquote-caution-color: #c4605a;

    --sidebar-header-border-color: var(--accent-dim);
}

/* ──────────────────────────────────────────────
   Typography
   ────────────────────────────────────────────── */

html {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

body {
    font-size: 1.6rem;
    letter-spacing: 0.005em;
}

.content p {
    line-height: 1.7;
    margin-block-end: 1.2em;
    color: rgba(255, 255, 255, 0.75);
}

.content ol,
.content ul {
    line-height: 1.7;
    margin-block-end: 1em;
    color: rgba(255, 255, 255, 0.75);
}

.content li + li {
    margin-block-start: 0.3em;
}

.content a:link {
    color: var(--accent);
    text-decoration: none;
    transition: color 250ms ease;
}

.content a:visited {
    color: var(--accent);
}

.content a:hover {
    color: var(--accent-bright);
    text-decoration: none;
}

/* ──────────────────────────────────────────────
   Headings
   ────────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
    letter-spacing: -0.02em;
}

h1 {
    font-size: 2.8rem;
    line-height: 1.15;
    margin-block-end: 1em;
    padding-block-end: 0.4em;
    border-block-end: 1px solid rgba(255, 255, 255, 0.06);
    letter-spacing: -0.03em;
}

h2 {
    font-size: 2.1rem;
    line-height: 1.2;
    margin-block-start: 3em;
    margin-block-end: 0.75em;
    padding-block-end: 0.3em;
    border-block-end: 1px solid rgba(255, 255, 255, 0.04);
}

h3 {
    font-size: 1.7rem;
    line-height: 1.25;
    margin-block-start: 2.5em;
    margin-block-end: 0.6em;
}

h4, h5, h6 {
    font-size: 1.5rem;
    line-height: 1.3;
    margin-block-start: 2em;
    margin-block-end: 0.5em;
}

/* ──────────────────────────────────────────────
   Code blocks
   ────────────────────────────────────────────── */

pre {
    margin-block: 1.5em;
    border-radius: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

pre > code {
    padding: 1.2rem 1.4rem;
    line-height: 1.65;
    font-size: var(--code-font-size);
    tab-size: 4;
    -moz-tab-size: 4;
}

.ayu pre > .hljs,
.ayu .hljs {
    background: #0d0e12;
    border-radius: 8px;
}

/* remove the old ayu override border — we handle it on `pre` now */
.ayu pre > .hljs {
    border: none;
}

/* Syntax colors — desaturated and refined */
.ayu .hljs {
    color: rgba(255, 255, 255, 0.70);
}

.ayu .hljs-comment,
.ayu .hljs-quote {
    color: rgba(255, 255, 255, 0.28);
}

.ayu .hljs-variable,
.ayu .hljs-template-variable,
.ayu .hljs-attribute,
.ayu .hljs-attr,
.ayu .hljs-tag,
.ayu .hljs-name,
.ayu .hljs-regexp,
.ayu .hljs-link,
.ayu .hljs-selector-id,
.ayu .hljs-selector-class {
    color: #c4605a;
}

.ayu .hljs-number,
.ayu .hljs-meta,
.ayu .hljs-built_in,
.ayu .hljs-builtin-name,
.ayu .hljs-literal,
.ayu .hljs-type,
.ayu .hljs-params {
    color: #d4a447;
}

.ayu .hljs-string,
.ayu .hljs-symbol,
.ayu .hljs-bullet {
    color: #7c9a82;
}

.ayu .hljs-title,
.ayu .hljs-section {
    color: #6ba3d6;
}

.ayu .hljs-keyword,
.ayu .hljs-selector-tag {
    color: #b8a0d6;
}

.ayu .hljs-addition {
    color: #7c9a82;
    background-color: rgba(124, 154, 130, 0.08);
}

.ayu .hljs-deletion {
    color: #c4605a;
    background-color: rgba(196, 96, 90, 0.08);
}

/* ──────────────────────────────────────────────
   Inline code
   ────────────────────────────────────────────── */

:not(pre):not(a) > .hljs {
    padding: 0.15em 0.45em;
    border-radius: 4px;
    font-size: 0.88em;
}

.ayu :not(pre) > .hljs {
    background-color: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

/* ──────────────────────────────────────────────
   Tables
   ────────────────────────────────────────────── */

table {
    width: 100%;
    margin-block: 1.5em;
    font-size: 0.95em;
    border-radius: 8px;
    overflow: hidden;
}

table thead th,
table thead td {
    padding: 12px 20px;
    font-weight: 600;
    text-align: left;
    letter-spacing: 0.01em;
    color: rgba(255, 255, 255, 0.60);
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

table td {
    padding: 10px 20px;
    line-height: 1.5;
    border-color: rgba(255, 255, 255, 0.04);
}

.ayu table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

/* ──────────────────────────────────────────────
   Blockquotes
   ────────────────────────────────────────────── */

blockquote {
    border-radius: 6px;
    margin-block: 1.5em;
    padding: 0.6em 1.25em;
    border-block-start: none;
    border-block-end: none;
    border-inline-start: 2px solid rgba(255, 255, 255, 0.08);
}

blockquote p {
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.55);
}

/* ──────────────────────────────────────────────
   Sidebar
   ────────────────────────────────────────────── */

.sidebar {
    border-right: 1px solid rgba(255, 255, 255, 0.04);
}

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

.chapter li.chapter-item {
    line-height: 1.6em;
    margin-block-start: 0.4em;
}

.chapter li a {
    color: rgba(255, 255, 255, 0.50);
    transition: color 200ms ease;
    letter-spacing: 0.005em;
}

.chapter li a:hover {
    color: var(--accent-bright);
}

.chapter li a.active {
    color: var(--accent-bright);
    font-weight: 500;
}

.chapter li.part-title {
    color: rgba(255, 255, 255, 0.30);
    font-weight: 600;
    font-size: 0.78em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-block-start: 1.5em;
    margin-block-end: 0.3em;
    font-family: var(--mono-font);
}

.spacer {
    height: 1px;
    background-color: rgba(255, 255, 255, 0.04) !important;
    margin: 8px 0;
}

.on-this-page {
    border-inline-start-color: var(--accent-dim);
}

/* ──────────────────────────────────────────────
   Menu bar
   ────────────────────────────────────────────── */

#mdbook-menu-bar {
    background-color: rgba(8, 9, 10, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-block-end: 1px solid rgba(255, 255, 255, 0.04);
}

.menu-title {
    font-weight: 500;
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.50);
    letter-spacing: -0.01em;
}

#mdbook-menu-bar .icon-button,
#mdbook-menu-bar a {
    transition: color 200ms ease;
}

/* ──────────────────────────────────────────────
   Theme popup
   ────────────────────────────────────────────── */

.theme-popup {
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #111214;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.theme-popup .theme {
    padding: 6px 20px;
    line-height: 28px;
    transition: background-color 150ms ease;
}

.theme-popup .theme:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

/* ──────────────────────────────────────────────
   Search
   ────────────────────────────────────────────── */

#mdbook-searchbar {
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background-color: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.85);
    padding: 10px 16px;
    transition: border-color 200ms ease, box-shadow 200ms ease;
}

#mdbook-searchbar:focus,
#mdbook-searchbar.active {
    border-color: var(--accent-border);
    box-shadow: 0 0 0 3px rgba(124, 154, 130, 0.08);
}

#mdbook-searchbar::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

/* ──────────────────────────────────────────────
   Navigation arrows
   ────────────────────────────────────────────── */

.nav-chapters {
    transition: color 200ms ease, background-color 200ms ease;
}

.nav-chapters:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.mobile-nav-chapters {
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

/* ──────────────────────────────────────────────
   Code block buttons
   ────────────────────────────────────────────── */

pre > .buttons button {
    border-radius: 6px;
    border-color: rgba(255, 255, 255, 0.08);
    background-color: rgba(255, 255, 255, 0.04);
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

pre > .buttons :hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.70);
}

/* ──────────────────────────────────────────────
   Scrollbar
   ────────────────────────────────────────────── */

.ayu pre::-webkit-scrollbar {
    height: 6px;
}

.ayu pre::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}

.ayu pre::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.10);
    border-radius: 3px;
}

.ayu pre::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.18);
}

.ayu pre {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.10) transparent;
}

/* Sidebar scrollbar */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
}

/* ──────────────────────────────────────────────
   Content spacing
   ────────────────────────────────────────────── */

.content {
    padding: 0 20px 80px 20px;
}

.content main > :last-child {
    margin-block-end: 3em;
}

/* ──────────────────────────────────────────────
   Help popup
   ────────────────────────────────────────────── */

#mdbook-help-popup {
    background-color: #111214;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

#mdbook-help-popup kbd {
    background-color: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 4px;
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.04);
}

/* ──────────────────────────────────────────────
   Selection
   ────────────────────────────────────────────── */

::selection {
    background: rgba(124, 154, 130, 0.25);
    color: inherit;
}

::-moz-selection {
    background: rgba(124, 154, 130, 0.25);
    color: inherit;
}

/* ──────────────────────────────────────────────
   Smooth transitions on page load
   ────────────────────────────────────────────── */

.page-wrapper {
    background-color: #08090a;
}

/* ──────────────────────────────────────────────
   Print overrides
   ────────────────────────────────────────────── */

@media print {
    pre > code {
        white-space: pre-wrap;
        word-break: break-all;
    }

    pre {
        border: 1px solid #ccc;
    }
}
