﻿/* Compact event rows grouped by competition date.
 *
 *   <div class="sc-evgroups">
 *     <details class="sc-evgroup" open>
 *       <summary class="sc-evgroup__head">date (weekday) | N events | chevron</summary>
 *       <div class="sc-evgroup__body"> .sc-evrow ... [.sc-evgroup__more] </div>
 *     </details>
 *   </div>
 *
 * Row markup: Views/Shared/V2/_EventRow.cshtml (Razor) and Scripts/tournament/event-rows.js (JS twin) - keep both in step.
 * Used by the tournament listing cards (_TournamentsList / tournament-list-v3.js) and the tournament Details page.
 * Layout follows the width of .sc-evgroups (container query), not the viewport: stacked rows below 840px, one table-like
 * row above. No colour literals: every colour is a theme-v2.css token.
 */

.sc-evgroups {
    container-type: inline-size;
    container-name: evl;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    min-width: 0;
}

/* ---------------------------------------------------------------- date group */
.sc-evgroup {
    min-width: 0;
    background: var(--v3-tile-bg);
    border: 1px solid var(--v3-tile-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.sc-evgroup__head {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 8px 12px;
    background: var(--tint-success-bg);
    color: var(--color-text-primary);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.sc-evgroup__head::-webkit-details-marker {
    display: none;
}

.sc-evgroup[open] > .sc-evgroup__head {
    border-bottom: 1px solid color-mix(in srgb, var(--color-success) 28%, transparent);
}

.sc-evgroup__head:hover {
    background: color-mix(in srgb, var(--color-success) 20%, transparent);
}

.sc-evgroup__head:focus-visible {
    outline: 2px solid var(--color-input-focus-border);
    outline-offset: -2px;
}

.sc-evgroup__date {
    font-size: 15px;
    font-weight: 800;
}

.sc-evgroup__dow {
    font-weight: 500;
    color: var(--color-text-muted);
}

.sc-evgroup__count {
    margin-left: auto;
    font-size: 13px;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.sc-evgroup__chev {
    flex: 0 0 auto;
    font-size: 11px;
    color: var(--color-text-muted);
    transition: transform 0.15s ease;
}

.sc-evgroup[open] > .sc-evgroup__head .sc-evgroup__chev {
    transform: rotate(180deg);
}

.sc-evgroup__more {
    padding: 8px 12px;
    border-top: 1px solid var(--color-border-light);
}

/* ---------------------------------------------------------------- event row (mobile = stacked) */
.sc-evrow {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
        "id name chev"
        "meta meta chev"
        "status status chev";
    column-gap: 10px;
    row-gap: 0;
    align-items: center;
    min-height: 44px;
    padding: 8px 12px;
    border-top: 1px solid var(--color-border-light);
}

.sc-evgroup__body > .sc-evrow:first-child {
    border-top: 0;
}

.sc-evrow.is-extra {
    display: none;
}

.sc-evgroup__body.expanded > .sc-evrow.is-extra {
    display: grid;
}

.sc-evrow:hover {
    background: var(--color-surface-hover);
}

.sc-evrow__id {
    grid-area: id;
    align-self: start;
    padding: 3px 9px;
    border: 1px solid var(--color-border-light);
    border-radius: 999px;
    background: var(--tint-neutral-bg);
    color: var(--color-text-secondary);
    font-size: 12px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* The name is the row's one link: its ::after stretches over the whole row, so the full row is the touch target.
   Anything else clickable inside the row (the register badge) sits above it (z-index). */
.sc-evrow__name {
    grid-area: name;
    min-width: 0;
    color: var(--color-text-primary);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    overflow-wrap: anywhere;
    text-decoration: none;
}

.sc-evrow__name::after {
    content: "";
    position: absolute;
    inset: 0;
}

.sc-evrow__name:hover {
    color: var(--color-text-primary);
    text-decoration: none;
}

.sc-evrow__name:focus {
    outline: none;
}

.sc-evrow__name:focus-visible::after {
    outline: 2px solid var(--color-input-focus-border);
    outline-offset: -2px;
}

.sc-evrow__meta {
    grid-area: meta;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    min-width: 0;
    margin-top: 4px;
}

.sc-evrow__type {
    padding: 2px 9px;
    border: 1px solid color-mix(in srgb, var(--color-info) 30%, transparent);
    border-radius: 999px;
    background: var(--tint-info-bg);
    color: var(--color-info);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
}

.sc-evrow__skill {
    min-width: 0;
}

.sc-evrow__count .sc-regbar-wrap {
    width: auto;
}

.sc-evrow__count .sc-regbar__label {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.sc-evrow__status {
    grid-area: status;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    min-width: 0;
    margin-top: 4px;
    font-size: 12px;
    color: var(--color-text-muted);
}

/* Nothing worth a line on a phone (closed / not started, no extras): shown on wide layouts only */
.sc-evrow__status--idle {
    display: none;
}

.sc-evrow__chev {
    grid-area: chev;
    align-self: center;
    font-size: 13px;
    color: var(--color-text-secondary);
}

/* registration badge: amber = open / closing soon, red = full; closed is muted text */
.sc-evrow__badge {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    height: 20px;
    padding: 0 9px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
}

.sc-evrow__badge i {
    flex: 0 0 auto;
    font-size: 10px;
}

.sc-evrow__badge--open,
.sc-evrow__badge--soon {
    background: var(--tint-warning-bg);
    border-color: color-mix(in srgb, var(--color-warning) 30%, transparent);
    color: var(--color-warning);
}

.sc-evrow__badge--full {
    background: var(--tint-danger-bg);
    border-color: color-mix(in srgb, var(--color-danger) 30%, transparent);
    color: var(--color-danger);
}

.sc-evrow__badge--link {
    background: transparent;
    border-color: var(--color-border);
    color: var(--color-text-secondary);
}

a.sc-evrow__badge:hover {
    filter: brightness(1.15);
    text-decoration: none;
}

a.sc-evrow__badge:focus-visible {
    outline: 2px solid var(--color-input-focus-border);
    outline-offset: 1px;
}

.sc-evrow__muted {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--color-text-muted);
}

.sc-evrow__muted i {
    font-size: 10px;
}

/* competition state: a dot + text (independent of the registration badge) */
.sc-evrow__comp {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
    color: var(--color-text-muted);
}

.sc-evrow__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-text-muted);
}

.sc-evrow__comp--inprogress { color: var(--color-success); }
.sc-evrow__comp--inprogress .sc-evrow__dot { background: var(--color-success); }
.sc-evrow__comp--notstarted .sc-evrow__dot { background: var(--color-info); }

/* "not started" is the default state: it is only spelled out on the wide layout */
.sc-evrow__comp--notstarted {
    display: none;
}

.sc-evrow__progress {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--color-text-secondary);
    font-variant-numeric: tabular-nums;
}

.sc-evrow__progress-bar {
    width: 48px;
    height: 4px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--color-border);
}

.sc-evrow__progress-bar > span {
    display: block;
    height: 100%;
    background: var(--color-success);
}

/* ---------------------------------------------------------------- wide layout: one table-like row */
@container evl (min-width: 840px) {
    .sc-evrow {
        grid-template-columns: 64px minmax(150px, 1.3fr) 88px 132px minmax(210px, 1.2fr) 100px 14px;
        grid-template-areas: "id name type skill status count chev";
        column-gap: 12px;
        padding: 8px 14px;
    }

    .sc-evrow__id { align-self: center; justify-self: start; text-align: center; }

    .sc-evrow__meta {
        display: contents;
    }

    .sc-evrow__type { grid-area: type; justify-self: start; }
    .sc-evrow__skill { grid-area: skill; }
    .sc-evrow__count { grid-area: count; }

    .sc-evrow__status,
    .sc-evrow__status--idle {
        display: flex;
        margin-top: 0;
    }

    .sc-evrow__comp--notstarted {
        display: inline-flex;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sc-evgroup__chev {
        transition: none;
    }
}
