/* Design tokens: all colors, sizes and fonts are variables. The target is blue (--color-target), the item ochre. */
:root {
    color-scheme: light;
    --font-text: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-code: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    --color-bg: #ffffff;
    --color-surface: #f6f6fa;
    --color-text: #1b1b26;
    --color-muted: #5a5a72;
    --color-border: #dedeea;
    --color-accent: #595991;
    --color-accent-text: #ffffff;
    --color-link: #4e4e7e;
    --color-focus: #595991;
    --color-header: #3c3c62;
    --color-header-end: #595991;
    --color-header-text: #ffffff;
    --color-target: #0b5fd1;
    --color-target-text: #ffffff;
    --color-error: #b42318;
    --color-item: #ffe58a;
    --color-item-border: #b58900;
    --color-mark-item: #d92d20;
    --color-mark-target: #ffffff;
    --color-draft: #fff4d6;
    --color-draft-text: #5c4300;
    --color-chart-other: #8a8a9a;
    --radius: 0.375rem;
    --nav-width: 15rem;
    --content-width: 48rem;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    color: var(--color-text);
    font: 1rem/1.7 var(--font-text);
}

a {
    color: var(--color-link);
    text-underline-offset: 0.18em;
}

:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}
.site-header :focus-visible,
.site-footer :focus-visible {
    outline-color: var(--color-header-text);
}

.skip-link {
    position: absolute;
    left: -100vw;
}
.skip-link:focus {
    left: 0.5rem;
    top: 0.5rem;
    z-index: 10;
    padding: 0.5rem 0.75rem;
    background: var(--color-bg);
}

.site-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.5rem;
    background: linear-gradient(135deg, var(--color-header), var(--color-header-end));
    color: var(--color-header-text);
}
.brand {
    font-weight: 700;
    font-size: 1.125rem;
    letter-spacing: 0.01em;
    color: var(--color-header-text);
    text-decoration: none;
}
.version {
    color: var(--color-header-text);
    font-size: 0.875rem;
}
.header-link {
    margin-left: auto;
    color: var(--color-header-text);
}

.shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0 2rem;
    max-width: calc(var(--nav-width) + var(--content-width) + 6rem);
    margin: 0 auto;
    padding: 0 1.25rem;
}
@media (min-width: 60rem) {
    .shell {
        grid-template-columns: var(--nav-width) minmax(0, 1fr);
    }
    .site-nav {
        position: sticky;
        top: 0;
        align-self: start;
        max-height: 100vh;
        overflow-y: auto;
        padding-top: 1.5rem;
    }
    .site-nav summary {
        display: none;
    }
}

.site-nav summary {
    margin: 0.75rem 0;
    cursor: pointer;
    font-weight: 600;
}
.site-nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
}
.site-nav a {
    display: block;
    padding: 0.15rem 0.6rem;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    color: var(--color-text);
    text-decoration: none;
}
.site-nav a:hover {
    background: var(--color-surface);
}
.site-nav a[aria-current="page"] {
    background: var(--color-accent);
    color: var(--color-accent-text);
}
.nav-title {
    margin: 1rem 0 0.25rem 0.6rem;
    color: var(--color-muted);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

main {
    min-width: 0;
    max-width: var(--content-width);
    padding: 1.5rem 0 3rem;
}
h1 {
    margin: 0 0 0.5rem;
    font-size: 1.875rem;
    line-height: 1.2;
}
/* The start page has the largest heading. The layout has no page class, so the current nav link tells which page it is. */
.shell:has(.site-nav a[aria-current="page"][href$="index.html"]) main > h1 {
    font-size: 2.25rem;
}
h2 {
    margin: 2.25rem 0 0.5rem;
    font-size: 1.3125rem;
    line-height: 1.3;
}
h3 {
    margin: 1.5rem 0 0.25rem;
    font-size: 1rem;
}
.lead {
    margin: 0 0 1.5rem;
    color: var(--color-muted);
    font-size: 1.0625rem;
}

code,
pre {
    font-family: var(--font-code);
    font-size: 0.875em;
}
/* The code in a block keeps the size of the block, else the reduction applies twice */
pre code {
    font-size: 1em;
}
:not(pre) > code {
    padding: 0.1em 0.35em;
    border-radius: 0.25rem;
    background: var(--color-surface);
}
h1 > code,
h2 > code,
h3 > code {
    padding: 0;
    background: none;
    font-size: 0.9em;
}
pre {
    margin: 1rem 0;
    padding: 0.875rem 1rem;
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    line-height: 1.5;
}

.code-block {
    position: relative;
}
.code-block pre {
    padding-right: 4.5rem;
}
.code-block .copy {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

button {
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text);
    font: inherit;
    font-size: 0.875rem;
    cursor: pointer;
}
button:hover {
    background: var(--color-surface);
}

table {
    width: 100%;
    margin: 1rem 0;
    border-collapse: collapse;
    font-size: 0.9375rem;
}
th,
td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    vertical-align: top;
    overflow-wrap: anywhere;
}
th {
    background: var(--color-surface);
}

