/* Court Allocator — visual system
   Colours come from the court itself: hard-court blue, the green surround, white lines, and
   optic yellow (the ball) kept for the one main action and for "selected / pinned". */

/* Fonts are bundled in wwwroot/fonts so the app looks right without internet (SIL Open Font License). */
@font-face { font-family: "Barlow"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/barlow-condensed-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/barlow-condensed-latin-700-normal.woff2") format("woff2"); }

:root {
    --ink: #16232e;
    --muted: #5d6b74;
    --paper: #eef2ec;
    --panel: #ffffff;
    --rule: #d3dbd2;
    --court: #1f5f9e;
    --court-deep: #174a7d;
    --surround: #2e7d4f;
    --surround-deep: #24663f;
    --ball: #d7e84a;
    --ball-deep: #b9cb2c;
    --danger: #b3322a;

    --font-ui: "Barlow", "Segoe UI", system-ui, sans-serif;
    --font-sign: "Barlow Condensed", "Arial Narrow", "Segoe UI", sans-serif;
}

html { font-size: 16px; }

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 1rem;
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--court); }

:focus-visible { outline: 3px solid var(--ball-deep); outline-offset: 2px; }

/* ------------------------------------------------------------------ top bar */

.topbar { background: var(--surround-deep); color: #fff; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 64px; flex-wrap: wrap; }

.brand { display: flex; align-items: center; gap: .65rem; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.brand-ball { width: 30px; height: 30px; flex: none; }
.brand-ball circle { fill: var(--ball); }
.brand-ball path { fill: none; stroke: #fff; stroke-width: 1.6; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-app { font-family: var(--font-sign); font-weight: 700; font-size: 1.35rem; letter-spacing: .01em; }
.brand-club { font-size: .8rem; opacity: .8; }

.mainnav { display: flex; gap: .25rem; flex-wrap: wrap; }
.mainnav a { color: #fff; text-decoration: none; padding: .45rem .8rem; border-radius: 6px; font-weight: 500; opacity: .85; }
.mainnav a:hover { opacity: 1; background: rgba(255, 255, 255, .1); }
.mainnav a.active { opacity: 1; background: rgba(255, 255, 255, .16); box-shadow: inset 0 -3px 0 var(--ball); }

/* ------------------------------------------------------------------ type */

.page-title { font-family: var(--font-sign); font-weight: 700; font-size: 2.25rem; line-height: 1.1; margin: 0 0 .35rem; }
.lede { color: var(--muted); max-width: 62ch; margin-bottom: 1.5rem; }
.section-title { font-family: var(--font-sign); font-weight: 600; font-size: 1.4rem; margin: 0 0 .75rem; }

.flash {
    background: var(--panel);
    border-left: 4px solid var(--surround);
    padding: .7rem 1rem;
    border-radius: 6px;
    margin-bottom: 1.25rem;
}

/* ------------------------------------------------------------------ buttons */

.btn { font-weight: 600; border-radius: 8px; }
.btn-court { background: var(--court); border-color: var(--court); color: #fff; }
.btn-court:hover, .btn-court:focus { background: var(--court-deep); border-color: var(--court-deep); color: #fff; }
.btn-outline-court { border: 2px solid var(--court); color: var(--court); background: transparent; }
.btn-outline-court:hover { background: var(--court); color: #fff; }
.btn-ball { background: var(--ball); border-color: var(--ball); color: var(--ink); }
.btn-ball:hover, .btn-ball:focus { background: var(--ball-deep); border-color: var(--ball-deep); color: var(--ink); }
.btn-ball.dropdown-toggle-split { border-left: 1px solid rgba(22, 35, 46, .25); }
.btn-quiet { background: transparent; border: 0; color: var(--muted); font-weight: 500; }
.btn-quiet:hover { color: var(--ink); background: rgba(22, 35, 46, .06); }
.btn-danger-quiet { background: transparent; border: 0; color: var(--danger); font-weight: 500; }
.btn-danger-quiet:hover { background: rgba(179, 50, 42, .08); color: var(--danger); }

/* ------------------------------------------------------------------ panels, tables, forms */

.panel { background: var(--panel); border-radius: 12px; padding: 1.25rem 1.4rem; border: 1px solid var(--rule); }
.panel + .panel { margin-top: 1.25rem; }

.table-club { margin: 0; }
.table-club th { font-weight: 600; color: var(--muted); font-size: .875rem; border-bottom-color: var(--rule); }
.table-club td { vertical-align: middle; border-color: var(--rule); }
.table-club tr.inactive td { color: var(--muted); }

.form-control, .form-select { border-radius: 8px; border-color: #c4cec4; }
.form-control:focus, .form-select:focus { border-color: var(--court); box-shadow: 0 0 0 3px rgba(31, 95, 158, .2); }
.form-check-input:checked { background-color: var(--court); border-color: var(--court); }
.form-label { font-weight: 500; }

/* Skill level: five pips, filled to the level. */
.level { display: inline-flex; gap: 3px; vertical-align: middle; }
.level i { width: 8px; height: 8px; border-radius: 50%; background: #d5ddd4; }
.level i.on { background: var(--surround); }
.level-none { color: var(--muted); font-size: .85rem; }

.level-picker { display: inline-flex; border: 1px solid #c4cec4; border-radius: 8px; overflow: hidden; }
.level-picker input { position: absolute; opacity: 0; pointer-events: none; }
.level-picker label { padding: .35rem .7rem; cursor: pointer; font-weight: 600; border-right: 1px solid #c4cec4; margin: 0; background: #fff; }
.level-picker label:last-of-type { border-right: 0; }
.level-picker input:checked + label { background: var(--surround); color: #fff; }
.level-picker input:focus-visible + label { outline: 3px solid var(--ball-deep); outline-offset: -3px; }

/* ------------------------------------------------------------------ mode badges */

.mode { display: inline-block; font-size: .8rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; }
.mode-mixed { background: #e1e7df; color: var(--ink); }
.mode-even { background: var(--court); color: #fff; }
.mode-grouped { background: var(--surround); color: #fff; }

/* ------------------------------------------------------------------ session list */

.session-list { list-style: none; padding: 0; margin: 0; }
.session-list li { display: flex; align-items: center; gap: 1rem; padding: .85rem 0; border-bottom: 1px solid var(--rule); }
.session-list li:last-child { border-bottom: 0; }
.session-date { font-family: var(--font-sign); font-weight: 700; font-size: 1.15rem; width: 7.5rem; flex: none; }
.session-name { flex: 1; }
.session-name a { font-weight: 600; text-decoration: none; }
.session-name small { display: block; color: var(--muted); }

/* ------------------------------------------------------------------ setup page */

.setup-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.setup-group { border: 1px solid var(--rule); border-radius: 10px; padding: .9rem 1rem; background: #fafcf9; }
.setup-group h3 { font-family: var(--font-sign); font-size: 1.25rem; font-weight: 600; margin: 0 0 .5rem; }

.court-chooser { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.court-choice { background: var(--surround); border-radius: 10px; padding: .6rem .7rem; color: #fff; }
.court-choice .num { font-family: var(--font-sign); font-weight: 700; font-size: 1.6rem; line-height: 1; display: block; margin-bottom: .35rem; }
.court-choice.unused { background: #c3ccc2; }
.court-choice .form-select { font-size: .9rem; }

.player-picker { columns: 3 260px; column-gap: 1.5rem; }
.pick-row { break-inside: avoid; display: flex; align-items: center; gap: .6rem; padding: .35rem .4rem; border-radius: 8px; }
.pick-row:hover { background: #f3f6f2; }
.pick-row .form-check-input { width: 1.3rem; height: 1.3rem; margin: 0; flex: none; cursor: pointer; }
.pick-row label { flex: 1; cursor: pointer; margin: 0; font-weight: 500; }
.pick-row .form-select { width: auto; max-width: 9.5rem; font-size: .85rem; padding-top: .2rem; padding-bottom: .2rem; }
.pick-row:not(.present) .form-select { opacity: .45; }
.picker-tools { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }
.present-count { font-weight: 600; margin-left: auto; }

.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--paper) 30%); padding: 1.25rem 0 .75rem; margin-top: 1rem; display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }

/* ------------------------------------------------------------------ round header */

.round-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.round-title { display: flex; align-items: baseline; gap: .9rem; flex-wrap: wrap; }
.round-number { font-family: var(--font-sign); font-weight: 700; font-size: 3.4rem; line-height: .9; margin: 0; }
.round-session { color: var(--muted); }
.round-session strong { color: var(--ink); font-weight: 600; }
.round-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.round-nav { display: flex; gap: .25rem; align-items: center; }

.notice { background: #fff8d6; border: 1px solid #eadb8f; border-radius: 8px; padding: .55rem .9rem; margin-bottom: 1rem; font-size: .95rem; }

.group-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin: 0 0 .75rem; }
.court-group:first-child .group-head { margin-top: 0; }
.court-group + .court-group { margin-top: 2.25rem; }
.group-name { font-family: var(--font-sign); font-weight: 700; font-size: 1.6rem; margin: 0; }
.group-head .reshuffle { margin-left: auto; }

/* ------------------------------------------------------------------ courts (the centrepiece) */

.courts { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 1rem; }

.court-card {
    background: var(--surround);
    border-radius: 12px;
    padding: .6rem .9rem .9rem;
    color: #fff;
    position: relative;
}
.court-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin-bottom: .45rem; }
.court-num { font-family: var(--font-sign); font-weight: 700; font-size: 1.9rem; line-height: 1; }
.court-num small { font-size: 1rem; font-weight: 600; opacity: .75; margin-right: .3rem; }
.court-info { font-size: .85rem; font-weight: 600; opacity: .9; }
.court-card.unused { background: #9fb0a2; }
.court-card.unused .court { filter: saturate(.25); opacity: .55; }

.court {
    position: relative;
    aspect-ratio: 2377 / 1097; /* doubles court, metres x 100 */
    background: var(--court);
    border-radius: 2px;
    display: grid;
    grid-template-columns: 1fr 1fr;
}
.court-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.court-lines * { fill: none; stroke: rgba(255, 255, 255, .92); stroke-width: 2; vector-effect: non-scaling-stroke; }
.court-net { position: absolute; top: -6px; bottom: -6px; left: 50%; width: 4px; margin-left: -2px; background: repeating-linear-gradient(#fff 0 3px, #cfd8de 3px 6px); border-radius: 2px; pointer-events: none; }

.half { position: relative; display: grid; grid-template-rows: 1fr 1fr; gap: 6%; padding: 9% 9%; align-items: center; z-index: 1; }

/* ------------------------------------------------------------------ player chips and slots */

.slot { min-height: 2.4rem; border-radius: 8px; display: flex; align-items: center; }
.slot.empty { border: 2px dashed rgba(255, 255, 255, .5); justify-content: center; color: rgba(255, 255, 255, .75); font-size: .85rem; }
.editable .slot.empty { cursor: pointer; }
.round-courts:not(.editable) .slot.empty { border-color: transparent; }
.court-card.unused .slot.empty span { visibility: hidden; }
.slot.drop-hover { outline: 3px solid var(--ball); outline-offset: 2px; }

.chip {
    display: flex;
    align-items: center;
    gap: .4rem;
    width: 100%;
    background: #fff;
    color: var(--ink);
    border-radius: 8px;
    padding: .3rem .4rem .3rem .65rem;
    font-family: var(--font-sign);
    font-weight: 600;
    font-size: 1.15rem;
    line-height: 1.15;
    box-shadow: 0 2px 0 rgba(0, 0, 0, .18);
    min-width: 0;
}
.chip-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-level { flex: none; width: 1.45rem; height: 1.45rem; border-radius: 50%; background: #e3e9e2; font-family: var(--font-ui); font-size: .78rem; font-weight: 600; display: grid; place-items: center; }
.chip-level.unknown { background: transparent; border: 1px dashed #9aa79b; color: var(--muted); }
.hide-levels .chip-level { display: none; }

.chip-pin { flex: none; border: 0; background: transparent; padding: 0 .15rem; color: #a9b4ab; line-height: 1; cursor: pointer; }
.chip-pin svg { width: 16px; height: 16px; display: block; }
.chip-pin:hover { color: var(--ink); }
.chip.pinned { box-shadow: 0 0 0 2px var(--ball), 0 2px 0 rgba(0, 0, 0, .18); }
.chip.pinned .chip-pin { color: var(--ink); }
.chip.pinned .chip-pin svg { fill: var(--ball-deep); }

.editable .chip { cursor: grab; }
.editable .chip:active { cursor: grabbing; }
.chip.selected { outline: 3px solid var(--ball); outline-offset: 2px; }
.chip.dragging { opacity: .4; }

/* ------------------------------------------------------------------ bench */

.bench { margin-top: .75rem; background: var(--panel); border: 1px solid var(--rule); border-radius: 12px; padding: .65rem .9rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; min-height: 3.4rem; }
.bench-label { font-weight: 600; color: var(--muted); margin-right: .25rem; }
.bench .chip { width: auto; max-width: 14rem; background: #f0f4ef; box-shadow: none; border: 1px solid var(--rule); }
.bench-empty { color: var(--muted); font-size: .9rem; }
.bench.drop-hover { outline: 3px solid var(--ball); outline-offset: 2px; }

.help-line { color: var(--muted); font-size: .9rem; margin-top: 1.25rem; }

.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-state p { color: var(--muted); max-width: 46ch; margin: .5rem auto 1.25rem; }

/* ------------------------------------------------------------------ history */

.history-round { margin-bottom: 1.5rem; }
.history-round h3 { font-family: var(--font-sign); font-weight: 700; font-size: 1.4rem; margin: 0 0 .5rem; }
.history-line { display: flex; gap: .75rem; padding: .3rem 0; border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.history-line .c { font-family: var(--font-sign); font-weight: 700; width: 5.5rem; flex: none; }
.history-line .v { color: var(--muted); padding: 0 .35rem; }

.matrix-wrap { overflow: auto; max-height: 70vh; }
.matrix { border-collapse: separate; border-spacing: 0; font-size: .85rem; }
.matrix th, .matrix td { padding: .25rem .4rem; text-align: center; border-bottom: 1px solid var(--rule); }
.matrix thead th { position: sticky; top: 0; background: var(--panel); writing-mode: vertical-rl; transform: rotate(180deg); text-align: left; font-weight: 600; height: 8rem; vertical-align: bottom; }
.matrix tbody th { text-align: left; position: sticky; left: 0; background: var(--panel); font-weight: 600; white-space: nowrap; }
.matrix td.n1 { background: #dbe9df; }
.matrix td.n2 { background: #a8cdb3; font-weight: 600; }
.matrix td.n3 { background: var(--surround); color: #fff; font-weight: 600; }
.matrix td.self { background: #eef1ee; }

/* ------------------------------------------------------------------ projector display */

body.display { background: #13323d; color: #fff; }
body.display main { padding-top: 1.5rem !important; }
.display .round-number { font-size: 5rem; color: #fff; }
.display .round-session, .display .round-session strong { color: rgba(255, 255, 255, .8); }
.display .courts { grid-template-columns: repeat(auto-fill, minmax(480px, 1fr)); gap: 1.25rem; }
.display .chip { font-size: 1.6rem; padding: .35rem .6rem; }
.display .chip-level { width: 1.8rem; height: 1.8rem; font-size: .95rem; }
.display .court-num { font-size: 2.6rem; }
.display .group-name { color: #fff; font-size: 2rem; }
.display .bench { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .15); }
.display .bench .chip { background: rgba(255, 255, 255, .9); font-size: 1.3rem; }
.display .bench-label, .display .bench-empty { color: rgba(255, 255, 255, .75); }
.display-exit { color: rgba(255, 255, 255, .55); }
.display-exit:hover { color: #fff; background: rgba(255, 255, 255, .1); }

/* ------------------------------------------------------------------ small screens */

@media (max-width: 575.98px) {
    .courts, .display .courts { grid-template-columns: 1fr; }
    .round-number { font-size: 2.6rem; }
    .chip { font-size: 1rem; }
    .session-date { width: 5.5rem; font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

@media print {
    .topbar, .round-actions, .chip-pin, .help-line, .reshuffle { display: none !important; }
    body { background: #fff; }
    .court-card { break-inside: avoid; }
}
