/* Participant view (/admin/users/{id}): the summary strip, the hand-ins table, the folder's fact cards,
   material and the account sections. Reference markup and screenshots: docs/design/participant-view/. */

.participant-view__meta {
    margin: 0.25rem 0 1.25rem;
    color: var(--md-sys-color-on-surface-variant);
    overflow-wrap: anywhere;
}

.participant-view__muted {
    color: var(--md-sys-color-on-surface-variant);
}

.participant-view .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* A tab's heading and intro on the left, its one action on the right */
.participant-view__panel-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.participant-view__panel-head h2 {
    margin: 0 0 0.25rem;
    font-size: 1.25rem;
}

.participant-view__panel-head p {
    max-width: 60ch;
    margin: 0;
}

.participant-view__panel-head .button-secondary {
    flex: none;
    margin: 0;
}

/* A form opened by a panel action: a bordered card above the list it adds to */
.participant-form-card {
    margin: 0 0 1.5rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--brand-shape-medium, 12px);
    background: var(--md-sys-color-surface);
}

.participant-form-card h3 {
    margin-top: 0;
    font-size: 1rem;
}

/* Summary strip: one card of label-over-value groups between the name and the tabs */
.participant-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 2.5rem;
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
}

.participant-strip__stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.participant-strip__stat--light {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.75rem;
}

.participant-strip__stat--light .participant-strip__label {
    flex-basis: 100%;
}

.participant-strip__label {
    color: var(--md-sys-color-outline);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.participant-strip__value {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.participant-strip__value .participant-view__muted {
    font-weight: 400;
}

.participant-strip form,
.participant-strip button {
    margin: 0;
}

/* Hand-ins: filter chips (links) above a table */
.participant-hand-ins__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.participant-hand-ins__chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    height: 2rem;
    padding: 0 0.875rem;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--brand-shape-small, 8px);
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
}

.participant-hand-ins__chip[aria-current="true"] {
    border-color: transparent;
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.participant-hand-ins__chip-count {
    font-weight: 400;
    opacity: 0.8;
}

.participant-hand-ins__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.participant-hand-ins__table th {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    color: var(--md-sys-color-outline);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
}

.participant-hand-ins__table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    vertical-align: middle;
}

.participant-hand-ins__date {
    color: var(--md-sys-color-on-surface-variant);
    white-space: nowrap;
}

.participant-hand-ins__task {
    font-weight: 500;
}

.participant-hand-ins__course {
    display: block;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.8125rem;
    font-weight: 400;
}

.participant-hand-ins__status {
    white-space: nowrap;
}

.participant-hand-ins__status-text {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.875rem;
}

.participant-hand-ins__status-text--waiting {
    color: var(--md-sys-color-on-surface);
    font-weight: 600;
}

.participant-hand-ins__status form {
    display: inline;
    margin: 0;
}

.participant-hand-ins__status .button-secondary {
    height: 2rem;
    margin: 0 0 0 0.5rem;
    padding: 0 0.875rem;
    line-height: 2rem;
}

.participant-hand-ins__open {
    text-align: right;
}

/* An unconfirmed Check-in's row carries its Light as a left edge, as on the mentor board */
.participant-hand-ins__row--waiting-red > td:first-child {
    box-shadow: inset 4px 0 0 var(--md-sys-color-error);
}

.participant-hand-ins__row--waiting-yellow > td:first-child {
    box-shadow: inset 4px 0 0 var(--md-sys-color-warning);
}

.participant-hand-ins__more {
    margin-top: 1rem;
}

/* Facts: one collapsed card per Folder fact, grouped by type */
.participant-facts__group > h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1.75rem 0 0.5rem;
    font-size: 1rem;
}

.participant-facts__list {
    display: grid;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.participant-facts__list > li {
    margin: 0;
}

.folder-fact-card {
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--brand-shape-medium, 12px);
    background: var(--md-sys-color-surface);
}

.folder-fact-card > summary {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    list-style: none;
}

.folder-fact-card > summary::-webkit-details-marker {
    display: none;
}

.folder-fact-card > summary::after {
    content: "▾";
    grid-row: 1 / span 2;
    grid-column: 2;
    align-self: center;
    color: var(--md-sys-color-outline);
    transition: transform 0.15s;
}

.folder-fact-card[open] > summary::after {
    transform: rotate(180deg);
}

.folder-fact-card__name {
    font-weight: 600;
}

.folder-fact-card__desc {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.9375rem;
}

.folder-fact-card__more {
    padding: 0 1rem 0.875rem;
    border-top: 1px solid var(--md-sys-color-outline-variant);
}

.folder-fact-card__more p {
    margin: 0.75rem 0 0;
}

.folder-fact-card__more .button-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.folder-fact-card__more .button-row form {
    margin: 0;
}

.staff-only-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    background: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
    font-size: 0.75rem;
    font-weight: 600;
}

.participant-facts__retired {
    margin-top: 1.75rem;
}

.participant-facts__retired > summary {
    color: var(--md-sys-color-primary);
    font-weight: 500;
    cursor: pointer;
}

