/* ── Interactions of Color ──────────────────────────────────────────
   Typography and layout inspired by Matthew Butterick's
   Practical Typography — clean, readable, minimal.
   ───────────────────────────────────────────────────────────────── */

/* ── Design tokens ─────────────────────────────────────────────── */

:root {
    /* Fonts */
    --title-font: 'Buckridge', Charter, serif;
    --text-font: 'WarblerText', Charter, "Bitstream Charter", "Sitka Text", Cambria, serif;
    --mono-font: 'InputMonoCompressed', "Menlo", "Consolas", "Fira Mono", monospace;

    /* Surfaces */
    --bg: #fffff8;             /* cream page background */
    --surface: #f0efe8;        /* code / pre tan */
    --surface-hover: #f7f4ea;  /* toc row hover */

    /* Text */
    --text-color: #2c2c2c;     /* primary ink */
    --text-strong: #1a1a1a;
    --text-soft: #555;
    --text-muted: #666;
    --text-dim: #6e6e6e;
    --text-faint: #888;
    --text-fainter: #999;
    --toc-number-color: #8a8579;
    --toc-subtitle-color: #7a7568;

    /* Rules / borders */
    --rule: #e0ddd5;
    --rule-strong: #d0cdc5;
    --rule-dim: #cbc8c0;
    --underline: #bbb;
    --border-soft: #ccc;
}

/* ── Fonts ─────────────────────────────────────────────────────── */

@font-face {
    src: url('fonts/Buckridge-Regular.woff2') format("woff2");
    font-family: 'Buckridge';
    font-style: normal;
    font-weight: normal;
    font-display: swap;
}

@font-face {
    src: url('fonts/Warbler/WarblerTextV1.2-Regular-Edu.woff2') format("woff2"),
         url('fonts/Warbler/WarblerTextV1.2-Regular-Edu.woff') format("woff");
    font-family: 'WarblerText';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

@font-face {
    src: url('fonts/Warbler/WarblerTextV1.2-Italic-Edu.woff2') format("woff2"),
         url('fonts/Warbler/WarblerTextV1.2-Italic-Edu.woff') format("woff");
    font-family: 'WarblerText';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
}

@font-face {
    src: url('fonts/Warbler/WarblerTextV1.2-Bold-Edu.woff2') format("woff2"),
         url('fonts/Warbler/WarblerTextV1.2-Bold-Edu.woff') format("woff");
    font-family: 'WarblerText';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
}

@font-face {
    src: url('fonts/Input/InputMonoCompressed-Regular-Edu.woff2') format("woff2"),
         url('fonts/Input/InputMonoCompressed-Regular-Edu.woff') format("woff");
    font-family: 'InputMonoCompressed';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

@font-face {
    src: url('fonts/Input/InputMonoCompressed-Italic-Edu.woff2') format("woff2"),
         url('fonts/Input/InputMonoCompressed-Italic-Edu.woff') format("woff");
    font-family: 'InputMonoCompressed';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
}

@font-face {
    src: url('fonts/Input/InputMonoCompressed-Bold-Edu.woff2') format("woff2"),
         url('fonts/Input/InputMonoCompressed-Bold-Edu.woff') format("woff");
    font-family: 'InputMonoCompressed';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
}

/* ── Reset ─────────────────────────────────────────────────────── */

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

/* ── Page ──────────────────────────────────────────────────────── */

html {
    font-size: 18px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--text-font);
    line-height: 1.55;
    color: var(--text-color);
    background-color: var(--bg);
}

/* ── Layout ────────────────────────────────────────────────────── */

header nav a {
    font-variant: all-small-caps;
    letter-spacing: 0.05em;
    text-decoration: none;
    color: var(--text-color);
    font-size: 1.1rem;
}

main {
    max-width: 40rem;
    margin: 3rem auto;
    padding: 0 1.5rem;
}

main:not(.home) article {
    font-size: 1.15rem;
}

footer {
    max-width: 33rem;
    margin: 4rem auto 2rem;
    padding: 1.5rem 1.5rem 0;
    border-top: 1px solid var(--rule);
    font-size: 0.85rem;
    color: var(--text-faint);
}

/* ── Typography ────────────────────────────────────────────────── */

h1 {
    font-size: 1.8rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 1.5rem;
    letter-spacing: -0.01em;
}

h2 {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.3;
    margin-top: 2.5rem;
    margin-bottom: 0.75rem;
    font-variant: all-small-caps;
    letter-spacing: 0.03em;
}

h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

p {
    margin-bottom: 0.9rem;
}

em {
    font-style: italic;
}

strong {
    font-weight: 600;
}

blockquote {
    margin: 1.5rem 0;
    padding-left: 1.25rem;
    border-left: 3px solid var(--rule-strong);
    color: var(--text-soft);
    font-style: italic;
}

blockquote p:last-child {
    margin-bottom: 0;
}

a {
    color: var(--text-color);
    text-decoration-color: var(--underline);
    text-underline-offset: 0.15em;
}

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

code {
    font-family: var(--mono-font);
    font-size: 0.85em;
    background: var(--surface);
    padding: 0.1em 0.3em;
    border-radius: 3px;
}

pre {
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--surface);
    border-radius: 4px;
    overflow-x: auto;
    line-height: 1.4;
}

pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}

hr {
    border: none;
    border-top: 1px solid var(--rule);
    margin: 2.5rem 0;
}

ul,
ol {
    margin-bottom: 0.9rem;
    padding-left: 1.5rem;
}

li {
    margin-bottom: 0.3rem;
}

/* ── Chapter heading ───────────────────────────────────────────── */

.chapter-heading {
    margin-bottom: 2.5rem;
}

.chapter-number {
    font-variant: all-small-caps;
    letter-spacing: 0.12em;
    font-size: 0.85rem;
    color: var(--text-fainter);
    margin-bottom: 0.3rem;
}

h1 .subtitle {
    display: block;
    margin-top: 0.4rem;
    font-size: 1.1rem;
    font-weight: 400;
    font-style: italic;
    color: var(--text-dim);
}

/* ── Chapter navigation ────────────────────────────────────────── */

.chapter-nav {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-top: 4rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--rule);
    font-size: 0.95rem;
}

.chapter-nav a {
    text-decoration: none;
    color: var(--text-color);
}

.chapter-nav a:hover {
    text-decoration: underline;
}

.chapter-nav .nav-toc {
    font-variant: all-small-caps;
    letter-spacing: 0.05em;
    color: var(--text-faint);
}

.chapter-nav .disabled {
    color: var(--rule-dim);
}

/* ── Home page (cover + TOC) ───────────────────────────────────── */

main.home {
    max-width: 44rem;
}

main.home + footer {
    text-align: center;
    border-top: none;
}

/* ── Sidenotes (Tufte) ─────────────────────────────────────────── */

/* Widen chapter container so a right-side gutter can hold sidenotes.
   The text column inside stays at the regular reading width. */
main.chapter {
    max-width: 58rem;
}

main.chapter article.sidenotes {
    max-width: 33rem;
    margin: 0;
    counter-reset: sidenote-counter;
}

main.chapter .chapter-nav {
    max-width: 33rem;
}

/* The numbered marker that stays inline with the text. */
.sidenote-number {
    counter-increment: sidenote-counter;
    cursor: pointer;
}
.sidenote-number::after {
    content: counter(sidenote-counter);
    font-size: 0.72rem;
    vertical-align: super;
    line-height: 0;
    color: var(--text-soft);
    margin-left: 0.05em;
}

/* The note body, floated into the right-hand gutter. */
.sidenote {
    float: right;
    clear: right;
    width: 19rem;
    margin-right: -21rem;     /* push out of the text column into the gutter */
    margin-top: 0.2rem;
    margin-bottom: 1rem;
    font-size: 0.88rem;
    line-height: 1.4;
    color: var(--text-soft);
    position: relative;
    vertical-align: baseline;
}
.sidenote::before {
    content: counter(sidenote-counter) " ";
    font-size: 0.72rem;
    vertical-align: super;
    line-height: 0;
    color: var(--text-soft);
    margin-left: -0.8rem;
    margin-right: 0.25em;
}

/* The mobile-toggle checkbox is never directly visible. */
input.margin-toggle {
    display: none;
}

/* Below the gutter breakpoint: collapse main back to the reading width and
   hide sidenotes by default. Tapping the number reveals the note inline. */
