/* ==========================================================================
   bimmerlink.plebbian.com — legal + overview pages

   A document theme, not a landing page. It borrows plebbian.com's tokens
   (same brand ramp, same fonts, same two themes) but none of its components:
   three pages of prose do not need a nav rail, a command palette or a dot
   field. Everything here is layout for long-form text.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Fonts — self-hosted latin subsets, copied from plebbian.com.
   Both variable, weight 400–700. See assets/fonts/LICENSE.md
   -------------------------------------------------------------------------- */
@font-face {
    font-family: 'Archivo';
    src: url('fonts/archivo-latin-var.woff2') format('woff2-variations');
    font-weight: 400 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Space Grotesk';
    src: url('fonts/space-grotesk-latin-var.woff2') format('woff2-variations');
    font-weight: 400 700;
    font-style: normal;
    font-display: swap;
}

/* --------------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------------- */
:root {
    --blue: #3b82f6;
    --violet: #8b5cf6;
    --pink: #ec4899;
    --grad: linear-gradient(135deg, #3b82f6, #8b5cf6, #ec4899);
    --grad-btn: linear-gradient(135deg, #3b82f6, #8b5cf6);

    --font-display: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-body: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

    --radius: 14px;
    --radius-lg: 22px;
    --wrap: 46rem;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark is the default, as on the parent site. */
:root,
:root[data-theme='dark'] {
    color-scheme: dark;

    --bg-0: #0f172a;
    --bg-1: #1a1f3a;
    --surface: rgba(26, 31, 58, 0.55);
    --surface-2: rgba(30, 41, 59, 0.72);

    --line: rgba(148, 163, 184, 0.14);
    --line-strong: rgba(148, 163, 184, 0.3);

    --text-bright: #f8fafc;   /* 15.8:1 */
    --text: #e2e8f0;          /* 14.5:1 */
    --text-dim: #cbd5e1;      /* 12.0:1 */
    --text-muted: #94a3b8;    /*  7.0:1 */

    --nav-bg: rgba(15, 23, 42, 0.82);
    --shadow: 0 18px 50px rgba(2, 6, 23, 0.55);
}

:root[data-theme='light'] {
    color-scheme: light;

    --bg-0: #f4f6fb;
    --bg-1: #e9edf7;
    --surface: rgba(255, 255, 255, 0.82);
    --surface-2: rgba(255, 255, 255, 0.92);

    --line: rgba(15, 23, 42, 0.1);
    --line-strong: rgba(15, 23, 42, 0.22);

    --text-bright: #0b1220;   /* 17.9:1 */
    --text: #16213a;          /* 13.6:1 */
    --text-dim: #33415a;      /*  8.9:1 */
    --text-muted: #4a5a75;    /*  6.4:1 */

    --nav-bg: rgba(255, 255, 255, 0.88);
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.1);
}

/* Follow the OS until someone presses the toggle, which sets data-theme
   explicitly and wins from then on. */
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) {
        color-scheme: light;

        --bg-0: #f4f6fb;
        --bg-1: #e9edf7;
        --surface: rgba(255, 255, 255, 0.82);
        --surface-2: rgba(255, 255, 255, 0.92);
        --line: rgba(15, 23, 42, 0.1);
        --line-strong: rgba(15, 23, 42, 0.22);
        --text-bright: #0b1220;
        --text: #16213a;
        --text-dim: #33415a;
        --text-muted: #4a5a75;
        --nav-bg: rgba(255, 255, 255, 0.88);
        --shadow: 0 18px 50px rgba(15, 23, 42, 0.1);
    }
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 6rem;
    -webkit-text-size-adjust: 100%;
}

body {
    background:
        radial-gradient(60rem 40rem at 80% -10%, rgba(139, 92, 246, 0.16), transparent 60%),
        radial-gradient(50rem 34rem at -10% 10%, rgba(59, 130, 246, 0.14), transparent 60%),
        var(--bg-0);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

img,
svg {
    max-width: 100%;
    display: block;
}

a {
    color: var(--text-bright);
    text-decoration-color: var(--line-strong);
    text-underline-offset: 0.2em;
}

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

:focus-visible {
    outline: 2px solid var(--violet);
    outline-offset: 3px;
    border-radius: 4px;
}

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

/* --------------------------------------------------------------------------
   Skip link
   -------------------------------------------------------------------------- */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 50;
    padding: 0.7rem 1.2rem;
    background: var(--bg-1);
    color: var(--text-bright);
    border: 1px solid var(--line-strong);
    border-radius: 0 0 var(--radius) 0;
    text-decoration: none;
}

.skip-link:focus {
    left: 0;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--nav-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
}

.header-inner {
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 0.8rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--text-bright);
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-right: auto;
}