.chart {
    display: block;
    width: 100%;
    max-width: 28rem;
    height: auto;
}
.chart-figure {
    margin: 1.5rem 0;
}
.chart-figure figcaption {
    margin-top: 0.5rem;
    color: var(--color-muted);
    font-size: 0.875rem;
}
.chart text {
    fill: var(--color-text);
}
.chart .bar {
    fill: var(--color-chart-other);
}
.chart .bar-own {
    fill: var(--color-accent);
}
.chart .group {
    font-weight: 600;
}
.chart .bar-base {
    fill: var(--color-surface);
    stroke: var(--color-muted);
}
details > table {
    margin-top: 0.5rem;
}
summary {
    cursor: pointer;
}

dt {
    margin-top: 0.75rem;
    font-weight: 600;
}
dd {
    margin: 0.125rem 0 0 1.5rem;
}

.draft {
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius);
    background: var(--color-draft);
    color: var(--color-draft-text);
}

.site-footer {
    margin-top: auto;
    display: grid;
    justify-items: center;
    gap: 0.75rem;
    padding: 1.5rem 1.25rem;
    background: linear-gradient(135deg, var(--color-header), var(--color-header-end));
    color: var(--color-header-text);
    font-size: 0.875rem;
    text-align: center;
}
.site-footer p {
    margin: 0;
}
.credit svg {
    display: block;
    width: auto;
    height: 4.5rem;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Try-it widget */
.tryit {
    margin: 1rem 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}
.tryit-hint {
    margin: 0;
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9375rem;
}
.tryit-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}
.tryit-bar[hidden] {
    display: none;
}
.tryit-picker {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-right: auto;
    font-size: 0.875rem;
}
.tryit-state {
    margin-left: auto;
    color: var(--color-error);
    font-size: 0.875rem;
}
.tryit-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem 0;
    border-bottom: 1px solid var(--color-border);
}
.tryit-tabs[hidden] {
    display: none;
}
.tryit-tabs [role="tab"] {
    margin-bottom: -1px;
    border-color: transparent;
    border-bottom-color: var(--color-border);
    border-radius: var(--radius) var(--radius) 0 0;
    background: none;
    color: var(--color-muted);
}
.tryit-tabs [role="tab"][aria-selected="true"] {
    border-color: var(--color-border);
    border-bottom-color: var(--color-bg);
    background: var(--color-bg);
    color: var(--color-text);
    font-weight: 600;
}
.tryit-label[hidden] {
    display: none;
}
.tryit-label {
    display: block;
    padding: 0.375rem 1rem 0;
    color: var(--color-muted);
    font-size: 0.8125rem;
    font-weight: 600;
}
.tryit-code {
    display: block;
    width: 100%;
    padding: 0.875rem 1rem;
    border: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font: 0.8125rem/1.5 var(--font-code);
    resize: vertical;
    tab-size: 4;
}
.tryit-pane + .tryit-pane > .tryit-label {
    border-top: 1px solid var(--color-border);
}
.tryit-view {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    border-bottom: 1px solid var(--color-border);
}
.tryit-view[hidden] {
    display: none;
}
.tryit-frame {
    display: block;
    width: 100%;
    height: auto;
    align-self: stretch;
    border: 0;
    background: var(--color-bg);
}
.values {
    padding: 0.625rem 0.75rem;
    background: var(--color-surface);
    font-size: 0.875rem;
}
.tryit-view .values {
    border-left: 1px solid var(--color-border);
}
.values-title {
    margin: 0 0 0.5rem;
    font-weight: 600;
}
.values-note {
    min-height: 2lh; /* two lines are reserved, so a note does not move the panel */
    inline-size: 0; /* the note wraps within the list and does not set the width of the panel */
    min-inline-size: 100%;
    margin: 0.5rem 0 0;
    color: var(--color-muted);
}
/* 24ch fits the longest value ("top, right, bottom, left"), so the panel keeps its width. ch needs the font here. */
.values-list {
    display: grid;
    grid-template-columns: max-content 24ch;
    gap: 0.125rem 0.75rem;
    margin: 0;
    color: var(--color-text);
    font: 0.8125rem/1.6 var(--font-code);
}
.values-list dt {
    margin: 0;
    color: var(--color-muted);
    font: 0.8125rem/1.6 var(--font-code);
}
.values-list dd {
    margin: 0;
    font: 0.8125rem/1.6 var(--font-code);
    white-space: nowrap;
}
@media (max-width: 40rem) {
    .values-list {
        grid-template-columns: max-content minmax(0, 1fr);
    }
    .values-list dd {
        white-space: normal;
    }
    .tryit-view {
        grid-template-columns: minmax(0, 1fr);
    }
    .tryit-view .values {
        border-top: 1px solid var(--color-border);
        border-left: 0;
    }
}
.tryit-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--color-surface);
    font-size: 0.875rem;
}

