/* The scope bar: the head of every page outside the Coach group (Your gaps and Your games).
   One row on a desktop: the page's name on the left, then the hero button, the window switch and who you are
   measured against. On a phone the name sits above and the bar pins to the top of the screen.
   Reads tokens.css. Write-up: docs/design/gap-header/README.md */

.gh { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 10px var(--s-6); margin: var(--s-5) 0 var(--s-5); padding: 10px 0; background: var(--dc-ground);
  border-bottom: 1px solid var(--dc-line); box-shadow: 0 8px 16px -12px rgba(0, 0, 0, .6); }
.gh-title { margin: 0; font: 800 34px/1 var(--dc-display); letter-spacing: .005em; text-transform: uppercase; color: var(--dc-ink); }
.gh-title:focus { outline: none; }
.gh-bar { position: relative; display: flex; align-items: center; flex-wrap: wrap; gap: 8px var(--s-3); min-width: 0; }

/* the hero button: the portrait on the hero's own colour, the name in caps, the games in mono */
.gh-hero { --hero: var(--dc-panel-3); display: inline-flex; align-items: center; gap: 10px; height: 40px; min-width: 0; padding: 0 12px 0 0;
  border: 1px solid var(--dc-line-strong); border-radius: var(--dc-r); background: var(--dc-panel); color: var(--dc-ink); cursor: pointer;
  box-shadow: inset 0 -2px 0 var(--dc-red); }
.gh-hero:hover { background: var(--dc-panel-2); }
.gh-hero.open { border-color: var(--dc-red); background: var(--dc-panel-2); }
.gh-face { position: relative; flex: none; width: 40px; height: 100%; overflow: hidden; display: grid; place-items: center;
  background: linear-gradient(160deg, color-mix(in oklab, var(--hero) 60%, var(--dc-panel-3)), var(--dc-panel-2)); }
.gh-face img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 18%; }
.gh-face .ini { font: 800 14px/1 var(--dc-display); text-transform: uppercase; color: var(--dc-ink); }
.gh-hero .gh-nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 17px/1 var(--dc-display); letter-spacing: .04em; text-transform: uppercase; }
.gh-hero .gh-ct { flex: none; font: 500 12px/1 var(--dc-mono); color: var(--dc-muted); }
.gh-caret { flex: none; font-size: 11px; color: var(--dc-muted); }

/* the window: the shell's segmented switch, as tall as the hero button */
.gh-win .chip { height: 40px; padding: 0 var(--s-3); font-size: 13px; }

/* who you are measured against: small, quiet, the rank badges carry it */
.gh-vs { display: flex; align-items: center; gap: 6px; margin: 0; font: 500 13px/1.2 var(--dc-text); color: var(--dc-muted); white-space: nowrap; }
.gh-vs b { font-weight: 600; color: var(--dc-read); }
.gh-vs .rk { width: 20px; height: 20px; margin-right: -2px; }
.gh-vs__k { color: var(--dc-muted); }

/* the hero list: opens under the button, a search box, then every hero you played in the window */
.gh-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; width: min(620px, calc(100vw - 2 * var(--gut)));
  display: grid; gap: 10px; padding: 12px; background: var(--dc-panel); border: 1px solid var(--dc-line-strong); border-radius: var(--dc-r);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .65); animation: gh-in .12s ease-out; }
.gh-menu__top { display: flex; align-items: center; gap: var(--s-3); }
.gh-find { flex: 1 1 auto; min-width: 0; height: 36px; padding: 0 10px; border: 1px solid var(--dc-line-strong); border-radius: var(--dc-r);
  background: var(--dc-ground); color: var(--dc-ink); font: 400 15px/1 var(--dc-text); }