.brand img {
    width: 28px;
    height: 28px;
    border-radius: 8px;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.site-nav a {
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.92rem;
    color: var(--text-dim);
    text-decoration: none;
    border: 1px solid transparent;
}

.site-nav a:hover {
    color: var(--text-bright);
    background: var(--surface);
}

.site-nav a[aria-current='page'] {
    color: var(--text-bright);
    border-color: var(--line-strong);
    background: var(--surface);
}

.theme-toggle {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text-dim);
    cursor: pointer;
}

.theme-toggle:hover {
    color: var(--text-bright);
    border-color: var(--line-strong);
}

.theme-toggle svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

:root[data-theme='light'] .theme-toggle .icon-moon,
:root:not([data-theme]) .theme-toggle .icon-moon { display: none; }

:root[data-theme='light'] .theme-toggle .icon-sun,
:root:not([data-theme]) .theme-toggle .icon-sun { display: block; }

@media (prefers-color-scheme: light) {
    :root:not([data-theme]) .theme-toggle .icon-sun { display: none; }
    :root:not([data-theme]) .theme-toggle .icon-moon { display: block; }
}

:root[data-theme='dark'] .theme-toggle .icon-sun { display: none; }
:root[data-theme='dark'] .theme-toggle .icon-moon { display: block; }

/* --------------------------------------------------------------------------
   Page shell
   -------------------------------------------------------------------------- */
main {
    flex: 1;
    width: 100%;
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 3rem 1.5rem 4rem;
}

.eyebrow {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.9rem;
}

h1 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5.5vw, 2.9rem);
    line-height: 1.12;
    letter-spacing: -0.03em;
    color: var(--text-bright);
}

h2 {
    font-family: var(--font-display);
    font-size: 1.32rem;
    line-height: 1.25;
    letter-spacing: -0.015em;
    color: var(--text-bright);
    margin: 2.6rem 0 0.8rem;
    scroll-margin-top: 6rem;
}

h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    color: var(--text-bright);
    margin: 1.6rem 0 0.5rem;
}

p { margin-bottom: 1rem; }

.lede {
    font-size: 1.1rem;
    color: var(--text-dim);
    margin-top: 1rem;
}

.updated {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 1.2rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--line);
}

ul, ol {
    margin: 0 0 1.1rem 1.3rem;
}

li { margin-bottom: 0.45rem; }

strong { color: var(--text-bright); }

code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    padding: 0.12em 0.4em;
    border-radius: 6px;
    background: var(--surface-2);
    border: 1px solid var(--line);
}

/* Numbered section headings, without hand-typed numbers. */
.doc { counter-reset: section; }

.doc h2 {
    counter-increment: section;
    display: flex;
    gap: 0.7rem;
    align-items: baseline;
}

.doc h2::before {
    content: counter(section);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--violet);
    flex: none;
}

/* --------------------------------------------------------------------------
   Cards, callouts, tables
   -------------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1.4rem 1.5rem;
    box-shadow: var(--shadow);
    margin: 1.6rem 0;
}

.card h2 { margin-top: 0; }

.card ul { margin-bottom: 0; }

.callout {
    border-left: 2px solid var(--violet);
    padding: 0.15rem 0 0.15rem 1.1rem;
    margin: 1.4rem 0;
    color: var(--text-dim);
}

.callout p:last-child { margin-bottom: 0; }

.table-scroll {
    overflow-x: auto;
    margin: 1.4rem 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

table {
    border-collapse: collapse;
    width: 100%;
    min-width: 34rem;
    font-size: 0.92rem;
}

th, td {
    text-align: left;
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    font-family: var(--font-display);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--surface-2);
    white-space: nowrap;
}

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

td:first-child { color: var(--text-bright); }

.no { color: var(--text-muted); }

/* --------------------------------------------------------------------------
   Index page bits
   -------------------------------------------------------------------------- */
.doc-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.doc-link {
    display: block;
    padding: 1.3rem 1.4rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: var(--surface);
    text-decoration: none;
    transition: transform 0.3s var(--ease), border-color 0.3s var(--ease);
}

.doc-link:hover {
    transform: translateY(-2px);
    border-color: var(--line-strong);
}

.doc-link span {
    display: block;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-bright);
    margin-bottom: 0.3rem;
}

.doc-link small {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.tagline {
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.site-footer {
    border-top: 1px solid var(--line);
    padding: 2rem 1.5rem 3rem;
}

.footer-inner {
    max-width: var(--wrap);
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1.4rem;
    align-items: center;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.footer-inner nav {
    display: flex;
    gap: 1.2rem;
    margin-left: auto;
}

.footer-inner a { color: var(--text-dim); }
