/* =========================================================================
   myTU PSD2 Open Banking API - documentation styles
   Modern 3-pane layout · light + dark · myTU design system
   ========================================================================= */

/* ----- Design tokens ----------------------------------------------------- */
:root {
    /* Brand */
    --brand:        #14b3ab;          /* turquoise, AA on white */
    --brand-strong: #0e928c;
    --brand-soft:   rgba(20, 179, 171, 0.12);
    --slate:        #2e3a45;          /* myTU dark slate */

    /* Light theme surfaces */
    --bg:           #ffffff;
    --bg-subtle:    #f5f7f8;
    --bg-sidebar:   #fbfcfc;
    --surface:      #ffffff;
    --surface-2:    #f3f6f7;

    /* Code panel (constant across themes) */
    --code-bg:      #1d262e;
    --code-bg-2:    #161d24;
    --code-border:  #2c3742;
    --code-fg:      #d7dee5;

    /* Text */
    --text:         #2e3a45;
    --text-muted:   #5d6b76;
    --text-faint:   #8a96a0;
    --heading:      #1f2a33;

    /* Lines & shadows */
    --border:       #e6eaed;
    --border-strong:#d4dade;
    --shadow-sm:    0 1px 2px rgba(20, 30, 40, 0.05);
    --shadow-md:    0 6px 24px rgba(20, 30, 40, 0.10);
    --shadow-lg:    0 18px 48px rgba(20, 30, 40, 0.16);

    /* Method / status colors */
    --m-get:    #2f7be0;
    --m-post:   #1f9d6b;
    --m-delete: #e0533d;
    --ok:       #1f9d6b;
    --warn:     #d98521;
    --danger:   #e0533d;
    --info:     #2f7be0;

    /* Metrics */
    --sidebar-w: 286px;
    --rail-w:    min(520px, 42vw);
    --content-max: 1320px;
    --topbar-h:  60px;
    --radius:    12px;
    --radius-sm: 8px;

    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: "JetBrains Mono", "Source Code Pro", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    color-scheme: light;
}

[data-theme="dark"] {
    --brand:        #2dd4ce;
    --brand-strong: #5fe0db;
    --brand-soft:   rgba(45, 212, 206, 0.14);

    --bg:           #161c22;
    --bg-subtle:    #1b232a;
    --bg-sidebar:   #141a20;
    --surface:      #1b232a;
    --surface-2:    #212b33;

    --code-bg:      #10161b;
    --code-bg-2:    #0c1115;
    --code-border:  #273039;
    --code-fg:      #cdd6de;

    --text:         #d4dde4;
    --text-muted:   #93a1ac;
    --text-faint:   #6c7a85;
    --heading:      #eef3f6;

    --border:       #28323b;
    --border-strong:#33404a;
    --shadow-sm:    0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md:    0 8px 28px rgba(0, 0, 0, 0.45);
    --shadow-lg:    0 20px 50px rgba(0, 0, 0, 0.55);

    --m-get:    #5aa0ff;
    --m-post:   #45c98f;
    --m-delete: #ff7a64;
    --ok:       #45c98f;
    --warn:     #eaa64a;
    --danger:   #ff7a64;
    --info:     #5aa0ff;

    color-scheme: dark;
}

/* ----- Reset ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    * { transition: none !important; }
}

body {
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--brand-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
[data-theme="dark"] a { color: var(--brand); }

img { max-width: 100%; display: block; }
ul, ol { padding-left: 1.25em; }
li { margin: 0.3em 0; }

::selection { background: var(--brand-soft); }

/* ----- Layout shell ------------------------------------------------------ */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
}

/* ----- Sidebar ----------------------------------------------------------- */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 40;
}
.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 18px 22px;
    position: sticky;
    top: 0;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    z-index: 2;
}
.sidebar__brand img { width: 30px; height: auto; }
.sidebar__brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar__brand-text b {
    font-size: 15px; font-weight: 700; color: var(--heading); letter-spacing: -0.01em;
}
.sidebar__brand-text span {
    font-size: 11px; font-weight: 600; color: var(--text-faint);
    text-transform: uppercase; letter-spacing: 0.07em;
}

