/*
 * Product components (cb-*), ported from docs/charte/bundle.css as native nested CSS,
 * without the .cb root that only isolated the design-system previews.
 * Generic controls (buttons, fields, switch, card, table, dropdown, badge) stay Tabler's:
 * nothing here redraws them. Colors come from tokens.css only.
 */

/*
 * Generation button: modifiers set on a Tabler .btn, through Tabler's own button variables
 * so that hover, active and focus states keep working. The only action that carries the
 * spark. Accent fill with an accent-soft ring, never a gradient, never purple.
 * The charte defines no accent-hover token: hover widens the ring instead.
 */
.cb-btn--generate {
    --tblr-btn-color: var(--on-accent);
    --tblr-btn-bg: var(--accent);
    --tblr-btn-border-color: transparent;
    --tblr-btn-hover-color: var(--on-accent);
    --tblr-btn-hover-bg: var(--accent);
    --tblr-btn-hover-border-color: transparent;
    --tblr-btn-active-color: var(--on-accent);
    --tblr-btn-active-bg: var(--accent);
    --tblr-btn-active-border-color: transparent;
    --tblr-btn-box-shadow: 0 0 0 3px var(--accent-soft);

    &:hover {
        --tblr-btn-box-shadow: 0 0 0 4px var(--accent-soft);
    }
}

.cb-btn--generate-outline {
    --tblr-btn-color: var(--ink);
    --tblr-btn-bg: transparent;
    --tblr-btn-border-color: var(--accent);
    --tblr-btn-hover-color: var(--ink);
    --tblr-btn-hover-bg: var(--accent-soft);
    --tblr-btn-hover-border-color: var(--accent);
    --tblr-btn-active-color: var(--ink);
    --tblr-btn-active-bg: var(--accent-soft);
    --tblr-btn-active-border-color: var(--accent);
}

/* Spark: a filled SVG (assets/icons/cb/spark.svg), always next to a label. */
.cb-spark {
    flex: none;
    width: 18px;
    height: 18px;
    fill: currentColor;
    stroke: none;

    .btn & {
        width: 20px;
        height: 20px;
    }
}

/* Deliverable status badge */
.cb-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    height: 24px;
    padding: 0 var(--space-2);
    border-radius: var(--radius-sm);
    font: 600 12px/16px var(--font-sans);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;

    /* Size only: a Tabler icon gets its 1.5px stroke from .icon, the spark its fill from .cb-spark */
    & svg {
        width: 14px;
        height: 14px;
    }
}

.cb-badge--brief {
    background: var(--info-soft);
    color: var(--info);
}

.cb-badge--draft {
    background: var(--accent-soft);
    color: var(--ink);

    & .cb-spark {
        width: 12px;
        height: 12px;
    }
}

.cb-badge--review {
    background: var(--warning-soft);
    color: var(--ink);
}

.cb-badge--validated {
    background: var(--success-soft);
    color: var(--success);
}

.cb-badge--delivered {
    background: var(--brand-soft);
    color: var(--brand);
}

.cb-badge--refused {
    background: var(--danger-soft);
    color: var(--danger);
}

.cb-badge--neutral {
    background: var(--surface-sunken);
    color: var(--ink-muted);
}

/* Version chip */
.cb-version {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    height: 28px;
    padding: 0 var(--space-3);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-pill);
    background: var(--surface-raised);
    color: var(--ink);
    font: 400 13px/20px var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.cb-version--current {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--brand);
}

.cb-version__meta {
    color: var(--ink-muted);
}

/* Annotation canvas, pin and bubble */
.cb-canvas {
    position: relative;
    width: 100%;
    max-width: 480px;
    aspect-ratio: 3 / 2;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface-sunken);
    overflow: hidden;
}

.cb-pin {
    position: absolute;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 2px solid var(--surface-raised);
    border-radius: var(--radius-pill);
    background: var(--info);
    box-shadow: var(--shadow-sm);
    color: var(--surface);
    font: 500 11px/16px var(--font-mono);
    transform: translate(-50%, -50%);
}

