/* Playground look: "Studio" by day, "Showroom" by night. Solid surfaces, one accent, data-theme on <html>. */

/* Light theme */
:root {
    color-scheme: light;

    --bg: #fafaf9;
    --surface: #ffffff;
    --line: #e7e5e4;
    --text: #111827;
    --muted: #78716c;
    --accent: #4f46e5;
    --accent2: #0ea5e9;
    /* Behind white text: the accent, or a deeper shade where the accent is too light for it */
    --accent-fill: #4f46e5;
    --on-accent: #ffffff;
    --glow: transparent;
    --ok-bg: #dcfce7;
    --ok: #166534;
    --no-bg: #fee2e2;
    --no: #991b1b;
    /* The green dot: the gateway archive holds this datum */
    --archived: #059669;
    /* The stand behind a make's monogram, and behind its logo: the logos are drawn for a light page */
    --plate: #f5f5f4;
    --logo-plate: #f5f5f4;
    --shadow: 0 1px 2px rgb(17 24 39 / .04), 0 12px 32px -16px rgb(17 24 39 / .14);

    --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
    --radius: 12px;
    --radius-lg: 18px;
    --gutter: clamp(16px, 4vw, 32px);

    /* Tabiot toasts and error panels read these: they follow the theme */
    --tsd-card-bg: var(--surface);
    --tsd-card-radius: var(--radius-lg);
    --tsd-card-shadow: var(--shadow);
    --tsd-border-color: var(--line);
    --bs-body-color: var(--text);
}

/* Dark theme */
[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0b1020;
    --surface: #131a2e;
    --line: #243049;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --accent: #8b5cf6;
    --accent2: #60a5fa;
    --accent-fill: #7c3aed;
    --on-accent: #ffffff;
    --glow: #3b82f633;
    --ok-bg: #14532d55;
    --ok: #86efac;
    --no-bg: #7f1d1d55;
    --no: #fca5a5;
    --archived: #34d399;
    --plate: #19213a;
    --logo-plate: #e3e8f0;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 16px 40px -20px rgb(0 0 0 / .6);
}

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

/* The page does not shift sideways when a step grows a scrollbar */
html {
    scrollbar-gutter: stable;
}

body {
    margin: 0;
    min-height: 100dvh;
    /* The showroom glow: transparent in the light theme */
    background: radial-gradient(1100px 380px at 78% -12%, var(--glow), transparent 62%) no-repeat, var(--bg);
    color: var(--text);
    font: 400 14px/1.5 var(--font-sans);
    -webkit-font-smoothing: antialiased;
    transition: background-color .2s ease, color .2s ease;
}

h1,
h2,
h3 {
    margin: 0;
    letter-spacing: -0.02em;
}