@media (max-width: 1000px) {
    main.chapter {
        max-width: 40rem;
    }
    main.chapter article.sidenotes,
    main.chapter .chapter-nav {
        max-width: none;
    }
    .sidenote {
        display: none;
    }
    .margin-toggle:checked + .sidenote {
        display: block;
        float: none;
        width: auto;
        margin: 0.5rem 0;
        padding: 0.5rem 0.75rem;
        background: var(--surface);
        border-left: 2px solid var(--rule-strong);
    }
    /* Make the number read as a control: larger tap target, tinted, boxed. */
    .sidenote-number::after {
        font-size: 0.78rem;
        padding: 0.05rem 0.3rem;
        margin-left: 0.1em;
        color: var(--text-color);
        background: var(--surface);
        border-radius: 0.2rem;
    }
    .margin-toggle:checked + .sidenote::before {
        color: var(--text-color);
        margin-left: 0;
    }
}

.cover {
    margin: 1rem 0 4rem;
    text-align: center;
}

.cover-title {
    margin: 0 0 1.5rem;
}

.cover-svg {
    display: block;
    width: 100%;
    height: auto;
    font-family: var(--title-font);
    font-weight: bold;
    fill: var(--text-color);
}

.cover-svg text {
    transition: fill 0.6s ease;
}

.cover-mark {
    display: block;
    width: clamp(6rem, 18vw, 9rem);
    height: auto;
    margin: 2rem auto 2rem;
    color: var(--text-color);
}

.cover-prelude {
    text-align: center;
    font-style: italic;
    font-size: 0.95rem;
    color: var(--text-dim);
    margin: 0 0 0.8rem;
}

.cover-prelude a {
    color: inherit;
    text-decoration-color: var(--underline);
}

.toc-heading {
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.4em;
    padding-left: 0.4em;
    font-size: 1rem;
    text-align: center;
    color: var(--text-color);
    margin: 4rem 0 2rem;
    position: relative;
}

.toc-heading::before,
.toc-heading::after {
    content: "";
    display: inline-block;
    width: 2.5rem;
    height: 1px;
    background: var(--rule-dim);
    vertical-align: middle;
    margin: 0 1rem;
}

ol.toc {
    list-style: none;
    padding-left: 0;
    max-width: 44rem;
    margin: 0 auto;
}

ol.toc li {
    margin: 0;
}

ol.toc a {
    display: grid;
    grid-template-columns: 3.5rem 1fr;
    align-items: baseline;
    gap: 1.25rem;
    padding: 1rem 0.25rem;
    text-decoration: none;
    color: var(--text-color);
    transition: background-color 0.15s ease;
}

ol.toc a:hover {
    background: var(--surface-hover);
}

ol.toc a:hover .toc-title {
    text-decoration: underline;
    text-decoration-color: var(--text-color);
}

.toc-number {
    font-size: 1rem;
    line-height: 1;
    color: var(--toc-number-color);
    text-align: right;
    letter-spacing: 0.04em;
}

.toc-title {
    font-size: 1.15rem;
    color: var(--text-color);
}

.toc-subtitle {
    color: var(--toc-subtitle-color);
}

@media (max-width: 480px) {
    .cover {
        margin: 0.25rem 0 2.5rem;
    }

    .cover-mark {
        margin: 1.5rem auto;
    }

    .toc-heading {
        letter-spacing: 0.28em;
    }

    .toc-heading::before,
    .toc-heading::after {
        width: 1.2rem;
        margin: 0 0.5rem;
    }

    ol.toc a {
        grid-template-columns: 2.5rem 1fr;
        gap: 0.9rem;
        padding: 0.9rem 0.1rem;
    }

    .toc-number {
        font-size: 1rem;
    }

    .toc-title {
        font-size: 1rem;
    }

    .toc-subtitle {
        font-size: 0.85rem;
    }
}

/* ── Widgets: shared ───────────────────────────────────────────── */

.widget {
    margin: 2rem 0;
    text-align: center;
}

.widget-prompt {
    font-style: italic;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.widget-result {
    margin-top: 1rem;
    font-style: italic;
    color: var(--text-soft);
}

.widget-controls {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1.25rem;
}

.widget-button {
    padding: 0.4rem 1.1rem;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-color);
    background: var(--bg);
    border: 1px solid var(--border-soft);
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.widget-button:hover {
    background: var(--surface);
}

.widget-button.selected {
    background: var(--text-color);
    color: var(--bg);
    border-color: var(--text-color);
}

.widget-slider {
    width: 18rem;
    max-width: 90%;
    accent-color: var(--text-color);
    cursor: pointer;
}

.widget-caption {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    font-variant: all-small-caps;
    letter-spacing: 0.05em;
    color: var(--text-faint);
}

/* ── Widget: color memory ──────────────────────────────────────── */

.memory-target {
    width: 8rem;
    height: 8rem;
    margin: 0 auto 1.25rem;
    border-radius: 4px;
}

.memory-target.small {
    width: 5rem;
    height: 5rem;
    margin-bottom: 0.5rem;
}

.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 4rem);
    gap: 0.6rem;
    justify-content: center;
}

