/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ============================================================= */
/* Paloma Design System tokens                                   */
/* Source: Paloma Design System (Grapefruit accent, Ink neutral) */
/* ============================================================= */
:root {
    /* --- Signature: Grapefruit --- */
    --grapefruit-500: #f36f6b; /* primary accent, CTAs, selection */
    --grapefruit-600: #dc5450; /* hover / press */
    --grapefruit-700: #b23e3b; /* darker: accessible link text */
    --grapefruit-100: #fdd6d4; /* tinted backgrounds, badges */
    --grapefruit-50: #feebea; /* row hover wash */

    /* --- Neutral core (Ink ramp) --- */
    --gray-900: #101828; /* Ink: body copy, primary CTAs */
    --gray-800: #1d2939;
    --gray-700: #344054;
    --gray-600: #475467; /* readable secondary text */
    --gray-500: #667085; /* muted text, placeholders */
    --gray-300: #d9d9d9; /* form fields, strong borders */
    --gray-200: #eaecf0; /* dividers, subtle borders */
    --gray-100: #f2f4f7; /* dashboard canvas, code wash */
    --gray-50: #f9fafb; /* subtle hover, inner tiles */
    --white: #ffffff;
    --black: #000000;

    /* --- Dashboard utility --- */
    --blue-600: #1570ef; /* action links (dashboard) */

    /* --- Semantic surfaces --- */
    --bg-surface: var(--white);
    --bg-surface-dim: var(--gray-50);
    --bg-page: var(--white);
    --bg-inverse: var(--black);

    /* --- Semantic text --- */
    --fg-primary: var(--gray-900);
    --fg-secondary: var(--gray-600);
    --fg-tertiary: var(--gray-500);
    --fg-on-dark: var(--white);
    --fg-on-dark-muted: rgba(255, 255, 255, 0.7);

    /* --- Borders --- */
    --border-subtle: var(--gray-200);
    --border-strong: var(--gray-300);

    /* --- Accent --- */
    --accent-primary: var(--grapefruit-500);
    --accent-primary-hi: var(--grapefruit-600);
    --accent-soft: var(--grapefruit-100);
    --accent-tint-bg: var(--grapefruit-50);

    /* --- Radius scale --- */
    --radius-xs: 4px;
    --radius-sm: 8px; /* buttons */
    --radius-md: 12px; /* cards */
    --radius-lg: 20px; /* chat bubble */
    --radius-xl: 24px; /* panels */
    --radius-pill: 100px;

    /* --- Shadows (never stack) --- */
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-sm:
        0 1px 3px rgba(16, 24, 40, 0.1), 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-md:
        0 4px 8px -2px rgba(16, 24, 40, 0.1), 0 2px 4px -2px rgba(16, 24, 40, 0.06);
    --shadow-lg:
        0 12px 16px -4px rgba(16, 24, 40, 0.08),
        0 4px 6px -2px rgba(16, 24, 40, 0.03);

    /* --- Motion --- */
    --ease-standard: cubic-bezier(0.2, 0.8, 0.2, 1);
    --dur-fast: 140ms;
    --dur-med: 220ms;
    --dur-slow: 420ms;

    /* --- Docs-site semantic aliases (mapped onto tokens above) --- */
    --primary-color: var(--accent-primary);
    --primary-hover: var(--accent-primary-hi);
    --link-color: var(--grapefruit-700);
    --link-hover: var(--gray-900);
    --text-color: var(--fg-primary);
    --text-light: var(--fg-secondary);
    --bg-color: var(--bg-surface);
    --bg-secondary: var(--gray-100);
    --border-color: var(--border-subtle);
    --code-bg: var(--gray-100);
    --shadow: var(--shadow-sm);

    /* --- Layout --- */
    --sidebar-width: 260px;
    --toc-width: 220px;
    --header-height: 60px;
}