code,
pre,
kbd {
    font-family: var(--font-mono);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Hidden on screen, read by screen readers */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Scroll areas: a thin scrollbar with a rounded thumb in the muted colour of the theme (or of the developer panel) */
.scroll-area {
    --scroll-thumb: color-mix(in srgb, var(--muted) 42%, transparent);
    --scroll-thumb-hover: color-mix(in srgb, var(--muted) 72%, transparent);
    overflow: auto;
}

.scroll-area::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.scroll-area::-webkit-scrollbar-track,
.scroll-area::-webkit-scrollbar-corner {
    background: transparent;
}

/* The transparent border keeps the thumb off the area's edge; a long answer still gets a thumb to grab */
.scroll-area::-webkit-scrollbar-thumb {
    min-width: 32px;
    min-height: 32px;
    border: 2px solid transparent;
    border-radius: 999px;
    background: var(--scroll-thumb) padding-box;
}

.scroll-area::-webkit-scrollbar-thumb:hover,
.scroll-area::-webkit-scrollbar-thumb:active {
    background-color: var(--scroll-thumb-hover);
}

/* Chromium drops the pseudo-elements above once these are set: only the browsers without them get the standard pair */
@supports not selector(::-webkit-scrollbar) {
    .scroll-area {
        scrollbar-width: thin;
        scrollbar-color: var(--scroll-thumb) transparent;
    }
}

/* A rounded panel around a scroll area: its padding keeps the full-height scrollbar inside the rounded border */
.scroll-frame {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 4px;
}

.scroll-frame > .scroll-area {
    flex: 1 1 auto;
    min-height: 0;
}

/* The frame shows the focus of its area along the rounded edge */
.scroll-frame:has(> .scroll-area:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.scroll-frame > .scroll-area:focus-visible {
    outline: none;
}

/* Page blocks */
.stage {
    padding: clamp(24px, 4vw, 40px);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.eyebrow {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.display {
    margin: 6px 0 12px;
    font-size: clamp(32px, 4.6vw, 52px);
    font-weight: 800;
    letter-spacing: -0.035em;
    line-height: 1.04;
}

/* The second colour of a display title, as in "Extended Range" */
.display em {
    color: var(--accent2);
    font-style: normal;
}

.lede {
    max-width: 62ch;
    margin: 0;
    color: var(--muted);
    font-size: 15px;
}

/* Buttons: .btn is the quiet one; the Tabiot markup pairs it with .btn-primary or .btn-outline-secondary */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: 600 13px/1 var(--font-sans);
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}

.btn:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.btn-primary {
    border-color: var(--accent-fill);
    background: var(--accent-fill);
    color: var(--on-accent);
}

.btn-primary:hover {
    border-color: var(--accent-fill);
    background: color-mix(in srgb, var(--accent-fill) 86%, #000);
}

.btn:disabled {
    cursor: default;
    opacity: .5;
}

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

/* Configure: pieces the steps share */
.display-sm {
    font-size: clamp(26px, 3.4vw, 38px);
}

/* Title on the left, tools on its baseline; the tools wrap under it when the row is full */
.step-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    align-items: last baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.step-head .display {
    margin-bottom: 0;
}

/* The make's logo beside the title of the model and version steps (MakeLogo reads the --plate-* variables) */
.make-head {
    --plate-width: 104px;
    --plate-height: 76px;
    --plate-padding: 12px;
    --plate-radius: var(--radius);
    --logo-height: 44px;
    --monogram-size: 52px;
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

/* A step's filter and switches: one row beside the title, stacked under it on a phone */
.step-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

/* A width, not a basis: the row measures its full length and wraps under the title as a whole */
.step-tools .field {
    flex: 1 1 auto;
    width: 260px;
}

.field {
    height: 38px;
    min-width: min(260px, 100%);
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.field:focus-visible {
    border-color: var(--accent);
    outline-offset: 0;
}

/* A pill holding a checkbox styled as a switch; --switch-on colours it when on */
.pill-switch {
    --switch-on: var(--accent-fill);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 14px 0 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

/* The archive switch: its dot is the legend of the cards' dots */
.pill-switch-archive {
    --switch-on: var(--archived);
}

.pill-switch:has(input:checked) {
    border-color: color-mix(in srgb, var(--switch-on) 55%, var(--line));
    background: color-mix(in srgb, var(--switch-on) 10%, var(--surface));
}

.pill-switch:has(input:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.pill-switch input {
    appearance: none;
    position: relative;
    flex: none;
    width: 30px;
    height: 18px;
    margin: 0;
    border-radius: 999px;
    background: var(--line);
    cursor: pointer;
    transition: background-color .15s ease;
}

.pill-switch input::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 1px 2px rgb(0 0 0 / .25);
    transition: transform .15s ease;
}

.pill-switch input:checked {
    background: var(--switch-on);
}

.pill-switch input:checked::after {
    transform: translateX(12px);
}

.pill-switch input:focus-visible {
    outline: none;
}

@media (max-width: 560px) {
    .make-head {
        --plate-width: 84px;
        --plate-height: 62px;
        --logo-height: 36px;
        --monogram-size: 44px;
        gap: 14px;
    }

    .step-tools {
        width: 100%;
    }

    .step-tools .field {
        flex-basis: 100%;
    }
}

/* A letter group's heading in the make and model lists: the letter, then a hairline to the edge */
.letter {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 22px 0 12px;
    color: var(--accent);
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
}

.letter::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}

.letter:focus-visible {
    outline-offset: 4px;
}

/* The gateway archive holds this datum's data: its legend is the make step's switch */
.archived-dot {
    display: inline-block;
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--archived);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--archived) 24%, transparent);
}

/* Badges: chosen, excluded, included, requires */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--muted) 14%, transparent);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
}

.tag-ok {
    background: var(--ok-bg);
    color: var(--ok);
}

.tag-no {
    background: var(--no-bg);
    color: var(--no);
}

.tag-info {
    background: color-mix(in srgb, var(--accent2) 16%, transparent);
    color: color-mix(in srgb, var(--accent2) 65%, var(--text));
}

/* A call's outcome in place of its data: "not in the archive", a refusal, an unreachable gateway */
.notice {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    background: var(--bg);
}

.notice svg {
    flex: none;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: var(--muted);
    stroke-linecap: round;
    stroke-width: 1.8;
}

.notice strong {
    display: block;
}

.notice p {
    margin: 2px 0 6px;
    color: var(--muted);
}

.notice-path {
    display: block;
    color: var(--muted);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.notice-alert {
    border-style: solid;
    border-color: color-mix(in srgb, var(--no) 35%, var(--line));
    background: var(--no-bg);
}

.notice-alert svg {
    stroke: var(--no);
}

.notice-action {
    margin-top: 10px;
}

/* The Bootstrap utilities of the Tabiot markup: icon spacing in buttons, the hidden state of <Loading> */
.me-2 {
    margin-inline-end: .5rem;
}

.d-none {
    display: none !important;
}

/* The loading indicator of the Tabiot components (PlaygroundLoading) */
.spinner {
    width: 28px;
    height: 28px;
    margin: 24px auto;
    border: 3px solid color-mix(in srgb, var(--accent) 22%, transparent);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    body {
        transition: none;
    }

    .spinner {
        animation-duration: 2.4s;
    }
}
