/* ==========================================================================
   CODETICA — Components
   ========================================================================== */

/* ------------------------------------------------------------- Buttons */

.btn {
    --btn-bg: transparent;
    --btn-fg: currentColor;
    --btn-border: transparent;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-3);
    padding: 0.95rem 1.6rem;
    border: 1px solid var(--btn-border);
    border-radius: var(--r-sm);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.005em;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--dur-2) var(--ease-out),
                border-color var(--dur-2) var(--ease-out),
                color var(--dur-2) var(--ease-out),
                transform var(--dur-1) var(--ease-out),
                box-shadow var(--dur-2) var(--ease-out);
}

.btn:active {
    transform: translateY(1px);
}

.btn__arrow {
    display: inline-block;
    transition: transform var(--dur-2) var(--ease-out);
}

.btn:hover .btn__arrow {
    transform: translateX(4px);
}

.btn--primary {
    --btn-bg: var(--accent);
    --btn-fg: #041009;
    --btn-border: var(--accent);
}

.btn--primary:hover {
    --btn-bg: var(--accent-bright);
    --btn-border: var(--accent-bright);
    box-shadow: 0 10px 30px -12px rgba(35, 180, 95, .7);
}

.btn--ghost {
    --btn-fg: var(--on-dark);
    --btn-border: var(--line-dark-2);
    backdrop-filter: blur(6px);
}

.btn--ghost:hover {
    --btn-border: var(--accent);
    --btn-bg: rgba(35, 180, 95, .1);
    --btn-fg: var(--accent-bright);
}

.btn--solid-dark {
    --btn-bg: var(--ink-1000);
    --btn-fg: #fff;
    --btn-border: var(--ink-1000);
}

.btn--solid-dark:hover {
    --btn-bg: var(--ink-700);
    --btn-border: var(--ink-700);
}

.btn--outline-dark {
    --btn-fg: var(--on-light);
    --btn-border: var(--line-light-2);
}

.btn--outline-dark:hover {
    --btn-border: var(--brand);
    --btn-fg: var(--brand);
    --btn-bg: rgba(44, 124, 66, .06);
}

.btn--sm {
    padding: 0.65rem 1.05rem;
    font-size: var(--fs-sm);
}

/* The header CTA is the one control every visitor reaches for — it gets a
   comfortable hit area rather than the compact --sm size. */
.site-header .btn--sm {
    min-width: 114px;
    padding: 0.85rem 1.4rem;
    font-size: 0.9375rem;
}

.btn--lg {
    padding: 1.1rem 2rem;
    font-size: 1rem;
}

.btn--block {
    width: 100%;
}

.btn[disabled],
.btn[aria-disabled='true'] {
    opacity: .5;
    pointer-events: none;
}

/* --------------------------------------------------------- Text link/arrow */

.link-arrow {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--accent);
    transition: gap var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out);
}

.link-arrow svg {
    transition: transform var(--dur-2) var(--ease-out);
}

.link-arrow:hover {
    color: var(--accent-bright);
}

.link-arrow:hover svg {
    transform: translateX(4px);
}

.section--light .link-arrow,
.section--alt .link-arrow {
    color: var(--brand);
}

.section--light .link-arrow:hover,
.section--alt .link-arrow:hover {
    color: var(--green-700);
}

.link-underline {
    background-image: linear-gradient(currentColor, currentColor);
    background-size: 0 1px;
    background-repeat: no-repeat;
    background-position: 0 100%;
    transition: background-size var(--dur-2) var(--ease-out);
}

.link-underline:hover {
    background-size: 100% 1px;
}

/* ------------------------------------------------- Buttons that open a family
   A component family has no page of its own, so the things that used to link
   to one are now buttons that open the dialog. These rules strip what a button
   brings with it — its own font, its centred text, its focus-inviting chrome —
   so the card, tile, chip or line of copy looks exactly as it did as a link.
   The component classes keep every other property, and each descendant still
   sets its own type. */

button.fam-card,
button.tile,
button.chip,
.linkish {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    letter-spacing: inherit;
    text-align: left;
    cursor: pointer;
}

button.fam-card,
button.tile {
    width: 100%;
}

button.chip {
    font-size: var(--fs-xs);
}

/* Reads as the sentence around it: a family name inside a line of copy. */
.linkish {
    display: inline;
    padding: 0;
    border: 0;
    background: none;
    transition: color var(--dur-1) var(--ease-out);
}

/* ------------------------------------------------------------- Chips/tags */

