/* ==========================================================================
   Framework Docs — dimmed dark stylesheet
   Palette derived from Framework\Utils\Color
   ========================================================================== */

:root {
    --red:          #e8384f;
    --orange:       #fd612c;
    --yellow:       #eec300;
    --green:        #62d26f;
    --blue-green:   #37c5ab;
    --aqua:         #20aaea;
    --blue:         #4186e0;
    --indigo:       #7a6ff0;
    --purple:       #aa62e3;
    --magenta:      #e362e3;
    --hotpink:      #ea4e9d;
    --pink:         #fc91ad;
    --gray:         #8da3a6;

    --brand:        #4186e0;
    --brand-2:      #7a6ff0;

    --bg:           #0b1020;
    --bg-soft:      #10162a;
    --surface:      #141b31;
    --border:       #232c46;
    --text:         #e7ecf5;
    --text-soft:    #a3adc6;
    --text-faint:   #6d78a0;
    --code-bg:      #060a16;
    --code-inline:  #9d93f0;

    --sidebar-bg:   #080d1c;
    --sidebar-text: #b9c2d6;
    --sidebar-head: #6d78a0;

    --radius:       18px;
    --radius-sm:    13px;
    --shadow:       0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
    --max-w:        1160px;
    --sidebar-w:    288px;
    --font:         "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-serif:   "Noto Serif", Georgia, "Times New Roman", serif;
    --mono:         ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 90px; }

body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.25; font-weight: 700; color: var(--text); }
h1, h2, h3 { font-family: var(--font-serif); font-weight: 400; }
h1 { font-size: 36px; margin: .2rem 0 .9rem; letter-spacing: -.01em; }
h2 { font-size: 1.75rem; margin: 2.6rem 0 1rem; }
h3 { font-size: 1.32rem; margin: 1.8rem 0 .5rem; }
h2 + h3 { margin-top: 1rem; }

/* Inline class names link to their source on GitHub — a code chip with a dashed border */
a.src-link, a.src-link:hover { text-decoration: none; }
a.src-link code {
    border-style: dashed;
    border-color: rgba(65, 134, 224, .5);
    cursor: pointer;
    transition: color .13s ease, background .13s ease, border-color .13s ease;
}
a.src-link:hover code {
    color: #fff;
    background: rgba(65, 134, 224, .14);
    border-color: var(--brand);
}

code {
    font-family: var(--mono);
    font-size: .875em;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .12em .4em;
    color: var(--code-inline);
}
/* Keep inline code (like #[ConsoleCommand("name")]) from wrapping mid-token */
:not(pre) > code { white-space: nowrap; }

/* Code blocks — Prism (dark theme) handles token colors on our own surface */
pre[class*="language-"],
pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.05rem 1.15rem;
    overflow-x: auto;
    font-size: .85rem;
    line-height: 1.6;
    position: relative;
    margin: 1rem 0 1.6rem;
    text-shadow: none;
}
pre code,
pre[class*="language-"] code {
    background: none; border: 0; padding: 0; color: inherit;
    font-size: inherit; text-shadow: none;
}
:not(pre) > code[class*="language-"] { background: var(--bg-soft); }

/* Code block with a filename "folder tab" */
.code { margin: 1rem 0 1.6rem; }
.code-tab {
    display: inline-block;
    font-family: var(--mono);
    font-size: .78rem;
    color: var(--text-soft);
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-bottom: none;
    padding: .45rem .95rem .5rem;
    border-radius: var(--radius) var(--radius) 0 0;
    line-height: 1;
    margin-bottom: -1px;
    position: relative;
    z-index: 1;
}
.code pre { margin: 0; border-top-left-radius: 0; }

/* --- Top bar (mobile) --- */
.topbar {
    display: none;
    position: sticky; top: 0; z-index: 30;
    align-items: center; gap: .8rem;
    padding: .7rem 1rem;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
}
.topbar .brand-mark { font-weight: 700; color: var(--text); }
.menu-toggle {
    margin-left: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 11px;
    padding: .35rem .6rem; font-size: 1.1rem; cursor: pointer; line-height: 1;
}

