/* ==========================================================================
   Official Roster – design tokens
   Chart colours follow the validated reference palette (dataviz skill):
   categorical slots in fixed order, blue sequential ramp, reserved status colours.
   ========================================================================== */
:root {
    color-scheme: light;
    --font: system-ui, -apple-system, "Segoe UI", sans-serif;

    --page: #f4f5f2;
    --surface-1: #fcfcfb;
    --surface-2: #f0efec;
    --surface-sunk: #e9e8e3;
    --ink: #0b0b0b;
    --ink-2: #52514e;
    --muted: #6f6d68;
    --line: #e1e0d9;
    --line-strong: #c3c2b7;
    --ring: rgba(11, 11, 11, 0.10);
    --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 16px rgba(0, 0, 0, .04);

    --accent: #1c5cab;
    --accent-ink: #ffffff;
    --accent-soft: #cde2fb;
    --accent-wash: #e8f1fc;

    --nav-bg: #0f2536;
    --nav-ink: #c9d6e2;
    --nav-ink-strong: #ffffff;
    --nav-active: rgba(255, 255, 255, .10);

    /* categorical (fixed order) */
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --series-3: #1baf7a;
    --series-4: #eda100;
    --series-5: #e87ba4;
    --series-6: #008300;
    --series-7: #6250d6;
    --series-8: #e34948;

    /* sequential blue */
    --seq-100: #cde2fb;
    --seq-250: #86b6ef;
    --seq-450: #2a78d6;
    --seq-600: #184f95;

    /* status – always paired with an icon/label */
    --good: #0ca30c;
    --good-ink: #006300;
    --warning: #fab219;
    --warning-ink: #8a5a00;
    --serious: #ec835a;
    --critical: #d03b3b;
    --critical-ink: #b02a2a;
    --info-ink: #1c5cab;

    /* venue graphic */
    --water: #cfe6f3;
    --water-deep: #b5d8ec;
    --rope: #ffffff;
    --rope-dot: #2a78d6;
    --deck: #ece9e1;
    --deck-edge: #d6d2c6;

    --radius: 10px;
    --radius-sm: 6px;
}

