/* TASK-1029 (owner 20.10, variant A of TASK-1022 docs/os/work/TASK-1022/spec.md): sorting the ranking.
   Everything here styles what /assets/sort.js adds; without JS none of these classes exist and the page is as before.
   >= 1200 px: the labels of the dark head bar are buttons with an arrow; < 1200 px: the «Sort by» list above the cards.
   Colours: the owner's tokens plus the three shades the designer set for this in TASK-1022 (spec «Вариант A», rule 4),
   defined once below. Homepage only, after load.css. */
:root {
  --sorted-cell: #f6f2fc;  /* background of the sorted column's cells: between white and --purple-soft (chips use it) */
  --head-hover: #5a2fa6;   /* a head button under the pointer: between --purple and --purple-deep */
  --head-off: #d7cdea;     /* a head that cannot sort yet («same for all», «not measured») on --purple-deep */
}

/* status line + the list (the list only below 1200, where the head bar is hidden) */
.rank-sort { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 14px; margin: 0 0 8px; }
/* sorted: the reset's 44 px zone sticks out 12 px under its line, so the list / first card / head bar keep 14 px away */
.rank-sort.is-sorted { row-gap: 14px; margin-bottom: 14px; }
.rank-sort-status { margin: 0; padding: 0 4px; color: var(--muted); font-size: 13px; line-height: 1.45; flex: 1 1 320px; }
.rank-sort-status b { color: var(--ink); }
.rank-sort-reset { border: 0; background: transparent; color: var(--purple); font: inherit; font-weight: 700; text-decoration: underline;
                   text-underline-offset: 3px; padding: 12px 2px; margin: -12px 0; min-height: 44px; cursor: pointer; }
.rank-sort-pick { margin: 0; display: none; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.rank-sort-pick select { font: inherit; font-weight: 700; font-size: 15px; color: var(--ink); background-color: var(--surface); border: 1.5px solid var(--line);
                         border-radius: 10px; min-height: 44px; padding: 8px 34px 8px 12px; cursor: pointer; max-width: 100%;
                         -webkit-appearance: none; appearance: none;
                         background-image: linear-gradient(45deg, transparent 50%, var(--purple) 50%), linear-gradient(135deg, var(--purple) 50%, transparent 50%);
                         background-position: right 16px top 50%, right 11px top 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.rank-sort-pick select:hover { border-color: var(--purple); }
.rank-sort-pick select:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; box-shadow: 0 0 0 3px var(--surface); }

/* the sorted column: a soft band on its cells (desktop row and phone card alike) */
.sorted-casino .identity, .sorted-licences .metric.licences, .sorted-searches .metric.searches, .sorted-load .metric.load,
.sorted-withdrawal .metric.payout, .sorted-cashout .metric.monthly, .sorted-games .metric.games, .sorted-games .metric.studios { background: var(--sorted-cell); }

/* TASK-1211: sort.js is deferred, it runs after the first paint. With scripting on the page is drawn with the room of
   what it adds, so nothing moves when it does: < 1200 the «Sort by» line above the cards (select 44 px + the 8 px
   margin of .rank-sort; it pushed the list 52 px down on a phone) is held by the head bar itself, hidden there and
   invisible, in the line's place; sort.js puts the line before it and hides it, so the list does not move at all;
   >= 1200 the 44 px buttons of the head bar (the bar grew from 39 to 44 px). Without scripting (sort.js never
   runs) neither applies. */
@media (scripting: enabled) and (max-width: 1199px) {
  .ranking .column-heads:not(.is-sortable) { display: block; visibility: hidden; overflow: hidden; height: 44px;
    margin: 0 0 8px; padding: 0; border: 0; }
}
@media (scripting: enabled) and (min-width: 1200px) {
  .column-heads:not(.is-sortable) { padding: 0; align-items: stretch; }
  .column-heads:not(.is-sortable) > span { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 44px; }
}

/* >= 1200: buttons in the head bar */
@media (min-width: 1200px) {
  .rank-sort:not(.is-sorted) { margin: 0; }  /* nothing visible above the head bar before sorting */
  .column-heads.is-sortable { padding: 0; align-items: stretch; }
  .column-heads.is-sortable > span { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 44px; }
  .column-heads.is-sortable > span:has(> .col-sort) { padding: 0 3px; }
  .col-sort { all: unset; box-sizing: border-box; display: flex; align-items: center; justify-content: center; gap: 2px 5px; flex-wrap: wrap; width: 100%;
              height: 100%; min-height: 44px; padding: 4px; border-radius: 9px; cursor: pointer; text-align: center; line-height: 1.25; }
  .col-sort:hover { background: var(--head-hover); }
  .col-sort:focus-visible { outline: 3px solid var(--on-purple); outline-offset: -3px; }
  .column-heads .is-sorted .col-sort { background: var(--purple); box-shadow: inset 0 -3px 0 var(--on-purple); }
  .col-arrow { width: 12px; height: 14px; flex: 0 0 auto; }
  .col-arrow path { stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .col-arrow .dim { opacity: .55; }
  .column-heads .col-off { color: var(--head-off); }
  .column-heads .col-off small { display: block; font-size: 10px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--head-off); margin-top: 2px; }
}
/* < 1200: no head bar, the list instead */
@media (max-width: 1199px) {
  .rank-sort-pick { display: inline-flex; }
}
@media (forced-colors: active) {
  .column-heads .is-sorted .col-sort { outline: 2px solid CanvasText; outline-offset: -2px; }
}
