/* ==========================================================================
   GRIDIRON — css/gridiron-challenges.css
   The CHALLENGES screen (js/gridiron-challenges.js): the tag + crew row, the
   DAILY and WEEKLY challenge cards, and the leaderboard under each.

   Every value is a var(--token) from css/gridiron-tokens.css. None of
   COMBINE's hexes and none of its token NAMES (--cb-accent, --cb-grade-a …)
   appear here — this game themes through its own file.

   One shape has no COMBINE counterpart: a challenge here names a UNIT
   (offense / defense / special teams / the whole team), so every card
   carries a unit chip tinted with that unit's own colour off data.UNITS.
   ========================================================================== */

/* ---------------------------------------------------------------------
   1. Shell
   --------------------------------------------------------------------- */
#screen-challenges .container {
  display: flex;
  flex-direction: column;
  padding-top: var(--s-4);
  padding-bottom: var(--s-8);
}

.challenges {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

.challenges__head {
  display: flex;
  align-items: flex-start;
  gap: var(--s-4);
}
.challenges__titles {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  flex: 1;
  min-width: 0;
}
.challenges__title {
  letter-spacing: 0.04em;
  color: var(--c-text);
}
.challenges__blurb {
  font-size: var(--fs-small);
  line-height: 1.6;
  color: var(--c-text-2);
  max-width: 68ch;
}

/* ---------------------------------------------------------------------
   2. Tag + crew — one row above both cards, since one identity and one crew
      serve the daily and the weekly board alike.
   --------------------------------------------------------------------- */
.challenges__crew {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s-2) var(--s-3);
  padding: var(--s-3) var(--s-4);
  border: var(--bw) solid var(--c-line);
  border-radius: var(--r-md);
  background: var(--c-panel);
}
.challenges__field {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}
.challenges__field-label {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  letter-spacing: 0.12em;
  color: var(--c-text-3);
}
.challenges__input {
  min-width: 0;
  width: 11ch;
  padding: 6px 8px;
  border: var(--bw) solid var(--c-line-strong);
  border-radius: var(--r-sm);
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}
.challenges__input:focus-visible {
  outline: var(--bw-2) solid var(--c-accent-bright);
  outline-offset: 1px;
}
/* A crew code is read aloud and typed off a screenshot, so it is always
   displayed in the uppercase it is stored in. */
.challenges__input--code {
  width: 9ch;
  text-transform: uppercase;
}
.challenges__crew-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}
.challenges__crew-hint {
  flex: 1 1 16rem;
  font-size: var(--fs-small);
  line-height: 1.5;
  color: var(--c-text-3);
}

/* ---------------------------------------------------------------------
   3. The two cards
   --------------------------------------------------------------------- */
.challenges__cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
}
@media (max-width: 760px) {
  .challenges__cards {
    grid-template-columns: 1fr;
  }
}

.challenge {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border: var(--bw) solid var(--c-line);
  border-left: 3px solid var(--c-line-strong);
  border-radius: var(--r-md);
  background: var(--c-panel);
}
.challenge--done {
  border-left-color: var(--c-ok);
}
/* An unplayed period — the whole point of the card is the PLAY button. */
.challenge--open {
  border-left-color: var(--c-accent-bright);
}

.challenge__head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.challenge__label {
  font-family: var(--font-display);
  font-size: var(--fs-label);
  letter-spacing: 0.14em;
  color: var(--c-accent);
}
/* Which unit the rule is about. Tinted per unit off the same tokens
   data.UNITS names, so the chip agrees with the depth chart's tabs. */
.challenge__scope {
  margin-left: auto;
  padding: 1px var(--s-2);
  border: var(--bw) solid currentColor;
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.1em;
  color: var(--c-text-3);
}
.challenge[data-unit="offense"] .challenge__scope { color: var(--c-off); }
.challenge[data-unit="defense"] .challenge__scope { color: var(--c-def); }
.challenge[data-unit="special"] .challenge__scope { color: var(--c-st); }
.challenge[data-unit="team"] .challenge__scope { color: var(--c-metal); }

.challenge__status {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  color: var(--c-text-3);
}
.challenge--done .challenge__status { color: var(--c-ok); }
.challenge--open .challenge__status { color: var(--c-accent-bright); }

.challenge__text {
  font-size: var(--fs-small);
  line-height: 1.5;
  color: var(--c-text-2);
}

/* Locked-in gauntlet score for a completed period. */
.challenge__score {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.challenge__score-num {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  line-height: 1;
  color: var(--c-accent-bright);
}
.challenge__score-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  letter-spacing: 0.1em;
  color: var(--c-text-3);
}

.challenge__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  min-height: 1.75rem;
}
.challenge__streak {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  color: var(--c-accent-bright);
}

/* ---------------------------------------------------------------------
   4. Board
   --------------------------------------------------------------------- */
.challenge__board {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  padding-top: var(--s-2);
  border-top: var(--bw) solid var(--c-line);
}
.challenge__board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  color: var(--c-text-3);
}

/* GLOBAL / CREW switch, only rendered once a crew code is set. */
.challenge__board-tabs {
  display: flex;
  flex: 0 0 auto;
  gap: 2px;
}
.challenge__board-tab {
  padding: 2px 6px;
  border: var(--bw) solid var(--c-line);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--c-text-3);
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  letter-spacing: 0.1em;
  cursor: pointer;
}
.challenge__board-tab.is-active {
  border-color: var(--c-accent-bright);
  color: var(--c-accent-bright);
}

/* Everyone on this board built out of their own saved roster, so it is a
   list of scores rather than a like-for-like race. Said once, quietly. */
.challenge__board-note {
  font-size: 0.6875rem;
  line-height: 1.5;
  color: var(--c-text-3);
}
.challenge__board-empty {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  color: var(--c-text-3);
}
.challenge__board-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.challenge__board-row {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr) auto;
  gap: var(--s-2);
  padding: 2px 0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--c-text-2);
}
.challenge__board-rank {
  color: var(--c-text-3);
}
.challenge__board-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.challenge__board-row.is-you {
  color: var(--c-accent-bright);
  font-weight: 600;
}
.challenge__board-row.is-you .challenge__board-rank {
  color: var(--c-accent-bright);
}
