/*
 * Forovanta Community Software
 * Copyright (c) 2026 Zovanta Software Co. <sales@zovanta.dev> - https://zovanta.dev
 * Licensed under the Forovanta Free License Agreement. See LICENSE for details.
 *
 * The Downloads area's own stylesheet: the index, a listing and the submission form.
 *
 * It is a page's worth of CSS rather than the board's, which is why it is a file of its own
 * and why `views/layout/header.php` loads it on those three pages and nowhere else. The
 * vocabulary is the same as `assets/forum.css` — the same tokens, the same radius, the same
 * one-card-shadow rule — so a heading, a button and a card on this page look like the ones
 * beside them, and a board that restyles itself restyles these too.
 *
 * The layout is the React build's, class for class in spirit:
 *
 *   * the heading with its three shortcuts and the lede under it;
 *   * the kind tabs, which are the Files / Add-ons / Themes filters;
 *   * the featured shelf, a slider of up to six cards, three of them in view;
 *   * a two-column body — a 240px sidebar of category, top-resource and review cards, and
 *     the resource list itself, with the dashed empty state it shows when there is nothing
 *     to list.
 *
 * Everything is inside `@layer legacy`, like the board's own sheet: an *unlayered* rule beats
 * a layered one whatever its specificity, so a file that skipped the layer would silently
 * outrank every rule it was written to sit beside.
 */
@layer legacy {

/* ---------- the page ---------- */

.dln-page {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 0;
}

.dln-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem;
}

.dln-head-text { min-width: 0; }

.dln-head h1 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1.5rem;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.dln-lede {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: var(--muted);
    max-width: 70ch;
}

.dln-head-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.dln-head-actions .button,
.dln-control { border-radius: 999px; }

.dln-head-actions form { margin: 0; }

.dln-button-icon { width: 1rem; height: 1rem; flex-shrink: 0; }

/* ---------- the kind tabs ---------- */

.dln-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.dln-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    background: var(--surface);
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.dln-tab:hover {
    text-decoration: none;
    background: color-mix(in srgb, var(--surface-2) 70%, transparent);
    color: var(--text);
}

.dln-tab.is-on {
    border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
    background: var(--accent-soft);
    color: var(--accent-soft-fg);
}

.dln-tab-icon { width: 0.875rem; height: 0.875rem; }
.dln-tab-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.dln-tab.is-on .dln-tab-count { color: inherit; opacity: 0.75; }

/* ---------- the featured shelf ---------- */

/*
 * The shelf is a slider: one row of cards that scrolls sideways under a wheel, a finger or
 * a trackpad, with two arrows for a mouse that has neither.
 *
 * It was a wrapping grid of up to six cards, which on a board with one featured listing was
 * a single card in the top-left corner of a large empty box. A track is the same six cards
 * in the same order and the same reading order; the arrows are drawn by this page's own
 * script and the track is an ordinary horizontal scroller, so with scripting off it is still
 * the shelf, scrolled the way the browser scrolls anything else.
 */
.dln-shelf {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

/*
 * The track is an ordinary horizontal scroller underneath, but its scrollbar is hidden on
 * purpose: the shelf slides itself (and the arrows step it), so a bar under the cards reads
 * as a control that is not the one moving them. Dragging and the wheel still work — the
 * overflow is only unseen, not suppressed.
 */
.dln-shelf-track {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    /*
     * No scroll snapping: the shelf is a seamless continuous loop now (`assets/shelf.js`), and a
     * snap point under an animated `scrollLeft` fights every frame of it. The arrows and the
     * wheel still move it by hand.
     */
    scroll-snap-type: none;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 0.35rem;
}

.dln-shelf-track::-webkit-scrollbar { display: none; }

.dln-shelf-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.dln-shelf-arrows { display: flex; align-items: center; gap: 0.35rem; }

.dln-shelf-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
}

.dln-shelf-arrow:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

/*
 * `[hidden]` is written out rather than left to the browser, for the same reason the
 * editor's popovers carry it: the attribute is only a user-agent rule, and this button
 * declares its own `display`, so `arrow.hidden = true` would hide nothing. An arrow at the
 * end it cannot scroll towards is a control that lies.
 */
.dln-shelf-arrow[hidden] { display: none; }
.dln-shelf-arrow-icon { width: 0.9rem; height: 0.9rem; }
/* The pause switch, pressed: it reads as "on" while the shelf is held still. */
.dln-shelf-playpause[aria-pressed="true"] {
    background: color-mix(in srgb, var(--accent) 16%, var(--surface));
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}

