/*
 * Content: icons, tables, lists, accordions, prose and dividers.
 */
@layer components {
    /* Icons (templates/components/Icon.html.twig): sized by the font size. */
    .icon {
        display: inline-flex;
        flex: none;
        width: 1em;
        height: 1em;
        vertical-align: -0.125em;
    }

    .icon svg {
        width: 100%;
        height: 100%;
    }

    /* Tables: <div class="table-wrapper"><table class="table">…</table></div> */
    .table-wrapper {
        overflow-x: auto;
        margin-bottom: var(--space-4);
        border: var(--border-width-thin) solid var(--color-border);
        border-radius: var(--radius-surface);
        background: var(--color-bg-surface);
    }

    .table {
        width: 100%;
        margin: 0;
        border-collapse: collapse;
        font-size: var(--font-size-sm);
    }

    .table caption {
        padding: var(--space-3) var(--space-4);
        text-align: start;
        font-weight: var(--font-weight-semibold);
    }

    .table th,
    .table td {
        padding: var(--space-3) var(--space-4);
        border-bottom: var(--border-width-thin) solid var(--color-border);
        text-align: start;
        vertical-align: middle;
    }

    .table thead th {
        background: var(--color-bg-subtle);
        color: var(--color-text-muted);
        font-size: var(--font-size-xs);
        font-weight: var(--font-weight-semibold);
        letter-spacing: var(--font-letter-spacing-wide);
        text-transform: uppercase;
        white-space: nowrap;
    }

    .table tbody tr:last-child > * {
        border-bottom: 0;
    }

    .table-hover tbody tr:hover {
        background: var(--color-bg-subtle);
    }

    .table-striped tbody tr:nth-child(even) {
        background: color-mix(in srgb, var(--color-bg-subtle) 50%, transparent);
    }

    .table-compact th,
    .table-compact td {
        padding: var(--space-2) var(--space-3);
    }

    .table .is-numeric {
        text-align: end;
        font-variant-numeric: tabular-nums;
    }

    /* Lists of items: people, events, files… */
    .list {
        margin: 0 0 var(--space-4);
        padding: 0;
        border: var(--border-width-thin) solid var(--color-border);
        border-radius: var(--radius-surface);
        background: var(--color-bg-surface);
        list-style: none;
    }

    .list-item {
        display: flex;
        align-items: center;
        gap: var(--space-3);
        padding: var(--space-3) var(--space-4);
    }

    .list-item + .list-item {
        border-top: var(--border-width-thin) solid var(--color-border);
    }

    .list-item-content {
        flex: 1;
        min-width: 0;
    }

    .list-item-title {
        display: block;
        font-weight: var(--font-weight-medium);
    }

    .list-item-meta {
        display: block;
        font-size: var(--font-size-sm);
        color: var(--color-text-muted);
    }

    /* Description lists: label / value pairs. */
    .description-list {
        display: grid;
        grid-template-columns: minmax(6rem, max-content) minmax(0, 1fr);
        gap: var(--space-2) var(--space-6);
    }

    .description-list dt {
        color: var(--color-text-muted);
        font-size: var(--font-size-sm);
    }

    .description-list dd {
        min-width: 0;
        margin: 0;
        overflow-wrap: anywhere;
    }

    .description-list .badge {
        white-space: normal;
    }

    /* Accordion: <details class="accordion"><summary>…</summary><div>…</div></details> */
    .accordion {
        border: var(--border-width-thin) solid var(--color-border);
        background: var(--color-bg-surface);
    }

    .accordion + .accordion {
        border-top: 0;
    }

    .accordion:first-of-type {
        border-top-left-radius: var(--radius-surface);
        border-top-right-radius: var(--radius-surface);
    }

    .accordion:last-of-type {
        margin-bottom: var(--space-4);
        border-bottom-left-radius: var(--radius-surface);
        border-bottom-right-radius: var(--radius-surface);
    }

    .accordion > summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-3);
        padding: var(--space-3) var(--space-4);
        font-weight: var(--font-weight-medium);
        list-style: none;
        cursor: pointer;
    }

    .accordion > summary::-webkit-details-marker {
        display: none;
    }

    .accordion > summary::after {
        content: '';
        width: 0.6em;
        height: 0.6em;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate(45deg);
        transition: transform var(--duration-fast) var(--easing-standard);
    }

    .accordion[open] > summary::after {
        transform: rotate(-135deg);
    }

    .accordion > :not(summary) {
        padding: 0 var(--space-4) var(--space-4);
    }

    /* Long texts written by users or converted from Markdown. */
    .prose {
        max-width: 70ch;
    }

    .prose h2,
    .prose h3 {
        margin-top: var(--space-8);
    }

    .prose blockquote {
        padding-left: var(--space-4);
        border-left: 4px solid var(--color-border-strong);
        color: var(--color-text-muted);
    }

    .prose li + li {
        margin-top: var(--space-1);
    }

    /* Divider with an optional label. */
    .divider {
        display: flex;
        align-items: center;
        gap: var(--space-3);
        margin: var(--space-6) 0;
        color: var(--color-text-subtle);
        font-size: var(--font-size-sm);
    }

    .divider::before,
    .divider::after {
        content: '';
        flex: 1;
        border-top: var(--border-width-thin) solid var(--color-border);
    }

    .divider:empty {
        gap: 0;
    }
}
