/* The live group draw (docs/decisions/0065-group-draw.md): a floodlit pitch at night, for a projector.
   Colors are the marketing world's variables (.mk-world in marketing.css); floodlight marks only the
   next spot and the main action. Numerals and team names are Barlow Condensed. */
.draw-world {
  margin: 0;
  background-color: var(--stand);
  background-image: repeating-linear-gradient(90deg, color-mix(in oklab, var(--field-b) 11%, transparent) 0 10rem, transparent 10rem 20rem);
  color: var(--chalk);
  caret-color: var(--flood);
}
.draw-world ::selection {
  background: var(--flood);
  color: var(--ink);
}
.draw-world :focus-visible {
  outline: 3px solid var(--chalk);
  outline-offset: 3px;
}

/* Landscape screens fit everything in one view; anything else scrolls with the dock in reach. */
.draw-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 100dvh;
}
@media (min-width: 64rem) and (min-height: 36rem) {
  .draw-screen { height: 100dvh; }
}

.draw-head {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 1.5vw, 1.5rem);
  padding: clamp(0.75rem, 2vh, 1.5rem) clamp(1rem, 2.5vw, 3rem);
  background: var(--stand);
}
.draw-logo {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: clamp(3rem, 8vh, 5.5rem);
  height: clamp(3rem, 8vh, 5.5rem);
  padding: 0.35rem;
  border-radius: 0.75rem;
  background: var(--color-white, #fff);
}
.draw-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.draw-title {
  min-width: 0;
  flex: 1;
}
.draw-title h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 6vh, 4rem);
  font-weight: 800;
  line-height: 0.95;
  text-transform: uppercase;
}
.draw-title p {
  margin: 0.2rem 0 0;
  color: var(--chalk-soft);
  font-size: clamp(0.875rem, 2.1vh, 1.25rem);
  font-weight: 600;
}
.draw-progress {
  margin: 0;
  flex-shrink: 0;
  color: var(--chalk-soft);
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 5vh, 3.25rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 1;
}
.draw-progress b {
  color: var(--chalk);
  font-weight: 800;
}
.draw-head-actions {
  display: flex;
  flex-shrink: 0;
  gap: 0.25rem;
}
.draw-icon-button {
  display: inline-flex;
  width: 2.75rem;
  height: 2.75rem;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  color: var(--chalk-soft);
  transition: background-color 160ms ease, color 160ms ease;
}
.draw-icon-button:hover {
  background: rgb(243 242 234 / 0.1);
  color: var(--chalk);
}

/* The board: every group and spot, sized by the room they have. */
.draw-pitch {
  min-height: 0;
  padding: clamp(0.5rem, 1.5vh, 1.25rem) clamp(1rem, 2.5vw, 3rem) clamp(1rem, 2.5vh, 2rem);
}
.draw-board {
  display: grid;
  grid-template-columns: repeat(var(--draw-cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--draw-rows), minmax(0, 1fr));
  gap: clamp(1rem, 3vh, 2.25rem) clamp(1.25rem, 3vw, 3.5rem);
  height: 100%;
}
.draw-group {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}
.draw-group h2 {
  margin: 0;
  padding-bottom: 0.2em;
  overflow: hidden;
  border-bottom: 3px solid var(--chalk);
  font-family: var(--font-display);
  font-size: clamp(1.25rem, min(calc(5.5vh / var(--draw-rows) + 1.25vh), 4.6vh), 3.25rem);
  font-weight: 800;
  line-height: 1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}
