/* ============================================================
   Athlete page — optimised for smartphone
   ============================================================ */

/* Override body centering from main.css */
body {
    display: block;
    align-items: unset;
    justify-content: unset;
    padding: 0;
}

/* The hidden attribute must win over the display:flex layout rules below,
   otherwise toggling element.hidden in JS has no visual effect. */
[hidden] {
    display: none !important;
}

/* --- Layout ------------------------------------------------- */

.ath-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 860px;
    margin: 0 auto;
}

/* --- Header ------------------------------------------------- */

.ath-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.7rem 1.4rem;
    background: #1a1a1a;
    border-bottom: 1px solid #333;
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}

.ath-header h1 {
    font-size: 1rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--color-accent);
    margin: 0;
    flex: 1;
}

.ath-back {
    color: var(--color-muted);
    text-decoration: none;
    font-size: 1.2rem;
    line-height: 1;
    transition: color 0.15s;
}

.ath-back:hover {
    color: var(--color-text);
}

.ath-subtitle {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--color-muted);
    white-space: nowrap;
}

@media (max-width: 540px) {
    .ath-subtitle { display: none; }
}

/* --- Search section ----------------------------------------- */

.ath-search {
    padding: 2rem 1.2rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.ath-search__label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--color-muted);
}

.ath-search__row {
    display: flex;
    gap: 0.5rem;
}

.ath-search__input {
    flex: 1;
    min-width: 0;          /* let the field shrink instead of pushing the button off screen */
    font-family: monospace;
    font-size: 1.1rem;
    background: #111;
    border: 1px solid #444;
    border-radius: 4px;
    color: var(--color-text);
    padding: 0.55rem 0.8rem;
    outline: none;
    transition: border-color 0.15s;
}

.ath-search__input:focus {
    border-color: var(--color-accent);
}

.ath-search__btn {
    font-family: monospace;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: transparent;
    border: 1px solid var(--color-accent);
    border-radius: 4px;
    color: var(--color-accent);
    padding: 0.5rem 1rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.ath-search__btn:hover,
.ath-search__btn:active {
    background: var(--color-accent);
    color: #0d0d0d;
}

.ath-search__btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.ath-search__error {
    font-size: 0.78rem;
    color: #e06060;
    min-height: 1.1em;
}

/* --- Multiple results list ---------------------------------- */

.ath-results-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem 1.2rem 0;
}

.ath-results-list__hint {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-muted);
    margin-bottom: 0.7rem;
}

.ath-results-list__ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
}

.ath-result-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    background: var(--color-surface);
    border-left: 4px solid #555;
    border-radius: 4px;
    padding: 0.65rem 0.9rem;
    cursor: pointer;
    transition: background 0.12s;
}

.ath-result-item:hover,
.ath-result-item:active {
    background: #242424;
}

/* Heat info — left side, fixed width */
.ath-result-item__heat {
    flex-shrink: 0;
    font-size: 0.65rem;
    color: #666;
    white-space: nowrap;
    text-align: left;
    min-width: 4rem;
}

/* Name + team stacked on the right */
.ath-result-item__right {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    overflow: hidden;
}

.ath-result-item__name {
    font-size: 0.95rem;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ath-result-item__team {
    font-size: 0.7rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Athlete directory (default view under the search) ------- */

.ath-directory {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem 1.2rem 1.2rem;
}

.ath-directory__title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-muted);
    margin-bottom: 0.7rem;
}