.sidebar__search {
    margin: 14px 16px 6px;
}
.sidebar__search input {
    width: 100%;
    font-family: var(--font-sans);
    font-size: 13.5px;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.sidebar__search input::placeholder { color: var(--text-faint); }
.sidebar__search input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

.nav { padding: 8px 12px 40px; flex: 1; }
.nav__group { margin-top: 20px; }
.nav__group:first-child { margin-top: 8px; }
.nav__title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-faint);
    padding: 6px 12px;
}
.nav__link {
    display: block;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--text-muted);
    border-left: 2px solid transparent;
    transition: background .12s, color .12s;
    cursor: pointer;
}
.nav__link:hover {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}
.nav__link.is-active {
    color: var(--brand-strong);
    background: var(--brand-soft);
    font-weight: 600;
}
[data-theme="dark"] .nav__link.is-active { color: var(--brand); }
.nav__link.is-hidden { display: none; }

/* ----- Main column ------------------------------------------------------- */
.main { min-width: 0; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 28px;
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border);
}
.topbar__crumb {
    font-size: 13px;
    color: var(--text-faint);
    font-weight: 500;
}
.topbar__crumb b { color: var(--text-muted); font-weight: 600; }
.topbar__spacer { flex: 1; }

.env-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 11px;
}
.env-badge code { font-family: var(--font-mono); color: var(--brand-strong); font-size: 11.5px; }
[data-theme="dark"] .env-badge code { color: var(--brand); }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: background .12s, color .12s, border-color .12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.menu-btn { display: none; }

/* ----- Content & hero ---------------------------------------------------- */
.content {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 28px 120px;
}

.hero {
    padding: 56px 0 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.hero__eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--brand-strong);
    background: var(--brand-soft);
    padding: 5px 12px; border-radius: 999px;
}
[data-theme="dark"] .hero__eyebrow { color: var(--brand); }
.hero h1 {
    font-size: clamp(30px, 4vw, 42px);
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--heading);
    margin: 18px 0 14px;
}
.hero p.lead {
    font-size: 17px;
    color: var(--text-muted);
    max-width: 720px;
}
.hero__meta {
    display: flex; flex-wrap: wrap; gap: 10px; margin: 26px 0 32px;
}
.chip {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 12.5px; font-weight: 600; color: var(--text-muted);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 999px; padding: 6px 13px;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }

/* ----- Doc section (3-pane row) ------------------------------------------ */
.doc-section {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--rail-w);
    gap: 56px;
    padding: 44px 0;
    border-top: 1px solid var(--border);
    scroll-margin-top: calc(var(--topbar-h) + 16px);
}
.doc-section:first-of-type { border-top: 0; }
.doc-section--full { display: block; }
.doc-section--full .doc-section__text { max-width: 860px; }

.doc-section__aside {
    position: sticky;
    top: calc(var(--topbar-h) + 24px);
    align-self: start;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ----- Prose ------------------------------------------------------------- */
.doc-section__text > * + * { margin-top: 16px; }

h2.sect {
    font-size: 25px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--heading);
    line-height: 1.2;
}
h3.sub {
    font-size: 18px;
    font-weight: 700;
    color: var(--heading);
    margin-top: 30px !important;
    letter-spacing: -0.01em;
}
h4.minor {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 22px !important;
}
.eyebrow {
    font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--brand-strong);
}
[data-theme="dark"] .eyebrow { color: var(--brand); }

.doc-section__text p { color: var(--text-muted); }
.doc-section__text strong { color: var(--text); font-weight: 650; }
.doc-section__text ul, .doc-section__text ol { color: var(--text-muted); }
.doc-section__text li { padding-left: 2px; }

/* inline code */
code.inline {
    font-family: var(--font-mono);
    font-size: 0.86em;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--brand-strong);
    padding: 1.5px 6px;
    border-radius: 6px;
    white-space: nowrap;
}
[data-theme="dark"] code.inline { color: var(--brand); }

/* ----- Endpoint header (method + path) ----------------------------------- */
.endpoint {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-family: var(--font-mono);
    font-size: 13.5px;
}
.endpoint .path { color: var(--text); word-break: break-all; }
.endpoint .path b { color: var(--heading); font-weight: 700; }

.method {
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fff;
    padding: 3px 9px;
    border-radius: 6px;
    flex-shrink: 0;
}
.method.get    { background: var(--m-get); }
.method.post   { background: var(--m-post); }
.method.delete { background: var(--m-delete); }
.method.outline {
    background: transparent;
    border: 1px solid currentColor;
}
.method.get.outline    { color: var(--m-get); }
.method.post.outline   { color: var(--m-post); }
.method.delete.outline { color: var(--m-delete); }

