/* The leaderboard box's tabs, and what came with them (shared/solo-leaderboard.js): the Solo | Daily switch and its
   pages, the ✓ on a signed-in player's name, the Daily tab's columns, the Show more button and the rows while they
   load. The box itself - the dialog, the card, the rows, the gap and the count - is the board-* rules in theme.css,
   which still apply here. */

/* Every rule here starts with :where([data-styles~="board"]): the game's screens are all on one page (app.html), with
   every screen's stylesheet loaded, and that keeps this one's rules to the screens that name it in their data-styles.
   (:where adds no weight, so the rules count for just what they did before it. A rule for the screen itself has no
   space after it.) */

/* Solo | Daily: a segmented control the width of the box, so both halves are easy to hit on a phone. The white pill
   under the tab picked, and its glide to the other, are /shared/tabs.css's (and tabs.js's). */
:where([data-styles~="board"]) .board-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  --tabs-gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--field);
}

:where([data-styles~="board"]) .board-tabs button {
  appearance: none;
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-muted);
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
}
@media (hover: hover) {
  :where([data-styles~="board"]) .board-tabs button:hover { color: var(--ink); }
}

/* Under the head, the tabs' pages side by side (tabs.js) */
:where([data-styles~="board"]) .board-stage {
  flex: 1 1 auto;
  min-height: 0;
}

/* A tab's page: Everyone | Friends (for someone signed in), and under it their two lists side by side in the same way
   - each scrolling itself, so each keeps its own place. The switch stays put over them. */
:where([data-styles~="board"]) .board-page {
  display: grid;
  grid-template: auto minmax(0, 1fr) / minmax(0, 1fr);
  min-height: 0;
}
:where([data-styles~="board"]) .board-who-bar {
  grid-row: 1;
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  padding: 12px var(--sheet-side, 20px) 10px;
  -webkit-user-select: none;
  user-select: none;
}
:where([data-styles~="board"]) .board-panes {
  grid-row: 2;
  min-height: 0;
}
/* Under the switch, a list starts a little closer to it than it would to the head */
:where([data-styles~="board"]) .board-page.has-who .board-pane { padding-top: 10px; }
/* A list scrolled down: the hairline is under the switch, not between it and the tabs (sheet.css has it under the head) */
:where([data-styles~="board"]) .board-card.has-who.is-scrolled > .sheet-head { box-shadow: none; }
:where([data-styles~="board"]) .board-card.has-who.is-scrolled .board-who-bar { box-shadow: 0 1px 0 var(--field-line); }

/* What the tab shows, spaced like the card around it */
:where([data-styles~="board"]) .board-panel {
  display: grid;
  gap: 16px;
}

/* The name and the ✓ side by side: the name gives way, the ✓ never does */
:where([data-styles~="board"]) .board-row .name {
  display: flex;
  align-items: center;
  gap: 6px;
}
:where([data-styles~="board"]) .board-row .name .text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Signed in */
:where([data-styles~="board"]) .board-badge {
  flex: none;
  width: 15px;
  height: 15px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--go);
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
}

/* Daily rows have three numbers where solo's have two, so they're laid out as a grid with the numbers in a group of
   their own - which can then drop under the name on a phone, where the one line would leave the name no room */
:where([data-styles~="board"]) .board-row.daily {
  display: grid;
  grid-template-columns: 30px 28px minmax(0, 1fr) auto;
  grid-template-areas: "place avatar name stats";
  column-gap: 10px;
}
:where([data-styles~="board"]) .board-row.daily .place { grid-area: place; }
:where([data-styles~="board"]) .board-row.daily .avatar { grid-area: avatar; }
:where([data-styles~="board"]) .board-row.daily .name { grid-area: name; }
:where([data-styles~="board"]) .board-row.daily .board-stats { grid-area: stats; }

/* Each number stays whole, but on a narrow screen they take a second line rather than running past the row's edge */
:where([data-styles~="board"]) .board-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 10px;
  white-space: nowrap;
}

/* "5 tries" like "12 words" next to it (.board-row .words in theme.css), wide enough for two digits so the times line
   up in a column */
:where([data-styles~="board"]) .board-stats .tries {
  min-width: 4em;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* Wide enough for "12:05" */
:where([data-styles~="board"]) .board-stats .time {
  min-width: 3.2em;
  text-align: right;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 480px) {
  :where([data-styles~="board"]) .board-row.daily {
    grid-template-columns: 30px 28px minmax(0, 1fr);
    grid-template-areas:
      "place avatar name"
      "place avatar stats";
    row-gap: 2px;
  }

  /* Under the name the numbers read left to right, so no columns to line up */
  :where([data-styles~="board"]) .board-stats .tries, :where([data-styles~="board"]) .board-stats .time {
    min-width: 0;
    text-align: left;
  }
}

/* Show more, centred under the rows */
:where([data-styles~="board"]) .board-more { justify-self: center; }

/* The tab's rows while they're fetched again (it was picked again): still up, dimmed, until the new ones are in. The
   first time, grey rows stand in instead (skeletonRow in solo-leaderboard.js). */
:where([data-styles~="board"]) .board-list.is-loading { opacity: 0.5; transition: opacity 0.2s ease; }

/* The narrowest screens: a solo row's words go under the name, so the name keeps some room beside the points */
@media (max-width: 359px) {
  :where([data-styles~="board"]) .board-row.solo {
    display: grid;
    grid-template-columns: 24px 28px minmax(0, 1fr) auto;
    grid-template-areas:
      "place avatar name pts"
      "place avatar words pts";
    column-gap: 8px;
  }
  :where([data-styles~="board"]) .board-row.solo .place { grid-area: place; }
  :where([data-styles~="board"]) .board-row.solo .avatar { grid-area: avatar; }
  :where([data-styles~="board"]) .board-row.solo .name { grid-area: name; }
  :where([data-styles~="board"]) .board-row.solo .words { grid-area: words; }
  :where([data-styles~="board"]) .board-row.solo .pts { grid-area: pts; min-width: 0; }
}


/* Everyone | Friends, over a tab's rows, for someone signed in (/shared/solo-leaderboard.js): a smaller switch than
   the tabs', in the middle, with the same white pill gliding under it (/shared/tabs.css) */
:where([data-styles~="board"]) .board-who {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  --tabs-gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--field);
}
:where([data-styles~="board"]) .board-who button {
  appearance: none;
  min-width: 100px;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-muted);
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
/* Easier to hit than it looks: the bar's own space above and below it counts */
:where([data-styles~="board"]) .board-who button::after { content: ""; position: absolute; inset: -9px 0; }
:where([data-styles~="board"]) .board-who > .tabs-pill { border-radius: 8px; }
@media (hover: hover) {
  :where([data-styles~="board"]) .board-who button:hover { color: var(--ink); }
}