.cb-pin--done {
    background: var(--success);
}

.cb-pin--ai {
    background: var(--accent);
    color: var(--on-accent);
}

.cb-bubble {
    position: absolute;
    max-width: 240px;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-raised);
    box-shadow: var(--shadow-md);
    font: 400 13px/20px var(--font-sans);
}

.cb-bubble__meta {
    display: block;
    margin-bottom: 2px;
    color: var(--ink-muted);
    font: 400 11px/16px var(--font-mono);
}

/* Deliverable card */
.cb-card {
    width: 100%;
    max-width: 320px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface-raised);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.cb-card__preview {
    display: grid;
    place-items: center;
    aspect-ratio: 4 / 3;
    background: var(--surface-sunken);
    color: var(--ink-faint);
    font: 400 13px/20px var(--font-mono);
}

.cb-card__body {
    display: grid;
    gap: var(--space-2);
    padding: var(--space-4);
}

.cb-card__title {
    margin: 0;
    font: 600 17px/24px var(--font-display);
}

.cb-card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    color: var(--ink-muted);
    font: 400 13px/20px var(--font-sans);
}

/* A line of meta: pieces (spans), each its own translated text, with the dot between them drawn here so that no sentence has to join them.
   A piece never breaks inside, and the dot ends the piece before it: when the line wraps, the dot stays at the end of the line it
   separates and never opens the next one. A piece longer than the line (a client name of 150 characters) ends in an ellipsis
   instead of pushing the page sideways. */
.cb-meta {
    display: flex;
    flex-wrap: wrap;
    column-gap: var(--space-2);
    min-width: 0;

    & > * {
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    & > :not(:last-child)::after {
        content: '·';
        content: '·' / '';
        margin-inline-start: var(--space-2);
    }
}

/*
 * A meta line that wraps (the address and the last visit of a person): each piece draws its dot before itself, in a
 * margin the line lends on its start side. The piece that opens a line has its dot in that margin, which the clip hides,
 * so a line never ends on a dot alone nor starts with one.
 */
.cb-meta--wrap {
    column-gap: 0;
    margin-inline-start: calc(-1 * var(--space-4));
    clip-path: inset(0 0 0 var(--space-4));

    & > :not(:last-child)::after {
        content: none;
    }

    & > ::before {
        content: '·';
        content: '·' / '';
        display: inline-block;
        width: var(--space-4);
        text-align: center;
    }
}

/*
 * Thumbnail of a file of a library: the image itself (up to 2 MB, Asset::hasPreview()) or a tile with its extension.
 * sm is a 40px square, md fills its column at 4:3 (the board of a library), lg is a 120px square.
 * The image is contained, never cropped: a logo keeps its whole shape on the sunken background.
 */
.cb-thumb {
    position: relative;
    display: grid;
    flex: none;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-sunken);
    color: var(--ink-muted);
}

.cb-thumb--sm {
    width: 40px;
    aspect-ratio: 1;
}

.cb-thumb--md {
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: var(--radius-md);
}

.cb-thumb--lg {
    width: 120px;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
}

.cb-thumb__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: var(--space-1);
    object-fit: contain;
}