.gh-find:focus { outline: none; border-color: var(--dc-red); }
.gh-menu__n { flex: none; font: 500 12px/1 var(--dc-mono); color: var(--dc-muted); }
.gh-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; max-height: min(60vh, 440px); overflow-y: auto; scrollbar-width: thin; }
.gh-opt { --hero: var(--dc-panel-3); display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 10px 0 0; min-width: 0;
  border: 0; border-radius: var(--dc-r); background: transparent; color: var(--dc-read); text-align: left; cursor: pointer; }
.gh-opt .gh-face { width: 38px; }
.gh-opt .gh-nm { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 500 14px/1.2 var(--dc-text); }
.gh-opt .gh-ct { flex: none; font: 500 12px/1 var(--dc-mono); color: var(--dc-muted); }
.gh-opt:hover, .gh-opt:focus-visible { background: var(--dc-panel-2); color: var(--dc-ink); }
.gh-opt.on { background: var(--dc-red-tint); color: var(--dc-ink); box-shadow: inset 3px 0 0 var(--dc-red); }
.gh-opt.few:not(.on) { opacity: .55; }
.gh-opt[hidden] { display: none; }
.gh-none { margin: 0; font-size: var(--dc-t-small); color: var(--dc-muted); }
@keyframes gh-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .gh-menu { animation: none; } }

/* desktops: the bar sits at the right end of the row, so the list opens leftwards from its right edge */
@media (min-width: 720px) { .gh-menu { left: auto; right: 0; } }

/* phones: the name above, then the bar pinned to the top: the hero button takes the room the switch leaves */
@media (max-width: 719px) {
  .gh { display: contents; }
  .gh-title { margin: var(--s-3) 0 10px; font-size: 30px; }
  .gh-bar { position: sticky; top: 0; z-index: 30; flex-wrap: wrap; gap: 6px 8px; margin: 0 calc(-1 * var(--gut)) var(--s-4); padding: 8px var(--gut);
    background: var(--dc-ground); border-bottom: 1px solid var(--dc-line); box-shadow: 0 8px 16px -12px rgba(0, 0, 0, .6); }
  .gh-hero { flex: 1 1 0; gap: 8px; padding-right: 10px; }
  .gh-hero .gh-nm { flex: 1 1 auto; font-size: 16px; text-align: left; }
  .gh-ct__w { display: none; }
  .gh-win .chip { padding: 0 9px; font-size: 12px; }
  .gh-vs { flex-basis: 100%; }
  .gh-menu { left: var(--gut); right: var(--gut); width: auto; }
  .gh-menu__top { flex-wrap: wrap; gap: 6px; }
  .gh-find { flex-basis: 100%; }
  .gh-list { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 56vh; }
}

/* ---------- takeaways: the coach's verdicts, one compact panel under the bar ----------
   Behind first, in amber with ▼; ahead in ice with ▲ (the colour rule in tokens.css: never green and red). */
.takeaways { margin-bottom: var(--s-5); }
.tk { list-style: none; margin: 0; padding: 0; border: 1px solid var(--dc-line); border-radius: var(--dc-r); background: var(--dc-panel); }
.tk li { display: flex; align-items: baseline; gap: 10px; padding: 9px 14px; font: 400 15px/1.4 var(--dc-text); color: var(--dc-read); }
.tk li + li { border-top: 1px solid var(--dc-line); }
.tk-mk { flex: none; width: 12px; font-size: 12px; color: var(--dc-muted); }
.tk li.bad .tk-mk { color: var(--dc-behind); }
.tk li.good .tk-mk { color: var(--dc-ahead); }
@media (max-width: 719px) { .tk li { padding: 8px 12px; font-size: 14px; } }

/* a block's "how this was measured" line, under its cards as small print */
.block__foot { margin: var(--s-3) 0 0; max-width: 80ch; font-size: var(--dc-t-small); line-height: 1.5; color: var(--dc-muted); }

/* a linked card lands under the pinned bar (app.js pinRoom sets --gh-h to the bar's height) */
.main:has(.gh) [id] { scroll-margin-top: calc(var(--gh-h, 0px) + var(--s-4)); }
