/* =====================================================================
   SFPO 2026 grading portal — neobrutalist design system
   Thick ink borders, hard offset shadows, and controls that physically
   press into the page when you hit them.
   ===================================================================== */

:root {
  --ink:        #10131a;
  --paper:      #fffbef;
  --card:       #ffffff;
  --muted:      #5b6472;
  --line:       #10131a;

  --cyan:       #5bc8f5;
  --lime:       #7be495;
  --amber:      #ffd84d;
  --red:        #ff6b6b;
  --violet:     #b98cff;
  --slate:      #e8eaef;
  /* Second place. --slate is the table's own header and border colour, so
     using it left the podium reading first, nothing, third. */
  --silver:     #c3cbd8;

  /* Text on a bright accent fill. The accents are the same in both themes,
     so their foreground has to be too: inheriting --ink put near-white
     text on yellow, lime, cyan and violet the moment the theme flipped,
     which measured between 1.3 and 2.4 to 1 — buttons you could not read. */
  --on-accent:  #10131a;

  --shadow:     6px 6px 0 var(--line);
  --shadow-sm:  4px 4px 0 var(--line);
  --shadow-xs:  2px 2px 0 var(--line);
  --radius:     14px;
  --radius-sm:  10px;
  --bw:         3px;

  --dot: rgba(16, 19, 26, .14);
  --font: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --ink:    #f4f6fb;
  --paper:  #14161d;
  --card:   #1c1f28;
  --muted:  #9aa4b5;
  --line:   #000000;
  --slate:  #2a2e3a;
  --silver: #8d97ab;
  --dot:    rgba(255, 255, 255, .10);
  --shadow:    6px 6px 0 #000;
  --shadow-sm: 4px 4px 0 #000;
  --shadow-xs: 2px 2px 0 #000;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(var(--dot) 1.4px, transparent 1.4px);
  background-size: 22px 22px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 800; letter-spacing: -.02em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- primitives ------------------------------------------- */

.card {
  background: var(--card);
  border: var(--bw) solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.btn {
  --btn-bg: var(--card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  background: var(--btn-bg);
  color: var(--ink);
  border: var(--bw) solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .06s ease, background .12s ease;
  user-select: none;
}
.btn:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--line); }
.btn:active:not(:disabled),
.btn.is-pressed        { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--line); }
.btn:disabled          { opacity: .45; cursor: not-allowed; box-shadow: var(--shadow-xs); }
.btn:focus-visible     { outline: 3px solid var(--violet); outline-offset: 3px; }

.btn--primary { --btn-bg: var(--cyan);   color: var(--on-accent); }
.btn--go      { --btn-bg: var(--lime);   color: var(--on-accent); }
.btn--warn    { --btn-bg: var(--amber);  color: var(--on-accent); }
.btn--danger  { --btn-bg: var(--red);    color: var(--on-accent); }
.btn--ghost   { box-shadow: var(--shadow-xs); padding: 7px 12px; font-size: 13px; }
.btn--block   { width: 100%; }

.input, .textarea, .select {
  width: 100%;
  padding: 12px 14px;
  background: var(--card);
  border: var(--bw) solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: inset 3px 3px 0 rgba(16, 19, 26, .07);
  font-weight: 600;
}
[data-theme="dark"] .input,
[data-theme="dark"] .textarea,
[data-theme="dark"] .select { box-shadow: inset 3px 3px 0 rgba(0, 0, 0, .35); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--line);
  box-shadow: var(--shadow-xs), inset 0 0 0 3px var(--cyan);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 2px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: var(--card);
  white-space: nowrap;
}
.tag--a { background: var(--cyan);  color: var(--on-accent); }
.tag--b { background: var(--lime);  color: var(--on-accent); }
.tag--flag { background: var(--amber); color: var(--on-accent); }
.tag--live { background: var(--lime); color: var(--on-accent); }

.muted { color: var(--muted); font-weight: 600; }

/* Class selectors below beat the user-agent [hidden] rule, so restate it. */
[hidden] { display: none !important; }
.mono  { font-family: var(--mono); }
.hidden { display: none !important; }

/* ---------- app shell -------------------------------------------- */

