/*
 * Phone first. One column that never scrolls sideways at 320px, every tappable
 * thing at least 44px tall, and the send button pinned to the bottom edge —
 * this is filled in one-handed on the mat, not at a desk.
 */

:root {
  --bg:      #f4f5f7;
  --card:    #ffffff;
  --sunk:    #f7f8fa;
  --ink:     #101828;
  --muted:   #5b6475;
  --faint:   #8a93a3;
  --line:    #dfe3ea;
  --brand:   #b3121b;
  --brand-d: #8d0e15;
  --ok:      #0f7b3f;
  --ok-d:    #0b5c2e;
  --err:     #b3121b;
  --radius:  14px;
  --shadow:  0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:    #0f1115;
    --card:  #171a21;
    --sunk:  #10131a;
    --ink:   #e9edf4;
    --muted: #98a2b3;
    --faint: #6b7486;
    --line:  #2a2f3a;
    --brand: #e2323c;
    --brand-d: #c4252e;
    --ok:    #16a34a;
    --ok-d:  #12833c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  /* Room for the pinned send bar, so the last list row is never trapped under it. */
  padding-bottom: 0;
  transition: padding-bottom .15s ease;
}
body.has-bar { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

main, .top, .foot {
  max-width: 560px;
  margin-inline: auto;
  padding-inline: 16px;
}

/* ----------------------------------------------------------------- brand */

/*
 * The wordmark is a silhouette in the file's alpha channel, so it is painted
 * as a mask rather than placed as an <img>. One file then works on both
 * themes — it takes currentColor instead of baking in black or white.
 */
.brand { display: block; width: 132px; height: calc(132px * 0.14761); }
.brand i {
  display: block;
  width: 100%; height: 100%;
  background: currentColor;
  -webkit-mask: url("/img/marqethub-mask.png") no-repeat left center / contain;
          mask: url("/img/marqethub-mask.png") no-repeat left center / contain;
}
.brand-sm {
  display: inline-block;
  width: 74px; height: calc(74px * 0.14761);
  vertical-align: -2px;
}

/* ------------------------------------------------------------------ head */

.top {
  padding-block: 22px 14px;
  padding-top: max(22px, env(safe-area-inset-top));
  color: var(--muted);
}
.top h1 {
  margin: 16px 0 0;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.club {
  margin: 5px 0 0;
  font-weight: 700;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 12px;
}

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

.tabs {
  display: flex;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.tab {
  flex: 1;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.tab.on { background: var(--brand); color: #fff; }

/* ------------------------------------------------------------------ card */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

/* Two fields per line where they are short; one column on a narrow phone. */
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 380px) { .row2 { grid-template-columns: 1fr; gap: 0; } }

.field { margin-bottom: 14px; border: 0; padding: 0; min-width: 0; }
.field.stack { margin-bottom: 18px; }
.row2 .field { margin-bottom: 14px; }

label, legend, .label, .pairlabel {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  padding: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.pairlabel {
  margin: 4px 0 8px;
  color: var(--faint);
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.card > .pairlabel:first-of-type { border-top: 0; padding-top: 0; }

input, select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--sunk);
  color: var(--ink);
  font: inherit;
  /* 16px keeps iOS Safari from zooming in when a field takes focus. */
  font-size: 16px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input::placeholder { color: var(--faint); }

/*
 * A chevron, drawn in CSS. The native arrow is dropped so the control matches
 * the text inputs, but a select with no affordance at all reads as a dead
 * field — so the arrow is put back by hand. currentColor keeps it on-theme.
 */
select {
  appearance: none;
  padding-right: 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 19px) 50%, calc(100% - 13px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

input:focus, select:focus { outline: none; }
input:focus-visible, select:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/*
 * The club is shown so the coach can see what will be filed, not edited.
 *
 * A notch smaller than the inputs beside it: "BJJ Arena Sarajevo" wraps to two
 * lines at 16px in a half-width field, leaving this box taller than the Godište
 * box next to it. It is read-only text, not something being typed into, so the
 * 16px iOS zoom-guard that the real inputs need does not apply here.
 */
.locked {
  margin: 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.25;
}

.hint { margin: 6px 0 0; font-size: 13px; line-height: 1.4; color: var(--muted); }
.hint:empty { display: none; }
/*
 * The year hint sits between the Godište field and the Disciplina heading.
 * Pulled up against the field it describes and given real space beneath, so it
 * does not read as a caption for the section below it.
 */
#p-year-hint { margin: -4px 0 18px; }
.hint.top-hint { margin: 0 0 16px; }
.hint.warn { color: var(--brand); font-weight: 600; }
.err { margin: 10px 0 0; font-size: 14px; color: var(--err); font-weight: 600; }
.err:empty { display: none; }

/* ---------------------------------------------------------- disciplines */

.checks { display: grid; gap: 8px; margin-top: 10px; }
.check {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--sunk);
  cursor: pointer;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  font-size: 16px;
  color: var(--ink);
  margin: 0;
  transition: border-color .12s ease, background .12s ease;
}
.check input { width: 22px; height: 22px; min-height: 0; flex: none; accent-color: var(--brand); }
.check:has(input:checked) {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 7%, transparent);
}

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

.add, .send {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 11px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  transition: background .12s ease;
}
.add:active { background: var(--brand-d); }
.add[disabled], .send[disabled] { opacity: 0.55; cursor: default; }

/* ---------------------------------------------------------------- basket */

.basket { margin-bottom: 18px; }
.basket[hidden] { display: none; }
.basket h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 10px;
}
.count, .pill {
  background: var(--brand);
  color: #fff;
  border-radius: 99px;
  min-width: 22px;
  padding: 1px 8px;
  font-size: 12px;
  text-align: center;
}
.pill { background: rgba(255, 255, 255, .22); margin-left: 4px; }

#rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
#rows li {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 8px 10px 14px;
  box-shadow: var(--shadow);
}
/* A red edge so a row reads as one competitor at a glance. */
#rows li { border-left: 3px solid var(--brand); }
.who { flex: 1; min-width: 0; }
.who strong { display: block; font-size: 15px; line-height: 1.3; }
.who span { display: block; font-size: 13px; color: var(--muted); margin-top: 1px; }
.drop {
  flex: none;
  width: 44px; height: 44px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--faint);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.drop:active { background: var(--sunk); color: var(--brand); }

/* ------------------------------------------------------------- send bar */

.sendbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  z-index: 20;
}
.sendbar[hidden] { display: none; }
.sendbar > .send {
  max-width: 528px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ok);
}
.sendbar > .send:active { background: var(--ok-d); }