.ath-directory__count { color: #555; }

.ath-directory__ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.ath-directory__item {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    background: var(--color-surface);
    border-left: 4px solid #555;
    border-radius: 4px;
    padding: 0.55rem 0.9rem;
    cursor: pointer;
    transition: background 0.12s;
}

.ath-directory__item:hover,
.ath-directory__item:active {
    background: #242424;
}

.ath-directory__bib {
    flex-shrink: 0;
    min-width: 2.2rem;
    font-size: 0.75rem;
    color: var(--color-muted);
}

.ath-directory__name {
    font-size: 0.95rem;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ath-directory__team {
    margin-left: auto;
    font-size: 0.7rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ath-directory__empty {
    font-size: 0.8rem;
    color: var(--color-muted);
    text-align: center;
    padding: 1rem 0;
}

/* --- Result section ----------------------------------------- */

.ath-result {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Colored strip at top of result card */
.ath-color-strip {
    height: 5px;
    width: 100%;
    flex-shrink: 0;
}

/* --- Athlete identity --------------------------------------- */

.ath-identity {
    padding: 1.2rem 1.2rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    border-bottom: 1px solid #222;
}

.ath-bib {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-accent);
    letter-spacing: 0.12em;
}
.ath-bib:empty {
    display: none; /* no bib for this team */
}

.ath-name {
    font-size: 1.3rem;
    color: var(--color-text);
    letter-spacing: 0.04em;
}

.ath-team {
    font-size: 0.75rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* --- Heat info ---------------------------------------------- */

.ath-heat-info {
    padding: 0.8rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    border-bottom: 1px solid #222;
}

.ath-heat-name {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text);
}

.ath-heat-cat {
    font-size: 0.72rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.ath-heat-start {
    font-size: 0.72rem;
    color: var(--color-muted);
    font-family: monospace;
}

/* --- Timer block -------------------------------------------- */

.ath-timer-block {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 2rem 1rem;
    transition: opacity 0.3s;
}

.ath-timer-block.is-stopped {
    opacity: 0.45;
    filter: grayscale(40%);
}

.ath-timer-status {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--color-muted);
    min-height: 1em;
}

.ath-timer-block.is-running .ath-timer-status {
    color: #4caf50;
}

.ath-timer-block.is-waiting .ath-timer-status {
    color: var(--color-muted);
}

.ath-timer-block.is-stopped .ath-timer-status {
    color: #e06000;
}

.ath-timer {
    font-family: monospace;
    font-size: clamp(3rem, 18vw, 5rem);
    letter-spacing: 0.04em;
    line-height: 1;
    color: var(--color-text);
}

.ath-timer-block.is-running .ath-timer {
    color: var(--color-accent);
}

/* --- Totals (run / stations / transitions) ------------------ */

.ath-totals {
    display: flex;
    justify-content: center;
    gap: 0.6rem;
    padding: 0 1.2rem 0.6rem;
}
.ath-total {
    flex: 1;
    max-width: 9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.5rem 0.3rem;
    background: #161616;
    border: 1px solid #262626;
    border-radius: 8px;
}
.ath-total__val {
    font-family: monospace;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text);
}
.ath-total__label {
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-muted);
}

/* --- Race result block -------------------------------------- */

.ath-result-block {
    padding: 0.8rem 1.2rem 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    border-top: 1px solid #222;
    flex-shrink: 0;
}

/* Finisher image — fills available width up to a comfortable size */
.ath-finisher-img {
    width: min(60vw, 180px);
    height: auto;
}

.ath-result-badge {
    font-family: monospace;
    font-size: 1rem;
    letter-spacing: 0.06em;
    padding: 0.5rem 1.2rem;
    border-radius: 4px;
    border: 1px solid currentColor;
}

.ath-result-badge--abandon {
    color: #666;
    background: rgba(80, 80, 80, 0.08);
}

.ath-result-badge--dns {
    color: #c89628;
    background: rgba(200, 150, 40, 0.08);
}

/* Penalty breakdown — shown below the total time when a penalty applies */
.ath-result-badge--penalty {
    color: #e06000;
    border-color: #e06000;
    background: rgba(224, 96, 0, 0.08);
    font-size: 0.85rem;
}

.ath-penalty-detail {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.ath-penalty-amount {
    color: #e06000;
    font-size: 0.9em;
    opacity: 0.85;
}

/* --- Race timeline ------------------------------------------ */

:root {
    --tl-work: var(--color-accent);
    --tl-run:  #2f9e6e;
    --tl-a:    #e23b3b;  /* athlete A (red)  */
    --tl-b:    #3b82f6;  /* athlete B (blue) */
}

.ath-timeline {
    border-top: 1px solid #222;
    padding: 0.8rem 1.2rem;
    flex-shrink: 0;
}

.ath-timeline__title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--color-muted);
    margin-bottom: 0.6rem;
}