select {
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text);
    font: inherit;
    font-size: 0.875rem;
}

/* Page of an example frame: only a little space around the example */
.example-frame {
    padding: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.4;
}
.example-frame p {
    margin: 0.5rem 0 0;
}

/* Configurator */
.configurator {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1.5rem;
    margin: 1rem 0;
}
.cfg-left {
    flex: 0 0 400px;
    max-width: 100%;
    overflow-x: auto;
}
.cfg-right {
    flex: 1 1 18rem;
    min-width: min-content; /* the panel has a fixed width, so the column wraps below the stage */
}
.cfg-field {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
}
.cfg-grid {
    display: grid;
    grid-template-columns: repeat(3, 1.75rem);
    gap: 0.25rem;
}
.cfg-grid label {
    position: relative;
    display: block;
    height: 1.75rem;
    border: 1px solid var(--color-border);
    border-radius: 0.25rem;
    background: var(--color-surface);
    cursor: pointer;
}
.cfg-grid input {
    position: absolute;
    inset: 0;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}
.cfg-grid label:has(input:checked) {
    border-color: var(--color-accent);
    background: var(--color-accent);
}
.cfg-grid label:has(input:focus-visible) {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}
.cfg-canvas {
    position: relative;
    width: 400px;
    height: 260px;
    overflow: hidden; /* an item that leaves the boundary is cut off by the edge of the canvas */
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
}
.cfg-stage {
    position: absolute;
    /* The gap to the canvas is wider than the target is high and narrower than it is wide */
    left: 60px;
    top: 60px;
    width: 280px;
    height: 140px;
    outline: 1px dashed var(--color-muted);
    background: var(--color-bg);
}
.cfg-target,
.cfg-item {
    position: absolute;
    display: grid;
    place-items: center;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}