/* ------------------------------------------------------------------ done */

.done {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 18px;
  text-align: center;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.done[hidden] { display: none; }
.tick {
  width: 54px; height: 54px;
  margin: 0 auto 12px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  color: var(--ok);
  font-size: 26px;
  font-weight: 700;
}
.done h2 { margin: 0 0 6px; font-size: 20px; }
.done .hint { margin-bottom: 20px; }

/* ------------------------------------------------------------------ foot */

.foot {
  padding-block: 10px 28px;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
  color: var(--faint);
  font-size: 12px;
  text-align: center;
}
.foot p { margin: 0; }
.powered {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-wrap: wrap;
  color: var(--muted);
}
.powered strong { color: var(--ink); font-weight: 700; }

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

/* --------------------------------------------------------- svi prijavljeni */

.lista { margin-bottom: 20px; }
.lista-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.lista h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.count2 {
  background: var(--line);
  color: var(--muted);
  border-radius: 99px;
  min-width: 22px;
  padding: 1px 8px;
  font-size: 12px;
  text-align: center;
}
.linkbtn {
  border: 0;
  background: none;
  padding: 6px 2px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand);
  cursor: pointer;
}

#lista-filter { min-height: 44px; margin-bottom: 10px; }
#lista-filter[hidden] { display: none; }