/* --- Layout --- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 0 0 3rem;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar nav { padding: 1.1rem 1.1rem 0; }
/* The brand and the search stay pinned while the nav scrolls under them */
.sidebar-head {
    position: sticky; top: 0; z-index: 4;
    background: var(--sidebar-bg);
    border-bottom: 1px solid transparent;
}
.sidebar-head.is-stuck { border-bottom-color: var(--border); }
.brand-row {
    display: flex; align-items: center; gap: .5rem;
    padding: 1.15rem 1.5rem .6rem;
}
.sidebar .brand {
    display: flex; align-items: center; gap: .55rem;
    color: var(--text);
    font-family: var(--font-serif); font-weight: 400; font-size: 1.5rem;
}
.brand-logo {
    flex: 0 0 auto;
    width: 34px; height: 34px;
}
.sidebar .brand:hover { text-decoration: none; }
.sidebar .version {
    font-family: var(--font); font-size: .68rem; font-weight: 600;
    color: var(--text-faint); background: var(--bg-soft);
    border: 1px solid var(--border); border-radius: 999px; padding: .08rem .45rem;
    transition: color .13s ease, border-color .13s ease;
}
.sidebar .version:hover { color: var(--brand); border-color: var(--brand); text-decoration: none; }
.nav-group { margin-bottom: 1.3rem; }
.nav-group h4 {
    color: var(--sidebar-head);
    font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
    margin: 0 .6rem .45rem;
}
.nav-group a {
    display: block; color: var(--sidebar-text);
    padding: .32rem .6rem; border-radius: 10px; font-size: .92rem;
}
.nav-group a:hover { background: rgba(65, 134, 224, .12); color: #fff; text-decoration: none; }
.nav-group a.active {
    background: rgba(65, 134, 224, .18);
    color: #fff; font-weight: 600;
    box-shadow: inset 2px 0 0 var(--brand);
}

.content { flex: 1 1 auto; min-width: 0; }
.container { max-width: var(--max-w); margin: 0 auto; padding: 2.6rem 2.4rem 5rem; }
.prose { max-width: 820px; }
.prose p, .prose li { color: var(--text-soft); }
.lead { font-size: 1.12rem; color: var(--text-soft); }

.eyebrow {
    text-transform: uppercase; letter-spacing: .1em;
    font-size: .74rem; font-weight: 700; color: var(--brand); margin-bottom: .5rem;
}

/* --- Guide layout with the "On this page" table of contents ---
   A small left spacer nudges the article toward center against the right TOC;
   it is dropped as soon as the viewport starts squeezing the article. */
.doc {
    display: grid;
    grid-template-columns: 100px minmax(0, 760px) 200px;
    column-gap: 2.5rem;
    max-width: 1220px;
    margin: 0 auto;
    padding: 2.4rem 2.4rem 5rem;
    align-items: start;
}
.doc-main { grid-column: 2; min-width: 0; }

.toc {
    grid-column: 3;
    position: sticky;
    top: 2.4rem;
    max-height: calc(100vh - 4.8rem);
    overflow-y: auto;
}
.toc-title {
    text-transform: uppercase; letter-spacing: .08em;
    font-size: .72rem; font-weight: 700; color: var(--text-faint);
    margin: 0 0 .7rem .9rem;
}
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc li { margin: 0; }
.toc a {
    display: block; padding: .3rem 0 .3rem .9rem; margin-left: -1px;
    color: var(--text-soft); font-size: .87rem; line-height: 1.35;
    border-left: 2px solid transparent;
}
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.active { color: var(--brand); border-left-color: var(--brand); }
.toc a.lvl-3 { padding-left: 1.7rem; font-size: .83rem; }

/* Once the viewport starts squeezing the article, drop the left spacer and let
   the article + TOC center on their own so the content keeps its width. */
@media (max-width: 1490px) {
    .doc {
        grid-template-columns: minmax(0, 760px) 200px;
        justify-content: center;
    }
    .doc-main { grid-column: 1; }
    .toc { grid-column: 2; }
}

@media (max-width: 1100px) {
    .toc { display: none; }
    .doc { display: block; max-width: 820px; padding: 2.4rem 2.4rem 4rem; }
}

/* --- Hero (landing) --- */
.hero {
    background:
        radial-gradient(900px 400px at 12% -20%, rgba(122, 111, 240, .2), transparent 60%),
        radial-gradient(820px 400px at 92% -10%, rgba(32, 170, 234, .16), transparent 55%),
        var(--bg-soft);
    border-bottom: 1px solid var(--border);
}
.hero-inner { max-width: var(--max-w); margin: 0 auto; padding: 4.4rem 2.4rem 3.8rem; }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.3rem); margin: .4rem 0 1rem; letter-spacing: -.02em; }
.hero h1 .grad {
    background: linear-gradient(120deg, var(--brand), var(--brand-2) 55%, var(--purple));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { font-size: 1.18rem; color: var(--text-soft); max-width: 620px; }

.btn-row { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 1.8rem; }
.btn {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .7rem 1.25rem; border-radius: 14px;
    font-weight: 600; font-size: .95rem; border: 1px solid transparent; cursor: pointer;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }

/* --- Cards --- */
.grid { display: grid; gap: 1.1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow);
}
.card h3 { margin: .2rem 0 .4rem; font-size: 1.05rem; }
.card p { color: var(--text-soft); margin: 0; font-size: .93rem; }