.cfg-target {
    left: 110px;
    top: 70px;
    width: 80px;
    height: 40px;
    background: var(--color-target);
    color: var(--color-target-text);
    cursor: grab;
    touch-action: none;
    user-select: none;
}
.cfg-target.cfg-dragging {
    cursor: grabbing;
}
.cfg-target:focus-visible {
    outline: 2px solid var(--color-text);
    outline-offset: 2px;
}
.cfg-item {
    left: 0;
    top: 0;
    width: 100px;
    height: 50px;
    /* an inset shadow instead of a border, so the dots are placed against the outer edge */
    box-shadow: inset 0 0 0 2px var(--color-item-border);
    background: var(--color-item);
    color: var(--color-text);
    pointer-events: none;
}
.cfg-marker {
    position: absolute;
    border: 1px solid var(--color-text);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}
/* Both dots have the same size and touch the edge of their box from the inside. The target dot is on top. */
.cfg-marker {
    width: 10px;
    height: 10px;
}
.cfg-item .cfg-marker {
    z-index: 2;
    background: var(--color-mark-item);
}
.cfg-target .cfg-marker {
    z-index: 3;
    background: var(--color-mark-target);
}
.cfg-stage.cfg-overflow {
    outline: 2px solid var(--color-error);
}
.cfg-value {
    padding: 0;
    border: 0;
    border-bottom: 1px dashed currentColor;
    border-radius: 0.125rem;
    background: none;
    color: var(--color-accent);
    font: inherit;
    cursor: pointer;
}
.cfg-value:hover,
.cfg-value[aria-expanded="true"] {
    background: color-mix(in srgb, var(--color-accent) 18%, transparent);
}
.cfg-value.cfg-default {
    color: var(--color-muted);
}
.cfg-dialog {
    position: absolute;
    z-index: 20;
    width: 15rem;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 0.2);
    font-size: 0.875rem;
}
.cfg-dialog[hidden] {
    display: none;
}
.cfg-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.cfg-dialog-close {
    border: 0;
    background: none;
    color: inherit;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}
.cfg-dialog-text {
    margin: 0.5rem 0;
    color: var(--color-muted);
}
.cfg-dialog-body {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.cfg-dialog-body label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.cfg-dialog-body .cfg-grid label {
    display: block;
}
.cfg-dialog-body [aria-invalid="true"] {
    border-color: var(--color-error);
}
.cfg-dialog-body input[type="number"] {
    width: 5rem;
    margin-left: 0.4rem;
}
/* The code block is a flex item of its own and takes the full width */
.configurator > .code-block {
    flex: 1 0 100%;
    min-width: 0;
}
.configurator .code-block pre {
    margin: 0;
}
.cfg-right .values {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
.cfg-right .values-note {
    display: none;
}
/* The small boxes before the names show which element or point a property belongs to */
.cfg-swatch {
    display: inline-block;
    box-sizing: border-box;
    width: 7.2px; /* as wide as a character, so the names stay aligned */
    height: 8px;
    border: 1px solid transparent;
    overflow: hidden; /* the box sits on the baseline of the line */
    font-size: 0;
}
.cfg-swatch-item {
    border-color: var(--color-item-border);
    background: var(--color-item);
}
.cfg-swatch-target {
    border-color: var(--color-target);
    background: var(--color-target);
}
.cfg-swatch-boundary {
    border: 1px dashed var(--color-muted);
}
.cfg-swatch-itemAt {
    border-color: var(--color-text);
    border-radius: 50%;
    background: var(--color-mark-item);
}
.cfg-swatch-targetAt {
    border-color: var(--color-text);
    border-radius: 50%;
    background: var(--color-mark-target);
}
@keyframes cfg-flash {
    from {
        background: color-mix(in srgb, var(--color-accent) 25%, transparent);
    }
}
.cfg-updated {
    animation: cfg-flash 0.8s ease-out;
}
@media (prefers-reduced-motion: reduce) {
    .cfg-updated {
        animation: none;
    }
}
