/* ==========================================================================
   NITRATE — THE GENRE ASSAY.  Pairs with genrelens.js.  Nothing else.

   A lab report, not a chart.  Every value comes from tokens.css and none are
   redefined, so it reads on the vault (dark) and the light table without a
   single theme-specific rule of its own.

   THE ONE COLOUR DECISION
   Safety orange appears in exactly two places: the row you have picked, and
   the sort you have chosen.  Both mean the same thing — "this is what you
   sorted by".  The bars are --muted and the tick is --ink, because a bar
   length is a measurement and not an alert; colouring a deficit red would be
   telling the reader what to think about a number they can already read.

   THE GUTTER
   The host owns it.  `padding: 0 var(--pad-x, 0px)` is the same contract
   anime.css and field.css use, so this lines up with whatever it is mounted
   beside.  If the host element ALREADY applies --pad-x (as .nsr does), mount
   this outside that element or the gutter is paid twice.

   THE GRID
   Six columns on desktop, and the header strip is the same grid so a label
   can never drift off the column it names.  Under 760px the row folds into
   three lines — name/hours, then the bar full width, then the mono strip —
   which keeps every figure at its full size instead of shrinking the type to
   fit a phone.
   ========================================================================== */

.ngl {
  display: block;
  padding: 0 var(--pad-x, 0px);
  margin: 0;
  color: var(--ink);
}

.ngl-empty {
  margin: 0;
  color: var(--muted);
  font-style: italic;
}

/* --- heading: a rule with the scope note sitting on it -------------------- */
.ngl-hd {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 10px;
}
.ngl-hd h3 {
  font-family: var(--font-marquee, var(--font-display));
  font-size: clamp(19px, 2.3vw, 27px);
  font-weight: 700;
  letter-spacing: -.01em;
  flex: 0 0 auto;
}
.ngl-rule {
  flex: 1 1 auto;
  min-width: 12px;
  height: 0;
  border-top: var(--hair) solid var(--rule);
  transform: translateY(-3px);
}
.ngl-scope {
  flex: 0 0 auto;
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--muted);
  white-space: nowrap;
}

/* --- the deck ------------------------------------------------------------ */
.ngl-deck {
  margin: 0 0 18px;
  max-width: 92ch;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-2);
}

/* --- the four figures ---------------------------------------------------- */
.ngl-figs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 0 0 26px;
  border-top: var(--hair) solid var(--rule);
  border-bottom: var(--hair) solid var(--rule);
}
.ngl-fig {
  padding: 12px 16px 13px 0;
  min-width: 0;
}
.ngl-fig + .ngl-fig {
  padding-left: 16px;
  border-left: var(--hair) solid var(--rule);
}
.ngl-fig-v {
  display: block;
  font-family: var(--font-marquee, var(--font-display));
  font-variant-numeric: tabular-nums;
  font-size: clamp(30px, 4vw, 46px);
  font-weight: 800;
  line-height: .92;
  letter-spacing: -.03em;
  color: var(--ink);
}
.ngl-fig-u {
  font-size: .48em;
  font-weight: 600;
  margin-left: .18em;
  letter-spacing: 0;
  color: var(--ink-2);
}
.ngl-fig-l {
  display: block;
  margin-top: 5px;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--muted);
  text-wrap: pretty;
}

/* --- the two panes ------------------------------------------------------- */
.ngl-body {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 30px;
  align-items: start;
}
.ngl-main { min-width: 0; }

.ngl-sub {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0 0 8px;
}
.ngl-sub h4,
.ngl-aside h4 {
  font-family: var(--font-marquee, var(--font-display));
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--ink);
}