.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    padding: 0.45rem 0.85rem;
    border: 1px solid var(--line-dark);
    border-radius: var(--r-pill);
    background: rgba(255, 255, 255, .03);
    font-size: var(--fs-xs);
    font-weight: 500;
    color: var(--on-dark-2);
    transition: all var(--dur-2) var(--ease-out);
}

a.chip:hover,
button.chip:hover {
    border-color: var(--accent);
    color: var(--accent-bright);
    background: rgba(35, 180, 95, .1);
}

.section--light .chip,
.section--alt .chip {
    border-color: var(--line-light);
    background: var(--paper);
    color: var(--on-light-2);
}

.section--light a.chip:hover,
.section--light button.chip:hover,
.section--alt a.chip:hover,
.section--alt button.chip:hover {
    border-color: var(--brand);
    color: var(--brand);
    background: rgba(44, 124, 66, .06);
}

.chip--accent {
    border-color: color-mix(in srgb, var(--accent) 45%, transparent);
    color: var(--accent);
    background: rgba(35, 180, 95, .08);
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
}

.tag-mono {
    display: inline-block;
    padding: 3px 8px;
    border-radius: var(--r-xs);
    background: rgba(35, 180, 95, .12);
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: .08em;
    text-transform: uppercase;
}

/* ---------------------------------------------------------------- Cards */

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    border: 1px solid var(--line-light);
    border-radius: var(--r-md);
    transition: border-color var(--dur-2) var(--ease-out),
                transform var(--dur-2) var(--ease-out),
                box-shadow var(--dur-2) var(--ease-out);
}

a.card:hover,
.card--interactive:hover {
    border-color: color-mix(in srgb, var(--brand) 40%, var(--line-light));
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.card__body {
    display: grid;
    gap: var(--s-3);
    padding: var(--s-6);
}

.card--dark {
    background: var(--ink-900);
    border-color: var(--line-dark);
    color: var(--on-dark);
}

a.card--dark:hover,
.card--dark.card--interactive:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, transparent);
    box-shadow: 0 24px 60px -30px rgba(0, 0, 0, .9);
}

/* -------------------------------------------------------------- Bordered
   The "spec row" pattern — used for specifications, metadata and results. */

.spec-list {
    display: grid;
    border-top: 1px solid var(--line-light);
}

.spec-list__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--s-4);
    padding: var(--s-4) 0;
    border-bottom: 1px solid var(--line-light);
    font-size: var(--fs-sm);
}

.spec-list__row dt {
    color: var(--on-light-3);
}

.spec-list__row dd {
    margin: 0;
    font-weight: 500;
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
}

.section--dark .spec-list,
.section--deep .spec-list {
    border-color: var(--line-dark);
}

.section--dark .spec-list__row,
.section--deep .spec-list__row {
    border-color: var(--line-dark);
}

.section--dark .spec-list__row dt,
.section--deep .spec-list__row dt {
    color: var(--on-dark-3);
}

/* ---------------------------------------------------------------- Forms */

.field {
    display: grid;
    gap: var(--s-2);
}

.field__label {
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: .01em;
    color: var(--on-light-2);
}

.field__label .opt {
    font-weight: 400;
    color: var(--on-light-3);
}

.field__control {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1px solid var(--line-light-2);
    border-radius: var(--r-sm);
    background: var(--paper);
    color: var(--on-light);
    font-size: 0.9375rem;
    transition: border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out);
}

.field__control::placeholder {
    color: var(--on-light-3);
}

.field__control:hover {
    border-color: var(--on-light-3);
}

.field__control:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(44, 124, 66, .14);
}

textarea.field__control {
    min-height: 130px;
    resize: vertical;
}

select.field__control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%236B7A81' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

/* "Other — not listed" companion input. Visible by default so the form still
   works without JavaScript; forms.js closes it unless "Other" is selected. */

.field__other {
    display: grid;
    gap: var(--s-2);
    margin-top: var(--s-3);
    padding-left: var(--s-4);
    border-left: 2px solid var(--brand);
}

.field__other[hidden],
.js .field__other[data-other-closed] {
    display: none;
}

.field__other-label {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--on-light-2);
}

.field__other-hint {
    font-size: var(--fs-xs);
    color: var(--on-light-3);
}

.field--dark .field__other-label {
    color: var(--on-dark-2);
}

.field--dark .field__other-hint {
    color: var(--on-dark-3);
}

.field--error .field__control {
    border-color: var(--error);
}

.field__error {
    font-size: var(--fs-xs);
    color: var(--error);
}