.cb-thumb__label {
    max-width: 100%;
    padding-inline: 2px;
    overflow: hidden;
    font: 500 10px/16px var(--font-mono);
    letter-spacing: 0.04em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cb-thumb--md .cb-thumb__label {
    padding-inline: var(--space-1);
    font-size: 13px;
}

.cb-thumb--lg .cb-thumb__label {
    padding-inline: var(--space-1);
    font-size: 14px;
}

/*
 * Mosaic: up to four thumbnails of a library in a 2 × 2 grid, or the initial of its name on the same sunken square.
 * The square is 56px (sm) or 96px (md) whatever it holds, so a list of them lines up.
 */
.cb-mosaic {
    display: grid;
    flex: none;
    grid-template-columns: repeat(2, 1fr);
    align-content: start;
    gap: 2px;
    padding: var(--space-1);
    border-radius: var(--radius-md);
    background: var(--surface-sunken);

    & .cb-thumb {
        width: auto;
        border: 0;
        border-radius: var(--radius-sm);
        background: var(--surface-raised);
    }

    & .cb-thumb__label {
        padding-inline: 0;
        font-size: 7px;
        line-height: 8px;
    }
}

.cb-mosaic--sm {
    width: 56px;
    height: 56px;
}

.cb-mosaic--md {
    width: 96px;
    height: 96px;
    gap: var(--space-1);
    padding: 6px;

    & .cb-thumb__label {
        font-size: 10px;
        line-height: 12px;
    }
}

.cb-mosaic--initial {
    grid-template-columns: 1fr;
    place-items: center;
    align-content: center;
    padding: 0;
    color: var(--ink);
    font-family: var(--font-display);
    font-weight: 600;
    text-transform: uppercase;
}

.cb-mosaic--initial.cb-mosaic--sm {
    font-size: 24px;
    line-height: 1;
}

.cb-mosaic--initial.cb-mosaic--md {
    font-size: 40px;
    line-height: 1;
}

/*
 * Object card: a project, a client, a library or a workspace as one link (a grid tile or a row). Nothing interactive goes
 * inside it. Hover and focus change the border and the shadow, never the text; the arrow shows with them, and stays visible
 * where nothing hovers (touch).
 */
.cb-object {
    position: relative;
    display: flex;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface-raised);
    box-shadow: var(--shadow-sm);

    &,
    &:hover,
    &:focus,
    &:active {
        color: var(--ink);
    }

    &:hover,
    &:focus-visible {
        border-color: var(--line-strong);
        box-shadow: var(--shadow-md);
    }
}

.cb-object__body {
    display: grid;
    flex: 1;
    align-content: start;
    gap: 2px;
    min-width: 0;
}

.cb-object__title {
    margin: 0;
    font: 600 16px/24px var(--font-display);
    overflow-wrap: anywhere;
}

.cb-object__meta {
    color: var(--ink-muted);
    font: 400 13px/20px var(--font-sans);
}

.cb-object__status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-block-start: var(--space-1);
    font: 500 13px/20px var(--font-sans);
}

.cb-object__arrow {
    display: inline-grid;
    flex: none;
    place-items: center;
    color: var(--ink-muted);
    font-size: 18px;
}

.cb-object__aside {
    display: flex;
    flex: none;
    align-items: center;
    gap: var(--space-3);
    color: var(--ink-muted);
    font: 400 13px/20px var(--font-sans);
}

/* Grid: the image zone on top (4:3, sunken), the text under it, the arrow at the foot */
.cb-object--grid {
    flex-direction: column;
    overflow: hidden;

    & .cb-object__media {
        display: grid;
        place-items: center;
        aspect-ratio: 4 / 3;
        padding: var(--space-3);
        border-block-end: 1px solid var(--line);
        background: var(--surface-sunken);
    }

    & .cb-object__body {
        padding: var(--space-3) var(--space-4) var(--space-4);
    }

    /* The arrow sits at the foot of the card: the last line keeps clear of it, whichever of the two it is */
    & .cb-object__meta,
    & .cb-object__status {
        padding-inline-end: var(--space-5);
    }

    & .cb-object__arrow {
        position: absolute;
        inset-inline-end: var(--space-4);
        bottom: var(--space-3);
    }
}

/*
 * Row: the media on the left, the text, then what the aside says. The line never wraps: in a narrow column (the libraries of a
 * client beside its projects) the text gives way, it is the media that never drops above it. The arrow leaves the flow and
 * sits in the room the right padding keeps for it, centered on the card.
 */
