/*
 * Product downloads. Uses the custom properties of the site package (--c-*), with fallbacks.
 * Legacy layout: one row per download (type | reference | title), coloured bar per type,
 * expanding to the file table.
 */

.downloads { display: grid; gap: 6px; margin: 0 0 1.5rem; container: downloads / inline-size; }

.download {
    --download-color: var(--c-brand, #003366);
    border: 1px solid var(--c-line, #dde3ea);
    border-left: 5px solid var(--download-color);
    border-radius: var(--radius, 6px);
    background: var(--c-surface, #fff);
}

.download__summary {
    display: grid;
    /* Fixed widths for type and reference, so the titles of all rows start at the same position */
    grid-template-columns: 8.5rem 9.5rem minmax(0, 1fr) auto;
    align-items: center;
    gap: .25rem 1rem;
    padding: .55rem .9rem;
    font-size: .925rem;
    cursor: pointer;
    list-style: none;
    background: var(--c-accent-softer, #f2f6fb);
    border-radius: 0 var(--radius, 6px) var(--radius, 6px) 0;
}
.download__summary::-webkit-details-marker { display: none; }
.download__summary::after {
    content: "";
    width: .55rem; height: .55rem;
    border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
    rotate: 45deg; translate: 0 -2px;
    color: var(--c-muted, #5b6875);
    transition: rotate .15s;
}
.download[open] > .download__summary::after { rotate: -135deg; translate: 0 2px; }
.download__summary:hover { background: var(--c-accent-soft, #e2ecf5); }
.download[open] > .download__summary { border-bottom: 1px solid var(--c-line, #dde3ea); border-radius: 0 var(--radius, 6px) 0 0; }

.download__type { color: var(--c-muted, #5b6875); }
.download__ref { font-variant-numeric: tabular-nums; color: var(--c-muted, #5b6875); overflow-wrap: anywhere; } /* long versions like 1.24.69/1.28.16/1.28.51 wrap */
.download__title { font-weight: 600; color: var(--c-brand, #003366); }

.download.is-archived .download__title { color: var(--c-muted, #5b6875); }

.download__body { padding: .9rem; }
.download__description > :first-child { margin-top: 0; }
.download__chapter { color: var(--c-muted, #5b6875); font-size: .875rem; }

.download__files { width: 100%; border-collapse: collapse; font-size: .9rem; margin: 0 !important; }
.download__files th, .download__files td { padding: .45rem .5rem !important; border-bottom: 1px solid var(--c-line, #dde3ea); vertical-align: middle !important; background: none !important; }
.download__files tr:last-child > * { border-bottom: 0; }
.download__file-title { font-weight: 500; text-align: left; color: var(--c-text, #1f2933) !important; }
.download__file-type, .download__file-size { color: var(--c-muted, #5b6875); white-space: nowrap; }
.download__file-size { text-align: right !important; font-variant-numeric: tabular-nums; }
.download__file-link { text-align: right !important; width: 1%; }
.download__files tr.is-archived .download__file-title { color: var(--c-muted, #5b6875) !important; }

.lang-flag { display: inline-block; vertical-align: middle; }

.lang-code {
    display: inline-block; min-width: 2.2em; padding: 0 .35em;
    font-size: .75rem; font-weight: 600; text-align: center; text-transform: uppercase; text-decoration: none;
    color: var(--c-brand, #003366); background: var(--c-accent-soft, #e2ecf5); border-radius: 4px;
}

.badge {
    display: inline-flex; align-items: center; gap: .3em;
    margin: 1px .25rem 1px 0; padding: 0 .45em;
    font-size: .75rem; line-height: 1.6; white-space: nowrap;
    color: var(--c-muted, #5b6875); background: var(--c-bg, #f5f7fa); border-radius: 999px;
}
.badge img { width: 14px; height: 14px; }
.badge--archive, .badge--status-1 { color: #8a5a00; background: #fff4d6; }
.badge--status-2 { color: #0b6b3a; background: #e3f6ea; }

.download__button {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .3rem .75rem;
    font-size: .85rem; font-weight: 600; white-space: nowrap; text-decoration: none;
    color: #fff !important; background: var(--c-brand, #003366);
    border-radius: 999px;
}
.download__button:hover { background: var(--c-brand-mid, #336699); }

.download-notice {
    padding: 1.25rem 1.5rem; margin-bottom: 1.5rem;
    border-left: 4px solid #c98a00; border-radius: var(--radius, 6px);
    background: #fff8e6;
}
.download-notice__title { margin-top: 0 !important; font-size: 1.3rem !important; }
.download-notice__file { color: var(--c-muted, #5b6875); }

/* Stacked layout on phones and in narrow columns (download list next to an image) */
@container downloads (max-width: 36rem) {
    .download__summary { grid-template-columns: 1fr auto; }
    .download__type { grid-column: 1; font-size: .8rem; }
    .download__ref { grid-column: 1; font-size: .8rem; }
    .download__title { grid-column: 1; }
    .download__summary::after { grid-column: 2; grid-row: 1 / span 3; }

    .download__files, .download__files tbody, .download__files tr { display: block; }
    .download__files tr { display: grid; grid-template-columns: 1fr auto; gap: .2rem .5rem; padding: .6rem 0; border-bottom: 1px solid var(--c-line, #dde3ea); }
    .download__files tr:last-child { border-bottom: 0; }
    .download__files th, .download__files td { display: block; padding: 0 !important; border: 0; }
    .download__file-title { grid-column: 1 / -1; }
    .download__file-link { grid-column: 2; grid-row: 2 / span 3; align-self: center; width: auto; }
    .download__file-size { text-align: left !important; }
}