body {
    font-family:
        "Satoshi",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        "Helvetica Neue",
        Arial,
        sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

/* Brand selection colour */
::selection {
    background: var(--accent-soft);
    color: var(--fg-primary);
}

/* Visually hidden for accessibility */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==================== */
/* Header               */
/* ==================== */
header {
    background: var(--bg-inverse);
    color: var(--fg-on-dark);
    padding: 0.75rem 0;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
    height: var(--header-height);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.logo-link:hover {
    text-decoration: none;
    opacity: 0.9;
}

.logo {
    height: 40px;
    width: auto;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
}

.header-nav ul {
    list-style: none;
    display: flex;
    gap: 2rem;
    margin: 0;
    padding: 0;
}

.header-nav a {
    color: var(--fg-on-dark);
    text-decoration: none;
    font-weight: 500;
    opacity: 0.85;
    transition: opacity var(--dur-fast) var(--ease-standard);
    font-size: 0.95rem;
}

.header-nav a:hover {
    opacity: 1;
    text-decoration: none;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--fg-on-dark);
    cursor: pointer;
    padding: 0.5rem;
}

/* ==================== */
/* Search               */
/* ==================== */
.search-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all var(--dur-fast) var(--ease-standard);
}

.search-trigger:hover {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
}

.search-trigger-text {
    display: none;
}

.search-shortcut {
    display: none;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-xs);
    font-family: inherit;
}

@media (min-width: 640px) {
    .search-trigger-text {
        display: inline;
    }
    .search-shortcut {
        display: inline;
    }
}

/* Search Modal */
.search-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
}

.search-modal.active {
    display: block;
}

.search-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(16, 24, 40, 0.5);
    backdrop-filter: blur(4px);
}

.search-modal-content {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    padding: 0.75rem;
}

.search-modal-header {
    position: relative;
}

.search-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
    z-index: 10;
}

.search-close:hover {
    color: var(--text-color);
}

/* Pagefind UI Overrides */
.pagefind-ui {
    --pagefind-ui-scale: 1;
    --pagefind-ui-primary: var(--accent-primary);
    --pagefind-ui-text: var(--text-color);
    --pagefind-ui-background: var(--bg-surface);
    --pagefind-ui-border: var(--border-strong);
    --pagefind-ui-tag: var(--gray-100);
    --pagefind-ui-border-width: 1px;
    --pagefind-ui-border-radius: var(--radius-sm);
    --pagefind-ui-font: inherit;
}

.pagefind-ui__search-input {
    font-size: 1rem !important;
    padding: 1rem 3rem !important;
    height: auto !important;
}

.pagefind-ui__search-clear {
    right: 0.5rem !important;
    top: 50% !important;
    transform: translateY(-50%);
}

.pagefind-ui__results-area {
    max-height: 60vh;
    overflow-y: auto;
    padding: 0 0.75rem 0.75rem !important;
}

/* ==================== */
/* Docs Layout          */
/* ==================== */
.docs-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr var(--toc-width);
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - var(--header-height) - 200px);
}

.docs-main {
    padding: 2rem;
    min-width: 0; /* Prevent overflow */
}

.docs-content {
    max-width: 800px;
}

/* ==================== */
/* Sidebar Navigation   */
/* ==================== */
.docs-sidebar {
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    padding: 1.5rem 1rem;
    border-right: 1px solid var(--border-subtle);
    background: var(--bg-surface);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-section {
    margin-bottom: 0.5rem;
}

.sidebar-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-color);
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: background var(--dur-fast) var(--ease-standard);
}

a.sidebar-section-title:hover {
    background: var(--gray-100);
    text-decoration: none;
}

a.sidebar-section-title.current {
    background: var(--accent-tint-bg);
    color: var(--accent-primary-hi);
}