.field--dark .field__label {
    color: var(--on-dark-2);
}

.field--dark .field__control {
    background-color: rgba(255, 255, 255, .04);
    border-color: var(--line-dark-2);
    color: var(--on-dark);
}

.field--dark .field__control::placeholder {
    color: var(--on-dark-4);
}

.field--dark .field__control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(35, 180, 95, .18);
}

.field--dark select.field__control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%238A9AA3' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.field-grid {
    display: grid;
    gap: var(--s-5);
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.field--full {
    grid-column: 1 / -1;
}

.form-note {
    font-size: var(--fs-xs);
    color: var(--on-light-3);
    line-height: var(--lh-relaxed);
}

.form-alert {
    padding: var(--s-4) var(--s-5);
    border-radius: var(--r-sm);
    border: 1px solid rgba(224, 91, 75, .4);
    background: rgba(224, 91, 75, .08);
    color: var(--error);
    font-size: var(--fs-sm);
}

.form-alert__title {
    font-weight: 600;
}

/* Each line names one problem and jumps to the field that has it. */
.form-alert__list {
    display: grid;
    gap: 4px;
    margin-top: var(--s-3);
    padding-left: 1.1rem;
    list-style: disc;
}

.form-alert__list .linkish {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: rgba(224, 91, 75, .45);
}

.form-alert__list .linkish:hover {
    text-decoration-color: currentColor;
}

.form-alert--ok {
    border-color: color-mix(in srgb, var(--brand) 45%, transparent);
    background: rgba(44, 124, 66, .08);
    color: var(--green-700);
}

.honeypot {
    position: absolute !important;
    left: -9999px;
    opacity: 0;
    height: 0;
    width: 0;
}

/* --------------------------------------------------------- Choice cards */

.choice-grid {
    display: grid;
    gap: var(--s-4);
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.choice {
    position: relative;
    display: block;
    cursor: pointer;
}

.choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.choice__inner {
    display: grid;
    gap: var(--s-2);
    height: 100%;
    padding: var(--s-6);
    border: 1px solid var(--line-light-2);
    border-radius: var(--r-md);
    background: var(--paper);
    transition: all var(--dur-2) var(--ease-out);
}

.choice:hover .choice__inner {
    border-color: var(--brand);
    transform: translateY(-2px);
}

.choice input:focus-visible + .choice__inner {
    outline: 2px solid var(--brand);
    outline-offset: 3px;
}

.choice input:checked + .choice__inner {
    border-color: var(--brand);
    background: rgba(44, 124, 66, .05);
    box-shadow: inset 0 0 0 1px var(--brand);
}

.choice__title {
    font-family: var(--font-display);
    font-size: 1.0625rem;
    font-weight: 600;
}

.choice__text {
    font-size: var(--fs-sm);
    color: var(--on-light-2);
    line-height: var(--lh-relaxed);
}

.choice__mark {
    position: absolute;
    top: var(--s-5);
    right: var(--s-5);
    width: 18px;
    height: 18px;
    border: 1px solid var(--line-light-2);
    border-radius: 50%;
    transition: all var(--dur-2) var(--ease-out);
}

.choice input:checked + .choice__inner .choice__mark {
    border-color: var(--brand);
    background: var(--brand);
    box-shadow: inset 0 0 0 3px var(--paper);
}

/* --------------------------------------------------------------- Upload */

.upload {
    display: grid;
    gap: var(--s-3);
    padding: var(--s-8);
    border: 1px dashed var(--line-light-2);
    border-radius: var(--r-md);
    text-align: center;
    background: var(--paper-alt);
    transition: all var(--dur-2) var(--ease-out);
}

.upload.is-dragging,
.upload:focus-within {
    border-color: var(--brand);
    background: rgba(44, 124, 66, .05);
}

.upload__icon {
    justify-self: center;
    color: var(--brand);
}

.upload__hint {
    font-size: var(--fs-xs);
    color: var(--on-light-3);
}

.upload__file {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    padding: var(--s-3) var(--s-4);
    border: 1px solid var(--line-light);
    border-radius: var(--r-sm);
    background: var(--paper);
    font-size: var(--fs-sm);
    text-align: left;
}

.upload.has-file .upload__file {
    display: flex;
}

.upload.has-file .upload__prompt {
    display: none;
}

/* ------------------------------------------------------------- Overlays */

.overlay-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--z-overlay);
    background: rgba(2, 10, 14, .72);
    backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--dur-2) var(--ease-out), visibility var(--dur-2);
}