.cb-object--row {
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) calc(var(--space-4) + var(--space-5)) var(--space-3) var(--space-3);

    & .cb-object__media {
        display: grid;
        flex: none;
    }

    & .cb-object__body {
        flex: 1 1 0;
    }

    & .cb-object__arrow {
        position: absolute;
        inset-inline-end: var(--space-4);
        inset-block: 0;
        height: fit-content;
        margin-block: auto;
    }
}

@media (hover: hover) {
    .cb-object__arrow {
        opacity: 0;
    }

    .cb-object:is(:hover, :focus-visible) .cb-object__arrow {
        color: var(--brand);
        opacity: 1;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .cb-object__arrow {
        transition:
            opacity 150ms,
            transform 150ms;
    }

    @media (hover: hover) {
        .cb-object__arrow {
            transform: translateX(-4px);
        }

        .cb-object:is(:hover, :focus-visible) .cb-object__arrow {
            transform: translateX(0);
        }
    }
}

/*
 * An object card with its menu of actions (a workspace of the administration): the menu is no part of the link, so it sits
 * beside it, over the right of the card. The row keeps room for it, and the arrow moves to its left.
 */
.cb-object-actions {
    position: relative;

    & > .cb-object--row {
        padding-inline-end: calc(var(--space-4) + var(--space-5) + var(--space-7));
    }

    & > .cb-object--row .cb-object__arrow {
        inset-inline-end: calc(var(--space-4) + var(--space-7));
    }
}

.cb-object-actions__menu {
    position: absolute;
    inset-inline-end: var(--space-3);
    inset-block: 0;
    height: fit-content;
    margin-block: auto;
}

/*
 * Searchable selects: Tom Select, started by symfony/ux-autocomplete, in its Bootstrap 5 theme. The theme reads the --bs-*
 * variables, which Tabler does not declare (its own carry the tblr prefix), so they are set here from the tokens. The
 * wrapper keeps the classes of the select (form-select, is-invalid), so Tabler draws the border, the chevron and the
 * state. The stylesheet of Tom Select loads after this one: each rule hangs from the wrapper to win by specificity.
 */
.ts-wrapper {
    --bs-border-color: var(--line-strong);
    --bs-border-color-translucent: var(--line);
    --bs-border-radius: var(--radius-md);
    --bs-border-radius-sm: var(--radius-sm);
    --bs-border-radius-lg: var(--radius-lg);
    --bs-border-width: 1px;
    --bs-body-bg: var(--surface-raised);
    --bs-body-color: var(--ink);
    --bs-secondary-bg: var(--surface-sunken);
    --bs-tertiary-bg: var(--surface-sunken);
    --bs-box-shadow-inset: none;
    --bs-form-invalid-color: var(--danger);
    --bs-form-valid-color: var(--success);

    /* Same height as a text field (40px: 24 + 2 x 7 + 2 x 1), whatever the control holds */
    &.single {
        min-height: 40px;
    }

    & .ts-control {
        padding-block: 7px;
        color: var(--ink);
        line-height: 24px;

        & input {
            color: var(--ink);
            line-height: 24px;
        }
    }

    /* The ring of the charte (2px, offset 2px, in the focus color), not the blue glow of the theme */
    &.focus .ts-control {
        border-color: var(--brand);
        outline: 2px solid var(--focus);
        outline-offset: 2px;
        box-shadow: none;
    }

    & .ts-dropdown {
        margin-top: var(--space-1);
        border: 1px solid var(--line);
        border-radius: var(--radius-md);
        background: var(--surface-raised);
        color: var(--ink);
        box-shadow: var(--shadow-md);

        & .option,
        & .no-results {
            padding: var(--space-2) var(--space-3);
            color: var(--ink);
        }

        & .no-results {
            color: var(--ink-muted);
        }

        & .active {
            background: var(--surface-sunken);
            color: var(--ink);
        }

        & .option.selected {
            background: var(--brand-soft);
        }

        /* What the search matched: heavier, not colored (ocre belongs to what the AI touched, and brand to the action) */
        & [data-selectable] .highlight {
            background: none;
            font-weight: 600;
        }
    }
}

/* The library list: an option is a mosaic and two lines, so the list is taller than the 200px of a plain one. */
.ts-dropdown-content.cb-library-list {
    max-height: 340px;
}

.cb-library-option {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.cb-library-option__body {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
}

.cb-library-option__name {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    overflow: hidden;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cb-library-option__meta {
    color: var(--ink-muted);
    font-size: 13px;
    line-height: 20px;
}

/* The library chosen, in the closed control: the same mosaic, smaller, then the name. */
.cb-library-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.cb-library-item .cb-mosaic {
    width: 24px;
    height: 24px;
    gap: 1px;
    padding: 2px;
    border-radius: var(--radius-sm);
}

.cb-library-item .cb-mosaic--initial {
    padding: 0;
    font-size: 13px;
}

.cb-library-item .cb-thumb {
    border-radius: 2px;
}

.cb-library-item .cb-thumb__img {
    padding: 0;
}

/* AI banner. In its working state the pulsing spark replaces the dot, and the text says what the AI works on. */
.cb-banner {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    max-width: 640px;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--accent);
    border-radius: var(--radius-md);
    background: var(--accent-soft);
    color: var(--ink);

    & .btn {
        flex: none;
        margin-inline-start: auto;
    }
}

.cb-banner__dot {
    flex: none;
    width: 10px;
    height: 10px;
    margin-top: 6px;
    border-radius: var(--radius-pill);
    background: var(--accent);
}

.cb-banner__title {
    margin: 0;
    font: 600 15px/24px var(--font-sans);
}

.cb-banner__text {
    margin: 0;
    color: var(--ink-muted);
    font: 400 13px/20px var(--font-sans);
}

.cb-banner__spark {
    flex: none;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    color: var(--accent);

    & .cb-spark {
        width: 20px;
        height: 20px;
    }
}

.cb-banner--working .cb-banner__dot {
    display: none;
}

/* The working spark on one line of text: a demo being prepared, in the administration's list. */
.cb-working-line {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    color: var(--ink);

    & .cb-spark {
        width: 14px;
        height: 14px;
        color: var(--accent);
    }
}

@media (prefers-reduced-motion: no-preference) {
    .cb-banner--working .cb-banner__spark,
    .cb-working-line .cb-spark {
        animation: cb-pulse 1.4s ease-in-out infinite;
    }

    @keyframes cb-pulse {
        0%,
        100% {
            opacity: 0.5;
            transform: scale(0.9);
        }

        50% {
            opacity: 1;
            transform: scale(1.05);
        }
    }
}

/* "Powered by" mention. The lockup is an inline SVG in currentColor: it takes the text color, never a fixed ink. */
.cb-powered {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--ink-muted);
    font: 400 12px/16px var(--font-sans);
}

.cb-powered__logo {
    display: inline-block;
    width: 98px;
    height: 18px;
    fill: currentColor;
}

/* Author mark */
.cb-author {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--ink);
    font: 400 13px/20px var(--font-sans);
}