.sidebar-icon {
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-links {
    list-style: none;
    padding: 0;
    margin: 0.25rem 0 0 0;
}

.sidebar-links li {
    margin: 0;
}

.sidebar-links > li > a {
    display: block;
    padding: 0.375rem 0.75rem 0.375rem 2rem;
    font-size: 0.875rem;
    color: var(--text-light);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all var(--dur-fast) var(--ease-standard);
}

.sidebar-links > li > a:hover {
    color: var(--text-color);
    background: var(--gray-100);
    text-decoration: none;
}

.sidebar-links > li > a.current {
    color: var(--accent-primary-hi);
    background: var(--accent-tint-bg);
    font-weight: 500;
}

.sidebar-sublinks {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-sublinks li a {
    display: block;
    padding: 0.25rem 0.75rem 0.25rem 2.75rem;
    font-size: 0.8125rem;
    color: var(--text-light);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all var(--dur-fast) var(--ease-standard);
}

.sidebar-sublinks li a:hover {
    color: var(--text-color);
    text-decoration: none;
}

.sidebar-sublinks li a.current {
    color: var(--accent-primary-hi);
    font-weight: 500;
}

/* ==================== */
/* Table of Contents    */
/* ==================== */
.docs-toc {
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    padding: 1.5rem 1rem;
    border-left: 1px solid var(--border-subtle);
}

.toc-container {
    position: sticky;
    top: 0;
}

.toc-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    margin: 0 0 1rem 0;
    padding: 0;
    border: none;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-list li {
    margin: 0;
}

.toc-list li.h2 {
    margin-top: 0;
}

.toc-list li.h3 {
    padding-left: 0.75rem;
}

.toc-link {
    display: block;
    padding: 0.375rem 0;
    font-size: 0.8125rem;
    color: var(--text-light);
    text-decoration: none;
    border-left: 2px solid transparent;
    padding-left: 0.75rem;
    margin-left: -0.75rem;
    transition: all var(--dur-fast) var(--ease-standard);
}

.toc-link:hover {
    color: var(--text-color);
    text-decoration: none;
}

.toc-link.active {
    color: var(--accent-primary-hi);
    border-left-color: var(--accent-primary);
    font-weight: 500;
}

/* ==================== */
/* Breadcrumbs          */
/* ==================== */
.breadcrumbs {
    margin-bottom: 1.5rem;
}

.breadcrumbs ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.875rem;
}

.breadcrumbs li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    color: var(--text-light);
}

.breadcrumbs li:not(:last-child)::after {
    content: "/";
    color: var(--border-strong);
}

.breadcrumbs a {
    color: var(--text-light);
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: var(--link-color);
    text-decoration: underline;
}

.breadcrumbs li:last-child span {
    color: var(--text-color);
    font-weight: 500;
}

/* ==================== */
/* Prev/Next Navigation */
/* ==================== */
.prev-next-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-subtle);
}

.prev-next-link {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all var(--dur-med) var(--ease-standard);
}

.prev-next-link:hover {
    border-color: var(--accent-primary);
    background: var(--gray-50);
    text-decoration: none;
}

.prev-next-link.next {
    text-align: right;
}

.prev-next-link.disabled {
    visibility: hidden;
}

.prev-next-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    margin-bottom: 0.25rem;
}

.prev-next-title {
    font-weight: 600;
    color: var(--link-color);
}

/* ==================== */
/* Typography           */
/* ==================== */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.2; /* --lh-snug */
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--text-color);
    letter-spacing: -0.02em;
}

h1 {
    font-size: 1.875rem; /* Headline XL, 30px */
    font-weight: 600;
    margin-top: 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-primary);
}

h2 {
    font-size: 1.5rem; /* Headline L, 24px */
    margin-top: 2.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border-subtle);
}

h3 {
    font-size: 1.25rem; /* Headline M, 20px */
    font-weight: 500;
}

h4 {
    font-size: 1.125rem; /* Headline S, 18px */
    font-weight: 500;
}

p {
    margin-bottom: 1.25rem;
    color: var(--text-color);
    line-height: 1.7;
}

/* Links */
a {
    color: var(--link-color);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color var(--dur-fast) var(--ease-standard);
}

a:hover {
    color: var(--link-hover);
}

/* Lists */
ul,
ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

li {
    margin-bottom: 0.5rem;
    color: var(--text-color);
    line-height: 1.7;
}