.overlay-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

/* ---------------------------------------------------------- Search modal */

.search-modal {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-overlay) + 1);
    display: grid;
    align-content: start;
    justify-items: center;
    padding: clamp(1rem, 8vh, 7rem) var(--gutter) var(--s-8);
    pointer-events: none;
}

.search-modal.is-open {
    pointer-events: auto;
}

.search-panel {
    width: min(760px, 100%);
    background: var(--ink-900);
    border: 1px solid var(--line-dark-2);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-dark);
    overflow: hidden;
    opacity: 0;
    transform: translateY(-14px) scale(.985);
    transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out);
}

.search-modal.is-open .search-panel {
    opacity: 1;
    transform: none;
}

.search-panel__head {
    display: flex;
    align-items: center;
    gap: var(--s-4);
    padding: var(--s-5) var(--s-6);
    border-bottom: 1px solid var(--line-dark);
}

.search-panel__input {
    flex: 1;
    min-width: 0;
    background: none;
    border: 0;
    outline: none;
    color: var(--on-dark);
    font-size: 1.0625rem;
}

.search-panel__input::placeholder {
    color: var(--on-dark-4);
}

.search-panel__kbd {
    padding: 3px 7px;
    border: 1px solid var(--line-dark-2);
    border-radius: var(--r-xs);
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--on-dark-3);
}

.search-panel__body {
    max-height: min(60vh, 520px);
    overflow-y: auto;
    padding: var(--s-3) 0 var(--s-4);
}

.search-empty {
    padding: var(--s-10) var(--s-6);
    text-align: center;
    color: var(--on-dark-3);
    font-size: var(--fs-sm);
}

.search-group__title {
    padding: var(--s-4) var(--s-6) var(--s-2);
    font-family: var(--font-mono);
    font-size: 0.625rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--on-dark-4);
}

.search-result {
    display: flex;
    align-items: center;
    gap: var(--s-4);
    padding: var(--s-3) var(--s-6);
    transition: background var(--dur-1) var(--ease-out);
}

.search-result:hover,
.search-result.is-active {
    background: rgba(35, 180, 95, .1);
}

.search-result__title {
    font-weight: 500;
    font-size: 0.9375rem;
}

.search-result__meta {
    font-size: var(--fs-xs);
    color: var(--on-dark-3);
}

.search-result__badge {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 0.625rem;
    letter-spacing: .1em;
    color: var(--accent);
}

/* ---------------------------------------------------------------- Drawer */

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: calc(var(--z-overlay) + 1);
    width: min(520px, 100%);
    background: var(--paper);
    color: var(--on-light);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform var(--dur-3) var(--ease-out);
    display: flex;
    flex-direction: column;
    visibility: hidden;
}

.drawer.is-open {
    transform: none;
    visibility: visible;
}

.drawer__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--s-4);
    padding: var(--s-8) var(--s-8) var(--s-5);
    border-bottom: 1px solid var(--line-light);
}

.drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: var(--s-6) var(--s-8) var(--s-10);
    display: grid;
    gap: var(--s-5);
    align-content: start;
}

.drawer__context {
    display: grid;
    gap: var(--s-2);
    padding: var(--s-4) var(--s-5);
    border: 1px solid var(--line-light);
    border-left: 2px solid var(--brand);
    border-radius: var(--r-sm);
    background: var(--paper-alt);
    font-size: var(--fs-xs);
}

.drawer__context dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--s-1) var(--s-4);
    margin: 0;
}

.drawer__context dt {
    color: var(--on-light-3);
}

.drawer__context dd {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line-light);
    border-radius: var(--r-sm);
    color: var(--on-light-2);
    transition: all var(--dur-2) var(--ease-out);
    flex: none;
}

.icon-btn:hover {
    border-color: var(--on-light);
    color: var(--on-light);
}

.icon-btn--dark {
    border-color: var(--line-dark-2);
    color: var(--on-dark-2);
}

.icon-btn--dark:hover {
    border-color: var(--accent);
    color: var(--accent-bright);
}

/* -------------------------------------------------------------- Breadcrumb */

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-2);
    font-size: var(--fs-xs);
    color: var(--on-dark-3);
}

.breadcrumb a:hover {
    color: var(--accent-bright);
}

.breadcrumb li:not(:last-child)::after {
    content: '/';
    margin-left: var(--s-2);
    opacity: .45;
}

.breadcrumb li {
    display: inline-flex;
    align-items: center;
}

/* ---------------------------------------------------------------- Scroll row */

