/* Sparring portal. Fonts are self-hosted so the pages work on a venue network with no internet. */

@font-face { font-family: 'Barlow Condensed'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/barlow-condensed-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/barlow-condensed-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Source Sans 3'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/source-sans-3-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Source Sans 3'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/source-sans-3-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Source Sans 3'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/source-sans-3-latin-700-normal.woff2') format('woff2'); }

:root {
  color-scheme: light;
  --ink: #12161c;
  --paper: #f3f4f7;
  --surface: #ffffff;
  --line: #dde1e7;
  --line-strong: #c4cad4;
  --muted: #566070;
  --faint: #7b8494;
  --slate: #3b4350;

  --blue: #1d5fd0;
  --blue-ink: #133f92;
  --blue-wash: #eaf1fd;
  --red: #d1292e;
  --red-ink: #9a1a1f;
  --red-wash: #fceded;

  --gold: #c99a1d;
  --gold-ink: #6c5000;
  --gold-wash: #fbf3dc;
  --silver: #8a93a1;
  --silver-ink: #434c5a;
  --silver-wash: #eef0f3;
  --bronze: #b0692b;
  --bronze-ink: #764113;
  --bronze-wash: #f8ece1;

  --font-display: 'Barlow Condensed', 'Arial Narrow', 'Roboto Condensed', system-ui, sans-serif;
  --font-body: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ol, ul, fieldset { margin: 0; padding: 0; }
ol, ul { list-style: none; }
fieldset { border: 0; min-width: 0; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- masthead ---------- */
.masthead { background: var(--ink); color: #fff; }
.masthead__inner {
  max-width: 1120px; margin: 0 auto; padding: 20px 24px 18px;
  display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 14px 32px;
}
.masthead__date { font-size: 14px; color: #aab3c2; margin-bottom: 3px; min-height: 20px; }
.masthead h1 { font: 600 clamp(26px, 4.4vw, 40px)/1.05 var(--font-display); letter-spacing: 0.005em; }
.masthead__tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; font-size: 14px; color: #c8cfda; }
.corner-rule { height: 5px; background: linear-gradient(90deg, var(--blue) 50%, var(--red) 50%); }

.live { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; }
.live__state { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: #fff; }
.live__dot { width: 9px; height: 9px; border-radius: 50%; background: #46d39a; box-shadow: 0 0 0 3px rgba(70, 211, 154, 0.22); }
.live[data-state='offline'] .live__dot { background: #f2b544; box-shadow: 0 0 0 3px rgba(242, 181, 68, 0.25); }
.live__detail { color: #9aa4b4; font-variant-numeric: tabular-nums; }
.masthead__badge { font-weight: 600; font-size: 13.5px; padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); color: #fff; }

/* ---------- page ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 26px 24px 96px; }
.back { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 10px -4px; padding: 6px 8px 6px 2px; color: var(--muted); font-weight: 600; font-size: 15px; text-decoration: none; border-radius: 6px; }
.back:hover { color: var(--ink); }
.page-title { font: 700 clamp(30px, 5vw, 46px)/1.04 var(--font-display); }
.page-lede { margin-top: 6px; color: var(--muted); font-size: 17px; }

.page-lede + .toolbar { margin-top: 18px; }
.tally { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 12px 0 22px; font-size: 16px; color: var(--muted); }
.tally b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; margin-right: 4px; }
.tally span { display: inline-flex; align-items: center; gap: 6px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-bottom: 14px; }
.search { position: relative; flex: 1 1 260px; max-width: 440px; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search input {
  width: 100%; height: 44px; padding: 0 14px 0 40px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px;
}
.search input::placeholder { color: var(--faint); }

.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; }
.seg button { height: 36px; padding: 0 13px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-weight: 600; font-size: 14.5px; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed='true'] { background: var(--ink); color: #fff; }
.seg .n { margin-left: 6px; font-weight: 400; opacity: 0.8; font-variant-numeric: tabular-nums; }

/* ---------- academy list ---------- */
.academies { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.academy {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto 20px; align-items: center; gap: 4px 28px;
  padding: 16px 22px; border-bottom: 1px solid var(--line); text-decoration: none;
}
li:last-child > .academy { border-bottom: 0; }
.academy:hover { background: #f7f8fa; }
.academy__name { font-weight: 700; font-size: 18px; line-height: 1.25; }
.academy__meta { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.academy__tally { display: inline-flex; align-items: center; gap: 14px; min-width: 92px; justify-content: flex-end; font-weight: 600; font-variant-numeric: tabular-nums; }
.academy__tally span { display: inline-flex; align-items: center; gap: 5px; }
.academy svg { color: var(--faint); }
.list-empty { padding: 36px 22px; text-align: center; color: var(--muted); }

.medal { width: 13px; height: 13px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5); }
.medal--gold { background: var(--gold); }
.medal--silver { background: var(--silver); }
.medal--bronze { background: var(--bronze); }

/* ---------- athlete sheet ---------- */
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.sheet__head,
.row {
  display: grid;
  grid-template-columns: minmax(170px, 1.05fr) minmax(110px, 0.65fr) minmax(0, 2.1fr) minmax(190px, 1.1fr);
  grid-template-areas: 'name cat trail status' 'editor editor editor editor';
  column-gap: 24px; align-items: center; padding-left: 22px; padding-right: 22px;
}
.sheet__head { height: 40px; background: #f9fafb; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13.5px; font-weight: 600; }
.sheet__head span:nth-child(1) { grid-area: name; }
.sheet__head span:nth-child(2) { grid-area: cat; }
.sheet__head span:nth-child(3) { grid-area: trail; }
.sheet__head span:nth-child(4) { grid-area: status; }

.group + .group { margin-top: 28px; }
.group__title { display: flex; align-items: baseline; gap: 12px; margin: 0 2px 10px; font: 700 21px/1.15 var(--font-display); }
.group__title span { font: 500 14px/1 var(--font-body); color: var(--muted); }

.row { padding-top: 16px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row[data-outcome='gold'] { box-shadow: inset 4px 0 0 var(--gold); }
.row[data-outcome='silver'] { box-shadow: inset 4px 0 0 var(--silver); }
.row[data-outcome='bronze'] { box-shadow: inset 4px 0 0 var(--bronze); }
.row__name { grid-area: name; font: 600 17px/1.25 var(--font-body); overflow-wrap: anywhere; }
.row[data-outcome='out'] .row__name { color: var(--muted); }
.row__cat { grid-area: cat; }
.row__cat strong { display: block; font-weight: 600; }
.row__cat span { display: block; color: var(--muted); font-size: 14px; }
.row__status { grid-area: status; }

@keyframes fresh { from { background: #fff1b8; } to { background: transparent; } }
.row--fresh { animation: fresh 9s ease-out 1; }
@media (prefers-reduced-motion: reduce) { .row--fresh { animation: none; background: #fff8dc; } }

/* ---------- fight trail ---------- */
.trail { grid-area: trail; display: flex; align-items: flex-end; gap: 22px; overflow-x: auto; padding: 8px 8px 4px 2px; margin: -8px 0 -4px; scrollbar-width: thin; }
.step { position: relative; display: flex; flex: 0 0 auto; flex-direction: column; align-items: center; gap: 11px; }
.step + .step::before { content: ''; position: absolute; left: -22px; bottom: 27px; width: 22px; height: 2px; background: var(--line-strong); }
.step__round { font-size: 12px; line-height: 1; color: var(--muted); white-space: nowrap; }
.step--next .step__round { color: var(--ink); font-weight: 700; }

.chip {
  --c: var(--slate); --c-ink: var(--slate); --c-wash: #eef0f3; --c-edge: rgba(59, 67, 80, 0.4); --c-halo: rgba(59, 67, 80, 0.18);
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 68px; height: 56px; border: 2px solid transparent; border-radius: 8px;
}
.chip--blue { --c: var(--blue); --c-ink: var(--blue-ink); --c-wash: var(--blue-wash); --c-edge: rgba(29, 95, 208, 0.42); --c-halo: rgba(29, 95, 208, 0.2); }
.chip--red { --c: var(--red); --c-ink: var(--red-ink); --c-wash: var(--red-wash); --c-edge: rgba(209, 41, 46, 0.42); --c-halo: rgba(209, 41, 46, 0.2); }
.chip__no { font: 700 26px/1 var(--font-display); letter-spacing: 0.01em; }
.chip--bye .chip__no { font-size: 22px; }
.chip__corner { margin-top: 3px; font: 600 11px/1 var(--font-body); }

.chip--won { background: var(--c); border-color: var(--c); color: #fff; }
.chip--next { background: var(--c-wash); border-color: var(--c); color: var(--c-ink); box-shadow: 0 0 0 4px var(--c-halo); }
.chip--upcoming { background: var(--surface); border-color: var(--c-edge); color: var(--c-ink); }
.chip--lost { background: var(--slate); border-color: var(--slate); color: #fff; }
.chip--lost .chip__no { text-decoration: line-through; text-decoration-thickness: 2px; }

.chip__mark {
  position: absolute; top: -8px; right: -8px; display: grid; place-items: center;
  width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 2px solid currentColor;
}
.chip--won .chip__mark { color: var(--c); }
.chip--lost .chip__mark { color: var(--slate); }

/* ---------- status ---------- */
.status__label { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15.5px; line-height: 1.25; }
.status__detail { margin-top: 3px; color: var(--muted); font-size: 14px; line-height: 1.35; }
.status__ring { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--ink); flex: none; }
.status--out .status__label { color: var(--muted); }
.status--gold .status__label { color: var(--gold-ink); }
.status--silver .status__label { color: var(--silver-ink); }
.status--bronze .status__label { color: var(--bronze-ink); }

/* ---------- empty / offline ---------- */
.empty { padding: 72px 24px; text-align: center; color: var(--muted); max-width: 560px; margin: 0 auto; }
.empty h2 { font: 700 30px/1.1 var(--font-display); color: var(--ink); margin-bottom: 10px; }
.banner { margin-bottom: 16px; padding: 11px 14px; border-radius: 8px; background: #fff3d6; color: #5f4500; font-size: 15px; }

/* ---------- buttons, inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid var(--ink);
  background: var(--ink); color: #fff; font-weight: 600; font-size: 15.5px; white-space: nowrap;
}
.btn:hover { background: #262d38; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn--quiet { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn--quiet:hover { background: #f3f5f8; }
.btn--danger { background: var(--surface); color: #9a1a1f; border-color: #e3b3b5; }
.btn--danger:hover { background: #fdf1f1; }
.btn--ghost { background: transparent; border-color: transparent; color: #fff; height: 36px; padding: 0 12px; }
.btn--ghost:hover { background: rgba(255, 255, 255, 0.12); }
.btn--text { background: transparent; border-color: transparent; color: var(--muted); height: 36px; padding: 0 8px; }
.btn--text:hover { background: #eef0f4; color: var(--ink); }
.btn--sm { height: 40px; padding: 0 20px; }
@media (pointer: coarse) { .btn--sm { height: 44px; } .btn--text { height: 44px; } }

.input { width: 100%; height: 44px; padding: 0 12px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; }
.field { display: block; }
.field > span { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; color: var(--muted); }

/* ---------- admin: quick actions and editor ---------- */
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.quick__wait { margin-top: 8px; color: var(--faint); font-size: 14px; }
.row__tools { margin-top: 8px; margin-left: -8px; }

.editor { grid-area: editor; margin: 16px -22px -20px; padding: 6px 22px 14px; background: #f7f8fa; border-top: 1px solid var(--line); }
.ed { display: grid; grid-template-columns: minmax(150px, 1fr) 150px auto auto; gap: 12px 24px; align-items: end; padding: 14px 0; border-bottom: 1px solid var(--line); }
.ed:last-of-type { border-bottom: 0; }
.ed__who strong { display: block; font-weight: 700; }
.ed__who span { display: block; color: var(--muted); font-size: 14px; line-height: 1.35; }
.ed .input { text-transform: uppercase; font-weight: 600; letter-spacing: 0.02em; }
.ed .seg button { height: 34px; padding: 0 12px; }
.ed .seg button[disabled] { opacity: 0.4; cursor: not-allowed; }
.ed .seg button[data-color='blue'][aria-pressed='true'] { background: var(--blue); }
.ed .seg button[data-color='red'][aria-pressed='true'] { background: var(--red); }
.ed__note { color: var(--muted); font-size: 13.5px; padding-top: 6px; }

/* ---------- login / import / dialogs ---------- */
.login { max-width: 400px; margin: 48px auto; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.login h2 { font: 700 30px/1.1 var(--font-display); margin-bottom: 6px; }
.login p { color: var(--muted); margin-bottom: 18px; }
.login .btn { width: 100%; margin-top: 14px; }
.form-error { margin-top: 12px; color: #9a1a1f; font-size: 14.5px; font-weight: 600; }

.panel { max-width: 760px; margin: 0 auto; }
.panel h2 { font: 700 32px/1.1 var(--font-display); margin-bottom: 8px; }
.panel > p { color: var(--muted); margin-bottom: 18px; }
.drop { position: relative; display: block; padding: 30px 20px; text-align: center; color: var(--muted); background: var(--surface); border: 1.5px dashed var(--line-strong); border-radius: 10px; cursor: pointer; }
.drop:hover, .drop.is-over, .drop:focus-within { border-color: var(--blue); background: var(--blue-wash); color: var(--blue-ink); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop strong { display: block; color: var(--ink); font-size: 17px; margin-bottom: 2px; }

.preview { margin-top: 20px; }
.preview h3 { font: 700 22px/1.1 var(--font-display); margin-bottom: 4px; }
.preview__sub { color: var(--muted); margin-bottom: 12px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { background: #f9fafb; color: var(--muted); font-weight: 600; font-size: 13.5px; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.notice { margin-top: 10px; padding: 11px 14px; border-radius: 8px; font-size: 14.5px; }
.notice--error { background: #fdecec; color: #8e1a1e; }
.notice--warn { background: #fff4d6; color: #5f4500; }
.notice ul { margin: 6px 0 0; padding-left: 18px; list-style: disc; }
.check { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; font-size: 15px; }
.check input { margin-top: 4px; width: 18px; height: 18px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 18px; }

dialog { width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 12px; background: var(--paper); color: var(--ink); box-shadow: 0 24px 70px rgba(10, 14, 20, 0.4); }
dialog::backdrop { background: rgba(10, 14, 20, 0.55); }
.dialog__body { padding: 26px; overflow-y: auto; max-height: calc(100vh - 32px); }
.dialog__body h2 { font: 700 28px/1.1 var(--font-display); margin-bottom: 8px; }
.dialog__body p { color: var(--muted); }
.dialog__close { float: right; margin: -8px -10px 0 12px; }
.divider { height: 1px; background: var(--line); margin: 24px 0; }
.danger-zone h3 { font: 700 20px/1.1 var(--font-display); margin-bottom: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 16px; max-width: min(580px, calc(100vw - 24px));
  padding: 12px 12px 12px 16px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 15px;
  box-shadow: 0 12px 34px rgba(10, 14, 20, 0.35);
}
.toast--error { background: #8e1a1e; }
.toast button { flex: none; height: 34px; padding: 0 12px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, 0.35); background: transparent; color: #fff; font-weight: 600; }
.toast button:hover { background: rgba(255, 255, 255, 0.14); }

.activity { margin-top: 34px; }
.activity h2 { font: 700 22px/1.1 var(--font-display); margin-bottom: 10px; }
.activity li { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.activity time { color: var(--muted); font-variant-numeric: tabular-nums; }
.is-busy { cursor: progress; }
.is-busy .btn, .is-busy .seg button { pointer-events: none; opacity: 0.7; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .sheet__head { display: none; }
  .row {
    grid-template-columns: minmax(0, 1fr) minmax(150px, 0.8fr);
    grid-template-areas: 'name status' 'cat status' 'trail trail' 'editor editor';
    row-gap: 4px; padding-left: 16px; padding-right: 16px; padding-bottom: 18px;
  }
  .trail { margin-top: 10px; }
  .editor { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
  .ed { grid-template-columns: 1fr 1fr; }
  .ed__who { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .page { padding: 18px 14px 80px; }
  .masthead__inner { padding: 16px 14px 14px; }
  .row { grid-template-columns: 1fr; grid-template-areas: 'name' 'cat' 'trail' 'status' 'editor'; }
  .row__status { margin-top: 12px; }
  .academy { grid-template-columns: minmax(0, 1fr) 20px; padding: 14px 16px; }
  .academy__meta, .academy__tally { grid-column: 1; justify-content: flex-start; }
  .academy svg { grid-column: 2; grid-row: 1 / span 3; }
  .chip { width: 62px; height: 54px; }
  .chip__no { font-size: 24px; }
  .trail { gap: 18px; }
  .step + .step::before { left: -18px; width: 18px; bottom: 26px; }
  .live__detail--long { display: none; }
  .toolbar .seg { width: 100%; }
  .toolbar .seg button { flex: 1 1 auto; padding: 0 8px; }
}

/* ---------- academy picker (draw import) ---------- */
.picker { margin-top: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.picker__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: #f9fafb; }
.picker__bar .search { flex: 1 1 220px; max-width: none; }
.picker__bar .search input { height: 40px; }
.picker__list { max-height: 320px; overflow-y: auto; }
.picker__list li[hidden] { display: none; }
.pick { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.picker__list li:last-child .pick { border-bottom: 0; }
.pick:hover { background: #f7f8fa; }
.pick input { flex: none; width: 20px; height: 20px; accent-color: var(--ink); }
.pick__name { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.pick__n { color: var(--muted); font-size: 14.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pick-summary { margin: 12px 0 14px; font-weight: 600; }