.cb-author__mark {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-pill);

    /* Size only: the 1.5px stroke comes from .icon */
    & svg {
        width: 14px;
        height: 14px;
    }
}

.cb-author--client .cb-author__mark {
    background: var(--info-soft);
    color: var(--info);
}

.cb-author--team .cb-author__mark {
    background: var(--brand-soft);
    color: var(--brand);
}

.cb-author--ai .cb-author__mark {
    background: var(--accent-soft);
    color: var(--ink);
    font: 500 10px/1 var(--font-mono);
    letter-spacing: 0.04em;
}

.cb-author__name {
    font-weight: 600;
}

.cb-author__meta {
    color: var(--ink-muted);
}

/*
 * Drop zone of an upload (templates/upload/_dropzone.html.twig): one dashed line, in brand while files hover over the board.
 * The element of the upload controller wraps the whole board and puts is-dragover on the zone, which may sit out of view on a
 * long board; the zone also rings when its hidden file field takes the keyboard focus.
 */
.cb-dropzone {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--ink-muted);
    font: 400 14px/20px var(--font-sans);

    &.is-dragover {
        border-style: solid;
        border-color: var(--brand);
        background-color: var(--brand-soft);
    }

    &:has(input:focus-visible) {
        outline: 2px solid var(--focus);
        outline-offset: 2px;
    }
}