.memory-cell {
    width: 4rem;
    height: 4rem;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    padding: 0;
}

.memory-cell:hover {
    outline: 2px solid var(--text-color);
    outline-offset: 2px;
}

.memory-compare {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.memory-labelled {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.memory-label {
    font-size: 0.8rem;
    font-variant: all-small-caps;
    letter-spacing: 0.05em;
    color: var(--text-faint);
}

.memory-channels {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.9rem;
    width: 10rem;
}

.memory-channel {
    display: grid;
    grid-template-columns: 0.9rem 1fr;
    gap: 0.45rem;
    align-items: center;
}

.memory-channel-label {
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
    font-size: 0.7rem;
    color: var(--text-faint);
    text-align: center;
}

.memory-channel-track {
    position: relative;
    height: 2px;
    background: var(--rule);
    border-radius: 1px;
}

.memory-channel-marker {
    position: absolute;
    top: 50%;
    width: 8px;
    height: 8px;
    background: var(--text-faint);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.memory-channel-value {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 4px;
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
    font-size: 0.65rem;
    color: var(--text-faint);
    line-height: 1;
    white-space: nowrap;
}

/* ── Widget: color lineup ─────────────────────────────────────── */

.lineup-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem 1rem;
    max-width: 28rem;
    margin: 0 auto 1rem;
}

.lineup-logo {
    width: 100%;
    background: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    padding: 0.5rem;
    transition: transform 0.12s ease, opacity 0.2s ease;
}

.lineup-logo svg {
    display: block;
    width: 100%;
    height: auto;
}

.lineup-logo:hover {
    transform: scale(1.08);
}

.lineup-correct {
    outline: 3px solid var(--text-color);
    outline-offset: 3px;
    border-radius: 2px;
    cursor: default;
}

.lineup-correct:hover {
    transform: none;
}

.lineup-wrong {
    opacity: 0.35;
    cursor: default;
}

.lineup-wrong:hover {
    transform: none;
}

.lineup-dim {
    opacity: 0.2;
    cursor: default;
}

.lineup-dim:hover {
    transform: none;
}

.lineup-compare {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 1rem 0;
}

.lineup-labelled {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lineup-mini {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 3px;
    margin-bottom: 0.4rem;
}

.lineup-label {
    font-size: 0.8rem;
    font-variant: all-small-caps;
    letter-spacing: 0.05em;
    color: var(--text-faint);
}

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

/* ── Widget: lightness sorter ──────────────────────────────────── */

.lightness-row {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.lightness-cell {
    width: 4.5rem;
    height: 6rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    cursor: grab;
    padding: 0;
    transition: transform 0.12s ease;
}

.lightness-cell:hover {
    transform: translateY(-4px);
}

.lightness-cell.dragging {
    cursor: grabbing;
    outline: 3px solid var(--text-color);
    outline-offset: 2px;
    opacity: 0.6;
}

.lightness-row-grey {
    margin-top: 0.75rem;
}

.lightness-row-grey .lightness-cell {
    height: 3rem;
    cursor: default;
}

.lightness-row-grey .lightness-cell:hover {
    transform: none;
}

/* ── Widget: color relativity ──────────────────────────────────── */

.color-panels {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.color-panel {
    width: 12rem;
    height: 10rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.8s ease;
}

.color-swatch {
    width: 4rem;
    height: 4rem;
    border-radius: 2px;
}

/* ── Widget: subtraction ───────────────────────────────────────── */

.subtraction-field {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    padding: 2rem 1.5rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.subtraction-swatch {
    width: 4rem;
    height: 5rem;
    border-radius: 2px;
}

/* ── Widget: after-image ───────────────────────────────────────── */

.afterimage-stage {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 16rem;
}

.afterimage-disc {
    width: 12rem;
    height: 12rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 50%;
    transition: background-color 0.1s ease;
}

.afterimage-dot {
    width: 0.5rem;
    height: 0.5rem;
    background: var(--text-strong);
    border-radius: 50%;
}

.afterimage-picker {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.afterimage-chip {
    width: 2rem;
    height: 2rem;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
}

.afterimage-chip.selected {
    outline: 2px solid var(--text-color);
    outline-offset: 2px;
}

/* ── Widget: illusion of transparence ──────────────────────────── */

.transparence-stage {
    position: relative;
    width: 18rem;
    height: 12rem;
    margin: 0 auto;
}

.transparence-band {
    position: absolute;
}

.transparence-band.horizontal {
    top: 33.333%;
    left: 0;
    width: 100%;
    height: 33.333%;
}

.transparence-band.vertical {
    top: 0;
    left: 33.333%;
    width: 33.333%;
    height: 100%;
}

.transparence-overlap {
    position: absolute;
    top: 33.333%;
    left: 33.333%;
    width: 33.333%;
    height: 33.333%;
}

/* ── Widget: factual mixtures ──────────────────────────────────── */

.mix-equation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.mix-swatch {
    width: 4rem;
    height: 4rem;
    border-radius: 3px;
}

.mix-operator {
    font-size: 1.3rem;
    color: var(--text-fainter);
    line-height: 1;
}

/* ── Widget: boundaries ────────────────────────────────────────── */

.boundary-stage {
    width: 20rem;
    max-width: 90%;
    height: 9rem;
    margin: 0 auto;
    border-radius: 4px;
}

/* ── Widget: optical mixture ───────────────────────────────────── */

.optical-compare {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
}

.optical-field {
    width: 14rem;
    height: 9rem;
    border-radius: 4px;
}

.optical-labelled {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.optical-swatch {
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 3px;
}

/* ── Widget: Bezold effect ─────────────────────────────────────── */

.bezold-field {
    width: 20rem;
    max-width: 90%;
    height: 11rem;
    margin: 0 auto;
    border-radius: 4px;
}

/* ── Widget: intervals & transformation ────────────────────────── */

.transform-groups {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.25rem;
}

.transform-labelled {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.transform-grid {
    display: grid;
    grid-template-columns: repeat(2, 3.5rem);
    grid-template-rows: repeat(2, 3.5rem);
}

.transform-cell {
    width: 3.5rem;
    height: 3.5rem;
}

.transform-arrow {
    font-size: 1.5rem;
    color: var(--text-fainter);
}

/* ── Widget: middle mixture / fluting ──────────────────────────── */

.fluting-row {
    display: flex;
    justify-content: center;
    width: 22rem;
    max-width: 92%;
    height: 9rem;
    margin: 0 auto;
    border-radius: 4px;
    overflow: hidden;
}

.fluting-band {
    height: 100%;
}

/* ── Widget: quantity ──────────────────────────────────────────── */

.quantity-row {
    display: flex;
    width: 22rem;
    max-width: 92%;
    height: 7rem;
    margin: 0 auto;
    border-radius: 4px;
    overflow: hidden;
}

.quantity-band {
    height: 100%;
    transition: flex-grow 0.3s ease;
}

/* ── Widget: film & volume color ───────────────────────────────── */

.film-stage {
    position: relative;
    width: 20rem;
    max-width: 90%;
    height: 9rem;
    margin: 0 auto;
    border-radius: 4px;
    overflow: hidden;
    background: var(--text-color);
}

.film-back {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.film-token {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
}

.film-veil {
    position: absolute;
    inset: 0;
}

/* ── Widget: free study (stripes) ──────────────────────────────── */

.stripes-row {
    display: flex;
    width: 24rem;
    max-width: 94%;
    height: 9rem;
    margin: 0 auto;
    border-radius: 4px;
    overflow: hidden;
}

.stripes-stripe {
    flex: 1;
    height: 100%;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: flex-grow 0.15s ease;
}

.stripes-stripe:hover {
    flex-grow: 1.4;
}

/* ── Widget: color instrumentation ─────────────────────────────── */

.homage-stage {
    display: flex;
    justify-content: center;
}

.homage-layer {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

.homage-outer {
    width: 14rem;
    height: 14rem;
}

.homage-mid {
    width: 10.5rem;
    height: 10.5rem;
}

.homage-inner {
    width: 7rem;
    height: 7rem;
}

.homage-core {
    width: 3.5rem;
    height: 3.5rem;
}

.homage-layer.selected-layer {
    position: relative;
}

.homage-layer.selected-layer::before,
.homage-layer.selected-layer::after {
    content: "";
    position: absolute;
    width: 12px;
    height: 12px;
    border-color: rgba(255, 255, 255, 0.8);
    border-style: solid;
    pointer-events: none;
}

.homage-layer.selected-layer::before {
    top: 4px;
    left: 4px;
    border-width: 2px 0 0 2px;
}

.homage-layer.selected-layer::after {
    bottom: 4px;
    right: 4px;
    border-width: 0 2px 2px 0;
}

/* ── Widget: Weber–Fechner ─────────────────────────────────────── */

.wf-labelled {
    margin: 0 auto 0.75rem;
    width: 22rem;
    max-width: 92%;
}

.wf-row {
    display: flex;
    height: 3rem;
    border-radius: 3px;
    overflow: hidden;
}

.wf-step {
    flex: 1;
    height: 100%;
}

/* ── Widget: hue wheel ────────────────────────────────────────── */

.hue-wheel-wrap {
    display: flex;
    justify-content: center;
}

.hue-wheel {
    position: relative;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: conic-gradient(from 0deg,
        hsl(0, 100%, 50%),
        hsl(30, 100%, 50%),
        hsl(60, 100%, 50%),
        hsl(90, 100%, 50%),
        hsl(120, 100%, 50%),
        hsl(150, 100%, 50%),
        hsl(180, 100%, 50%),
        hsl(210, 100%, 50%),
        hsl(240, 100%, 50%),
        hsl(270, 100%, 50%),
        hsl(300, 100%, 50%),
        hsl(330, 100%, 50%),
        hsl(360, 100%, 50%)
    );
    cursor: crosshair;
    touch-action: none;
    user-select: none;
}

.hue-wheel.dragging {
    cursor: grabbing;
}

.hue-marker {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    margin-left: -7px;
    margin-top: -7px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.hue-marker.draggable {
    pointer-events: auto;
    cursor: grab;
}

.hue-wheel.dragging .hue-marker {
    pointer-events: none;
}

.hue-diameter {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.hue-diameter line {
    stroke: rgba(255, 255, 255, 0.7);
    stroke-width: 2;
    stroke-dasharray: 4 4;
}

.hue-arc-mask {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
}

.hue-offset-controls {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.75rem;
}

.hue-offset-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.hue-offset-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.hue-offset-slider {
    flex: 1;
    accent-color: var(--text-color);
    cursor: pointer;
}

/* ── Widget: aside panel (margin picker) ──────────────────────── */

.widget-body {
    position: relative;
}

.aside-toggle {
    margin: 1rem auto 0;
}

.widget-aside .aside-content {
    display: none;
    margin-top: 1rem;
}

.widget-aside.aside-open .aside-content {
    display: block;
}

@media (min-width: 56rem) {
    .aside-toggle {
        display: none;
    }

    .widget-aside {
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        margin-left: 1.5rem;
    }

    .widget-aside .aside-content {
        display: block;
        margin-top: 0;
    }
}

/* ── Widget: swatch row (sliders + swatches) ─────────────────── */

.swatch-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
}

.swatch-row .contrast-stage {
    width: 16rem;
    margin: 0;
}

.swatch-row .afterimage-stage {
    margin: 0;
    flex: 0 0 auto;
}

.swatch-row .transparence-stage {
    margin: 0;
    flex: 0 0 auto;
}

.swatch-row .boundary-stage {
    margin: 0;
    flex: 0 0 auto;
}

.swatch-row .optical-compare {
    margin: 0;
    flex: 0 0 auto;
}

.swatch-row .bezold-field {
    margin: 0;
    flex: 0 0 auto;
}

.swatch-slider {
    writing-mode: vertical-lr;
    direction: rtl;
    height: 9rem;
    accent-color: var(--text-color);
    cursor: pointer;
}

/* ── Widget: vibrating & vanishing boundaries ──────────────────── */

.contrast-stage {
    display: flex;
    width: 20rem;
    max-width: 90%;
    height: 9rem;
    margin: 0 auto;
    border-radius: 4px;
    overflow: hidden;
}

.contrast-half {
    flex: 1;
    height: 100%;
}

/* ── Responsive ────────────────────────────────────────────────── */

@media (max-width: 480px) {
    html {
        font-size: 16px;
    }

    .color-panels {
        gap: 0.75rem;
    }

    .color-panel {
        width: 9rem;
        height: 7.5rem;
    }

    .color-swatch {
        width: 3rem;
        height: 3rem;
    }
}