.app { min-height: 100%; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 18px;
  background: var(--ink);
  color: var(--paper);
  border-bottom: var(--bw) solid var(--line);
}
[data-theme="dark"] .topbar { background: #0a0c11; color: var(--ink); }

.topbar__brand { display: flex; align-items: baseline; gap: 10px; margin-right: auto; }
.topbar__brand b { font-size: 17px; letter-spacing: -.02em; }
.topbar__brand span { font-size: 12px; opacity: .7; font-weight: 600; }

/* The grader identity plate. Set once, stays put while you grade. */
.whoami {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 6px 5px 13px;
  background: var(--cyan);
  color: #10131a;
  border: 2px solid var(--paper);
  border-radius: 999px;
  font-weight: 800;
}
.whoami__label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; opacity: .72; }
.whoami__name  { font-size: 14px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whoami__edit {
  border: 2px solid #10131a; background: #fff; border-radius: 999px;
  padding: 2px 9px; font-size: 11px; font-weight: 800; cursor: pointer;
}
.whoami__edit:active { transform: translate(1px, 1px); }

.presence { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--paper); background: var(--muted); }
.dot--live { background: var(--lime); animation: pulse 2s ease-in-out infinite; }
.dot--demo { background: var(--amber); }
.dot--down { background: var(--red); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.icon-btn {
  background: transparent; color: inherit; border: 2px solid currentColor;
  border-radius: 9px; padding: 5px 9px; cursor: pointer; font-weight: 800; font-size: 13px;
}
.icon-btn:active { transform: translate(1px, 1px); }

/* ---------- two-column layout ------------------------------------ */

.layout {
  flex: 1;
  display: grid;
  /* The entry column carries a 20-box grid, so it earns more room than it
     had; the side panel stays the wider of the two. */
  grid-template-columns: minmax(470px, 545px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  align-items: start;
}
@media (max-width: 1180px) { .layout { grid-template-columns: 1fr; } }

.console { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 76px; }
@media (max-width: 1180px) { .console { position: static; } }

.panel { padding: 18px; }
.panel__head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px; padding-bottom: 12px;
  border-bottom: var(--bw) dashed var(--line);
}
.panel__head h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; }
.panel__head .spacer { margin-left: auto; }

.step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; flex: none;
  background: var(--amber); color: var(--on-accent);
  border: 2px solid var(--line); border-radius: 8px;
  font-size: 13px; font-weight: 800;
}

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.field__label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.field__hint  { font-size: 12px; font-weight: 600; color: var(--muted); }
.field__hint--error { color: #c0392b; }
[data-theme="dark"] .field__hint--error { color: #ff9b9b; }

/* ---------- contestant id ---------------------------------------- */

.id-input {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 14px 16px;
}

/* ---------- problem chips ---------------------------------------- */

.chip-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip-row + .chip-row { margin-top: 9px; }
.chip:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--line); }

/* ---------- score pad -------------------------------------------- */

.score:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--line); }

/* ---------- banners ---------------------------------------------- */

.banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 13px; margin-bottom: 13px;
  border: var(--bw) solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  font-size: 13px; font-weight: 700;
}
.banner--warn  { background: var(--amber); color: #10131a; }
.banner--info  { background: var(--cyan);  color: #10131a; }
.banner--ok    { background: var(--lime);  color: #10131a; }
.banner--error { background: var(--red);   color: #10131a; }
.banner b { display: block; }
/* A banner that offers an action keeps it on the right, centred on the text. */
.banner .btn { margin-left: auto; align-self: center; flex-shrink: 0; }
.banner span { font-weight: 600; }

/* Tinted from whatever it sits on rather than a fixed grey: inside a lime
   Save button on a dark theme, a --slate chip was dark ink on dark. */
.kbd {
  display: inline-block; padding: 1px 6px; margin: 0 1px;
  border: 2px solid var(--line); border-radius: 6px;
  background: color-mix(in srgb, currentColor 14%, transparent);
  color: inherit;
  font-family: var(--mono); font-size: 11px; font-weight: 700;
}

/* ---------- suggestions ------------------------------------------ */

.suggest { display: flex; flex-direction: column; gap: 8px; }
.suggest__item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 10px 12px; text-align: left;
  background: var(--card);
  border: var(--bw) solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: transform .06s ease, box-shadow .06s ease;
}
.suggest__item:hover  { transform: translate(-1px, -1px); box-shadow: var(--shadow-sm); }
.suggest__item:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--line); }
.suggest__id { font-family: var(--mono); font-size: 16px; font-weight: 800; min-width: 62px; }
.suggest__why { font-size: 12px; font-weight: 600; color: var(--muted); }

/* ---------- tabs -------------------------------------------------- */

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
  padding: 9px 15px; font-weight: 800; font-size: 13px;
  background: var(--card);
  border: var(--bw) solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: transform .06s ease, box-shadow .06s ease, background .12s ease;
}
.tab:hover  { transform: translate(-1px, -1px); box-shadow: var(--shadow-sm); }
.tab:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--line); }
.tab[aria-selected="true"] {
  background: var(--violet);
  color: var(--on-accent);
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--line);
}