.module-card { display: block; color: inherit; transition: transform .12s ease, border-color .12s ease; }
.module-card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--brand); }
.module-card .tag { display: none; }
.module-card h3 { color: var(--text); }
.module-card .count { color: var(--text-faint); font-size: .8rem; font-weight: 600; }

/* --- Tables --- */
.api-table { width: 100%; border-collapse: collapse; margin: 1rem 0 2rem; font-size: .9rem; }
.api-table th, .api-table td {
    text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--border); vertical-align: top;
}
.api-table th { color: var(--text-faint); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.api-table td:first-child { white-space: nowrap; }
.api-table code { background: none; border: 0; padding: 0; color: var(--code-inline); font-weight: 600; }
.api-table tr:hover td { background: var(--bg-soft); }
.api-table tr.group td {
    background: var(--bg-soft);
    color: var(--text);
    font-family: var(--font-serif);
    font-size: .95rem;
    font-weight: 600;
    padding-top: .75rem;
    padding-bottom: .5rem;
}
.api-table tr.group:hover td { background: var(--bg-soft); }
/* .env reference: a title + description + table per section */
.prose h3.env-title {
    font-family: var(--font-serif); font-weight: 600; font-size: 1.1rem;
    margin: 2rem 0 .4rem;
}

/* --- Callouts --- */
.note {
    border-left: 3px solid var(--brand); background: var(--bg-soft);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: .9rem 1.1rem; margin: 1.4rem 0; font-size: .92rem; color: var(--text-soft);
}
.note strong { color: var(--text); }
.note.warn { border-left-color: var(--orange); }

/* --- Copy button on code --- */
.copy-btn {
    position: absolute; top: .5rem; right: .5rem;
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text-soft); font-size: .72rem;
    padding: .22rem .55rem; border-radius: 9px; cursor: pointer;
    opacity: 0; transition: opacity .12s;
}
pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { border-color: var(--brand); color: var(--brand); }

/* --- Page nav (prev / next) --- */
.page-nav {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    margin-top: 3.5rem;
    padding-top: 1.8rem;
    border-top: 1px solid var(--border);
}
.page-nav a {
    display: inline-flex;
    flex-direction: column;
    gap: .1rem;
    color: var(--text);
}
.page-nav a:hover { text-decoration: none; }
.page-nav .dir { font-size: .78rem; font-weight: 600; color: var(--text-faint); }
.page-nav .ttl { font-weight: 600; transition: color .14s ease; }
.page-nav a:hover .ttl { color: var(--brand); }
.page-nav .next { margin-left: auto; text-align: right; align-items: flex-end; }