#lista-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
#lista-rows:empty { display: none; }
#lista-rows li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-top: 1px solid var(--line);
  font-size: 15px;
}
#lista-rows li:first-child { border-top: 0; }
/* Zebra striping, because this is scanned for one name among many. */
#lista-rows li:nth-child(even) { background: var(--sunk); }
.l-who { flex: 1; min-width: 0; font-weight: 600; }
.l-cat {
  flex: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 3px 9px;
  white-space: nowrap;
}
#lista-rows li:nth-child(even) .l-cat { background: var(--card); }

/* ------------------------------------------------------ čestitka + konfete */

.slavlje {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 10, 14, .74);
  backdrop-filter: blur(3px);
  animation: slavlje-in .22s ease both;
}
.slavlje[hidden] { display: none; }

/* The canvas covers the whole overlay and must never eat taps meant for the
   button underneath it. */
.konfete { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.slavlje-box {
  position: relative;
  width: 100%;
  max-width: 340px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 26px 20px 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
  animation: box-pop .34s cubic-bezier(.2, .9, .3, 1.25) both;
}

.crest {
  width: 96px; height: 96px;
  object-fit: contain;
  margin: 0 auto 10px;
  display: block;
  animation: crest-in .5s cubic-bezier(.2, .9, .3, 1.3) .08s both;
}
/* The crest artwork is dark, so it needs a light plate to sit on in dark mode. */
@media (prefers-color-scheme: dark) {
  .crest { background: #f2f2f2; border-radius: 16px; padding: 8px; }
}

.slavlje-klub {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand);
}
.slavlje-box h2 { margin: 0 0 8px; font-size: 23px; letter-spacing: -0.02em; }
.slavlje-tekst { margin: 0 0 14px; font-size: 15px; color: var(--muted); }

.slavlje-imena {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  gap: 6px;
  max-height: 34vh;
  overflow-y: auto;
}
.slavlje-imena li {
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 600;
}
.slavlje-imena li span { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }

@keyframes slavlje-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes box-pop {
  from { opacity: 0; transform: translateY(14px) scale(.92); }
  to   { opacity: 1; transform: none; }
}
@keyframes crest-in {
  from { opacity: 0; transform: scale(.4) rotate(-12deg); }
  to   { opacity: 1; transform: none; }
}

/* Someone who asked for less motion still gets the message, just no theatre. */
@media (prefers-reduced-motion: reduce) {
  .slavlje, .slavlje-box, .crest { animation: none !important; }
  .konfete { display: none; }
}

/* ------------------------------------------------------------ uputstvo */

.kako {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.kako h2 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.kako ol { margin: 0; padding-left: 20px; display: grid; gap: 7px; }
.kako li { font-size: 14px; line-height: 1.45; }
.kako strong { font-weight: 700; }

.hint.under { text-align: center; margin-top: 8px; }

/* The one thing people miss: added is not sent. */
.nijeposlano {
  margin: 0 0 10px;
  padding: 9px 12px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--brand) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 28%, transparent);
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

/* Disciplines on a list row. Two of them means two separate entries. */
.l-who .l-jedna, .l-who .l-dvaput {
  display: block;
  font-weight: 600;
  font-size: 12px;
  margin-top: 2px;
}
.l-who .l-jedna { color: var(--faint); }
.l-who .l-dvaput { color: var(--brand); }
#lista-rows li.dvaput { box-shadow: inset 3px 0 0 var(--brand); }

/* --------------------------------------------------------- greške u poljima */

/*
 * The complaint sits directly under the control it belongs to, in the brand
 * red, with the control itself outlined. Between them there is no hunting for
 * which of five fields was the problem.
 */
.fielderr {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 600;
  color: var(--err);
}
.fielderr:empty { display: none; }

input.invalid, select.invalid {
  border-color: var(--err);
  background: color-mix(in srgb, var(--err) 5%, var(--sunk));
}
/* The discipline group is a container, not a control — outline the whole box. */
#p-disciplines.invalid {
  border: 1px solid var(--err);
  border-radius: 11px;
  padding: 8px;
  background: color-mix(in srgb, var(--err) 4%, transparent);
}

.obavezno {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
}