.cb-dropzone__limit {
    color: var(--ink);
    font-weight: 600;
}

/* The progress rows of the files in flight, under the drop zone: a gap under them only when there are some */
.cb-upload-rows:not(:empty) {
    margin-block-end: var(--space-3);
}

/*
 * Board of a library (templates/workspace/library.html.twig): the grid of files, the format filter, and the column of memories.
 * The memories column follows the scroll on a large screen and falls under the grid on a small one.
 */
.cb-filter {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);

    /* The current choice: the pair of the current entry of the menu, a toggle of links like the one of the projects */
    & .btn {
        border-radius: var(--radius-pill);

        &.active {
            background: var(--brand-soft);
            border-color: transparent;
            color: var(--brand);
        }
    }
}

.cb-filter__count {
    margin-inline-start: var(--space-1);
    color: var(--ink-muted);
    font-family: var(--font-mono);
    font-size: 12px;

    .active > & {
        color: inherit;
    }
}

.cb-board__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: var(--space-3);
    padding: 0;
}

/* A file: the thumbnail on top with its menu over a corner, then the name and its line of meta. The card is no link: it holds a menu. */
.cb-file {
    min-width: 0;
    margin: 0;
    padding: var(--space-2);
    gap: var(--space-2);
}

.cb-file__media {
    position: relative;
}

.cb-file__menu {
    position: absolute;
    inset-block-start: var(--space-2);
    inset-inline-end: var(--space-2);
}

.cb-file__body {
    min-width: 0;
    padding-inline: var(--space-1);
    padding-block-end: var(--space-1);
}

.cb-file__name {
    font: 600 14px/20px var(--font-sans);
}

.cb-file__meta {
    color: var(--ink-muted);
    font: 400 13px/20px var(--font-sans);
}

.cb-memory__main {
    flex: 1;
    min-width: 0;
}

/* The header of a library carries a menu and the brand button: on a narrow screen they drop under the title instead of squeezing it */
.page-header .row:has(.cb-add-files) > .col {
    flex-basis: 16rem;
}

@media (min-width: 992px) {
    .cb-board__memories {
        position: sticky;
        /* The fixed environment banner (app.css) covers the top of the window: the column sticks under it. 0 without banner. */
        inset-block-start: calc(var(--space-4) + var(--cb-env-banner-height, 0px));
    }
}

/*
 * Options of a single choice, each with a title and one line (cb_choices_row in templates/form/theme.html.twig): the radio,
 * then the text. The option chosen takes the brand-soft background; a disabled one fades and shows its other line (the
 * reason), so a script only disables the radio. Cards sit three in a row from 576px, one under the other below; a stack
 * holds its options in one frame.
 */
.cb-choices--cards {
    display: grid;
    gap: var(--space-3);

    @media (min-width: 576px) {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    & .cb-choice {
        border: 1px solid var(--line);
        border-radius: var(--radius-md);
    }

    & .cb-choice:has(:checked) {
        border-color: var(--brand);
    }
}

.cb-choices--stack {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);

    & .cb-choice + .cb-choice {
        border-block-start: 1px solid var(--line);
    }
}

.cb-choice {
    display: flex;
    gap: var(--space-3);
    margin: 0;
    padding: var(--space-3) var(--space-4);
    cursor: pointer;

    & .form-check-input {
        flex: none;
        margin-block-start: 0.25em;
    }

    &:has(:checked) {
        background: var(--brand-soft);
    }

    /* A disabled option fades its radio and its title; its line, the reason, stays readable */
    &:has(:disabled) {
        cursor: not-allowed;

        & :is(.form-check-input, .cb-choice__title) {
            opacity: 0.55;
        }
    }
}

