/* setup-page.css - Tournament Setup page
 *
 * The current tournament and its next step, a new tournament, the saved tournaments and
 * the current tournament's match history. Uses the shared tokens in css/design-tokens.css.
 * Light only, desktop first.
 */

#setup.page.active { display: block; background: var(--nt-bg); padding: 0; font-family: var(--nt-sans); color: var(--nt-ink); }

.st-wrap { max-width: var(--nt-page-max); margin: 0 auto; padding: 28px 24px 40px; display: grid; gap: 20px; }
.st-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.st-title h2 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -.02em; color: var(--nt-ink); }
.st-title p { margin: 4px 0 0; color: var(--nt-muted); font-size: 14px; }
.st-eyebrow { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--nt-muted); }

.st-panel { background: var(--nt-surface); border: 1px solid var(--nt-line); border-radius: 12px; min-width: 0; }
.st-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 20px 12px; }
.st-panel-head h3 { margin: 0; font-size: 15px; font-weight: 700; color: var(--nt-ink); }
.st-panel-head h3 small { font-weight: 500; color: var(--nt-muted); font-size: 13px; margin-left: 6px; }
.st-head-l { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* ---- controls ---- */
.st-btn { height: 36px; border-radius: 8px; padding: 0 14px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid var(--nt-line-2); background: var(--nt-surface); color: var(--nt-ink-2); white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
.st-btn:hover { border-color: var(--nt-ink-2); }
.st-btn.st-primary { background: var(--nt-header); border-color: var(--nt-header); color: var(--nt-header-ink); }
.st-btn.st-primary:hover { background: var(--nt-accent); border-color: var(--nt-accent); color: #fff; }
.st-btn.st-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.st-btn.st-icon { width: 30px; padding: 0; justify-content: center; color: var(--nt-muted); }
.st-btn.st-icon:hover { color: var(--nt-danger); border-color: var(--nt-danger); }
.st-btn:focus { outline: none; }
.st-btn:focus-visible, .st-link:focus-visible, .st-seg button:focus-visible { outline: 2px solid var(--nt-accent); outline-offset: 2px; }
.st-link { border: 0; background: none; padding: 0; font: inherit; color: var(--nt-muted); font-size: 13px; font-weight: 500; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.st-link:hover { color: var(--nt-ink); }
.st-link.st-danger:hover { color: var(--nt-danger); }
.st-link[hidden] { display: none; }
.st-seg { display: inline-flex; border: 1px solid var(--nt-line-2); border-radius: 8px; overflow: hidden; background: var(--nt-surface); }
.st-seg[hidden] { display: none; }
.st-seg button { border: 0; background: transparent; padding: 6px 12px; font: inherit; font-weight: 600; font-size: 13px; color: var(--nt-ink-2); cursor: pointer; }
.st-seg button + button { border-left: 1px solid var(--nt-line-2); }
.st-seg button[aria-pressed="true"] { background: var(--nt-header); color: var(--nt-header-ink); }
.st-seg button:hover:not([aria-pressed="true"]) { background: var(--nt-surface-2); }
.st-seg .st-n { font-weight: 500; opacity: .7; margin-left: 4px; }

/* status: Setup grey, Active orange (live), Completed green */
.st-pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 99px; padding: 2px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--nt-inset); color: var(--nt-ink-2); }
.st-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-pill.st-active { background: var(--nt-accent-soft); color: #b2410f; }
.st-pill.st-completed { background: var(--nt-ok-soft); color: var(--nt-ok); }

/* ---- top row: the current tournament, and a new one ---- */
.st-top { display: grid; gap: 20px; } /* the current tournament, then a quiet New tournament */
/* The panel to act on is framed (.st-focus, set by syncSetupNew()): the current tournament while it is New
   or Active, the New tournament form once it is Completed or when nothing is loaded. The frame is a ring
   around the 1px border, so a panel never changes size. The dark button inside is the action. */
.st-panel.st-focus { border-color: var(--nt-card-line); box-shadow: 0 0 0 1px var(--nt-card-line); }
/* Completed, or nothing loaded: the form goes first (.st-new-first), always open, under a heading in
   place of the toggle (syncSetupNew()) */
.st-top.st-new-first .st-create { order: -1; }
.st-new-heading { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -.01em; color: var(--nt-ink); }
.st-new-heading[hidden], .st-new-toggle[hidden] { display: none; }
.st-bottom { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 20px; }
/* Tournaments and Match history end at the same line: both panels take the row's height,
   and each list fills its panel (still scrolling past 470px) */
.st-bottom > .st-panel { display: flex; flex-direction: column; }
.st-bottom .st-scroll, .st-bottom .st-hlist { flex: 1 1 auto; }

/* The loaded tournament's status band (currentTournamentStatusBand()): across the top of
   Setup's current tournament and Registration's next step, tinted by status */
.st-band { display: flex; align-items: baseline; gap: 10px; padding: 9px 22px; border-radius: 11px 11px 0 0; background: var(--nt-inset); color: var(--nt-ink-2); font-size: 14px; }
.st-band b { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.st-band b::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.st-band span { font-weight: 600; }
.st-band-active { background: var(--nt-accent-soft); color: #b2410f; }
.st-band-completed { background: var(--nt-ok-soft); color: var(--nt-ok); }
.st-current > .st-band { margin: -20px -22px 0; }
.st-current { padding: 20px 22px; display: grid; gap: 16px; align-content: start; }
.st-current-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.st-current-head > div { min-width: 0; }
.st-state { margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; font-weight: 600; color: var(--nt-ink-2); }
.st-current h3 { margin: 8px 0 2px; font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; color: var(--nt-ink); overflow-wrap: anywhere; }
.st-current .st-sub { color: var(--nt-ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.st-facts-line { margin: 0; font-size: 14px; color: var(--nt-ink-2); font-variant-numeric: tabular-nums; }
.st-progress { height: 6px; border-radius: 99px; background: var(--nt-inset); overflow: hidden; margin-top: -4px; }
.st-progress span { display: block; height: 100%; background: var(--nt-ink-2); border-radius: 99px; }
/* the next step sits open on the card, under a line: no box inside the card */
.st-next { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; padding: 16px 0 2px; border-top: 1px solid var(--nt-line); }
.st-next-what { display: grid; gap: 2px; flex: 1 1 240px; min-width: 0; }
.st-next-what b { font-size: 16px; font-weight: 700; color: var(--nt-ink); }
.st-hint { color: var(--nt-muted); font-size: 13px; }
.st-next-acts { display: flex; gap: 8px; flex-wrap: wrap; flex: none; }
.st-next .st-btn { height: 40px; padding: 0 18px; font-size: 15px; } /* both buttons alike; the dark one is the main step */
.st-quiet { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.st-empty { display: grid; gap: 6px; padding: 22px; place-content: center; text-align: center; min-height: 220px; color: var(--nt-muted); }
.st-empty b { color: var(--nt-ink); font-size: 17px; }
.st-empty.st-small { min-height: 140px; }

/* New tournament: a quiet bar (the toggle, and Import), the form under it when open. Collapsed it is
   just the bar, with no panel; with nothing loaded the form is open and Create is the dark button. */
.st-create { padding: 14px 22px 18px; }
.st-create.st-collapsed { background: none; border: 0; padding: 0 2px; }
.st-create-bar { display: flex; align-items: center; gap: 6px 18px; flex-wrap: wrap; }
.st-new-toggle { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 0; font: inherit; font-size: 15px; font-weight: 700; color: var(--nt-ink-2); cursor: pointer; }
.st-new-toggle:hover { color: var(--nt-ink); }
.st-new-toggle:focus { outline: none; }
.st-new-toggle:focus-visible { outline: 2px solid var(--nt-accent); outline-offset: 3px; border-radius: 4px; }
.st-plus { display: inline-grid; place-items: center; width: 22px; height: 22px; border: 1px solid var(--nt-line-2); border-radius: 6px; background: var(--nt-surface); font-size: 16px; line-height: 1; }
.st-plus::before { content: "+"; }
.st-new-toggle[aria-expanded="true"] .st-plus::before { content: "\2212"; }
.st-create-form { display: grid; grid-template-columns: minmax(0, 760px) auto; justify-content: start; align-items: end; gap: 12px 20px; padding-top: 16px; }
.st-create-form[hidden] { display: none; }
.st-create-row { display: grid; grid-template-columns: minmax(0, 1fr) 170px; gap: 10px; }
.st-create .st-btn.st-primary, .st-create-go .st-btn { height: 38px; }
.st-import-status { margin-top: 12px; }
.st-field { display: grid; gap: 6px; }
.st-field label { font-weight: 600; font-size: 13px; color: var(--nt-ink-2); }
.st-text { height: 38px; border: 1px solid var(--nt-line-2); border-radius: 8px; padding: 0 12px; background: var(--nt-surface); width: 100%; font: inherit; font-size: 14px; color: var(--nt-ink); }
.st-text:focus { outline: none; border-color: var(--nt-ink-2); box-shadow: 0 0 0 3px var(--nt-inset); }
.st-text.st-mono { font-family: var(--nt-mono); font-size: 13px; }
.st-or { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--nt-muted); font-size: 13px; }
.st-import-status { font-size: 13px; color: var(--nt-ink-2); background: var(--nt-surface-2); border: 1px solid var(--nt-line); border-radius: 8px; padding: 8px 12px; }
.st-import-status.alert-success { color: var(--nt-ok); background: var(--nt-ok-soft); border-color: transparent; }
.st-import-status.alert-warning { color: var(--nt-warn); background: var(--nt-warn-soft); border-color: transparent; }
.st-import-status.alert-error { color: var(--nt-danger); background: #fdecec; border-color: transparent; }

/* ---- tournaments: one scrolling table ---- */
.st-storage { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-size: 12px; color: var(--nt-muted); border: 0; background: none; cursor: pointer; padding: 4px 0; }
.st-storage:hover { color: var(--nt-ink); }
.st-meter { width: 56px; height: 6px; border-radius: 99px; background: var(--nt-inset); overflow: hidden; }
.st-meter span { display: block; height: 100%; min-width: 3px; background: var(--nt-ok); }
.st-storage.storage-yellow .st-meter span { background: var(--nt-ready); }
.st-storage.storage-amber .st-meter span { background: var(--nt-danger); }
.st-storage.storage-amber { color: var(--nt-danger); }

.st-scroll { max-height: 470px; overflow: auto; border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; }
.st-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.st-table th { position: sticky; top: 0; z-index: 1; background: var(--nt-surface); text-align: left; font-size: 12px; font-weight: 600; color: var(--nt-muted); padding: 6px 8px; border-bottom: 1px solid var(--nt-line); white-space: nowrap; }
.st-table td { padding: 10px 8px; border-bottom: 1px solid var(--nt-line); vertical-align: middle; color: var(--nt-ink); }
.st-table th:first-child, .st-table td:first-child { padding-left: 20px; }
.st-table th:last-child, .st-table td:last-child { padding-right: 20px; text-align: right; }
.st-table tr:last-child td { border-bottom: 0; }
.st-table tbody tr:hover, .st-table tr.st-loaded { background: var(--nt-surface-2); }
.st-table .st-name { width: 100%; }
.st-table .st-name b { font-weight: 600; }
.st-table .st-tag { margin-left: 8px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--nt-ink); border: 1px solid var(--nt-ink); border-radius: 4px; padding: 0 5px; white-space: nowrap; }
.st-table .st-date, .st-table .st-num { font-variant-numeric: tabular-nums; color: var(--nt-ink-2); white-space: nowrap; }
.st-table .st-num { text-align: right; }
.st-table .st-format { color: var(--nt-ink-2); white-space: nowrap; }
.st-table .st-faint { color: var(--nt-faint); }
.st-row-acts { display: inline-flex; gap: 6px; }
.st-alink { border: 0; background: none; padding: 0; font: inherit; font-size: 13px; font-weight: 600; color: var(--nt-ink-2); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--nt-line-2); white-space: nowrap; }
.st-alink:hover { color: var(--nt-ink); text-decoration-color: var(--nt-ink); }
.st-alink.st-add { color: var(--nt-muted); }

/* ---- match history: one entry per match ---- */
.st-hlist { max-height: 470px; overflow-y: auto; border-top: 1px solid var(--nt-line); border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; }
.st-hrow { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; padding: 10px 20px; }
.st-hrow + .st-hrow { border-top: 1px solid var(--nt-line); }
.st-hrow[data-mh-idx] { cursor: pointer; }
.st-hrow[data-mh-idx]:hover { background: var(--nt-surface-2); }
.st-hrow .nt-id { justify-self: start; } /* the tag itself: .nt-id in css/components.css */
.st-hrow .st-players { min-width: 0; color: var(--nt-ink); }
.st-hrow .st-players b { font-weight: 700; color: var(--nt-ok); }
.st-hrow .st-vs { color: var(--nt-faint); margin-inline: 4px; }
.st-hrow .st-score { font-family: var(--nt-mono); font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--nt-ink); }
.st-hrow .st-meta { grid-column: 2 / -1; font-size: 12px; color: var(--nt-muted); }
.st-hrow.st-wo, .st-hrow.st-wo .st-players, .st-hrow.st-wo .st-score { color: var(--nt-faint); }
.st-hrow.st-wo .st-players b { color: var(--nt-muted); }

@media (max-width: 1000px) {
  .st-bottom { grid-template-columns: 1fr; }
  .st-create-form { grid-template-columns: minmax(0, 1fr); align-items: stretch; }
}
