/* ---------- Tokens ---------- */
:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-alt: #eef2f7;
    --text: #18212f;
    --text-muted: #5a6577;
    --border: #d9e0ea;
    --primary: #0b4f8a;
    --primary-contrast: #ffffff;
    --accent: #c77700;
    --accent-bg: #fff3df;
    --header-bg: #0d1b2e;
    --header-text: #e8eef6;
    --danger: #b42318;
    --danger-bg: #fef3f2;
    --code-bg: #0d1b2e;
    --code-text: #e6ecf4;
    --code-tag: #7cc4ff;
    --code-decl: #ffb547;
    --code-comment: #8a9bb3;
    --radius: 10px;
    --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 4px 12px rgb(16 24 40 / 6%);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
    --max-width: 1100px;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1320;
        --surface: #121c2c;
        --surface-alt: #0f1826;
        --text: #e6ecf4;
        --text-muted: #9aa7b8;
        --border: #24334a;
        --primary: #5aa9f0;
        --primary-contrast: #06121f;
        --accent: #ffb547;
        --accent-bg: #3a2a10;
        --header-bg: #070d17;
        --danger: #ff8a80;
        --danger-bg: #3b1412;
        --code-bg: #070d17;
        --shadow: none;
    }
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 1.0625rem;
    line-height: 1.6;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
}

h1, h2, h3 {
    line-height: 1.2;
    margin: 0 0 .5em;
}

h1 { font-size: clamp(2rem, 5vw, 3rem); }
h2 { font-size: 1.5rem; margin-top: 1.75em; }
h2:first-child { margin-top: 0; }
h3 { font-size: 1.125rem; }

p { margin: 0 0 1em; }

a {
    color: var(--primary);
}

img {
    max-width: 100%;
    height: auto;
}

.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 16px;
}

.container.narrow {
    max-width: 760px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- Header ---------- */
.site-header {
    background: var(--header-bg);
    color: var(--header-text);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-inner {
    display: flex;
    align-items: center;
    min-height: 60px;
    gap: 8px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.125rem;
    margin-right: auto;
}

.brand-icon {
    width: 26px;
    height: 26px;
    fill: #ffb547;
    transform: rotate(45deg);
}

.site-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 4px;
}

.site-nav a {
    display: block;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--header-text);
    text-decoration: none;
    opacity: .85;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
    opacity: 1;
    background: rgb(255 255 255 / 10%);
}

/* Language selector */
.lang-switch {
    position: relative;
}

.lang-switch summary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    list-style: none;
    font-size: .9375rem;
    font-weight: 600;
    opacity: .85;
}

.lang-switch summary::-webkit-details-marker {
    display: none;
}

.lang-switch summary:hover,
.lang-switch[open] summary {
    opacity: 1;
    background: rgb(255 255 255 / 10%);
}

.lang-icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.lang-switch ul {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 20;
    list-style: none;
    margin: 0;
    padding: 6px;
    min-width: 160px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgb(0 0 0 / 20%);
}

.lang-switch a {
    display: block;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
}

.lang-switch a:hover {
    background: var(--surface-alt);
}

.lang-switch a[aria-current] {
    font-weight: 700;
    color: var(--primary);
}

.nav-toggle {
    display: none;
    background: none;
    border: 0;
    padding: 10px;
    cursor: pointer;
    color: inherit;
}

.nav-toggle-bar,
.nav-toggle-bar::before,
.nav-toggle-bar::after {
    display: block;
    width: 22px;
    height: 2px;
    background: currentColor;
    position: relative;
}

.nav-toggle-bar::before,
.nav-toggle-bar::after {
    content: "";
    position: absolute;
    left: 0;
}

.nav-toggle-bar::before { top: -7px; }
.nav-toggle-bar::after { top: 7px; }

@media (max-width: 720px) {
    .nav-toggle {
        display: block;
    }

    .site-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--header-bg);
        padding: 8px 16px 16px;
    }

    .site-nav.open {
        display: block;
    }

    .site-nav ul {
        flex-direction: column;
    }
}

/* ---------- Sections ---------- */
.hero,
.page-header {
    background: linear-gradient(180deg, var(--header-bg) 0%, #16314f 100%);
    color: var(--header-text);
    padding: 72px 0 64px;
}

.page-header {
    padding: 56px 0 48px;
}

.hero a:not(.button),
.page-header a:not(.button) {
    color: #9fd0ff;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: .8125rem;
    font-weight: 600;
    color: #ffb547;
    margin-bottom: .75em;
}

.lead {
    font-size: 1.25rem;
    max-width: 40em;
    opacity: .9;
}

.section {
    padding: 56px 0;
}

.section-alt {
    background: var(--surface-alt);
}

/* ---------- Buttons ---------- */
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 1.5em;
}

.button {
    display: inline-block;
    padding: 12px 22px;
    border-radius: 999px;
    background: #ffb547;
    color: #1a1204;
    font-weight: 600;
    text-decoration: none;
    border: 2px solid transparent;
}

