/* Member portal: neutral background, cards with thin borders, numbers first. Colours come from the palette in app.css;
   the logo blue is the only accent. Green and red appear only on result tags. Layout and shapes live here; the shared
   components are in Components/Shared (PortalCard, PortalRow, PortalStats, PortalTabs, PortalColumns, ScoreTag). */
.theme-portal {
    --color-bg: var(--graphite-900);
    --color-surface: var(--graphite-800);
    --color-text: var(--graphite-100);
    --color-muted: var(--graphite-300);
    --color-primary: var(--blue-400);
    --color-accent: var(--blue-400);
    --color-border: var(--graphite-700);
    --color-focus: var(--blue-400);
}

.p-shell {
    width: 100%;
    max-width: 72rem;
    margin-inline: auto;
    padding-inline: var(--space-3);
}

.theme-portal h1 {
    margin-bottom: var(--space-3);
    font-size: 1.35rem;
    font-weight: 700;
}

/* Header: the navigation scrolls sideways on a phone instead of wrapping into several lines */
.p-header-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-3);
    padding-block: var(--space-2);
}

.p-nav-scroll {
    flex: 1 1 100%;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.p-nav-scroll .portal-nav {
    flex-wrap: nowrap;
    align-items: center;
    white-space: nowrap;
}

.p-nav-scroll .portal-nav a {
    color: var(--color-muted);
    text-decoration: none;
}

.p-nav-scroll .portal-nav a:hover, .p-nav-scroll .portal-nav a.active {
    color: var(--blue-400);
}

.p-nav-scroll .portal-nav .btn-link {
    color: var(--color-muted);
    text-decoration: none;
}

/* White text on the button shade of the logo blue (WCAG AA), not on the lighter text shade. */
.theme-portal .btn-primary {
    --bs-btn-color: var(--white);
    --bs-btn-bg: var(--blue-700);
    --bs-btn-border-color: var(--blue-700);
    --bs-btn-hover-color: var(--white);
    --bs-btn-hover-bg: var(--blue-800);
    --bs-btn-hover-border-color: var(--blue-800);
    --bs-btn-active-color: var(--white);
    --bs-btn-active-bg: var(--blue-800);
    --bs-btn-active-border-color: var(--blue-800);
    --bs-btn-disabled-color: var(--white);
    --bs-btn-disabled-bg: var(--blue-700);
    --bs-btn-disabled-border-color: var(--blue-700);
}

.theme-portal .form-label {
    margin-bottom: 0.15rem;
    font-size: 0.8rem;
    color: var(--color-muted);
}

.theme-portal .prediction-input .form-control {
    min-width: 5rem;
}

/* Cards */
.p-card {
    margin-bottom: var(--space-3);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.p-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-2);
    padding: 0.75rem var(--space-3);
    border-bottom: 1px solid var(--color-border);
}

.p-card-head h2 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
}

.p-card-note {
    margin-left: 0.35em;
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--color-muted);
}

.p-card-link {
    font-size: 0.8rem;
    white-space: nowrap;
}

.p-card-body {
    padding: var(--space-3);
}

.p-card-flush {
    padding: 0;
}

.p-card-foot {
    padding: 0.6rem var(--space-3);
    margin: 0;
    border-top: 1px solid var(--color-border);
}

.p-muted {
    font-size: 0.85rem;
    color: var(--color-muted);
}

.p-empty {
    margin: 0;
    padding: var(--space-3);
    font-size: 0.9rem;
    color: var(--color-muted);
}

.p-card-body:not(.p-card-flush) > .p-empty {
    padding: 0;
}

.p-group {
    margin: 0 0 var(--space-1);
    font-size: 0.8rem;
    color: var(--color-muted);
}

.p-group:not(:first-child) {
    margin-top: var(--space-3);
}

/* Two columns on a desktop, one on a phone */
.p-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0 var(--space-3);
}

/* Hero of a member */
.p-hero-body {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}

.p-hero-body > div {
    min-width: 0;
}

.p-hero-name {
    margin: 0 0 0.15rem;
    font-size: 1.25rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.theme-portal h1.p-hero-name {
    margin-bottom: 0.15rem;
    font-size: 1.25rem;
}

.p-hero-name a {
    color: inherit;
    text-decoration: none;
}

.p-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 0 0.75rem;
    margin: 0 0 0.15rem;
    padding: 0;
    font-size: 0.85rem;
    color: var(--color-muted);
    list-style: none;
}

/* Tabs */
.p-tabs {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
    overflow-x: auto;
    border-bottom: 1px solid var(--color-border);
    scrollbar-width: none;
}