/* ----- Tables ------------------------------------------------------------ */
.table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}
table.tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
table.tbl thead th {
    background: var(--surface-2);
    text-align: left;
    font-weight: 700;
    color: var(--text);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 11px 16px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
table.tbl tbody td {
    padding: 11px 16px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
table.tbl td code, table.tbl th code {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--brand-strong);
    white-space: nowrap;
}
[data-theme="dark"] table.tbl td code { color: var(--brand); }
table.tbl td b { color: var(--text); }
table.tbl ul { margin: 4px 0; padding-left: 1.1em; }

/* ----- Pills / badges ---------------------------------------------------- */
.pill {
    display: inline-flex; align-items: center;
    font-family: var(--font-sans);
    font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
    padding: 2px 8px; border-radius: 999px;
    white-space: nowrap;
}
.pill--req   { color: #fff; background: var(--m-delete); }
.pill--opt   { color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border); }
.pill--ok    { color: var(--ok);     background: color-mix(in srgb, var(--ok) 14%, transparent); }
.pill--warn  { color: var(--warn);   background: color-mix(in srgb, var(--warn) 16%, transparent); }
.pill--danger{ color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.pill--info  { color: var(--info);   background: color-mix(in srgb, var(--info) 14%, transparent); }
.pill--muted { color: var(--text-faint); background: var(--surface-2); border: 1px solid var(--border); }

.http {
    font-family: var(--font-mono);
    font-weight: 700; font-size: 12px;
    padding: 2px 7px; border-radius: 6px;
}
.http.s2 { color: var(--ok);     background: color-mix(in srgb, var(--ok) 13%, transparent); }
.http.s4 { color: var(--warn);   background: color-mix(in srgb, var(--warn) 15%, transparent); }
.http.s5 { color: var(--danger); background: color-mix(in srgb, var(--danger) 13%, transparent); }

/* ----- Callouts ---------------------------------------------------------- */
.callout {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 14px;
    color: var(--text-muted);
}
.callout__icon { flex-shrink: 0; width: 20px; height: 20px; margin-top: 1px; }
.callout strong { color: var(--text); }
.callout--note    { border-left: 3px solid var(--info);  }
.callout--warn    { border-left: 3px solid var(--warn);  }
.callout--tip     { border-left: 3px solid var(--brand); }
.callout--note    .callout__icon { color: var(--info); }
.callout--warn    .callout__icon { color: var(--warn); }
.callout--tip     .callout__icon { color: var(--brand); }

/* ----- Flow steps -------------------------------------------------------- */
.flow { display: flex; flex-direction: column; gap: 2px; margin: 8px 0; }
.flow__step {
    display: grid;
    grid-template-columns: 30px 1fr;
    gap: 14px;
    padding: 14px 0;
    position: relative;
}
.flow__step:not(:last-child)::before {
    content: "";
    position: absolute;
    left: 14px; top: 38px; bottom: -2px;
    width: 2px;
    background: var(--border);
}
.flow__num {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-weight: 700; font-size: 13px;
    z-index: 1;
}
[data-theme="dark"] .flow__num { color: var(--brand); }
.flow__body h5 { font-size: 14.5px; font-weight: 700; color: var(--heading); margin-bottom: 3px; }
.flow__body p { font-size: 13.5px; color: var(--text-muted); margin: 0 !important; }

/* ----- Code panel -------------------------------------------------------- */
.code-card {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}
.code-card__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    height: 40px;
    background: var(--code-bg-2);
    border-bottom: 1px solid var(--code-border);
}
.code-card__dots { display: flex; gap: 6px; }
.code-card__dots span { width: 10px; height: 10px; border-radius: 50%; background: #39424c; }
.code-card__label {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: #8b97a2;
    font-weight: 500;
}
.code-tabs { display: flex; gap: 2px; margin-left: auto; }
.code-tab {
    font-family: var(--font-sans);
    font-size: 12px; font-weight: 600;
    color: #8b97a2;
    background: transparent;
    border: 0;
    padding: 5px 11px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .12s, color .12s;
}
.code-tab:hover { color: #d7dee5; }
.code-tab.is-active { color: #fff; background: rgba(255,255,255,0.08); }

.copy-btn {
    margin-left: auto;
    display: inline-flex; align-items: center; gap: 6px;
    font-family: var(--font-sans);
    font-size: 11.5px; font-weight: 600;
    color: #8b97a2;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 5px 9px;
    cursor: pointer;
    transition: background .12s, color .12s, border-color .12s;
}
.code-tabs + .copy-btn { margin-left: 6px; }
.copy-btn:hover { color: #fff; background: rgba(255,255,255,0.07); }
.copy-btn svg { width: 14px; height: 14px; }
.copy-btn.copied { color: var(--brand); }

.code-card__body { position: relative; }
.code-card pre {
    margin: 0;
    overflow-x: auto;
    padding: 16px 18px;
    max-height: 560px;
}
.code-card pre code {
    font-family: var(--font-mono);
    font-size: 12.7px;
    line-height: 1.7;
    color: var(--code-fg);
    background: transparent !important;
    padding: 0 !important;
}
.code-pane { display: none; }
.code-pane.is-active { display: block; }

/* scrollbars inside code */
.code-card pre::-webkit-scrollbar { height: 9px; width: 9px; }
.code-card pre::-webkit-scrollbar-thumb { background: #3a4651; border-radius: 5px; }
.code-card pre::-webkit-scrollbar-track { background: transparent; }

/* Standalone code blocks inside prose (full-width sections) */
.code-inline-block {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.code-inline-block pre { margin: 0; padding: 16px 18px; overflow-x: auto; }
.code-inline-block pre code {
    font-family: var(--font-mono); font-size: 12.7px; line-height: 1.7; color: var(--code-fg);
    background: transparent !important; padding: 0 !important;
}

/* ASCII diagram block */
.diagram {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: var(--radius);
    padding: 18px 20px;
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}
.diagram pre {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
    color: #9fb4c2;
    white-space: pre;
}
.diagram pre b { color: var(--brand); font-weight: 600; }

/* ----- highlight.js token theme (slate) ---------------------------------- */
.hljs { color: var(--code-fg); background: transparent; }
.hljs-attr, .hljs-attribute       { color: #7fd1e8; }
.hljs-string                      { color: #9ad88c; }
.hljs-number, .hljs-literal       { color: #e6c07b; }
.hljs-keyword, .hljs-built_in     { color: #e69b6e; }
.hljs-comment                     { color: #647383; font-style: italic; }
.hljs-meta                        { color: #c792ea; }
.hljs-punctuation, .hljs-symbol   { color: #8b97a2; }
.hljs-title, .hljs-section        { color: #7fd1e8; }
.hljs-name                        { color: #e69b6e; }

/* ----- Footer ------------------------------------------------------------ */
.footer {
    border-top: 1px solid var(--border);
    margin-top: 40px;
    padding-top: 28px;
    display: flex;
    flex-wrap: wrap;
    gap: 14px 28px;
    align-items: center;
    font-size: 13px;
    color: var(--text-faint);
}
.footer b { color: var(--text-muted); }
.footer .footer__spacer { flex: 1; }

/* ----- Scroll-to-top ----------------------------------------------------- */
.to-top {
    position: fixed;
    right: 24px; bottom: 24px;
    width: 42px; height: 42px;
    border-radius: 50%;
    background: var(--brand);
    color: #04201f;
    border: 0;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    opacity: 0; pointer-events: none;
    transform: translateY(8px);
    transition: opacity .2s, transform .2s;
    z-index: 35;
}
.to-top.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
.to-top svg { width: 20px; height: 20px; }

/* ----- Sidebar backdrop (mobile) ----------------------------------------- */
.backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15, 22, 28, 0.5);
    z-index: 39;
    opacity: 0;
    transition: opacity .2s;
}

/* ----- Responsive -------------------------------------------------------- */
@media (max-width: 1180px) {
    .doc-section {
        grid-template-columns: 1fr;
        gap: 22px;
    }
    .doc-section__aside { position: static; top: auto; }
    .doc-section--full .doc-section__text { max-width: none; }
}

@media (max-width: 860px) {
    :root { --sidebar-w: 0px; }
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 300px;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }
    .backdrop.show { display: block; opacity: 1; }
    .menu-btn { display: inline-flex; }
    .content { padding: 0 18px 90px; }
    .topbar { padding: 0 16px; }
    .topbar__crumb { display: none; }
    .hero { padding: 36px 0 8px; }
}

@media (max-width: 480px) {
    .env-badge--prod { display: none; }
    .hero__meta { gap: 8px; }
}