.button:hover {
    filter: brightness(1.05);
}

.button-ghost {
    background: transparent;
    color: var(--header-text);
    border-color: rgb(255 255 255 / 35%);
}

/* Outline button for light sections (ghost is for the dark header) */
.button-outline {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
}

.button-small {
    padding: 6px 14px;
    font-size: .875rem;
    font-family: inherit;
    cursor: pointer;
}

.button.copied {
    background: #3fbf7f;
    color: #04140b;
}

/* ---------- Cards ---------- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.card h3 a {
    color: inherit;
    text-decoration: none;
}

.card p:last-child {
    margin-top: auto;
    margin-bottom: 0;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    display: inline-block;
    font-size: .8125rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--surface-alt);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.tag-accent {
    background: var(--accent-bg);
    color: var(--accent);
    border-color: transparent;
}

.more {
    font-weight: 600;
    text-decoration: none;
}

.more::after {
    content: " \2192";
}

/* ---------- Content blocks ---------- */
.feature-list {
    padding-left: 1.25em;
}

.feature-list li {
    margin-bottom: .5em;
}

.notice {
    background: var(--accent-bg);
    color: var(--accent);
    border-left: 4px solid var(--accent);
    padding: 12px 16px;
    border-radius: 6px;
    font-weight: 600;
}

.page-header .notice {
    background: rgb(255 181 71 / 15%);
    color: #ffd18a;
    border-left-color: #ffb547;
    max-width: 40em;
}

/* Four nested levels of the checklist app */
.levels {
    list-style: none;
    counter-reset: level;
    margin: 1.5em 0;
    padding: 0;
}

.levels li {
    counter-increment: level;
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px 14px 60px;
    margin-bottom: 10px;
}

.levels li:nth-child(2) { margin-left: 4%; }
.levels li:nth-child(3) { margin-left: 8%; }
.levels li:nth-child(4) { margin-left: 12%; }

.levels li::before {
    content: counter(level);
    position: absolute;
    left: 16px;
    top: 14px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--primary-contrast);
    font-weight: 700;
    display: grid;
    place-items: center;
}

.levels h3 {
    margin-bottom: .2em;
}

.levels p {
    margin: 0;
    color: var(--text-muted);
}

/* Numbered how-to steps */
.steps {
    list-style: none;
    counter-reset: step;
    margin: 1.5em 0 0;
    padding: 0;
}

.steps li {
    counter-increment: step;
    position: relative;
    padding: 0 0 1.5em 52px;
}

.steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: -2px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--primary-contrast);
    font-weight: 700;
    display: grid;
    place-items: center;
}

/* Vertical line joining the step numbers */
.steps li:not(:last-child)::after {
    content: "";
    position: absolute;
    left: 16px;
    top: 38px;
    bottom: 4px;
    width: 2px;
    background: var(--border);
}

.steps h3 {
    margin-bottom: .25em;
}

.steps p {
    margin: 0;
    color: var(--text-muted);
}

/* App menu path, e.g. Menu › Import */
.ui-path {
    font-weight: 600;
    color: var(--text);
}

/* Inline code and code blocks */
code {
    font-family: var(--font-mono);
    font-size: .9em;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 4px;
}

.code-block {
    background: var(--code-bg);
    border-radius: var(--radius);
    overflow: hidden;
    margin: 1em 0;
}

.code-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 8px 8px 16px;
    border-bottom: 1px solid rgb(255 255 255 / 10%);
    color: var(--code-comment);
    font-size: .875rem;
}

.code {
    margin: 0;
    padding: 16px;
    max-width: 100%;
    overflow: auto;
    color: var(--code-text);
    font-family: var(--font-mono);
    font-size: .8125rem;
    line-height: 1.55;
    tab-size: 4;
}

/* Long prose prompt: wrap lines instead of scrolling sideways on phones */
.code-wrap {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 26rem;
}

.xml-tag { color: var(--code-tag); }
.xml-decl { color: var(--code-decl); }
.xml-comment { color: var(--code-comment); }

.xml-path {
    font-weight: 600;
}

.defs {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 8px 16px;
    margin: 0 0 1.25em;
}

.defs dt {
    font-weight: 600;
}

.defs dd {
    margin: 0;
}

@media (max-width: 480px) {
    .defs {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .defs dd {
        margin-bottom: 10px;
    }
}

/* Safety warning */
.alert-safety {
    background: var(--danger-bg);
    border: 2px solid var(--danger);
    border-left-width: 8px;
    border-radius: var(--radius);
    padding: 20px 20px 4px;
}

.alert-safety h2 {
    color: var(--danger);
}

.alert-safety h2::before {
    content: "\26A0\FE0E  ";
}

/* ---------- Footer ---------- */
.site-footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: .9375rem;
    padding: 24px 0;
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.footer-inner p {
    margin: 0;
}

.footer-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.footer-links a {
    color: inherit;
}