@media (prefers-color-scheme: dark) {
    :root:where(:not([data-theme="light"])) {
        color-scheme: dark;
        --page: #0d0d0d;
        --surface-1: #1a1a19;
        --surface-2: #232321;
        --surface-sunk: #121211;
        --ink: #f0efec;
        --ink-2: #c3c2b7;
        --muted: #9b998f;
        --line: #2c2c2a;
        --line-strong: #383835;
        --ring: rgba(255, 255, 255, 0.10);
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
        --accent: #3987e5;
        --accent-ink: #0b0b0b;
        --accent-soft: #184f95;
        --accent-wash: #16273b;
        --nav-bg: #0a1823;
        --series-1: #3987e5;
        --series-2: #d95926;
        --series-3: #199e70;
        --series-4: #c98500;
        --series-5: #d55181;
        --series-6: #008300;
        --series-7: #9085e9;
        --series-8: #e66767;
        --seq-100: #1c2f45;
        --seq-250: #184f95;
        --seq-450: #3987e5;
        --seq-600: #86b6ef;
        --good-ink: #0ca30c;
        --warning-ink: #fab219;
        --critical-ink: #e66767;
        --info-ink: #86b6ef;
        --water: #12324a;
        --water-deep: #0e2a3f;
        --rope: #5a7a92;
        --rope-dot: #3987e5;
        --deck: #232321;
        --deck-edge: #383835;
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --surface-2: #232321;
    --surface-sunk: #121211;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #9b998f;
    --line: #2c2c2a;
    --line-strong: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-ink: #0b0b0b;
    --accent-soft: #184f95;
    --accent-wash: #16273b;
    --water: #12324a;
    --water-deep: #0e2a3f;
    --rope: #5a7a92;
    --deck: #232321;
    --deck-edge: #383835;
}

/* ---------- base ---------- */
html, body {
    font-family: var(--font);
    background: var(--page);
    color: var(--ink);
}

body {
    --bs-body-bg: var(--page);
    --bs-body-color: var(--ink);
    --bs-border-color: var(--line);
    --bs-secondary-color: var(--ink-2);
    --bs-link-color-rgb: 28, 92, 171;
    --bs-table-bg: transparent;
}

h1, h2, h3, h4 { font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
h1:focus { outline: none; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.small-caps { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- buttons & forms (light Bootstrap overrides) ---------- */
.btn { border-radius: var(--radius-sm); font-weight: 550; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); border-color: var(--accent); }
.btn-outline-secondary { color: var(--ink-2); border-color: var(--line-strong); }
.btn-outline-secondary:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost { background: transparent; border: 1px solid transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
/* Bootstrap gives a disabled button a visible border; a ghost button stays borderless and just fades. */
.btn-ghost:disabled, .btn-ghost.disabled { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn:focus-visible, .form-control:focus, .form-select:focus, .form-check-input:focus {
    box-shadow: 0 0 0 2px var(--surface-1), 0 0 0 4px var(--accent);
    outline: none;
}
.form-control, .form-select {
    background-color: var(--surface-1);
    color: var(--ink);
    border-color: var(--line-strong);
    border-radius: var(--radius-sm);
}
.form-label { font-size: .82rem; font-weight: 600; color: var(--ink-2); margin-bottom: .25rem; }

/* ---------- cards & layout helpers ---------- */
.card-x {
    background: var(--surface-1);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-x > .card-x-head {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .8rem 1rem; border-bottom: 1px solid var(--line);
}
.card-x > .card-x-head h2, .card-x > .card-x-head h3 { margin: 0; }
.card-x > .card-x-body { padding: 1rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row-gap { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.grid-auto { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 960px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- tables ---------- */
.table-x { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.table-x th {
    position: sticky; top: 0; z-index: 1;
    background: var(--surface-2); color: var(--ink-2);
    font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 650;
    text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line-strong);
}
.table-x td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table-x tbody tr:hover td { background: var(--accent-wash); }
.table-x tfoot td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--line-strong); }
.table-wrap { overflow: auto; max-width: 100%; }

/* ---------- badges / pills ---------- */
.pill {
    display: inline-flex; align-items: center; gap: .3rem;
    font-size: .74rem; font-weight: 600; line-height: 1;
    padding: .28rem .5rem; border-radius: 999px;
    background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
    white-space: nowrap;
}
.pill .dot { width: .55rem; height: .55rem; border-radius: 50%; display: inline-block; }
.pill-good { color: var(--good-ink); }
.pill-warn { color: var(--warning-ink); }
.pill-bad { color: var(--critical-ink); }
.pill-info { color: var(--info-ink); }
.swatch { width: .7rem; height: .7rem; border-radius: 3px; display: inline-block; flex: none; }

/* category identity (series slots 1-4) */
.cat-host { --cat: var(--series-1); }
.cat-alumni { --cat: var(--series-2); }
.cat-visiting { --cat: var(--series-3); }
.cat-none { --cat: var(--series-4); }

/* ---------- toasts ---------- */
.toast-stack { position: fixed; right: 1rem; bottom: 4.5rem; /* clear of the assistant launcher */ display: flex; flex-direction: column; gap: .5rem; z-index: 2000; max-width: min(420px, calc(100vw - 2rem)); }
.toast-x {
    background: var(--surface-1); color: var(--ink); border: 1px solid var(--line-strong);
    border-left: 4px solid var(--accent); border-radius: var(--radius-sm);
    padding: .65rem .8rem; box-shadow: 0 6px 24px rgba(0, 0, 0, .15); font-size: .9rem;
    display: flex; gap: .6rem; align-items: flex-start;
    animation: toast-in .18s ease-out;
}
.toast-x.toast-warn { border-left-color: var(--warning); }
.toast-x.toast-error { border-left-color: var(--critical); }
.toast-x.toast-good { border-left-color: var(--good); }
.toast-x button { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 1.1rem; line-height: 1; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- modal ---------- */
.modal-x-backdrop { position: fixed; inset: 0; background: rgba(5, 15, 25, .45); z-index: 1500; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 1rem; overflow: auto; }
.modal-x { background: var(--surface-1); color: var(--ink); border-radius: var(--radius); width: min(640px, 100%); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); border: 1px solid var(--line); }
.modal-x.wide { width: min(980px, 100%); }
.modal-x-head { padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.modal-x-head h2 { margin: 0; font-size: 1.1rem; }
.modal-x-body { padding: 1.1rem; }
.modal-x-foot { padding: .8rem 1.1rem; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: .5rem; }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty strong { display: block; color: var(--ink-2); font-size: 1rem; margin-bottom: .25rem; }

/* ---------- validation / error boundary ---------- */
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--good); }
.invalid { outline: 1px solid var(--critical); }
.validation-message { color: var(--critical-ink); font-size: .85rem; }

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 1.2rem;
    color: white;
    border-radius: var(--radius-sm);
}
.blazor-error-boundary::after { content: "An error has occurred."; }

/* ---------- print ---------- */
@media print {
    .no-print { display: none !important; }
    body { background: #fff; color: #000; }
}

/* ---------- charts (HTML marks; see dataviz mark specs) ---------- */
.chart { margin: 0; position: relative; }
.chart-legend { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem 1rem; padding: 0; margin: 0 0 .75rem; font-size: .8rem; color: var(--ink-2); }
.chart-legend li { display: inline-flex; align-items: center; gap: .4rem; }

.chart-tip {
    display: none; position: absolute; z-index: 20; pointer-events: none;
    background: var(--surface-1); color: var(--ink); border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(0, 0, 0, .14);
    padding: .5rem .65rem; font-size: .8rem; min-width: 170px; white-space: nowrap;
}
.chart-tip strong { display: block; margin-bottom: .25rem; }
.tip-row { display: flex; align-items: center; gap: .4rem; color: var(--ink-2); }
.tip-val { margin-left: auto; padding-left: 1rem; color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
.tip-total { border-top: 1px solid var(--line); margin-top: .2rem; padding-top: .2rem; }
.tip-detail { color: var(--muted); margin-top: .25rem; white-space: normal; max-width: 260px; }

/* horizontal bars */
.hbars { display: flex; flex-direction: column; gap: 6px; }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr; align-items: center; gap: .75rem; position: relative; border-radius: 4px; outline: none; }
.hbar-row:hover, .hbar-row:focus-visible { background: var(--accent-wash); }
.hbar-row:hover .chart-tip, .hbar-row:focus-visible .chart-tip { display: block; left: min(55%, 260px); top: 100%; }
.hbar-label { font-size: .82rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.hbar-area { display: flex; align-items: center; gap: .4rem; min-width: 0; padding-right: 2.5rem; }
.hbar { display: flex; gap: 2px; height: 18px; min-width: 2px; }
.hbar .seg { height: 100%; min-width: 2px; }
.hbar .seg:last-child { border-radius: 0 4px 4px 0; }
.hbar-value { font-size: .78rem; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* vertical columns */
.vcols { display: flex; align-items: flex-end; gap: .25rem; position: relative; padding-left: 2.2rem; }
.vcols-grid { position: absolute; left: 2.2rem; right: 0; top: 0; height: var(--plot-h); pointer-events: none; }
.vgrid-line { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.vgrid-line span { position: absolute; left: -2.2rem; width: 2rem; text-align: right; top: -.55rem; font-size: .68rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.vcol { flex: 1 1 0; min-width: 28px; display: flex; flex-direction: column; align-items: center; position: relative; outline: none; border-radius: 4px; }
.vcol:hover, .vcol:focus-visible { background: var(--accent-wash); }
.vcol:hover .chart-tip, .vcol:focus-visible .chart-tip { display: block; bottom: calc(100% - 1rem); left: 50%; transform: translateX(-50%); }
.vcol-plot { height: var(--plot-h); width: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; border-bottom: 1px solid var(--line-strong); }
.vcol-bar { width: min(24px, 70%); display: flex; flex-direction: column; gap: 2px; min-height: 2px; }
.vcol-bar .seg { width: 100%; min-height: 2px; }
.vcol-bar .seg:first-child { border-radius: 4px 4px 0 0; }
.vcol-value { font-size: .72rem; color: var(--ink-2); font-variant-numeric: tabular-nums; margin-bottom: 2px; }
.vcol-label { font-size: .72rem; color: var(--ink-2); text-align: center; margin-top: .3rem; line-height: 1.15; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* ---------- pages made for a larger screen (Shared/LargeScreenOnly) ---------- */
.large-screen-note { display: none; }

@media (max-width: 760px) {
    .large-screen-note:not(.dismissed) { display: block; }
    /* Everything else the page renders stays out of the way until "Show it anyway". */
    .app-content:has(> .large-screen-note:not(.dismissed)) > :not(.large-screen-note) { display: none; }

    .large-screen-card { padding: 1.5rem 1.25rem; text-align: center; }
    .large-screen-card h1 { font-size: 1.25rem; margin: .5rem 0; }
    .large-screen-card .row-gap { justify-content: center; margin-top: 1rem; }
    .large-screen-icon { color: var(--accent); }
}

/* ---------- phones (≤760px) ---------- */
/* Tables drop secondary columns (hide-phone) and show a compact summary under the name instead (phone-only). */
.phone-only { display: none; }

@media (max-width: 760px) {
    .hide-phone { display: none !important; }
    .phone-only { display: revert; }
    .phone-meta { display: block; font-size: .78rem; color: var(--muted); margin-top: .1rem; }

    /* Page headers: actions under the title, full width so they're easy to tap. */
    .page-actions { width: 100%; }

    /* Dialogs use the whole width and start near the top. */
    .modal-x-backdrop { padding: .75rem .5rem 0; }
    .modal-x-head, .modal-x-body { padding-left: .9rem; padding-right: .9rem; }
    /* Long dialogs (a sign-up's positions) keep Save and Cancel on screen. */
    .modal-x-foot {
        flex-wrap: wrap;
        position: sticky;
        bottom: 0;
        background: var(--surface-1);
        border-radius: 0 0 var(--radius) var(--radius);
    }

    /* Comfortable tap targets for row buttons. */
    .table-x .btn-sm { min-height: 36px; }
}