ul ul,
ol ol,
ul ol,
ol ul {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Code */
code {
    font-family: "Geist Mono", "Fira Code", "Courier New", monospace;
    background-color: var(--code-bg);
    padding: 0.2em 0.4em;
    border-radius: var(--radius-xs);
    font-size: 0.9em;
    color: var(--gray-800);
    font-weight: 500;
}

pre {
    background-color: var(--gray-900);
    border: 1px solid var(--gray-800);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    max-height: 400px;
    overflow-y: auto;
}

pre code {
    background: none;
    padding: 0;
    color: #e4e7ec;
    font-size: 0.875rem;
    font-weight: 400;
    white-space: pre-wrap;
    word-wrap: break-word;
    display: block;
    line-height: 1.6;
}

/* Blockquotes */
blockquote {
    border-left: 3px solid var(--accent-primary);
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    background-color: var(--gray-50);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

blockquote p:last-child {
    margin-bottom: 0;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-xs);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

th,
td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
}

th:last-child,
td:last-child {
    border-right: none;
}

th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tbody tr {
    background-color: var(--bg-surface);
    transition: background-color var(--dur-fast) var(--ease-standard);
}

tbody tr:nth-child(even) {
    background-color: var(--gray-50);
}

tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background-color: var(--accent-tint-bg);
}

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

/* Images */
img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin: 1.5rem 0;
}

/* ==================== */
/* Footer               */
/* ==================== */
footer {
    background-color: var(--bg-inverse);
    color: var(--fg-on-dark);
    padding: 0;
    margin-top: 4rem;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 2rem;
    display: flex;
    justify-content: space-between;
    gap: 3rem;
}

.footer-brand {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.footer-logo {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    margin: 0;
    box-shadow: none;
}

.footer-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.footer-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--fg-on-dark);
}

.footer-tagline {
    font-size: 0.875rem;
    color: var(--fg-on-dark-muted);
}

.footer-links {
    display: flex;
    gap: 4rem;
}

.footer-section h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--fg-on-dark-muted);
    margin: 0 0 1rem 0;
    font-weight: 600;
    border: none;
}

.footer-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-section li {
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: var(--fg-on-dark);
    font-weight: 400;
    font-size: 0.9rem;
    opacity: 0.9;
    transition: opacity var(--dur-fast) var(--ease-standard);
    text-decoration: none;
}

.footer-section a:hover {
    opacity: 1;
}

/* Override mailto button style in footer */
footer a[href*="mailto"] {
    background: none;
    padding: 0;
    color: var(--fg-on-dark) !important;
    font-weight: 400;
    margin: 0;
}

footer a[href*="mailto"]:hover {
    transform: none;
    background: none;
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding: 1.5rem 2rem;
    text-align: center;
}

.footer-bottom p {
    color: var(--fg-on-dark-muted);
    font-size: 0.8rem;
    margin: 0;
}

/* ==================== */
/* Responsive Design    */
/* ==================== */

/* Hide TOC on medium screens */
@media (max-width: 1100px) {
    .docs-layout {
        grid-template-columns: var(--sidebar-width) 1fr;
    }

    .docs-toc {
        display: none;
    }
}

/* Mobile: Hide sidebar by default */
@media (max-width: 768px) {
    .docs-layout {
        grid-template-columns: 1fr;
    }

    .docs-sidebar {
        display: none;
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 0;
        height: auto;
        z-index: 500;
        border-right: none;
        box-shadow: var(--shadow-lg);
    }

    .docs-sidebar.mobile-open {
        display: block;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .header-nav {
        display: none;
    }

    .mobile-menu-toggle {
        display: block;
    }

    .header-container {
        padding: 0 1rem;
    }

    .docs-main {
        padding: 1.5rem 1rem;
    }

    h1 {
        font-size: 1.625rem;
    }

    h2 {
        font-size: 1.375rem;
    }

    h3 {
        font-size: 1.125rem;
    }

    .prev-next-nav {
        grid-template-columns: 1fr;
    }

    .prev-next-link.next {
        text-align: left;
    }

    .footer-container {
        flex-direction: column;
        gap: 2rem;
        padding: 2rem 1rem;
    }

    .footer-brand {
        justify-content: center;
        text-align: center;
    }

    .footer-links {
        flex-direction: column;
        gap: 2rem;
        text-align: center;
    }

    .footer-section h4 {
        margin-bottom: 0.75rem;
    }

    /* Search modal adjustments */
    .search-modal-content {
        top: 5%;
        width: 95%;
    }
}

/* ==================== */
/* Utility Classes      */
/* ==================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.text-center {
    text-align: center;
}

.mt-0 {
    margin-top: 0;
}

.mb-0 {
    margin-bottom: 0;
}