.dln-feature {
    /*
     * Three across at the shell's width — the React shelf's own `lg:grid-cols-3` — and no
     * more on a wider one: four cards is a different shelf, not a longer one.
     */
    flex: 0 0 min(17rem, calc((100% - 1.5rem) / 3));
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    background: var(--surface);
    color: var(--text);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.dln-feature:hover {
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

.dln-feature-body {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.dln-feature-title {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
    min-width: 0;
}

.dln-feature-title > span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dln-feature-tagline {
    font-size: 0.75rem;
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dln-feature-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.688rem;
    color: var(--muted);
}

.dln-featured-more { margin: 0; text-align: right; font-size: 0.75rem; }
.dln-featured-more a { color: var(--accent); }

/* ---------- the two columns ---------- */

.dln-columns {
    display: grid;
    grid-template-columns: 15rem minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.dln-side,
.dln-main { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

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

/*
 * The card clips so its head and cover art stop at the rounded corners — and it clips with
 * `clip`, not `hidden`.
 *
 * The listing's own edit form holds the rich text editor, and the editor's bars are sticky
 * (`.editor-bars` in `assets/forum.css`). `overflow: hidden` would make this card their scroll
 * container — and a card never scrolls, so a sticky box inside one never moves and the bars
 * would slide away down a long description. `clip` cuts exactly the same way, corners included,
 * without creating that container. `hidden` stays first for a browser with no `clip`.
 */
.dln-card {
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
    overflow: clip;
}

.dln-card-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
}

.dln-card-head h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 0.938rem;
    font-weight: 600;
    min-width: 0;
}

.dln-card-icon { width: 1rem; height: 1rem; color: var(--muted); flex-shrink: 0; }

.dln-card-toggle {
    margin-left: auto;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 999px;
    border: 1px solid var(--border);
}

.dln-card-toggle:hover { text-decoration: none; color: var(--text); background: var(--surface-2); }
.dln-card-toggle-icon { width: 0.8rem; height: 0.8rem; }

.dln-card-body { padding: 0.5rem; }
.dln-card-body.dln-form,
.dln-card-body.dln-info,
.dln-card-body.dln-figures { padding: 1rem; }

/* ---------- the sidebar's three cards ---------- */

.dln-cat,
.dln-top,
.dln-review-line,
.dln-related {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.4rem 0.6rem;
    border-radius: calc(var(--radius) - 4px);
    color: var(--text);
    font-size: 0.875rem;
    min-width: 0;
}

.dln-cat:hover,
.dln-top:hover,
.dln-review-line:hover,
.dln-related:hover {
    text-decoration: none;
    background: color-mix(in srgb, var(--surface-2) 60%, transparent);
}

.dln-cat.is-on {
    background: var(--accent-soft);
    color: var(--accent-soft-fg);
    font-weight: 500;
}

.dln-cat-name { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }

.dln-cat-name img { width: 1.25rem; height: 1.25rem; border-radius: 0.25rem; object-fit: cover; }
.dln-cat-dot { width: 0.5rem; height: 0.5rem; border-radius: 999px; flex-shrink: 0; }
.dln-cat-count { margin-left: auto; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.dln-cat.is-on .dln-cat-count { color: inherit; opacity: 0.8; }

.dln-top-body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }

.dln-top-title {
    font-size: 0.813rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dln-top-meta { font-size: 0.688rem; color: var(--muted); }
.dln-review-line { flex-direction: column; align-items: flex-start; gap: 0.15rem; }
.dln-empty-line { margin: 0; padding: 0.75rem 0.6rem; font-size: 0.75rem; color: var(--muted); }

/* ---------- the list's heading and filters ---------- */

.dln-list-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.dln-count { margin: 0; font-size: 0.875rem; color: var(--muted); }

.dln-filter-badge {
    margin-left: 0.25rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-fg);
    font-size: 0.625rem;
    font-weight: 700;
}

.dln-filters {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.dln-filters-title {
    margin: 0;
    font-size: 0.688rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.dln-filters-row { display: flex; flex-wrap: wrap; gap: 0.375rem; }

.dln-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted);
}

.dln-pill:hover { text-decoration: none; background: color-mix(in srgb, var(--surface-2) 70%, transparent); color: var(--text); }

.dln-pill.is-on {
    border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
    background: var(--accent-soft);
    color: var(--accent-soft-fg);
}

.dln-pill-icon { width: 0.875rem; height: 0.875rem; }

.dln-filters-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.dln-check {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text);
}

.dln-check:hover { text-decoration: none; }

.dln-check-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    border: 1px solid var(--input);
    border-radius: 0.25rem;
    background: var(--bg);
}

.dln-check-box.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.dln-check-icon { width: 0.75rem; height: 0.75rem; }

/* ---------- the empty state ---------- */

/*
 * What the list says when there is nothing in it, drawn as the React page's `EmptyState`
 * draws it: a dashed frame, the glyph above the sentence, and everything centred.
 *
 * It had no rule at all, which is why the icon and the message sat against the card's left
 * edge as if the text had fallen in rather than been placed.
 */
.dln-blank {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 3.5rem 1.5rem;
    border: 1px dashed var(--border);
    text-align: center;
}

.dln-blank-icon {
    width: 2.5rem;
    height: 2.5rem;
    margin-bottom: 0.25rem;
    color: color-mix(in srgb, var(--muted) 60%, transparent);
}

.dln-blank-title { margin: 0; font-weight: 500; }
.dln-blank-text { margin: 0; max-width: 24rem; font-size: 0.875rem; color: var(--muted); }
.dln-blank .button { margin-top: 0.75rem; }

/* ---------- one resource row ---------- */

.dln-list {
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.dln-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.dln-row:last-child { border-bottom: none; }
.dln-row:hover { text-decoration: none; background: color-mix(in srgb, var(--surface-2) 45%, transparent); }

.dln-row-body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; flex: 1; }

.dln-row-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.dln-row-name { font-size: 0.875rem; font-weight: 600; }

.dln-row-meta { font-size: 0.688rem; color: var(--muted); }

.dln-row-tagline {
    font-size: 0.75rem;
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dln-row-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.1rem;
    flex-shrink: 0;
    text-align: right;
}

.dln-row-figure { font-size: 0.688rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- the shared marks ---------- */

.dln-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    flex-shrink: 0;
    border-radius: 0.5rem;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 30%, transparent), color-mix(in srgb, var(--accent) 6%, transparent));
    color: var(--accent);
    font-size: 0.875rem;
    font-weight: 700;
    overflow: hidden;
}