/* --- sort segment -------------------------------------------------------- */
.ngl-seg {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.ngl-seg-l {
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.ngl-segb {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: .04em;
  padding: 5px 10px;
  min-height: 28px;
  color: var(--muted);
  border: var(--hair) solid var(--rule);
  background: transparent;
  transition: color .12s linear, border-color .12s linear;
}
.ngl-segb:hover { color: var(--ink); }
.ngl-segb.is-on {
  color: var(--accent);
  border-color: var(--accent);
}

/* --- column header, same grid as a row ----------------------------------- */
.ngl-cols,
.ngl-pick {
  display: grid;
  grid-template-columns:
    minmax(84px, 1.35fr)   /* name     */
    46px                   /* titles   */
    minmax(110px, 4fr)     /* bar      */
    62px                   /* hours    */
    58px                   /* vs pred  */
    58px;                  /* unplayed */
  align-items: center;
  gap: 0 12px;
}
.ngl-cols {
  padding: 0 6px 6px;
  font-size: 11px;
  letter-spacing: .05em;
  color: var(--muted);
  border-bottom: var(--hair) solid var(--rule);
}
.ngl-cols > span { min-width: 0; }
.ngl-c-n, .ngl-c-h, .ngl-c-d, .ngl-c-u { text-align: right; }
.ngl-c-bar {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- the ledger ---------------------------------------------------------- */
.ngl-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}
.ngl-row { border-bottom: var(--hair) solid var(--rule); }

.ngl-pick {
  width: 100%;
  min-height: 40px;
  padding: 6px;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.ngl-pick:hover { background: var(--panel); }
.ngl-pick:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.ngl-name {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -.005em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ngl-n, .ngl-h, .ngl-d, .ngl-u {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  text-align: right;
  color: var(--ink-2);
  white-space: nowrap;
}
.ngl-n, .ngl-u { color: var(--muted); }
.ngl-h { color: var(--ink); }
.ngl-d.is-far { color: var(--ink); }

/* --- the bar: length is hours, the tick is the prediction ---------------- */
.ngl-bar {
  position: relative;
  display: block;
  height: 13px;
  min-width: 0;
  border-bottom: var(--hair) solid var(--rule);
}
.ngl-fill {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 9px;
  background: var(--muted);
  display: block;
}
.ngl-tick {
  position: absolute;
  bottom: -2px;
  width: 1px;
  height: 15px;
  margin-left: -1px;
  background: var(--ink);
  display: block;
}
.ngl-pick.is-picked { background: var(--panel-2); }
.ngl-pick.is-picked .ngl-name { color: var(--accent); }
.ngl-pick.is-picked .ngl-fill { background: var(--accent); }

/* --- the key under the ledger -------------------------------------------- */
.ngl-key {
  margin: 10px 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
  max-width: 76ch;
}
.ngl-key-bar,
.ngl-key-tick {
  display: inline-block;
  vertical-align: middle;
  position: relative;
  top: -1px;
}
.ngl-key-bar { width: 22px; height: 8px; background: var(--muted); }
.ngl-key-tick { width: 1px; height: 13px; background: var(--ink); margin: 0 4px 0 2px; }

/* --- the aside: the names the rules dropped ------------------------------ */
.ngl-aside {
  min-width: 0;
  border-left: var(--hair) solid var(--rule);
  padding-left: 24px;
}
.ngl-aside > h4 { margin-bottom: 4px; }

.ngl-band { margin-top: 16px; }
/* 12.5px is the floor for anything not in the mono face — an uppercase
   letterspaced label reads small at that size but must not go under it. */
.ngl-band-h {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink);
}
.ngl-band-r,
.ngl-band-ev {
  margin: 3px 0 0;
  font-size: 12.5px;
  line-height: 1.42;
  color: var(--muted);
}
.ngl-band-ev { margin-top: 7px; color: var(--ink-2); }

.ngl-chips {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 6px;
}
.ngl-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 7px;
  border: var(--hair) solid var(--rule);
  font-size: 12.5px;
  color: var(--ink-2);
  min-width: 0;
}
.ngl-chip-n { white-space: nowrap; }
.ngl-chip-into {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}
.ngl-chip-f {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.ngl-chip.is-fold { border-style: dashed; }

/* --- the footnote -------------------------------------------------------- */
.ngl-note {
  margin: 24px 0 0;
  padding-top: 12px;
  border-top: var(--hair) solid var(--rule);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 30px;
}
.ngl-note p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
  text-wrap: pretty;
}

/* ==========================================================================
   NARROWER.  Desktop is the priority, so nothing above is written for a
   phone; these are the four points where the desktop shape actually breaks.
   ========================================================================== */

/* the two panes stop fitting side by side well before the figures do */
@media (max-width: 1040px) {
  .ngl-body { grid-template-columns: minmax(0, 1fr); gap: 26px; }
  .ngl-aside {
    border-left: 0;
    padding-left: 0;
    border-top: var(--hair) solid var(--rule);
    padding-top: 16px;
  }
}

@media (max-width: 860px) {
  .ngl-figs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ngl-fig:nth-child(3) { padding-left: 0; border-left: 0; }
  .ngl-fig:nth-child(3), .ngl-fig:nth-child(4) {
    border-top: var(--hair) solid var(--rule);
  }
  .ngl-note { grid-template-columns: minmax(0, 1fr); gap: 8px; }
}

/* the row folds rather than shrinking: three lines, full-size figures, and a
   44px target.  The column header goes with it — a header for a grid that no
   longer exists is worse than no header. */
@media (max-width: 760px) {
  .ngl-cols { display: none; }
  /* a narrow viewport is a thumb whether or not the engine admits to a coarse
     pointer, so the sort control takes a real target here and not only under
     the (pointer: coarse) query below */
  .ngl-segb { min-height: 44px; padding: 6px 14px; }
  .ngl-pick {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "name  hours"
      "bar   bar"
      "figs  figs";
    gap: 4px 12px;
    min-height: 44px;
    padding: 9px 6px 10px;
  }
  .ngl-name { grid-area: name; font-size: 14px; }
  .ngl-h    { grid-area: hours; font-size: 12px; }
  .ngl-h::after { content: ' h'; color: var(--muted); }
  .ngl-bar  { grid-area: bar; height: 12px; margin: 2px 0 3px; }
  .ngl-n    { grid-area: figs; text-align: left; }
  .ngl-n::after  { content: ' titles'; }
  .ngl-d    { grid-area: figs; text-align: center; }
  .ngl-d::before { content: 'vs pred '; color: var(--muted); }
  .ngl-u    { grid-area: figs; text-align: right; }
  .ngl-u::after  { content: ' unplayed'; }
  .ngl-n, .ngl-d, .ngl-u { font-size: 11px; align-self: end; }
}

/* one flat line, so a 360px screen never scrolls sideways.
   Folded 420 → 430, the house narrow tier (MOBILE_SPEC §1): an iPhone 16 Pro
   Max is 430 CSS px and was landing on the two-column figure grid by ten
   pixels. 1040 and 860 are above 820 and stay as they are. */
@media (max-width: 430px) {
  .ngl-figs { grid-template-columns: minmax(0, 1fr); }
  .ngl-fig { padding: 11px 0 12px; }
  .ngl-fig + .ngl-fig {
    padding-left: 0;
    border-left: 0;
    border-top: var(--hair) solid var(--rule);
  }
  .ngl-deck { font-size: 13px; }
  .ngl-d::before { content: ''; }
  .ngl-u::after  { content: ' unpl.'; }
}

/* touch: the sort buttons have to be reachable with a thumb too */
@media (pointer: coarse) {
  .ngl-segb { min-height: 44px; padding: 6px 14px; }
  .ngl-pick { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .ngl-segb { transition: none; }
}