.cb-choice__body {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.cb-choice__title {
    font-weight: 600;
}

.cb-choice__text {
    color: var(--ink-muted);
    font: 400 13px/18px var(--font-sans);
}

.cb-choice__text--disabled,
.cb-choice:has(:disabled) .cb-choice__text--enabled {
    display: none;
}

.cb-choice:has(:disabled) .cb-choice__text--disabled {
    display: block;
}

/* A switch in a frame the width of the form: its label at the start of the line, the switch at the end */
.cb-switch-frame {
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);

    & .form-switch {
        display: flex;
        flex-direction: row-reverse;
        justify-content: space-between;
        gap: var(--space-4);
        min-height: 0;
        margin: 0;
        padding: 0;
    }

    & .form-switch .form-check-input {
        flex: none;
        float: none;
        margin: 0;
    }

    & .form-check-label {
        font-weight: 600;
    }
}

/*
 * The People page: one card per perimeter, one row per line. From 768px a row reads on one line: the person, the access in
 * a word, the menu. Below, the access goes under the name and the menu stays top right. An invitation has a dashed circle
 * with an envelope in place of a photo.
 */
.cb-person {
    --cb-person-avatar: 2rem;
    display: grid;
    grid-template: "who menu" "access ." / minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-1) var(--space-4);

    /* The menu keeps to the first line, top right, whatever the height of the row */
    & > .dropdown {
        grid-area: menu;
        align-self: start;
    }

    @media (min-width: 768px) {
        grid-template: "who access menu" / minmax(0, 1fr) 11rem auto;
    }
}

.cb-person__who {
    display: flex;
    grid-area: who;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;

    /* A long address shortens itself, never the photo */
    & > .avatar {
        flex: none;
    }
}

.cb-person__text {
    min-width: 0;
}

.cb-person__name {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.cb-person__meta {
    color: var(--ink-muted);
    font: 400 13px/20px var(--font-sans);
}

.cb-person__access {
    grid-area: access;
    /* Under the name on a phone, past the avatar */
    padding-inline-start: calc(var(--cb-person-avatar) + var(--space-3));
    font-size: 14px;

    @media (min-width: 768px) {
        padding-inline-start: 0;
    }

    & .icon,
    & svg {
        width: 16px;
        height: 16px;
        vertical-align: -3px;
    }
}

.cb-invite-mark {
    --tblr-avatar-bg: transparent;
    --tblr-avatar-box-shadow: none;
    border: 1px dashed var(--line-strong);
    color: var(--ink-muted);

    & svg {
        width: 16px;
        height: 16px;
    }
}

/* An invitation that ran out: the tone of a warning, the text in ink */
.cb-badge-expired {
    background: var(--warning-soft);
    color: var(--ink);
}

/* The title of a section of the People page: the type (Client, Projet) small before the name, then the client of a project */
.cb-section-title .cb-meta {
    display: inline-flex;
    vertical-align: baseline;
}

.cb-section-client {
    color: var(--ink-muted);
    font-weight: 400;
}

.cb-section-kind {
    margin-inline-end: var(--space-1);
    color: var(--ink-muted);
    font: 500 13px/20px var(--font-sans);
}

/* Consent banner of www.: a card pinned to the bottom of the viewport, above the page, readable in both themes through the card tokens */
.cb-consent {
    position: fixed;
    inset-inline: var(--space-4);
    bottom: var(--space-4);
    z-index: 1030;
    max-width: 720px;
    margin-inline: auto;
    box-shadow: var(--shadow-md);
}

/* "Manage cookies" sits among the footer links as a button: drawn like them, underlined on hover like them */
.cb-consent-open {
    padding: 0;
    border: 0;
    background: none;

    &:hover {
        text-decoration: underline;
    }
}