.dln-mark img { width: 100%; height: 100%; object-fit: cover; }
.dln-mark--lg { width: 4rem; height: 4rem; font-size: 1rem; }
.dln-mark--sm { width: 2.25rem; height: 2.25rem; font-size: 0.75rem; }
.dln-mark--dot { border-radius: 999px; font-size: 0.688rem; }

.dln-kind {
    display: inline-flex;
    align-items: center;
    padding: 0.05rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.dln-kind--addon {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    color: var(--accent-soft-fg);
}

.dln-kind--theme {
    border-color: color-mix(in srgb, #0d9488 45%, var(--border));
    background: color-mix(in srgb, #0d9488 14%, transparent);
    color: #2dd4bf;
}

.dln-official {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.05rem 0.5rem;
    border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent-soft-fg);
}

.dln-badge-icon { width: 0.75rem; height: 0.75rem; }
.dln-pin { display: inline-flex; color: #f59e0b; }
.dln-pin-icon { width: 1rem; height: 1rem; }

/* Five stars, drawn wherever a rating is shown. */
.res-stars { display: inline-flex; align-items: center; gap: 0.0625rem; color: color-mix(in srgb, var(--muted) 45%, transparent); }
.res-star { display: inline-flex; }
.res-star.is-on { color: #fbbf24; }
.res-star-icon { width: 0.8rem; height: 0.8rem; }

/* ---------- the listing page ---------- */

.dln-head--listing { align-items: flex-start; }

.dln-meta-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin: 0.4rem 0 0;
    font-size: 0.813rem;
    color: var(--muted);
}

.dln-meta-line a { color: var(--muted); }
.dln-meta-line .dln-mark { width: 2.25rem; height: 2.25rem; }

.dln-area-chip {
    padding: 0.05rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.dln-price {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.875rem;
    font-weight: 600;
}

.dln-price.is-paid { background: color-mix(in srgb, #10b981 16%, transparent); color: #34d399; }

.dln-control {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    height: 2.25rem;
    padding: 0 0.95rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
}

.dln-control:hover { text-decoration: none; background: color-mix(in srgb, var(--surface-2) 70%, var(--accent-soft)); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }

.dln-manage { position: relative; }
.dln-manage > summary { list-style: none; }
.dln-manage > summary::-webkit-details-marker { display: none; }

.dln-manage-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.35rem);
    z-index: 20;
    min-width: 15rem;
    padding: 0.35rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.dln-manage-menu form { margin: 0; }

.dln-manage-menu button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: none;
    border-radius: calc(var(--radius) - 6px);
    background: none;
    color: var(--text);
    font: inherit;
    font-size: 0.813rem;
    text-align: left;
    cursor: pointer;
}

.dln-manage-menu button:hover { background: var(--surface-2); }
.dln-manage-menu button.is-danger { color: var(--danger); }

/* What the menu does not do, said under the two controls that do it. A note rather than a third
   button: nothing here is pressable, so it is not drawn as something that is. */
.dln-manage-note {
    margin: 0.35rem 0 0.15rem;
    padding: 0.45rem 0.6rem 0;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.75rem;
    line-height: 1.45;
}

.dln-allowance { margin: 0; font-size: 0.75rem; color: var(--muted); }

.dln-notice {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    background: var(--surface);
    font-size: 0.875rem;
}

.dln-notice.is-pending { border-color: color-mix(in srgb, #f59e0b 45%, var(--border)); background: color-mix(in srgb, #f59e0b 10%, transparent); }
.dln-notice.is-bad { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.dln-notice-title { margin: 0; font-weight: 600; }
.dln-notice p + p { margin: 0.25rem 0 0; color: var(--muted); }

.dln-tag-row { display: flex; flex-wrap: wrap; gap: 0.375rem; }

.dln-tag {
    padding: 0.15rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.75rem;
}

.dln-tag:hover { text-decoration: none; color: var(--text); }

.dln-tabbar {
    display: flex;
    overflow-x: auto;
    gap: 0.25rem;
    padding: 0.25rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.dln-tabbar-item {
    flex: 1 1 auto;
    min-width: 7rem;
    padding: 0.5rem 1rem;
    border-radius: calc(var(--radius) - 4px);
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--muted);
}

.dln-tabbar-item:hover { text-decoration: none; background: var(--surface-2); color: var(--text); }
.dln-tabbar-item.is-on { background: var(--accent); color: var(--accent-fg); box-shadow: var(--shadow); }

.dln-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.dln-detail-main,
.dln-detail-side { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

.dln-lead-line { margin: 0 0 0.75rem; font-weight: 500; }

.dln-hint {
    margin: 0 0 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 4px);
    background: color-mix(in srgb, var(--surface-2) 40%, transparent);
    font-size: 0.75rem;
    color: var(--muted);
}

.dln-cover {
    margin: 0 0 1rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 4px);
    background: color-mix(in srgb, var(--surface-2) 35%, transparent);
    overflow: hidden;
}

.dln-cover img { display: block; width: 100%; max-height: 34rem; object-fit: contain; }

/*
 * The screenshot gallery under the cover.
 *
 * A stable main viewer above a row of small thumbnails, and a lightbox over the page. The
 * viewer is a **fixed-aspect box** with a reserved height, so a square, a wide and a tall shot
 * all occupy the same box and selecting a different one cannot make the page move — the image is
 * `object-fit: contain`, so it is never cropped and never stretched. Nothing here is sized from
 * the image's own pixels, which is what the old slider got wrong.
 */
.dln-gallery { margin: 0 0 1rem; display: flex; flex-direction: column; gap: 0.5rem; }

.dln-gallery-viewer { position: relative; }

/*
 * The reserved box. `aspect-ratio` gives it its height before any image has loaded, and the
 * image fills it with `object-fit: contain`, so the height is the stylesheet's and not the
 * screenshot's. The mobile ratio is taller so a portrait shot is not letterboxed to a slit.
 */
.dln-gallery-frame {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 4px);
    background: color-mix(in srgb, var(--surface-2) 35%, transparent);
    overflow: hidden;
    aspect-ratio: 16 / 9;
    cursor: zoom-in;
}
.dln-gallery-img { display: block; width: 100%; height: 100%; object-fit: contain; }
.dln-gallery-img.is-broken { visibility: hidden; }

/* `[hidden]` is written out: the element declares its own `display`, so the attribute alone
   would be out-ranked and the placeholder would show over every picture. */
.dln-gallery-broken {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    color: var(--muted);
    font-size: 0.813rem;
}
.dln-gallery-broken[hidden] { display: none; }
.dln-gallery-broken-icon { width: 1.5rem; height: 1.5rem; }

.dln-gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    color: var(--text);
    cursor: pointer;
}
.dln-gallery-arrow:hover { background: var(--surface); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.dln-gallery-arrow--prev { left: 0.5rem; }
.dln-gallery-arrow--next { right: 0.5rem; }
.dln-gallery-icon { width: 1.1rem; height: 1.1rem; }

.dln-gallery-counter {
    position: absolute;
    right: 0.5rem;
    bottom: 0.5rem;
    z-index: 2;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: color-mix(in srgb, #000 55%, transparent);
    color: #fff;
    font-size: 0.688rem;
    font-variant-numeric: tabular-nums;
}

/* The thumbnail strip: small by design, and a horizontal scroller on a narrow screen. */
.dln-gallery-thumbs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding-bottom: 0.25rem;
    scrollbar-width: thin;
}
.dln-gallery-thumb {
    flex: 0 0 auto;
    width: 4.5rem;
    height: 3rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 6px);
    background: var(--surface);
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.dln-gallery-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.dln-gallery-thumb:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.dln-gallery-thumb.is-on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.dln-gallery-thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/*
 * Theme-proofing (REQ-074).
 *
 * A board's own theme stylesheet is printed **after** this file (`theme_style_html()` in the
 * layout head), and a theme may carry a broad rule — `img { … }`, `.downloads img { … }` — whose
 * specificity beats the single-class rules above. When that happened, the main viewer lost its
 * fixed height and drew a portrait screenshot at full size (an oversized, tall viewer) and the
 * thumbnail strip lost its small fixed boxes. These scoped rules raise the structural gallery
 * rules one class above any such selector, so the frame stays a fixed-aspect `contain` box and the
 * thumbnails stay small whatever the theme does. They are additive: on a board that already
 * follows the base rules the rendering is identical.
 */
.dln-gallery .dln-gallery-frame { display: block; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; }
.dln-gallery .dln-gallery-img { display: block; width: 100%; height: 100%; object-fit: contain; }
.dln-gallery .dln-gallery-thumbs { display: flex; flex-wrap: nowrap; gap: 0.5rem; overflow-x: auto; }
.dln-gallery .dln-gallery-thumb { flex: 0 0 auto; width: 4.5rem; height: 3rem; overflow: hidden; }
.dln-gallery .dln-gallery-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }

/*
 * The lightbox.
 *
 * Fixed over the whole page. The script locks the background scroll while it is open and restores
 * the exact scroll position when it closes, traps focus inside it, and returns focus to whatever
 * opened it. The dialog itself is styled on the dark backdrop rather than on the theme's surface
 * tokens, so it reads the same in light and dark modes.
 */
.dln-lightbox {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3.5rem 1rem;
    background: color-mix(in srgb, #000 82%, transparent);
}
.dln-lightbox[hidden] { display: none; }
.dln-lightbox-stage { display: flex; align-items: center; justify-content: center; margin: 0; max-width: min(96vw, 72rem); max-height: 100%; }
.dln-lightbox-img {
    max-width: 100%;
    max-height: calc(100vh - 7rem);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: calc(var(--radius) - 4px);
}
.dln-lightbox-img.is-broken { visibility: hidden; }

.dln-lightbox-arrow,
.dln-lightbox-close {
    position: absolute;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 1px solid color-mix(in srgb, #fff 28%, transparent);
    border-radius: 999px;
    background: color-mix(in srgb, #fff 16%, transparent);
    color: #fff;
    cursor: pointer;
}
.dln-lightbox-arrow:hover,
.dln-lightbox-close:hover { background: color-mix(in srgb, #fff 30%, transparent); }
.dln-lightbox-arrow:focus-visible,
.dln-lightbox-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.dln-lightbox-arrow--prev { left: 0.75rem; top: 50%; transform: translateY(-50%); }
.dln-lightbox-arrow--next { right: 0.75rem; top: 50%; transform: translateY(-50%); }
.dln-lightbox-close { top: 0.75rem; right: 0.75rem; }

.dln-lightbox-counter {
    position: absolute;
    left: 50%;
    bottom: 1rem;
    transform: translateX(-50%);
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    background: color-mix(in srgb, #000 55%, transparent);
    color: #fff;
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

/* A narrower screen gets a taller viewer and smaller arrows that sit over the corners. */
@media (max-width: 40rem) {
    .dln-gallery-frame { aspect-ratio: 4 / 3; }
    .dln-gallery-arrow { width: 2rem; height: 2rem; }
    .dln-lightbox-arrow--prev { left: 0.375rem; }
    .dln-lightbox-arrow--next { right: 0.375rem; }
}

@media (prefers-reduced-motion: reduce) {
    .dln-gallery-thumb { transition: none; }
}

/* The gallery editor on the listing's own edit form. */
/*
 * The demo URL row's “open in a new tab” checkbox.
 *
 * The board's global `input` rule is `width: 100%; height: 2.25rem`, which would stretch this
 * tick box across the field; the same correction the area picker makes applies here.
 */
.dln-demo-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}
.dln-demo-tab input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    flex: 0 0 auto;
}

/*
 * The Compatibility picker.
 *
 * A multiple select: the global `input` rule does not reach it, but it still needs a sensible
 * height (a few rows, not the whole list) and room to breathe under its label, so a board with
 * many presets does not stretch the form to the length of the list.
 */
.dln-compat-select {
    width: 100%;
    max-width: 100%;
    min-height: 4.5rem;
    padding: 0.35rem;
    line-height: 1.35;
}
.dln-compat-select option {
    padding: 0.15rem 0.35rem;
}

.dln-shots-edit {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 4px);
}
.dln-shots-edit legend { padding: 0 0.375rem; font-weight: 600; }
.dln-shots-edit-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.dln-shots-thumb { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.75rem; cursor: pointer; }
.dln-shots-thumb img { display: block; width: 5rem; height: 3.25rem; border: 1px solid var(--border); border-radius: calc(var(--radius) - 6px); object-fit: cover; }
/*
 * The screenshot Remove tick box.
 *
 * The board's global `input, textarea, select { width: 100%; }` and `input { height: 2.25rem; }`
 * (assets/forum.css) are right for a text field and wrong for a tick box: without an override
 * this control was drawn stretched to the thumbnail's full width and half again as tall as it is
 * wide. `.dln-area input[type="checkbox"]` already corrects the same rule for "Where this is
 * listed"; the gallery editor needs the same treatment, scoped to this one control so no other
 * form input changes size. The `<label>` around the thumbnail and its caption stays clickable,
 * and the caption keeps a 1rem box on the text baseline.
 */
.dln-shots-thumb > span { display: inline-flex; align-items: center; gap: 0.375rem; }
.dln-shots-thumb input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    margin: 0;
    padding: 0;
    flex: 0 0 auto;
    accent-color: var(--accent);
}
.dln-body { font-size: 0.938rem; line-height: 1.65; overflow-wrap: anywhere; }

.dln-share {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.dln-share form { margin: 0; }
.dln-report { position: relative; }
.dln-report > summary { list-style: none; }
.dln-report > summary::-webkit-details-marker { display: none; }

.dln-report form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 4px);
    background: var(--surface-2);
    width: min(28rem, 100%);
}

.dln-report label { font-size: 0.75rem; color: var(--muted); }
.dln-report input { margin-top: 0.25rem; }

/* the tables the History tab draws */
.dln-table { border: 1px solid var(--border); border-radius: calc(var(--radius) - 4px); overflow: hidden; }

.dln-table-head,
.dln-table-row {
    display: grid;
    grid-template-columns: minmax(6rem, 0.8fr) minmax(7rem, 0.8fr) minmax(0, 1.6fr) auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.6rem 0.85rem;
    font-size: 0.813rem;
}

.dln-table-head {
    background: color-mix(in srgb, var(--surface-2) 45%, transparent);
    font-size: 0.688rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.dln-table-row { border-top: 1px solid var(--border); }
/*
 * The History table's releases — a row of facts, then the note.
 *
 * The grid above is for facts (a version, a date, a file). A release note is prose, and drawn as
 * the third column of that grid it sat in a strip a few hundred pixels wide with the rest of the
 * row empty beside it — which is exactly the "tiny skinny space" a long changelog was unreadable
 * in. So a release row is two lines: the version, the date and the file on the first, and the note
 * spanning the whole table on the second, where a paragraph has the width to be one.
 */
.dln-table--releases .dln-table-head,
.dln-table-row--release { grid-template-columns: minmax(6rem, 0.8fr) minmax(7rem, 0.8fr) auto; }
.dln-table-row--release { row-gap: 0.5rem; }
.dln-table-row--release > .dln-changelog { grid-column: 1 / -1; min-width: 0; }
.dln-release-file { display: flex; justify-content: flex-end; }
.dln-version { display: flex; align-items: center; gap: 0.4rem; font-weight: 500; }

.dln-current {
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent-soft-fg);
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: lowercase;
}

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

/*
 * A release note in the History table, and the "Read more" that opens the rest of it.
 *
 * The short cut and the whole note are the same two spans; `is-open` — set here by the script, or
 * server-side when the link was followed to `?version=<id>` — shows one and hides the other. The
 * whole note keeps its own line breaks (`white-space: pre-wrap`), because a changelog is written
 * as lines and lists and re-flowing it into one paragraph reads as neither.
 *
 * The opened note is a **block**, not an inline span, because it is read: it spans the row it is
 * in (see `.dln-table-row--release` above), is capped at a comfortable measure so a wide screen
 * does not turn a line of prose into a scan across the whole page, gets the line height prose
 * wants, and is set off the row's facts by a rule and a tint so where the release ends and its
 * note begins is never a guess.
 */
.dln-changelog { display: block; min-width: 0; color: var(--muted); }
.dln-changelog-text { color: var(--muted); }
.dln-changelog-full { display: none; white-space: pre-wrap; color: var(--muted); }
.dln-changelog.is-open .dln-changelog-text { display: none; }
.dln-changelog.is-open .dln-changelog-full {
    display: block;
    max-width: 80ch;
    padding: 0.65rem 0.8rem;
    border-left: 2px solid color-mix(in srgb, var(--accent) 45%, var(--border));
    border-radius: calc(var(--radius) - 6px);
    background: color-mix(in srgb, var(--surface-2) 50%, transparent);
    line-height: 1.65;
}

.dln-more { margin-left: 0.35rem; font-size: 0.75rem; font-weight: 600; white-space: nowrap; color: var(--accent-soft-fg); }
.dln-more:hover { text-decoration: underline; }
.dln-more[aria-busy="true"] { opacity: 0.6; }

/* the reviews */
.dln-review-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin: 0 0 1rem;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 4px);
    background: color-mix(in srgb, var(--surface-2) 40%, transparent);
}

.dln-review-label { margin: 0; font-size: 0.875rem; font-weight: 500; }
.dln-rating-picker { display: flex; align-items: center; gap: 0.25rem; }
.dln-rating-star { cursor: pointer; color: color-mix(in srgb, var(--muted) 45%, transparent); display: inline-flex; }
.dln-rating-star.is-on { color: #fbbf24; }
.dln-rating-star input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.dln-star-icon { width: 1.25rem; height: 1.25rem; }
.dln-review-form textarea { width: 100%; }
.dln-review-form button { align-self: flex-start; border-radius: 999px; }
.dln-review-list { display: flex; flex-direction: column; }

.dln-review { padding: 0.75rem 0; border-top: 1px solid var(--border); }
.dln-review:first-child { border-top: none; padding-top: 0; }

.dln-review-head { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; font-weight: 500; }
.dln-review-head a { color: var(--text); }
.dln-review-when { margin-left: auto; font-size: 0.75rem; font-weight: 400; }
.dln-review-body { margin: 0.4rem 0 0; font-size: 0.875rem; color: var(--muted); }

/* the figures, the facts and the related list */
.dln-figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.dln-figure { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; }
.dln-figure b { font-size: 1.125rem; }
.dln-figure span { color: var(--muted); }

.dln-info { display: flex; flex-direction: column; gap: 0.6rem; font-size: 0.875rem; }
.dln-info > div { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.dln-info > div > span:first-child { color: var(--muted); }
.dln-info b { font-weight: 500; text-align: right; }
.dln-info-wide { text-align: right; }
.dln-related { align-items: center; }

/* ---------- the submission form ---------- */

.dln-page--form { max-width: 46rem; margin: 0 auto; }

.dln-submit {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.dln-field { display: flex; flex-direction: column; gap: 0.375rem; min-width: 0; }
/*
 * The board's global `label` rule carries a 0.9rem top margin. That is right for a label
 * sitting directly in a card and wrong inside one of these fields, which already space
 * themselves — the label was being pushed down its own column and the control with it.
 */
.dln-field > label { margin: 0; font-size: 0.875rem; font-weight: 500; line-height: 1.3; }
.dln-field-hint { margin: 0; font-size: 0.75rem; color: var(--muted); }

/*
 * A row of pickers.
 *
 * Two columns at the form's width, which is the React form's own `sm:grid-cols-2`, and the
 * labels are its `text-xs text-muted-foreground`: 12px and muted rather than 14px and white.
 *
 * Both numbers matter. At three columns of 13rem and a 14px label, "Forum discussion
 * category (optional)" wrapped to two lines, which pushed its select below the two either
 * side of it and turned one row of dropdowns into a ragged staircase.
 */
.dln-field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    gap: 0.75rem;
}

.dln-field-row > .dln-field > label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted);
}

/* The controls are the React `Input`'s and `SelectTrigger`'s 14px, not the page's 15px. */
.dln-submit input:not([type="checkbox"]):not([type="file"]),
.dln-submit select,
.dln-submit textarea {
    font-size: 0.875rem;
}

.dln-area-picker {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 4px);
    background: color-mix(in srgb, var(--surface-2) 35%, transparent);
}

.dln-area-title {
    margin: 0;
    font-size: 0.688rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.dln-area { display: flex; align-items: flex-start; gap: 0.5rem; font-size: 0.875rem; margin: 0; }

/*
 * The board's global `input` rule is `width: 100%; height: 2.25rem`, which is right for a
 * text field and wrong for a tick box: `Where this is listed` was drawing both of its boxes
 * stretched and half again as tall as they are wide, with the browser's own check mark
 * scaled up inside them. A tick box is the same 1rem square `.switch-row` and `.api-scope`
 * draw.
 */
.dln-area input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    margin: 0.15rem 0 0;
    flex: 0 0 auto;
    accent-color: var(--accent);
}
.dln-area-name { font-weight: 500; display: block; }
.dln-area-text { display: block; margin-top: 0.15rem; font-size: 0.75rem; color: var(--muted); }

.dln-attachments { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.dln-attachments .button { cursor: pointer; }

/*
 * A file picker wearing a button.
 *
 * The three attachment controls are `<label>`s around real `<input type="file">`s, so a click
 * anywhere on the label opens the picker with no script at all. The input itself is taken out
 * of the flow rather than `display: none` — a visually hidden input is still focusable and
 * still submit, which is what "Attach download file" has to be.
 */
.dln-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.dln-form-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
.dln-form-actions .button { border-radius: 999px; }

/*
 * The upload guard's note.
 *
 * It is drawn by `assets/upload-guard.js` above the form's buttons when a request is refused on
 * size — either the ceiling the board reports, or an HTTP 413 the web server returned before PHP
 * saw the request. It reads as a warning rather than as a successful save, and the form below it
 * is left exactly as the member filled it in.
 */
.upload-guard-notice {
    margin: 0 0 0.9rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid color-mix(in srgb, var(--warn, #b45309) 45%, var(--border));
    border-radius: calc(var(--radius) - 4px);
    background: color-mix(in srgb, var(--warn, #b45309) 12%, transparent);
    color: var(--text);
    font-size: 0.875rem;
    line-height: 1.5;
}

/* ---------- narrow screens ---------- */

@media (max-width: 1100px) {
    .dln-columns { grid-template-columns: minmax(0, 1fr); }
    .dln-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); align-items: start; }
    .dln-detail-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
    .dln-head { align-items: flex-start; }
    .dln-head-actions { justify-content: flex-start; }
    .dln-row { flex-wrap: wrap; }
    .dln-row-right { flex-direction: row; gap: 0.5rem; width: 100%; align-items: center; justify-content: flex-start; }
    .dln-table-head { display: none; }
    .dln-table-row { grid-template-columns: minmax(0, 1fr); row-gap: 0.35rem; }
    /* A release's facts stack like every other row's cells; its note is already full width. */
    .dln-table-row--release { grid-template-columns: minmax(0, 1fr); }
    .dln-release-file { justify-content: flex-start; }
    .dln-table-row--release > .dln-changelog { grid-column: auto; }
}

}