.draw-group ol {
  display: grid;
  grid-template-rows: repeat(var(--draw-spots), minmax(0, 1fr));
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.draw-slot {
  position: relative;
  min-height: 0;
  border-bottom: 1px solid var(--field-line-faint);
  container-type: size;
}
.draw-slot-row {
  --draw-u: clamp(0.875rem, min(56cqh, 10.5cqw), 5rem);
  display: flex;
  height: 100%;
  align-items: center;
  gap: calc(var(--draw-u) * 0.45);
  padding-inline: calc(var(--draw-u) * 0.25);
  font-family: var(--font-display);
  font-size: var(--draw-u);
  font-weight: 800;
  line-height: 1;
}
.draw-slot-number {
  width: 1.1em;
  flex-shrink: 0;
  color: rgb(243 242 234 / 0.42);
  font-variant-numeric: tabular-nums lining-nums;
  text-align: right;
}
.draw-team {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: calc(var(--draw-u) * 0.4);
}
/* A long name shrinks to fit its spot: on one line if it can, on two if the row is tall enough to
   keep it bigger that way, and never wider than its longest word allows. The markup sets --draw-len
   (its length) and --draw-word (its longest word's). */
.draw-team-name {
  --draw-room: calc(100cqw - var(--draw-u) * 3.5);
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  font-size: max(0.8rem, min(var(--draw-u), calc(var(--draw-room) / (var(--draw-word) * 0.49)), max(calc(var(--draw-room) / (var(--draw-len) * 0.47)), min(44cqh, calc(var(--draw-room) / (var(--draw-len) * 0.29))))));
  line-height: 0.98;
  text-transform: uppercase;
  text-wrap: balance;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.draw-crest {
  width: calc(var(--draw-u) * 1.05);
  height: calc(var(--draw-u) * 1.05);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: calc(var(--draw-u) * 0.36);
}
/* A thin edge, so a black or white crest tile holds its shape on any ground. */
.draw-crest,
.draw-option-crest,
.draw-stage-crest > :not(.draw-logo) {
  outline: 1px solid rgb(243 242 234 / 0.32);
  outline-offset: -1px;
}

/* The next spot, under the floodlight. */
.draw-slot[data-next] {
  border-bottom: 3px solid var(--flood);
  background: var(--flood);
}
.draw-slot[data-next] .draw-slot-number { color: var(--ink); }

.draw-slot[data-arriving] .draw-team { visibility: hidden; }
/* While a team is on its way, the light waits: the next spot is lit once it has landed. */
.draw-board:has([data-arriving]) .draw-slot[data-next] {
  border-bottom: 1px solid var(--field-line-faint);
  background: none;
  animation: none;
}
.draw-board:has([data-arriving]) .draw-slot[data-next] .draw-slot-number { color: rgb(243 242 234 / 0.42); }
.draw-slot[data-landed]::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--flood);
  content: "";
  opacity: 0;
}
@media (prefers-reduced-motion: no-preference) {
  .draw-slot[data-next] { animation: draw-floodlight 1.8s ease-in-out infinite alternate; }
  .draw-slot[data-landed]::before { animation: draw-landed 1.4s cubic-bezier(0.16, 1, 0.3, 1) both; }
}
@keyframes draw-floodlight {
  from { background-color: color-mix(in oklab, var(--flood) 80%, var(--stand)); }
  to { background-color: var(--flood); }
}
@keyframes draw-landed {
  from { opacity: 0.9; }
  to { opacity: 0; }
}

/* The dock: what's next, the team input, and the way back. */
.draw-dock {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 34rem) minmax(0, 1fr);
  align-items: center;
  gap: clamp(0.75rem, 2vw, 2.5rem);
  padding: clamp(0.75rem, 1.8vh, 1.25rem) clamp(1rem, 2.5vw, 3rem);
  border-top: 3px solid var(--field-line-faint);
  background: var(--stand-raised);
}
.draw-next p { margin: 0; }
.draw-next-spot {
  color: var(--flood);
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 5vh, 3.25rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 1;
  text-transform: uppercase;
}
.draw-next-spot--done { color: var(--chalk); }
.draw-next-note {
  color: var(--chalk);
  font-size: 1rem;
  font-weight: 600;
}
.draw-entry {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.draw-entry > .draw-primary { align-self: center; }
.draw-form {
  display: flex;
  gap: 0.5rem;
}
.draw-combo {
  position: relative;
  min-width: 0;
  flex: 1;
}
.draw-input {
  width: 100%;
  height: 3rem;
  padding: 0 1rem;
  border: 0;
  border-radius: 0.5rem;
  background: var(--stand);
  box-shadow: inset 0 0 0 2px var(--field-line);
  color: var(--chalk);
  caret-color: var(--flood);
  font-size: 1.125rem;
}
.draw-input:focus-visible {
  box-shadow: inset 0 0 0 2px var(--chalk);
  outline: 0;
}
.draw-input::placeholder { color: var(--chalk-soft); }
.draw-primary {
  display: inline-flex;
  height: 3rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  padding: 0 1.5rem;
  border-radius: 0.5rem;
  background: var(--flood);
  box-shadow: 0 10px 24px -12px rgb(0 0 0 / 0.6);
  color: var(--ink);
  font-weight: 700;
  transition: background-color 160ms ease, transform 160ms ease;
}
.draw-primary:hover { background: var(--flood-hover); }
.draw-primary:active { transform: translateY(1px); }

/* The teams list opens upwards, away from the bottom of the screen. */
.draw-options {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.5rem);
  left: 0;
  z-index: 30;
  max-height: min(22rem, 50vh);
  margin: 0;
  padding: 0.25rem;
  overflow-y: auto;
  border-radius: 0.5rem;
  background: var(--stand);
  box-shadow: 0 -16px 40px -12px rgb(0 0 0 / 0.6), inset 0 0 0 2px var(--field-line);
  color: var(--chalk);
  list-style: none;
  scrollbar-color: var(--field-line) transparent;
}
.draw-option {
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  gap: 0.625rem;
  padding: 0.25rem 0.625rem;
  border-radius: 0.3rem;
  font-weight: 600;
  cursor: pointer;
}
.draw-option[hidden] { display: none; }
.draw-option[aria-selected="true"] {
  background: var(--chalk);
  color: var(--ink);
}
.draw-option-crest {
  width: 1.75rem;
  height: 1.75rem;
}
.draw-option[aria-selected="true"] .draw-option-crest { outline-color: rgb(7 23 14 / 0.32); }
.draw-message {
  margin: 0;
  color: #ffc9bd;
  font-size: 0.9375rem;
  font-weight: 600;
}
.draw-message:not(:empty) { margin-top: 0.375rem; }