.p-tabs a {
    flex: none;
    padding: 0.5rem 0.15rem;
    margin-bottom: -1px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
}

.p-tabs a[aria-current="page"] {
    color: var(--blue-400);
    border-bottom-color: var(--blue-500);
}

/* Choice of discipline and season */
.p-chips ul {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin: 0 0 var(--space-2);
    padding: 0;
    list-style: none;
}

.p-chips a {
    display: block;
    padding: 0.15rem 0.6rem;
    font-size: 0.8rem;
    color: var(--color-text);
    text-decoration: none;
    border: 1px solid var(--color-border);
    border-radius: 999px;
}

.p-chips a[aria-current="true"] {
    color: var(--white);
    background: var(--blue-700);
    border-color: var(--blue-700);
}

/* Key numbers: label small above the value */
.p-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
    gap: var(--space-3);
    margin: 0;
}

.p-stats dt {
    margin-bottom: 0.1rem;
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--color-muted);
}

.p-stats dd {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.p-stats-compact {
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
}

.p-stats-compact dd {
    font-size: 0.95rem;
    font-weight: 500;
}

/* Dense rows: date | title | tag | rank; on a phone the date sits above the title */
.p-list {
    display: flex;
    flex-direction: column;
}

.p-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(2rem, auto);
    grid-template-areas: "date tag rank" "title tag rank";
    gap: 0 var(--space-2);
    align-items: center;
    padding: 0.55rem var(--space-3);
    border-bottom: 1px solid var(--color-border);
}

.p-list > :last-child .p-row, .p-list > .p-row:last-child {
    border-bottom: 0;
}

.p-row-date {
    grid-area: date;
    font-size: 0.75rem;
    color: var(--color-muted);
    font-variant-numeric: tabular-nums;
}

.p-row-title {
    grid-area: title;
    min-width: 0;
}

.p-row-title > a, .p-row-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.p-row-title > a:hover {
    color: var(--blue-300);
}

.p-row-sub {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 0.5rem;
    font-size: 0.78rem;
    color: var(--color-muted);
}

.p-row-tag {
    grid-area: tag;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-1);
}

.p-row-rank {
    grid-area: rank;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.score-tag {
    display: inline-block;
    min-width: 3.25rem;
    padding: 0.1rem 0.45rem;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    border-radius: 0.3rem;
    background: var(--graphite-700);
    font-variant-numeric: tabular-nums;
}

.score-tag-above {
    color: var(--green-300);
    background: rgba(var(--green-300-rgb), 0.16);
}

.score-tag-below {
    color: var(--red-300);
    background: rgba(var(--red-300-rgb), 0.16);
}

.p-pill {
    display: inline-block;
    padding: 0 0.4rem;
    font-size: 0.72rem;
    color: var(--color-muted);
    border: 1px solid var(--color-border);
    border-radius: 0.25rem;
}

.p-pill-blue {
    color: var(--blue-400);
    border-color: var(--blue-500);
}

.p-pill-amber {
    color: var(--amber-300);
    border-color: var(--amber-700);
}

/* People */
.p-people {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    margin: 0;
    padding: 0;
    list-style: none;
}

.p-people a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem var(--space-3);
    color: var(--color-text);
    text-decoration: none;
}

.p-people a:hover {
    background: var(--graphite-700);
}

.theme-portal .category-filter {
    margin-bottom: var(--space-3);
}

.theme-portal .table {
    margin-bottom: 0;
}

.p-row-date:empty {
    display: none;
}

@media (max-width: 30rem) {
    .athlete-hero-photo {
        width: 5rem;
        height: 5rem;
    }
}

/* The wide layout is for the main column; the side column keeps the stacked one. */
@media (min-width: 48rem) {
    .p-main .p-row, main > .p-card .p-row {
        grid-template-columns: 5.75rem minmax(0, 1fr) auto 3.5rem;
        grid-template-areas: "date title tag rank";
    }

    .p-main .p-row:has(.p-row-date:empty), main > .p-card .p-row:has(.p-row-date:empty) {
        grid-template-columns: minmax(0, 1fr) auto 3.5rem;
        grid-template-areas: "title tag rank";
    }
}

@media (min-width: 62rem) {
    .p-header-inner {
        flex-wrap: nowrap;
    }

    .p-nav-scroll {
        flex: 1 1 auto;
    }

    .p-nav-scroll .portal-nav {
        justify-content: flex-end;
    }

    .p-columns {
        grid-template-columns: minmax(0, 1fr) 21rem;
    }
}