/* Vertical infographic: wide alternating cards (stations left, runs right)
   threaded on a continuous central line, transition bubbles between them. */
.ath-rt {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 0.3rem 0;
}
.ath-rt::before {                 /* continuous central line linking all stations */
    content: "";
    position: absolute;
    left: 50%;
    top: 0.4rem;
    bottom: 0.4rem;
    width: 2px;
    transform: translateX(-50%);
    background: #383838;
    z-index: 0;
}

/* Card row: wide card aligned to its side, above the line */
.rt-item {
    display: flex;
    margin: 0.55rem 0;
    position: relative;
    z-index: 1;
}
.rt-item--left  { justify-content: flex-start; }
.rt-item--right { justify-content: flex-end; }

/* Card */
.rt-card {
    width: 86%;
    box-sizing: border-box;
    background: #1b1b1b;
    border: 1px solid #2e2e2e;
    border-left: 4px solid var(--tl-work);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
}
.rt-card--run { border-left-color: var(--tl-run); }

.rt-card__head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.rt-num {
    width: 1.4rem;
    height: 1.4rem;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--tl-work);
    color: #0c0c0c;
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.rt-card--run .rt-num { background: var(--tl-run); }
.rt-card__name {
    flex: 1;
    min-width: 0;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rt-card__cards {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: #fff;
    background: #c0271f;
    border-radius: 3px;
    padding: 0.12rem 0.4rem;
    line-height: 1.2;
}
/* small red-card glyph before the count */
.rt-card__cards::before {
    content: "";
    width: 0.46rem;
    height: 0.66rem;
    border-radius: 1px;
    background: #fff;
    opacity: 0.92;
}
.rt-card__time {
    font-family: monospace;
    font-size: 1rem;
    color: var(--color-accent);
    flex-shrink: 0;
}
.rt-card--run .rt-card__time { color: var(--tl-run); }

/* Relay rep split: bicolor bar + one named row per athlete */
.rt-card__bar {
    display: flex;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    background: #111;
    margin: 0.5rem 0 0.4rem;
}
.rt-card__bar-a { flex-basis: 0; background: var(--tl-a); }
.rt-card__bar-b { flex-basis: 0; background: var(--tl-b); }
/* Synchro: one solid green bar (no split) */
.rt-card__bar--synchro { background: var(--tl-run); }

.rt-athlete {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.25rem;
    font-size: 0.78rem;
}
.rt-athlete__dot {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    flex-shrink: 0;
}
.rt-athlete--a .rt-athlete__dot { background: var(--tl-a); }
.rt-athlete--b .rt-athlete__dot { background: var(--tl-b); }
.rt-athlete--synchro .rt-athlete__dot { background: var(--tl-run); }
.rt-athlete__name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text);
}
.rt-athlete__count {
    font-family: monospace;
    font-weight: 700;
    flex-shrink: 0;
}
.rt-athlete--a .rt-athlete__count { color: #ff9b9b; }
.rt-athlete--b .rt-athlete__count { color: #9bbcff; }
.rt-athlete--synchro .rt-athlete__count { color: #8fe0b8; }
.rt-athlete--synchro .rt-athlete__name { font-weight: 600; }

/* Transition bubble sitting on the central line between two cards */
.rt-trans {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    margin: 0.1rem 0;
}
.rt-bubble {
    font-family: monospace;
    font-size: 0.74rem;
    color: #ffc265;
    background: #271f12;
    border: 1px solid #4a3a1e;
    padding: 0.12rem 0.6rem;
    border-radius: 999px;
}