/* ---------- matrix ------------------------------------------------ */

.matrix__bar {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 13px;
  border-bottom: var(--bw) solid var(--line);
  background: var(--slate);
  font-weight: 800; font-size: 13px;
}
.matrix__bar .spacer { margin-left: auto; }

.legend { display: flex; flex-wrap: wrap; gap: 13px; font-size: 12px; font-weight: 700; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i {
  width: 14px; height: 14px; border: 2px solid var(--line); border-radius: 4px; display: inline-block;
}

/* ---------- tables ------------------------------------------------ */

.table-wrap { overflow-x: auto; border: var(--bw) solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  position: sticky; top: 0;
  background: var(--slate);
  padding: 10px 12px; text-align: left;
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  border-bottom: var(--bw) solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 9px 12px; border-bottom: 2px solid var(--slate); font-weight: 600; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: color-mix(in srgb, var(--cyan) 16%, transparent); }
.rank { font-family: var(--mono); font-weight: 800; width: 44px; }
.rank--1, .rank--2, .rank--3 { color: var(--on-accent); }
.rank--1 { background: var(--amber); }
.rank--2 { background: var(--silver); }
.rank--3 { background: color-mix(in srgb, var(--amber) 45%, var(--red)); }
.num { text-align: right; font-family: var(--mono); font-weight: 800; }


/* ---------- setup / drop zone ------------------------------------- */

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 13px; }

/* ---------- disqualification -------------------------------------- */

.table-wrap--dq { margin-top: 8px; border-color: var(--red); }
.table-wrap--dq tbody td { color: var(--muted); }
.table-wrap--dq tbody td:nth-child(2) { text-decoration: line-through; }
.table-wrap--dq .rank { background: var(--red); color: #10131a; font-size: 11px; }

.dq-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 13px;
  border: 2px solid var(--line); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--red) 13%, var(--card));
  box-shadow: var(--shadow-xs);
}
.dq-row + .dq-row { margin-top: 8px; }
.dq-row > div { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.dq-row b { font-size: 14px; }
.dq-row .muted { font-size: 12px; }

/* ---------- danger zone ------------------------------------------- */

.danger {
  border: var(--bw) solid var(--red);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--red) 12%, var(--card));
  padding: 15px;
  box-shadow: var(--shadow-xs);
}
.danger__counts { font-size: 13px; font-weight: 700; margin-bottom: 11px; }
.danger__row { display: flex; gap: 9px; flex-wrap: wrap; }
.danger__row .input { flex: 1; min-width: 190px; }

/* ---------- gate -------------------------------------------------- */

.gate {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center; padding: 22px;
  background: var(--paper);
  background-image: radial-gradient(var(--dot) 1.4px, transparent 1.4px);
  background-size: 22px 22px;
}
.gate__card { width: min(460px, 100%); padding: 30px; }
.gate__title { font-size: 27px; margin-bottom: 5px; }
.gate__sub { color: var(--muted); font-weight: 600; margin-bottom: 22px; font-size: 14px; }

/* ---------- toasts ------------------------------------------------ */

.toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 80;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border: var(--bw) solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  background: var(--lime); color: #10131a; font-weight: 800;
  animation: toast-in .18s cubic-bezier(.2, .9, .3, 1.4);
}
.toast--error { background: var(--red); }
.toast--info  { background: var(--cyan); }
@keyframes toast-in { from { transform: translate(0, 14px); opacity: 0; } }

.empty { padding: 34px 18px; text-align: center; color: var(--muted); font-weight: 700; }

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

/* =====================================================================
   Answer-entry additions
   ===================================================================== */

.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }

.subhead {
  font-size: 12px; font-weight: 800; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 10px;
}

/* ---------- the answer grid --------------------------------------- */
/* Kept tight and in reading order so a whole sheet is one glance and
   one run of the fingers — the boxes are the job, everything else is
   chrome around them. */