.scroll-row {
    display: grid;
    gap: var(--s-4);
}

@media (max-width: 720px) {
    .scroll-row {
        grid-auto-flow: column;
        grid-auto-columns: minmax(255px, 78%);
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scroll-padding-inline: var(--gutter);
        padding-inline: var(--gutter);
        margin-inline: calc(var(--gutter) * -1);
        padding-bottom: var(--s-3);
        scrollbar-width: none;
    }

    .scroll-row::-webkit-scrollbar {
        display: none;
    }

    .scroll-row > * {
        scroll-snap-align: start;
    }
}

/* ================================================= Component family dialog
   Opens from a family tile on the home page. Native <dialog>, so focus is
   trapped, Escape closes and the backdrop is the browser's own. */

.fam-modal {
    width: min(100% - 2rem, 46rem);
    max-height: min(88vh, 44rem);
    /* Picture, then copy: the copy takes the space that is left and scrolls
       inside it, so the button is never pushed past the screen edge.
       The layout belongs to [open] and not here: a `display` on the element
       itself would beat the browser's own `dialog:not([open]) { display:none }`
       — author styles win over the user-agent sheet — and the dialog would
       stay painted in the page after close(). */
    grid-template-rows: auto minmax(0, 1fr);
    padding: 0;
    border: 1px solid var(--line-light);
    border-radius: var(--r-md);
    background: var(--paper);
    color: var(--on-light);
    box-shadow: 0 40px 90px -40px rgba(2, 10, 14, .45);
    overflow: hidden;
}

.fam-modal::backdrop {
    background: rgba(2, 10, 14, .55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.fam-modal[open] {
    display: grid;
    animation: famIn 220ms var(--ease-out);
}

.fam-modal[open]::backdrop {
    animation: famFade 220ms var(--ease-out);
}

@keyframes famIn {
    from { opacity: 0; transform: translateY(10px) scale(.985); }
    to { opacity: 1; transform: none; }
}

@keyframes famFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .fam-modal[open],
    .fam-modal[open]::backdrop { animation: none; }
}

.fam-modal__close {
    position: absolute;
    top: var(--s-4);
    right: var(--s-4);
    z-index: 2;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line-light);
    border-radius: 50%;
    background: rgba(255, 255, 255, .92);
    color: var(--on-light-2);
    cursor: pointer;
    transition: color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out);
}

.fam-modal__close:hover {
    color: var(--on-light);
    border-color: var(--on-light-3);
}

/* A band, not a half-screen: capped in viewport units as well as by ratio so
   the copy and its buttons still fit on a laptop screen. */
.fam-modal__media {
    /* The width has to be stated: a box with both an aspect-ratio and a
       max-height is sized by its ratio, and would narrow instead of fill. */
    width: 100%;
    margin: 0;
    aspect-ratio: 16 / 6.6;
    max-height: 32vh;
    overflow: hidden;
    background: var(--paper-alt);
}

.fam-modal__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fam-modal__body {
    display: grid;
    align-content: start;
    gap: var(--s-4);
    padding: clamp(1.25rem, 0.9rem + 1.6vw, 2rem) clamp(1.5rem, 1rem + 2vw, 2.25rem);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.fam-modal__title {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 1.1rem + 1vw, 1.9rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--on-light);
}

.fam-modal__text {
    font-size: calc(var(--fs-sm) + 1px);
    line-height: var(--lh-relaxed);
    color: var(--on-light-2);
}

.fam-modal__label {
    margin-bottom: var(--s-3);
    font-family: var(--font-mono);
    font-size: clamp(11px, 0.7vw, 12px);
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--on-light-3);
}

.fam-modal__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    list-style: none;
}

.fam-modal__chips li {
    padding: 5px 11px;
    border: 1px solid var(--line-light);
    border-radius: var(--r-sm);
    background: var(--paper-alt);
    font-size: var(--fs-xs);
    color: var(--on-light-2);
}

.fam-modal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-3);
    padding-top: var(--s-4);
    margin-top: var(--s-2);
    border-top: 1px solid var(--line-light);
}

.fam-modal__block[hidden],
.fam-modal__media[hidden] {
    display: none;
}

@media (max-width: 560px) {
    .fam-modal {
        width: calc(100% - 1.5rem);
        max-height: 92vh;
    }

    .fam-modal__media {
        aspect-ratio: 16 / 7.6;
        max-height: 28vh;
    }

    .fam-modal__actions .btn {
        width: 100%;
        justify-content: center;
    }
}