/* --- Back-to-top button --- */
.to-top {
    position: fixed;
    right: 1.6rem;
    bottom: 1.6rem;
    z-index: 45;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    box-shadow: var(--shadow);
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease, color .14s ease, border-color .14s ease;
}
.to-top.is-visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.to-top:hover { color: var(--brand); border-color: var(--brand); }

/* --- Responsive --- */
@media (max-width: 900px) {
    .topbar { display: flex; }
    .sidebar {
        position: fixed; top: 0; left: 0; bottom: 0;
        transform: translateX(-100%); transition: transform .22s ease;
        z-index: 40; box-shadow: 0 0 40px rgba(0, 0, 0, .5);
    }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 35; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .hero-inner { padding: 3rem 1.3rem; }
    .container { padding: 1.8rem 1.3rem 4rem; }
    .doc { padding: 1.8rem 1.3rem 4rem; }
}


/* --- Search --- */
.search-open {
    display: flex; align-items: center; gap: .5rem;
    width: calc(100% - 3rem);
    margin: 0 1.5rem .75rem;
    padding: .45rem .7rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-soft);
    color: var(--text-faint);
    font-family: var(--font);
    font-size: .88rem;
    text-align: left;
    cursor: pointer;
    transition: border-color .13s ease, color .13s ease;
}
.search-open:hover { border-color: var(--brand); color: var(--text-soft); }
.search-open span { flex: 1 1 auto; }
kbd {
    font-family: var(--font);
    font-size: .7rem;
    color: var(--text-faint);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .05rem .3rem;
    line-height: 1.5;
}

.search-dialog {
    position: fixed; inset: 0; z-index: 60;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 12vh 1rem 1rem;
    background: rgba(3, 6, 15, .66);
    backdrop-filter: blur(2px);
}
.search-dialog[hidden] { display: none; }
body.search-open-body { overflow: hidden; }
.search-panel {
    width: 100%; max-width: 640px;
    display: flex; flex-direction: column;
    max-height: 70vh;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.search-field {
    display: flex; align-items: center; gap: .6rem;
    padding: .9rem 1.1rem;
    border-bottom: 1px solid var(--border);
}
.search-field input {
    flex: 1 1 auto;
    border: 0; background: none; outline: none;
    color: var(--text);
    font-family: var(--font); font-size: 1.05rem;
}
.search-field input::placeholder { color: var(--text-faint); }

.search-results { overflow-y: auto; padding: .4rem; }
.search-results a {
    display: block;
    padding: .5rem .7rem;
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
}
/* Only the selected row is highlighted — hover moves the selection instead of
   painting a second one (see the mousemove handler in docs.js) */
.search-results a.active { background: rgba(65, 134, 224, .16); }
.sr-group {
    margin: .35rem .7rem .25rem;
    font-size: .7rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
    color: var(--text-faint);
}
.search-results .sr-title { display: block; font-size: .93rem; }
.search-results .sr-where { display: block; font-size: .76rem; color: var(--text-faint); }
.search-results .sr-text  { display: block; font-size: .78rem; color: var(--text-faint); margin-top: .15rem; }
.search-results mark { background: none; color: var(--brand); font-weight: 600; }
.search-empty { padding: 1.4rem; text-align: center; font-size: .88rem; color: var(--text-faint); }

.search-foot {
    display: flex; gap: 1.1rem;
    padding: .55rem 1.1rem;
    border-top: 1px solid var(--border);
    font-size: .74rem; color: var(--text-faint);
}
.search-foot kbd { margin-right: .25rem; }

@media (max-width: 900px) {
    .search-dialog { padding-top: 6vh; }
}