/* Headless Agent Guide — reading-room system (apprun.icu family).
   Warm paper, ink, hairline rules, slate-blue accent. The page body is
   Tailwind-CDN driven, so the most-used utilities are re-mapped here to
   the paper palette (specificity: one class, same as Tailwind — this
   file loads AFTER the CDN script and wins by order). */

:root {
    --primary: #33566e;
    --secondary: #2f7d5c;
    --accent: #c2361a;
    --neutral: #151515;
    --base-100: #f3f0e9;   /* page / toc background */
    --base-200: #ece8df;   /* secondary surface */
    --base-300: rgba(21,21,21,.16);  /* hairlines */
    --ink: #151515;
    --muted: #56504a;
    --faint: #6b6862;
    --paper: #f3f0e9;
    --paper-2: #ece8df;
    --card: #faf7f0;
    --line: rgba(21,21,21,.16);
    --line-strong: rgba(21,21,21,.32);
    --accent-wash: rgba(51,86,110,.10);
}

.font-canela { font-family: "Fraunces", ui-serif, Georgia, Cambria, "Times New Roman", serif; }
.font-inter { font-family: "Inter Tight", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
html { scroll-behavior: smooth; }

body {
    background: var(--base-100);
    color: var(--neutral);
}

/* ---- Tailwind utility re-maps (paper palette) ---- */
.bg-white { background-color: var(--card) !important; }
.bg-gray-50 { background-color: var(--paper-2) !important; }
.bg-gray-100 { background-color: var(--paper-2) !important; }
.bg-blue-50 { background-color: var(--accent-wash) !important; }
.bg-green-50 { background-color: rgba(47,125,92,.08) !important; }
.bg-yellow-50 { background-color: rgba(169,113,31,.08) !important; }
.bg-white\/10 { background-color: rgba(243,240,233,.12) !important; }
.text-gray-900 { color: var(--ink) !important; }
.text-gray-800 { color: var(--ink) !important; }
.text-gray-700 { color: #3d3a35 !important; }
.text-gray-600 { color: var(--muted) !important; }
.text-gray-500 { color: var(--faint) !important; }
.text-blue-600 { color: var(--primary) !important; }
.text-yellow-600 { color: #8a6409 !important; }
.text-green-600 { color: #2f7d5c !important; }
.text-red-600 { color: #b03a2e !important; }
.border-gray-300 { border-color: var(--line-strong) !important; }
.border-gray-200 { border-color: var(--line) !important; }
.border-blue-200 { border-color: rgba(51,86,110,.3) !important; }
.border-blue-300 { border-color: rgba(51,86,110,.4) !important; }
.border-yellow-300 { border-color: rgba(169,113,31,.4) !important; }
.border-green-300 { border-color: rgba(47,125,92,.4) !important; }
.shadow-sm { box-shadow: 0 1px 3px rgba(60,45,20,.10) !important; }
.shadow { box-shadow: 0 12px 32px rgba(60,45,20,.13) !important; }
.shadow-md { box-shadow: 0 12px 32px rgba(60,45,20,.13) !important; }
.shadow-lg { box-shadow: 0 24px 56px rgba(60,45,20,.20) !important; }
.divide-gray-200 > :not([hidden]) ~ :not([hidden]) { border-color: var(--line) !important; }
.backdrop-blur-sm { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

/* ---- hero: ink plate (deliberate dark contrast, family ink) ---- */
.hero-gradient {
    background: #151515;
    color: #f3f0e9;
}
.hero-gradient h1, .hero-gradient h2, .hero-gradient h3 { color: #f3f0e9; }
.hero-gradient p, .hero-gradient span, .hero-gradient li { color: #b8b3a8; }
.hero-gradient a { color: #e8a03c; }

/* ---- TOC sidebar ---- */
.toc-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: var(--base-100);
    border-right: 1px solid var(--base-300);
    overflow-y: auto;
    z-index: 1000;
    padding: 2rem 1.5rem;
}

.main-content {
    margin-left: 280px;
    min-height: 100vh;
}

.toc-link {
    display: block;
    padding: 0.5rem 0;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.875rem;
    line-height: 1.25rem;
    border-left: 2px solid transparent;
    padding-left: 0.75rem;
    transition: all 0.2s;
}

.toc-link:hover {
    color: var(--primary);
    border-left-color: var(--primary);
}

.toc-link.level-2 {
    margin-left: 1rem;
    font-size: 0.8rem;
    opacity: 0.9;
}

.toc-link.level-3 {
    margin-left: 2rem;
    font-size: 0.75rem;
    opacity: 0.8;
}

.section-divider {
    height: 1px;
    background: var(--base-300);
    margin: 3rem 0;
}

/* ---- code blocks: ink plate (dark on purpose, family ink) ---- */
.code-block {
    background: #151515;
    color: #f3f0e9;
    border-radius: 0.5rem;
    padding: 1.5rem;
    overflow-x: auto;
    font-family: "IBM Plex Mono", "Monaco", "Menlo", monospace;
    font-size: 0.875rem;
    line-height: 1.5;
}

.highlight-box {
    background: var(--accent-wash);
    border-left: 4px solid var(--primary);
    padding: 1.5rem;
    border-radius: 0.5rem;
    margin: 2rem 0;
}

.warning-box {
    background: rgba(169,113,31,.08);
    border-left: 4px solid #a9711f;
    padding: 1.5rem;
    border-radius: 0.5rem;
    margin: 2rem 0;
}

.mermaid-container {
    display: flex;
    justify-content: center;
    min-height: 300px;
    max-height: 800px;
    background: var(--card);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    padding: 30px;
    margin: 30px 0;
    box-shadow: 0 8px 25px rgba(60, 45, 20, 0.10);
    position: relative;
    overflow: hidden;
}

.mermaid-container .mermaid {
    width: 100%;
    max-width: 100%;
    height: 100%;
    cursor: grab;
    transition: transform 0.3s ease;
    transform-origin: center center;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

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

.mermaid-container .mermaid:active {
    cursor: grabbing;
}

.mermaid-container.zoomed .mermaid {
    height: 100%;
    width: 100%;
    cursor: grab;
}

.mermaid-controls {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    gap: 10px;
    z-index: 20;
    background: rgba(243, 240, 233, 0.95);
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(60, 45, 20, 0.10);
}

.mermaid-control-btn {
    background: var(--card);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--muted);
    font-size: 14px;
    min-width: 36px;
    height: 36px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mermaid-control-btn:hover {
    background: var(--paper-2);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.mermaid-control-btn:active {
    transform: scale(0.95);
}

@media (max-width: 1024px) {
    .mermaid-control-btn:not(.reset-zoom) {
        display: none;
    }
    .mermaid-controls {
        top: auto;
        bottom: 15px;
        right: 15px;
    }
}

.toc-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1100;
    width: 44px;
    height: 44px;
    background: var(--base-100);
    border: 1px solid var(--base-300);
    border-radius: 8px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: 0 2px 8px rgba(60, 45, 20, 0.10);
}

.toc-toggle-bar {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--muted);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

.toc-toggle[aria-expanded="true"] .toc-toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.toc-toggle[aria-expanded="true"] .toc-toggle-bar:nth-child(2) {
    opacity: 0;
}
.toc-toggle[aria-expanded="true"] .toc-toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.toc-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.toc-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(21, 21, 21, 0.4);
    z-index: 999;
}

.toc-backdrop.visible {
    display: block;
}

@media (max-width: 768px) {
    .toc-toggle {
        display: flex;
    }
    .toc-sidebar {
        transform: translateX(-100%);
        visibility: hidden;   /* off-canvas drawer: keep links out of tab order/a11y tree */
        box-shadow: 2px 0 12px rgba(21, 21, 21, 0.10);
    }
    .toc-sidebar.open {
        transform: translateX(0);
        visibility: visible;
    }
    .main-content {
        margin-left: 0;
    }
    .mermaid-container {
        padding: 15px;
    }
}

.toc-link:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 2px;
    color: var(--primary);
    border-left-color: var(--primary);
}

/* privacy-flow diagram (ps-*) inside the guide */
.ps-rect { fill: var(--card, #faf7f0); stroke: var(--line-strong, rgba(21,21,21,.32)); stroke-width: 1.2; }
.ps-title { font-family: "Inter Tight", -apple-system, sans-serif; font-size: 14.5px; font-weight: 600; fill: var(--ink, #151515); }
.ps-sub { font-family: "Inter Tight", -apple-system, sans-serif; font-size: 10.5px; fill: var(--muted, #56504a); }

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 640px) {
    .hero-gradient .grid {
        grid-template-columns: 1fr;
    }
    .hero-gradient h1 {
        font-size: 2.25rem;
    }
    .hero-gradient p {
        font-size: 1rem;
    }
    .hero-gradient .text-lg {
        font-size: 0.875rem;
    }
    .hero-gradient .flex-wrap a {
        font-size: 0.75rem;
        padding: 0.375rem 0.625rem;
    }
}
