/* S3U Gate - documentation style (user guide, admin guide, maintainer reference)
 * Light / dark like the portal (same localStorage key "s3u-gate-theme"), no external files.
 * Brand: teal #0E9F8E, ink #0E1A24, slate #4A5560; fonts Space Grotesk and JetBrains Mono (fonts/, SIL OFL).
 */

@font-face { font-family: "Space Grotesk"; font-weight: 400; font-display: swap; src: url("fonts/SpaceGrotesk-Regular.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-weight: 500; font-display: swap; src: url("fonts/SpaceGrotesk-Medium.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-weight: 700; font-display: swap; src: url("fonts/SpaceGrotesk-Bold.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url("fonts/JetBrainsMono-Regular.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-display: swap; src: url("fonts/JetBrainsMono-Medium.woff2") format("woff2"); }

:root,
[data-theme="light"] {
    --teal: #0E9F8E;
    --brand: #0B7F72;              /* teal for text and links on light backgrounds (4.9:1) */
    --brand-soft: rgba(14, 159, 142, .10);
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #0E1A24;
    --muted: #4A5560;
    --border: #e4e7ec;
    --code-bg: #f2f4f7;
    --sidebar: #0E1A24;
    --sidebar-text: #B7C0C8;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
    --info: #1570ef;
    --info-bg: rgba(46, 144, 250, .10);
    --warn: #b54708;
    --warn-bg: rgba(247, 144, 9, .12);
    --danger: #d92d20;
    --danger-bg: rgba(240, 68, 56, .10);
    --tip: #0B7F72;
    --tip-bg: rgba(14, 159, 142, .10);
    --mark: rgba(253, 176, 34, .45);
}

[data-theme="dark"] {
    --brand: #2CC3AE;
    --brand-soft: rgba(14, 159, 142, .16);
    --bg: #0A141C;
    --surface: #101C26;
    --text: #E6EBEF;
    --muted: #B7C0C8;
    --border: #1f2937;
    --code-bg: #1a2233;
    --sidebar: #08111A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --info: #53b1fd;
    --info-bg: rgba(46, 144, 250, .14);
    --warn: #fdb022;
    --warn-bg: rgba(247, 144, 9, .14);
    --danger: #f97066;
    --danger-bg: rgba(240, 68, 56, .14);
    --tip: #2CC3AE;
    --tip-bg: rgba(14, 159, 142, .16);
    --mark: rgba(253, 176, 34, .35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 5rem; }

body {
    margin: 0;
    font: 16px/1.65 "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

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

code, kbd, pre, .mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: .88em; }
code { background: var(--code-bg); padding: .1em .35em; border-radius: .35rem; word-break: break-word; }
kbd { border: 1px solid var(--border); border-bottom-width: 2px; border-radius: .35rem; padding: .05em .4em; background: var(--surface); }
pre { background: #0b1020; color: #c9d4e5; padding: 1rem 1.2rem; border-radius: .8rem; overflow-x: auto; line-height: 1.5; }
pre code { background: none; padding: 0; color: inherit; }

/* ---------- layout ---------- */
.doc-topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: .8rem;
    padding: .75rem 1.5rem;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}
.doc-logo { display: flex; align-items: center; text-decoration: none; }
.doc-logo img { height: 2.25rem; width: auto; }
.doc-logo .logo-dark { display: none; }
[data-theme="dark"] .doc-logo .logo-light { display: none; }
[data-theme="dark"] .doc-logo .logo-dark { display: inline; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.doc-title { color: var(--muted); font-size: .9rem; }
.doc-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.doc-search {
    width: 14rem; padding: .4rem .7rem; border-radius: .6rem;
    border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem;
}
.doc-button {
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    border-radius: .6rem; padding: .35rem .7rem; font: inherit; font-size: .85rem; cursor: pointer; text-decoration: none;
}
.doc-button:hover, .doc-button.active { border-color: var(--brand); color: var(--brand); }

.doc-layout { display: flex; align-items: flex-start; max-width: 1400px; margin: 0 auto; }

.doc-sidebar {
    position: sticky; top: 3.6rem; width: 280px; flex-shrink: 0;
    max-height: calc(100vh - 3.6rem); overflow-y: auto;
    padding: 1.5rem 1rem 2rem 1.5rem;
}
.doc-sidebar .toc-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin: 0 0 .6rem; }
#toc a { display: block; padding: .28rem .6rem; border-radius: .5rem; color: var(--muted); text-decoration: none; font-size: .9rem; line-height: 1.35; }
#toc a.level-3 { padding-left: 1.4rem; font-size: .84rem; }
#toc a:hover { color: var(--text); background: var(--brand-soft); }
#toc a.active { color: var(--brand); background: var(--brand-soft); font-weight: 600; }
#toc a.hidden { display: none; }

.doc-content { flex: 1; min-width: 0; padding: 2rem 2.5rem 5rem; max-width: 960px; }

@media (max-width: 960px) {
    .doc-sidebar { display: none; }
    .doc-content { padding: 1.5rem 1rem 4rem; }
    .doc-search { width: 9rem; }
    .doc-title { display: none; }
}

/* phones: logo on top, search and buttons in a second row */
@media (max-width: 600px) {
    .doc-topbar { flex-wrap: wrap; padding: .6rem 1rem; }
    .doc-actions { width: 100%; margin-left: 0; }
    .doc-search { flex: 1; width: auto; min-width: 0; }
}

/* ---------- content ---------- */
.doc-hero {
    background: #0E1A24; border-left: 4px solid var(--teal);
    color: #fff; border-radius: 1.2rem; padding: 2rem 2.2rem; margin-bottom: 2rem; box-shadow: var(--shadow);
}
.doc-hero .hero-logo { display: block; height: 3.5rem; width: auto; margin: 0 0 1rem -.4rem; }
.doc-hero h1 { margin: 0 0 .4rem; font-size: 2rem; letter-spacing: -.02em; line-height: 1.2; }
.doc-hero p { margin: 0; color: #B7C0C8; font-size: 1.05rem; }
.doc-hero .meta { margin-top: 1rem; font-size: .85rem; opacity: .85; }

section.doc-section {
    background: var(--surface); border: 1px solid var(--border); border-radius: 1rem;
    padding: 1.6rem 1.9rem; margin-bottom: 1.5rem; box-shadow: var(--shadow);
}
section.doc-section.hidden { display: none; }
h2 { font-size: 1.45rem; margin: 0 0 1rem; letter-spacing: -.02em; display: flex; align-items: center; gap: .6rem; }
h2 .num { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: .6rem;
    background: var(--brand-soft); color: var(--brand); font-size: .95rem; flex-shrink: 0; }
h3 { font-size: 1.1rem; margin: 1.6rem 0 .6rem; }
h4 { font-size: .98rem; margin: 1.2rem 0 .4rem; }
p, ul, ol { margin: 0 0 .9rem; }
li { margin-bottom: .3rem; }
.muted { color: var(--muted); }

table { width: 100%; border-collapse: collapse; margin: 0 0 1rem; font-size: .92rem; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--code-bg); }
.table-wrap { overflow-x: auto; }

/* callouts */
.callout { border-radius: .8rem; padding: .85rem 1.1rem; margin: 0 0 1rem; border-left: 4px solid; }
.callout > :last-child { margin-bottom: 0; }
.callout strong:first-child { display: block; margin-bottom: .2rem; }
.callout.info { background: var(--info-bg); border-color: var(--info); }
.callout.warn { background: var(--warn-bg); border-color: var(--warn); }
.callout.danger { background: var(--danger-bg); border-color: var(--danger); }
.callout.tip { background: var(--tip-bg); border-color: var(--tip); }

/* numbered steps */
ol.steps { list-style: none; counter-reset: step; padding-left: 0; }
ol.steps > li { counter-increment: step; position: relative; padding-left: 2.6rem; margin-bottom: .9rem; }
ol.steps > li::before {
    content: counter(step); position: absolute; left: 0; top: .05rem;
    width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--teal); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem;
}
[data-theme="dark"] ol.steps > li::before { color: #04120b; }

/* screenshots and diagrams */
figure { margin: 1rem 0 1.4rem; }
figure img { display: block; max-width: 100%; height: auto; border-radius: .8rem; border: 1px solid var(--border); box-shadow: var(--shadow); cursor: zoom-in; }
figure.diagram img { background: #fff; padding: .8rem; cursor: default; }
figure.small img { max-width: min(340px, 100%); }
figcaption { font-size: .85rem; color: var(--muted); margin-top: .5rem; text-align: center; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; margin: 0 0 1rem; }
.card { border: 1px solid var(--border); border-radius: .9rem; padding: 1rem 1.1rem; background: var(--surface); text-decoration: none; color: var(--text); }
.card:hover { border-color: var(--brand); }
.card .card-title { font-weight: 700; margin-bottom: .3rem; }
.card .card-text { color: var(--muted); font-size: .9rem; }

.badge { display: inline-block; padding: .1em .6em; border-radius: 2rem; font-size: .78rem; font-weight: 600; background: var(--brand-soft); color: var(--brand); }

mark { background: var(--mark); color: inherit; border-radius: .2rem; padding: 0 .1em; }

.no-results { display: none; text-align: center; color: var(--muted); padding: 2rem; }
.no-results.visible { display: block; }

/* image zoom */
.zoom-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(5, 8, 15, .85); display: flex; align-items: center; justify-content: center; padding: 2rem; cursor: zoom-out; }
.zoom-overlay img { max-width: 100%; max-height: 100%; border-radius: .6rem; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }

.doc-footer { color: var(--muted); font-size: .85rem; text-align: center; padding: 1rem; }

@media print {
    .doc-topbar, .doc-sidebar { display: none; }
    body { background: #fff; color: #000; }
    section.doc-section { box-shadow: none; break-inside: avoid-page; }
    pre { white-space: pre-wrap; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

.doc-hero a { color: #fff; }

/* start page without sidebar */
.doc-layout > .doc-content:only-child { margin: 0 auto; }