.answers { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.answers--guts { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 520px) { .answers { grid-template-columns: repeat(4, 1fr); } }

.ans { position: relative; }
.ans__no {
  position: absolute; top: 3px; left: 6px;
  font-family: var(--mono); font-size: 10px; font-weight: 800;
  color: var(--muted); pointer-events: none;
}
.ans input {
  width: 100%; padding: 18px 8px 7px;
  font-family: var(--mono); font-size: 17px; font-weight: 700; text-align: center;
  background: var(--card);
  border: var(--bw) solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  transition: box-shadow .1s ease, background .12s ease;
  -moz-appearance: textfield;
}
.ans input::-webkit-outer-spin-button,
.ans input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ans input:focus {
  outline: none;
  box-shadow: var(--shadow-sm), inset 0 0 0 3px var(--cyan);
}
.ans--filled input { background: color-mix(in srgb, var(--cyan) 15%, var(--card)); }
.ans--bad input { box-shadow: var(--shadow-xs), inset 0 0 0 3px var(--red); }
.ans--correct input { background: color-mix(in srgb, var(--lime) 42%, var(--card)); }
.ans--wrong input   { background: color-mix(in srgb, var(--red) 30%, var(--card)); }
.ans--unkeyed input { background: color-mix(in srgb, var(--amber) 30%, var(--card)); }

/* ---------- guts key sets ------------------------------------------ */
.keyset { border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 11px; }
.keyset + .keyset { margin-top: 10px; }
.keyset__head { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.keyset__head b { font-size: 13px; }
.keyset__points { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.keyset__points input { width: 68px; padding: 6px 8px; text-align: center; }
.keyset__points span { font-size: 11px; font-weight: 800; text-transform: uppercase; color: var(--muted); }

/* ---------- clock -------------------------------------------------- */
.clockchip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px; border: 2px solid var(--paper); border-radius: 999px;
  background: var(--lime); color: #10131a; font-weight: 800;
}
.clockchip--frozen { background: var(--violet); color: var(--on-accent); }
.clockchip--stopped { background: var(--slate); color: var(--muted); }
.clockchip__label { font-size: 10px; letter-spacing: .1em; opacity: .7; }
.clockchip__time { font-size: 15px; font-variant-numeric: tabular-nums; }

.clockbig {
  font-size: clamp(48px, 11vw, 84px); font-weight: 800; letter-spacing: -.03em;
  text-align: center; padding: 14px 0 18px; font-variant-numeric: tabular-nums;
}

/* ---------- per-contestant progress -------------------------------- */
/* Fills the screen it is given. A fixed height left a third of a big
   monitor empty while still needing a scroll on a laptop. */
.roster {
  max-height: max(260px, calc(100vh - 300px));
  overflow: auto;
  display: flex; flex-direction: column; gap: 6px;
  overscroll-behavior: contain;
}
.rosterteam {
  border: 2px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 10px; background: var(--card);
}
.rosterteam--dq { border-color: var(--red); opacity: .7; }
.rosterteam__head {
  display: flex; align-items: center; gap: 9px; margin-bottom: 7px;
  font-family: var(--mono); font-size: 11px; font-weight: 800; color: var(--muted);
}
.rosterteam__name { color: var(--ink); font-family: var(--font); }
.rosterteam__head .spacer { margin-left: auto; }
.people { display: flex; flex-wrap: wrap; gap: 6px; }
.person {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 9px; border: 2px solid var(--line); border-radius: 999px;
  background: var(--slate); font-size: 12px; font-weight: 700; cursor: pointer;
  font-family: var(--mono);
}
.person:hover { transform: translate(-1px, -1px); }
.person:active { transform: translate(1px, 1px); }
.person--done, .person--partial, .person--claimed { color: var(--on-accent); }
.person--done { background: var(--lime); }
.person--partial { background: var(--amber); }
.person--claimed { background: var(--violet); }
.person__score { font-weight: 800; }

.setpips { display: flex; gap: 3px; }
.setpip {
  width: 15px; height: 15px; border: 2px solid var(--line); border-radius: 4px;
  background: var(--slate); font-size: 9px; display: grid; place-items: center;
  font-family: var(--mono); font-weight: 800;
}
.setpip--done, .setpip--partial, .setpip--claimed { color: var(--on-accent); }
.setpip--done { background: var(--lime); }
.setpip--partial { background: var(--amber); }
.setpip--claimed { background: var(--violet); }

/* ---------- leaderboard pager -------------------------------------- */
.pager { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.pager .btn { min-width: 44px; padding: 7px 12px; font-size: 15px; }
.pager__where {
  font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--muted);
}

/* A quiet per-row copy, so reading the top ten out one at a time does not
   mean pasting all ten and picking. */
.rowcopy {
  border: 2px solid var(--line); border-radius: 7px;
  background: var(--card); color: inherit;
  padding: 2px 9px; font-size: 11px; font-weight: 800;
  font-family: var(--font); letter-spacing: .04em; text-transform: uppercase;
  cursor: pointer; opacity: .55; transition: opacity .12s ease;
}
tbody tr:hover .rowcopy, .rowcopy:focus-visible { opacity: 1; }
.rowcopy:active { transform: translate(1px, 1px); }
.person--out { background: var(--red); text-decoration: line-through; }