.participant-facts__retired .participant-facts__list {
    margin-top: 0.75rem;
    opacity: 0.8;
}

/* Material: one card per piece, and the add form's label hint and text-or-recording choice */
.participant-material__list {
    display: grid;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.participant-material__item {
    margin: 0;
    padding: 0.875rem 1rem;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--brand-shape-medium, 12px);
    background: var(--md-sys-color-surface);
}

.participant-material__item p {
    margin: 0.25rem 0 0.5rem;
}

.participant-material__item summary {
    color: var(--md-sys-color-primary);
    cursor: pointer;
}

.participant-material__hint {
    margin: 0.375rem 0 0;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.875rem;
}

.segmented-choice {
    display: flex;
    margin: 0.5rem 0 1rem;
    padding: 0;
    border: 0;
}

.segmented-choice legend {
    margin-bottom: 0.375rem;
    padding: 0;
    font-weight: 600;
}

.segmented-choice label {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin: 0;
    padding: 0.5rem 0.875rem;
    border: 1px solid var(--md-sys-color-outline);
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}

.segmented-choice label:first-of-type {
    border-radius: 999px 0 0 999px;
}

.segmented-choice label:last-of-type {
    border-left: 0;
    border-radius: 0 999px 999px 0;
}

.segmented-choice label:has(input:checked) {
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.segmented-choice label:has(input:focus-visible) {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}

.segmented-choice input {
    margin: 0;
}

/* Account: sections split by thin rules, block user last */
.participant-account__section {
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.participant-account__section:first-of-type {
    padding-top: 0;
}

.participant-account__courses {
    list-style: none;
    margin: 0 0 0.75rem;
    padding: 0;
}

.participant-account__courses li {
    padding: 0.25rem 0;
}

.participant-account__section h3 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}

.participant-account__dl {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.5rem 1.5rem;
    margin: 0;
}

.participant-account__dl dt {
    color: var(--md-sys-color-on-surface-variant);
}

.participant-account__dl dd {
    margin: 0;
}

.participant-account__reveal summary {
    color: var(--md-sys-color-primary);
    cursor: pointer;
}

.participant-account__reveal[open] summary {
    display: none;
}

.participant-account__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
}

.participant-account__tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0;
    padding: 0.25rem 0.25rem 0.25rem 0.75rem;
    border-radius: var(--brand-shape-small, 8px);
    background: var(--md-sys-color-surface-variant);
    font-size: 0.875rem;
}

.participant-account__tag form {
    display: inline;
    margin: 0;
}

.participant-account__tag-remove {
    width: 1.75rem;
    height: 1.75rem;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
}

.participant-account__tag-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.participant-account__tag-form .button-secondary {
    margin: 0;
}

.participant-account__danger {
    border-bottom: 0;
}

.participant-account__danger p {
    margin: 0 0 0.75rem;
}

.participant-account__danger .button-secondary {
    border-color: var(--md-sys-color-error);
    color: var(--md-sys-color-error);
}

/* Phones: chips scroll in one row, table rows become cards, the profile list stacks */
@media (max-width: 600px) {
    .participant-strip {
        gap: 1rem 1.5rem;
    }

    .participant-view__panel-head {
        flex-direction: column;
    }

    .participant-hand-ins__chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        margin-inline: -1.25rem;
        padding-inline: 1.25rem;
    }

    .participant-hand-ins__chip {
        flex: none;
    }

    /* Column headers stay in the accessibility tree, visually hidden */
    .participant-hand-ins__table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .participant-hand-ins__table,
    .participant-hand-ins__table tbody {
        display: block;
    }

    .participant-hand-ins__table tr {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "task light"
            "date open"
            "status status";
        gap: 0.25rem 0.75rem;
        padding: 0.75rem 0;
        border-bottom: 1px solid var(--md-sys-color-outline-variant);
    }

    .participant-hand-ins__table td {
        display: block;
        padding: 0;
        border: 0;
    }

    .participant-hand-ins__table td:empty {
        display: none;
    }

    .participant-hand-ins__task { grid-area: task; }
    .participant-hand-ins__light { grid-area: light; text-align: right; }
    .participant-hand-ins__date { grid-area: date; font-size: 0.875rem; }
    .participant-hand-ins__open { grid-area: open; }
    .participant-hand-ins__status { grid-area: status; }

    .participant-hand-ins__row--waiting-red > td:first-child,
    .participant-hand-ins__row--waiting-yellow > td:first-child {
        box-shadow: none;
    }

    .participant-hand-ins__table tr.participant-hand-ins__row--waiting-red {
        padding-left: 0.75rem;
        box-shadow: inset 4px 0 0 var(--md-sys-color-error);
    }

    .participant-hand-ins__table tr.participant-hand-ins__row--waiting-yellow {
        padding-left: 0.75rem;
        box-shadow: inset 4px 0 0 var(--md-sys-color-warning);
    }

    .participant-account__dl {
        grid-template-columns: 1fr;
        gap: 0.125rem;
    }

    .participant-account__dl dd {
        margin-bottom: 0.5rem;
    }
}