.draw-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem 0.5rem;
  min-width: 0;
}
.draw-tool {
  display: inline-flex;
  min-height: 2.75rem;
  max-width: 100%;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.75rem;
  border-radius: 0.5rem;
  box-shadow: inset 0 0 0 2px var(--field-line);
  color: var(--chalk);
  font-size: 0.9375rem;
  font-weight: 600;
  transition: background-color 160ms ease, box-shadow 160ms ease;
}
.draw-tool:hover {
  background: rgb(243 242 234 / 0.06);
  box-shadow: inset 0 0 0 2px var(--chalk);
}
.draw-tool-text {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.draw-tool--quiet {
  box-shadow: none;
  color: var(--chalk-soft);
}
.draw-tool--quiet:hover { box-shadow: none; }

/* The reveal: a name in the centre circle. */
.draw-stage {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.draw-stage[hidden] { display: none; }
.draw-stage {
  --draw-ring: min(82vh, 86vw);
}
/* Rotated so the line starts drawing at the top. */
.draw-stage-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--draw-ring);
  height: var(--draw-ring);
  transform: translate(-50%, -50%) rotate(-90deg);
}
.draw-stage-ring circle {
  fill: none;
  stroke: var(--chalk);
  stroke-width: 3;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}
/* The halfway line, from each touchline to the circle, so it never crosses the name. */
.draw-stage-line {
  position: absolute;
  top: calc(50% - 1.5px);
  height: 3px;
  width: calc(50% - var(--draw-ring) / 2);
  background: var(--chalk);
}
.draw-stage-line--left { left: 0; transform-origin: left; }
.draw-stage-line--right { right: 0; transform-origin: right; }
.draw-stage-body {
  position: relative;
  display: flex;
  max-width: min(66vh, 68vw);
  flex-direction: column;
  align-items: center;
  gap: clamp(0.75rem, 2.5vh, 1.75rem);
  text-align: center;
}
.draw-stage-crest > * {
  width: min(clamp(4.5rem, 15vh, 8.5rem), 18vw);
  height: min(clamp(4.5rem, 15vh, 8.5rem), 18vw);
  border-radius: 0.75rem;
  font-size: calc(min(clamp(4.5rem, 15vh, 8.5rem), 18vw) * 0.34);
}
.draw-stage-crest:empty { display: none; }
.draw-stage-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: min(clamp(2.75rem, 11vh, 6rem), 11vw);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 0.92;
  text-transform: uppercase;
  text-wrap: balance;
  transform-origin: center;
}
.draw-stage-spot {
  margin: 0;
  color: var(--flood);
  font-family: var(--font-display);
  font-size: min(clamp(1.5rem, 5vh, 3rem), 6vw);
  font-weight: 800;
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 1;
  text-transform: uppercase;
  text-wrap: balance;
}

/* The close names the league and tournament, one per line; floodlight stays on the action. */
.draw-stage[data-finale] .draw-stage-spot {
  color: var(--chalk-soft);
  white-space: pre-line;
}

/* Below a landscape screen: the board stacks and scrolls, the dock stacks too. */
@media (max-width: 63.999rem), (max-height: 35.999rem) {
  .draw-board {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
    grid-template-rows: none;
    height: auto;
  }
  .draw-group ol { grid-template-rows: none; grid-auto-rows: 3rem; }
  .draw-group h2 { font-size: 1.75rem; }
  .draw-dock { grid-template-columns: minmax(0, 1fr); }
  .draw-tools { justify-content: flex-start; }
  .draw-progress { font-size: 1.5rem; }
  .draw-head { gap: 0.5rem; }
  .draw-logo { width: 2.75rem; height: 2.75rem; padding: 0.25rem; }
  .draw-title h1 { font-size: 1.625rem; }
  .draw-title p { overflow-wrap: anywhere; font-size: 0.8125rem; }
  .draw-head-actions { gap: 0; }
  .draw-tool { white-space: nowrap; }
}
