/* Top navigation (header.nav). Loaded after styles.css and power.css; every rule is scoped to
   header.nav so it outranks the older .nav rules without editing them.
   Three zones, in DOM and visual order: identity (back to AI Radar, brand, LIVE) | user search | site actions (Stats,
   Heroes, Join) and compact tools (Agent Speed on GitHub as an icon, motion, language).
   Wide screens: one sticky row (61px with its border). Below that the header becomes two rows and
   scrolls away with the page, so the existing 64px anchor offsets never sit under a taller bar.
   No new looping animation; the two existing loops (cursor, LIVE dot) stop with FX off. The page links'
   one-shot icon passes are at the end of this file; their touch press and the Number effects opt-out use a small module (ui/nav-motion.mjs). */
header.nav {
  --hn-h: 34px;            /* primary controls */
  --hn-tool: 28px;         /* motion and language */
  --hn-chip-line: #264a35;
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: max-content minmax(160px, 1fr) max-content;
  align-items: center; column-gap: 20px; row-gap: 0;
  padding: 11px var(--gutter);
  background: linear-gradient(180deg, rgba(8, 14, 10, .95), rgba(5, 8, 6, .9));
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
  box-shadow: 0 1px 0 rgba(57, 255, 136, .035);
  font-family: var(--sans);
}
header.nav a:hover { text-decoration: none; }
/* Search shares the header with LIVE; status text floats without moving the bar. */
header.nav .user-search { position: relative; justify-self: start; display: flex; flex-wrap: nowrap; gap: 5px;
  width: min(100%, 270px); min-width: 0; margin: 0; }
header.nav .user-search input { flex: 1; width: 0; max-width: none; height: var(--hn-h); padding: 0 9px; }
header.nav .user-search button { flex: none; height: var(--hn-h); padding: 0 9px; white-space: nowrap; }
header.nav .user-search-status:not(:empty) { position: absolute; top: calc(100% + 6px); right: 0; z-index: 2;
  width: max-content; max-width: min(290px, 85vw); padding: 6px 9px; border: 1px solid var(--line); border-radius: 4px;
  background: #0b130d; line-height: 1.4; }
header.nav .hn-rule { flex: none; width: 1px; height: 20px; background: var(--line); }

/* ---- identity ---- */
/* Leave a useful field beside the explicit search-and-pin action on medium desktops. */
@media (min-width: 1280px) and (max-width: 1599.98px) {
  body[data-page="ladder"] header.nav { position: relative; grid-template-columns: max-content minmax(240px, 1fr); row-gap: 8px; }
  body[data-page="ladder"] header.nav .user-search { justify-self: end; }
  body[data-page="ladder"] header.nav .nav-links { grid-column: 1 / -1; justify-self: stretch; justify-content: flex-end; }
}

header.nav .hn-id { justify-self: start; display: flex; align-items: center; gap: 14px; min-width: 0; }
header.nav .hn-lockup { display: flex; align-items: center; gap: 10px; min-width: 0; }
header.nav .hn-sites { position: relative; flex: none; margin: 0; }
header.nav .hn-sites > summary {
  display: inline-flex; align-items: center; gap: 7px; height: var(--hn-h); padding: 0 10px;
  border: 1px solid var(--line); border-radius: 5px; background: var(--panel-2); color: var(--ink-2);
  font: 650 12px/1 var(--sans); list-style: none; white-space: nowrap; cursor: pointer;
}
header.nav .hn-sites > summary::-webkit-details-marker { display: none; }
header.nav .hn-sites > summary::after {
  content: ""; width: 5px; height: 5px; border: solid currentColor; border-width: 0 1px 1px 0;
  transform: rotate(45deg); margin-top: -3px;
}
header.nav .hn-sites[open] > summary::after { transform: rotate(225deg); margin-top: 2px; }
header.nav .hn-sites > summary:hover,
header.nav .hn-sites[open] > summary { color: var(--accent); border-color: var(--accent-2); }
header.nav .hn-sites-menu {
  position: absolute; z-index: 32; top: calc(100% + 6px); left: 0;
  display: grid; gap: 2px; min-width: 154px; padding: 5px; border: 1px solid var(--line);
  border-radius: 7px; background: var(--panel-2); box-shadow: 0 10px 26px #0009;
}
header.nav .hn-sites-menu a {
  display: flex; align-items: center; min-height: var(--hn-h); height: auto; padding: 0 9px;
  border: 0; border-radius: 4px; box-shadow: none; background: transparent; color: var(--ink);
  font: 600 13px/1.25 var(--sans); white-space: nowrap;
}
header.nav .hn-sites-menu a:hover { background: rgba(57, 255, 136, .08); color: var(--accent); }
header.nav .hn-sites :is(summary, a):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
header.nav .brand { display: inline-flex; align-items: center; gap: 9px; height: var(--hn-h); margin: 0; color: var(--ink);
  font: 700 16px/1 var(--sans); letter-spacing: .06em; white-space: nowrap; }
header.nav .brand .cursor { width: 8px; height: 17px; }
header.nav .live-pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; flex: none;
  font: 600 10.5px/1 var(--mono); letter-spacing: .1em; border-radius: 99px; white-space: nowrap; }
header.nav .live-pill i { flex: none; width: 6px; height: 6px; }
header.nav .live-pill[data-state="live"] { background: rgba(57, 255, 136, .06); }
header.nav .live-pill[data-state="stale"] { background: rgba(242, 193, 78, .06); }

/* ---- actions ---- */
header.nav .nav-links { justify-self: end; display: flex; align-items: center; gap: 4px; margin: 0; font-size: 13.5px; white-space: nowrap; }
header.nav .nav-links :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes) {
  position: relative; display: inline-flex; align-items: center; height: var(--hn-h); padding: 0 10px; border-radius: 5px;
  color: var(--ink-2); font-weight: 500; transition: color .15s, background-color .15s; }
header.nav .nav-links :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes)::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 6px; height: 1px; background: var(--accent);
  transform: scaleX(0); transform-origin: left; transition: transform .18s ease-out; }
/* Hover only where the primary pointer hovers, so a tapped link never keeps a stuck hover look. */
@media (hover: hover) {
  header.nav .nav-links :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes):hover { color: var(--ink); background: rgba(57, 255, 136, .05); }
  header.nav .nav-links :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes):hover::after { transform: scaleX(1); }
}
header.nav .nav-links .cta { display: inline-flex; align-items: center; justify-content: center; height: var(--hn-h); margin-left: 6px;
  padding: 0 16px; border: 0; border-radius: 5px; background: var(--accent); color: var(--accent-ink); cursor: pointer;
  font: 700 13.5px/1 var(--sans); letter-spacing: .04em; white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 0 0 1px rgba(57, 255, 136, .45), 0 6px 20px -8px rgba(57, 255, 136, .6);
  transition: background-color .15s, box-shadow .15s; }
header.nav .nav-links .cta:hover { background: #63ffa3; color: var(--accent-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 0 0 1px rgba(57, 255, 136, .6), 0 0 22px var(--glow); }
header.nav .nav-links .cta:active { background: var(--accent-2); }
header.nav .nav-links .hn-rule { margin: 0 8px 0 10px; }
header.nav .fx-toggle { display: inline-flex; align-items: center; gap: 7px; height: var(--hn-tool); padding: 0 10px 0 9px;
  border: 1px solid var(--line); border-radius: 99px; background: transparent; color: var(--ink-3); cursor: pointer;
  font: 500 11px/1 var(--mono); white-space: nowrap; transition: color .15s, border-color .15s; }
header.nav .fx-toggle::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; border: 1px solid currentColor; box-sizing: border-box; }
header.nav .fx-toggle[aria-pressed="true"] { color: var(--mint); border-color: rgba(111, 227, 194, .32); }
header.nav .fx-toggle[aria-pressed="true"]::before { border: 0; background: currentColor; box-shadow: 0 0 6px currentColor; }
header.nav .fx-toggle:hover { color: var(--ink); border-color: #2f5a42; }
header.nav .background-effects { position: relative; flex: none; }
header.nav .background-effects > summary { display: flex; align-items: center; gap: 7px; height: var(--hn-tool); box-sizing: border-box;
  padding: 0 10px; border: 1px solid var(--line); border-radius: 99px; color: var(--ink-3); cursor: pointer;
  font: 500 11px/1 var(--mono); list-style: none; }
header.nav .background-effects > summary::-webkit-details-marker { display: none; }
header.nav .background-effects[data-active] > summary { color: var(--mint); border-color: rgba(111, 227, 194, .32); }
header.nav .background-effects > summary:hover { color: var(--ink); border-color: #2f5a42; }
header.nav .background-effects-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; width: 190px;
  box-sizing: border-box; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #0b1510;
  box-shadow: 0 8px 24px #0008; white-space: normal; }
header.nav .background-effect { display: flex; align-items: center; gap: 10px; min-height: 44px; color: var(--ink); cursor: pointer; }
header.nav .background-effect input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); cursor: pointer; }
header.nav .background-effects-menu p { margin: 0 0 8px; font-size: 12px; line-height: 1.5; color: var(--ink-3); }
header.nav #lang-switch { display: inline-flex; align-items: center; justify-content: center; height: var(--hn-tool); min-width: 36px;
  margin-left: 4px; padding: 0 9px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink-2);
  font: 600 11px/1 var(--mono); letter-spacing: .06em; transition: color .15s, border-color .15s; }
header.nav #lang-switch:hover { color: var(--ink); border-color: #2f5a42; }
/* Agent Speed on GitHub: an icon tool beside motion and language; its name is in aria-label and title. */
header.nav .source-link { display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: var(--hn-tool); height: var(--hn-tool); margin-right: 6px; border: 1px solid var(--line); border-radius: 5px;
  color: var(--ink-2); transition: color .15s, border-color .15s; }
header.nav .source-link svg { width: 15px; height: 15px; }
header.nav .source-link:hover { color: var(--ink); border-color: #2f5a42; }

/* Effects off: the header's two existing loops hold still too. */
header.nav:has(#fx-toggle[aria-pressed="false"]) .cursor,
header.nav:has(#fx-toggle[aria-pressed="false"]) .live-pill i { animation: none; }

/* Touch: every header control is a 44px target. The wide row is 63px with its border, still inside the
   64px anchor offset. Search text is 16px because smaller text makes iOS zoom the page on focus. */
@media (pointer: coarse) {
  header.nav { --hn-h: 44px; --hn-tool: 44px; padding-top: 9px; padding-bottom: 9px; }
  header.nav #lang-switch { min-width: 44px; }
  header.nav .user-search input { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  header.nav *, header.nav *::before, header.nav *::after { animation: none !important; transition: none !important; }
}

/* ---- two rows: identity, then a full-width action bar; scrolls with the page ---- */
@media (max-width: 1279.98px) {
  header.nav { position: relative; display: flex; flex-wrap: wrap; align-items: center; column-gap: 16px;
    padding: 10px var(--gutter) 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
  header.nav .user-search { flex: 1 1 160px; margin-left: auto; }
  header.nav .nav-links { flex: 1 0 100%; margin: 10px calc(-1 * var(--gutter)) 0; padding: 7px var(--gutter);
    border-top: 1px solid var(--line-soft); background: rgba(9, 17, 12, .55); }
  header.nav .nav-links a.nav-stats { margin-left: -10px; }
  header.nav .nav-links .cta { margin-left: auto; }
}

/* ---- phones ---- */
@media (max-width: 599.98px) {
  header.nav { --hn-h: 44px; --hn-tool: 44px; column-gap: 8px; padding-top: 8px; }
  header.nav .hn-id { gap: 8px; }
  header.nav .hn-id .hn-rule { display: none; }
  header.nav .back-main { padding: 0 10px; font-size: 12.5px; }
  header.nav .live-pill .clock { display: none; }
  /* The action bar is full on phones: the GitHub tool takes the free right end of the identity row. */
  header.nav .source-link { position: absolute; top: 8px; right: var(--gutter); width: var(--hn-h); height: var(--hn-h); margin: 0; }
  header.nav .source-link svg { width: 17px; height: 17px; }
  header.nav .nav-links { gap: 4px; margin-top: 8px; padding: 6px var(--gutter) 8px; font-size: 13px; }
  header.nav .nav-links :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes) { padding: 0 8px; }
  header.nav .nav-links a.nav-stats { margin-left: -8px; }
  header.nav .nav-links :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes)::after { left: 8px; right: 8px; }
  header.nav .nav-links .cta { flex: 1 1 auto; min-width: 0; margin: 0 4px; padding: 0 12px; font-size: 13px; }
  header.nav .nav-links .hn-rule { display: none; }
  header.nav .fx-toggle { padding: 0 8px 0 7px; gap: 5px; }
  header.nav #lang-switch { min-width: 44px; margin-left: 0; }
}

@media (max-width: 759.98px) {
  header.nav .user-search { flex-basis: 100%; width: 100%; max-width: none; margin-top: 8px; }
  header.nav .user-search input { font-size: 16px; }
  header.nav .user-search button { min-width: 56px; font-size: 13px; }
  /* Brand over its live status, so the longest state labels never widen the identity row. */
  header.nav .hn-lockup { flex-direction: column; align-items: flex-start; gap: 0; }
  header.nav .brand { height: 24px; gap: 7px; font-size: 15px; }
  header.nav .brand .cursor { width: 7px; height: 14px; }
  header.nav .live-pill { height: 16px; padding: 0 6px; gap: 5px; font-size: 9.5px; letter-spacing: .08em; }
  header.nav .live-pill i { width: 5px; height: 5px; }
}

/* Keep the site-statistics label and actions within narrow phone screens. */
@media (max-width: 380px) {
  header.nav .nav-links { gap: 2px; }
  header.nav .nav-links :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes) { padding: 0 6px; }
  header.nav .nav-links .cta { margin: 0 2px; padding: 0 8px; }
}

/* Site pages share the same navigation. */
header.nav .nav-pages { display: flex; align-items: center; gap: 4px; }
header.nav .nav-pages [aria-current="page"] { color: var(--ink); background: rgba(57, 255, 136, .07); }
header.nav .nav-pages [aria-current="page"]::after { transform: scaleX(1); }
body:not([data-page="ladder"]) header.nav { grid-template-columns: minmax(0, 1fr) max-content; }
body[data-page="stats"] .overview { border-top: 0; padding-top: 26px; }
body[data-page="heroes"] .heroes { border-top: 0; padding-top: 26px; }
/* The back-to-AI-Radar link works the same way (aria-label / data-i18n-label="backMain" keeps the full
   name; desktop and wider phones show it in full). Below 375px the English label "← Back to AI Radar"
   (~142px at 320px) left only ~86px for the brand and clipped it to "Speed …"; "← AI Radar" (~89px) leaves
   the whole "Speed Radar" room beside the GitHub tool. The Chinese short label is the existing text. */
header.nav .back-main-short { display: none; }
@media (max-width: 374.98px) {
  header.nav .back-main-long { display: none; }
  header.nav .back-main-short { display: inline; }
}
@media (max-width: 599.98px) {
  header.nav .nav-links { flex-wrap: wrap; row-gap: 6px; }
  /* Every page shares one phone navigation: all four page links in a single row (the treatment the company
     race page introduced), so the current page sits in the same place on every page and the bar is one row
     shorter. Longer English labels take two lines inside their 44px target instead of a second row. */
  header.nav .nav-pages { flex: 1 0 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; }
  header.nav .nav-pages :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes) { justify-content: center; margin-left: 0;
    padding: 0 2px; text-align: center; white-space: normal; line-height: 1.15; }
  header.nav .nav-pages :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes)::after { left: 6px; right: 6px; }
  header.nav .nav-links .cta { margin-left: 0; }
  /* The top-right tool (GitHub) is absolutely placed; the identity row never runs underneath it. */
  header.nav:has(.source-link) .hn-id { max-width: calc(100% - var(--hn-h) - 8px); }
  header.nav .hn-lockup .brand { max-width: 100%; }
  header.nav .brand > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
}
/* Pages whose action row would hold nothing but the language link (Claude Streaks, ride rewards): on phones wide enough for it, the link takes the free right end of the identity row, the
   place the GitHub tool has on the other pages, instead of a row of its own. Narrower phones keep the row. */
@media (min-width: 360px) and (max-width: 599.98px) {
  header.nav:not(:has(.cta, .source-link, .background-effects, .rr-launch)) #lang-switch { position: absolute; top: 8px; right: var(--gutter); }
  header.nav:not(:has(.cta, .source-link, .background-effects, .rr-launch)) .hn-id { max-width: calc(100% - var(--hn-h) - 8px); }
}
/* Claude Streaks belongs to the heroes section: the Heroes link keeps its underline there. A visual cue only;
   aria-current stays on exact pages (ui/page-shell.mjs). */
body[data-page="claude-streak"] header.nav .nav-pages a.nav-heroes { color: var(--ink); }
body[data-page="claude-streak"] header.nav .nav-pages a.nav-heroes::after { transform: scaleX(1); opacity: .55; }
/* Forced colours drop the tinted background and underline bar, so the current page keeps a text underline. */
@media (forced-colors: active) {
  header.nav .nav-pages [aria-current="page"] { text-decoration: underline 2px; text-underline-offset: 6px; }
}

/* ---- effect menus: background (#background-effects) and number (#number-effects), side by side ---- */
/* Both share the .background-effects chip and menu; data-active colours the border while one paints.
   The tools never push the bar wider than the screen: in the two-row layout a row too narrow for every
   tool lets the last ones wrap to the right instead. */
@media (max-width: 1279.98px) {
  header.nav .nav-links { flex-wrap: wrap; justify-content: flex-end; row-gap: 6px; }
}
/* Phones: Join keeps its whole label; the two menus and the language link share its row. */
@media (max-width: 599.98px) {
  header.nav .nav-links .cta { min-width: max-content; }
  /* At 44px tall a full pill turns into an oval; match the square corners of Join and the language link. */
  header.nav .background-effects > summary { gap: 5px; padding: 0 9px; border-radius: 5px; }
}
/* 400px and below (360/390): the state word gives way, the border colour (data-active) still shows it. */
@media (max-width: 400px) {
  header.nav :is(#background-effects-state, #number-effects-state) { display: none; }
  header.nav .background-effects > summary { padding: 0 8px; }
}
/* The single wide row in English: the longer labels drop the state word until the row has room. */
@media (min-width: 1280px) and (max-width: 1439.98px) {
  header.nav:lang(en) :is(#background-effects-state, #number-effects-state) { display: none; }
}

/* ---- search result: position, previous / next, the pinned match; floats under the field ---- */
header.nav .user-search-result { position: absolute; top: calc(100% + 6px); left: 0; z-index: 3; display: flex; align-items: center; gap: 4px;
  width: max(100%, 280px); max-width: min(360px, calc(100vw - 2 * var(--gutter))); padding: 4px; border: 1px solid var(--line); border-radius: 4px;
  background: #0b130d; box-shadow: 0 8px 24px #0008; font: 12px/1.3 var(--mono); }
header.nav .user-search-result[hidden] { display: none; }
header.nav .user-search-result button { flex: none; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--line);
  border-radius: 4px; background: var(--panel); color: var(--accent); font: 16px/1 var(--mono); cursor: pointer; }
header.nav .user-search-result button:disabled { color: var(--ink-3); cursor: default; }
header.nav .user-search-result .us-close { margin-left: auto; color: var(--ink-2); border-color: transparent; }
header.nav .us-where { min-width: 3.6em; color: var(--accent); text-align: center; font-variant-numeric: tabular-nums; }
header.nav .us-who { flex: 1; min-width: 0; overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; }
header.nav .us-who::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 5px; vertical-align: -1px; background: var(--mint);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6 1.5h4l-.6 4.2 2.6 2.3v1.5H8.7L8 14.5l-.7-5H4V8l2.6-2.3z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6 1.5h4l-.6 4.2 2.6 2.3v1.5H8.7L8 14.5l-.7-5H4V8l2.6-2.3z'/%3E%3C/svg%3E") center / contain no-repeat; }
/* While the bar shows, the status line is for screen readers only (it repeats the bar). */
header.nav .user-search[data-results] .user-search-status { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; white-space: nowrap; }
@media (pointer: coarse), (max-width: 759.98px) {
  header.nav .user-search-result button { width: 44px; height: 44px; }
  header.nav .user-search-result { width: 100%; max-width: none; }
}

@media (max-width: 599.98px) { header.nav .nav-pages a { font-size: 12px; overflow-wrap: anywhere; } }
@media (max-width: 599.98px) { header.nav:lang(en) .nav-pages a { font-size: 11px; letter-spacing: -.01em; } }

/* ---- page-link icons: Speed Ladder, Company race, Site Stats, Heroes ----
   Each of the four page links draws its icon in ::before (::after stays the underline): a masked
   16-unit SVG painted in --nav-ico-c, so the markup, IDs, routes, aria-current and the data-i18n /
   data-rr-i18n labels (runtime textContent) are untouched and the icon never enters the link's name.
   Other icons use one short pass on hover (hover-capable pointers only), on keyboard
   :focus-visible, and on a touch or pen press (data-nav-press, ui/nav-motion.mjs, so a quick tap still
   plays it while the browser follows the link). Transform, mask/background position only: no layout.
   Held still, static cues only, by prefers-reduced-motion (header rule above), Number effects → Off
   (.nav-pages[data-nav-still], ui/nav-motion.mjs), the ladder's Pause and the header FX-off hook. */
header.nav .nav-pages {
  --nav-ico: 15px; --nav-ico-gap: 6px;
  --nav-ico-rest: #5cbf89; --nav-ico-on: var(--accent); --nav-ico-glint: #eafff2;
  --nav-ico-c: var(--nav-ico-rest);
}
header.nav .nav-pages :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes) {
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
header.nav .nav-pages :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes)::before {
  content: ""; flex: none; box-sizing: border-box; width: 1em; height: 1em; margin-right: var(--nav-ico-gap);
  font-size: var(--nav-ico);
  background: none no-repeat var(--nav-ico-c);
  -webkit-mask-image: var(--nav-ico-mask); -webkit-mask-position: 0 0; -webkit-mask-size: 100% 100%; -webkit-mask-repeat: no-repeat;
  mask-image: var(--nav-ico-mask); mask-position: 0 0; mask-size: 100% 100%; mask-repeat: no-repeat;
  transition: background-color .15s;
}
/* Speed Ladder: reserve the static bicycle in the first paint, then use the SVG from nav-motion.mjs. */
header.nav .nav-pages a.nav-ladder {
  --nav-ico-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg fill='none' stroke='black' stroke-width='1.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='3.5' cy='11.3' r='2.6'/%3E%3Ccircle cx='12.5' cy='11.3' r='2.6'/%3E%3Cpath d='M3.5 11.3 6.4 6.3l2.25 5H3.5m5.15 0 2.2-5H6.4m6.1 5L10.2 4.1h2.3M5.2 5.25h2'/%3E%3C/g%3E%3C/svg%3E");
}
header.nav .nav-pages a.nav-ladder:has(.nav-bike)::before { content: none; }
header.nav .nav-pages .nav-bike {
  flex: none; inline-size: var(--nav-ico); block-size: var(--nav-ico);
  margin-right: var(--nav-ico-gap); color: var(--nav-ico-c);
}
header.nav .nav-pages .nav-bike-wheel {
  transform-box: fill-box; transform-origin: center;
}
@media (prefers-reduced-motion: no-preference) {
  header.nav .nav-pages a.nav-ladder:is(:focus-visible, [data-nav-press]) .nav-bike-wheel {
    animation: nav-bike-roll .56s linear;
  }
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  header.nav .nav-pages a.nav-ladder:hover .nav-bike-wheel {
    animation: nav-bike-roll .5s linear infinite;
  }
}
header.nav .nav-pages[data-nav-still] .nav-bike-wheel,
html[data-presentation-paused] header.nav .nav-pages .nav-bike-wheel,
header.nav:has(#fx-toggle[aria-pressed="false"]) .nav-pages .nav-bike-wheel { animation: none !important; }
@media (forced-colors: active) {
  header.nav .nav-pages .nav-bike { forced-color-adjust: none; color: LinkText; }
}
@keyframes nav-bike-roll {
  to { transform: rotate(1turn); }
}
/* Company race: a checkered flag on its pole. Motion "flutter": the flag snaps and settles about the pole. */
header.nav .nav-pages a.nav-companies {
  --nav-ico-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1.75 1h1.5v14h-1.5z'/%3E%3Cpath fill-rule='evenodd' d='M3.25 1.75h11v8h-11zM4.5 3v5.5H13V3z'/%3E%3Cpath d='M4.5 3h2.83v2.75H4.5zM10.17 3H13v2.75h-2.83zM7.33 5.75h2.84V8.5H7.33z'/%3E%3C/svg%3E");
  --nav-ico-motion: nav-ico-flutter .52s;
}
header.nav .nav-pages a.nav-companies::before { transform-origin: 16% 50%; }
/* Site Stats: three bars on a baseline, four mask layers. Motion "tally": the bars dip into the baseline
   and spring back one after another, left to right. The content box clips what dips below the baseline. */
header.nav .nav-pages a.nav-stats {
  --nav-ico-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1 12.5h14V14H1z'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 7.5h2.75v5H2z'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6.63 2h2.75v10.5H6.63z'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M11.25 5H14v7.5h-2.75z'/%3E%3C/svg%3E");
  --nav-ico-motion: nav-ico-tally .6s;
}
header.nav .nav-pages a.nav-stats::before {
  padding-bottom: .125em; -webkit-mask-clip: content-box; mask-clip: content-box;
  -webkit-mask-origin: border-box; mask-origin: border-box;
}
/* Heroes: a three-point crown over its band. Motion "crown": a short lift and tilt while a glint crosses it. */
header.nav .nav-pages a.nav-heroes {
  --nav-ico-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 11V5.25l3.4 3.1L8 3.5l2.6 4.85L14 5.25V11z'/%3E%3Ccircle cx='2' cy='4.25' r='1.15'/%3E%3Ccircle cx='8' cy='2.6' r='1.15'/%3E%3Ccircle cx='14' cy='4.25' r='1.15'/%3E%3Cpath d='M2 12.25h12v2.25H2z'/%3E%3C/svg%3E");
  --nav-ico-motion: nav-ico-crown .56s;
}
header.nav .nav-pages a.nav-heroes::before {
  transform-origin: 50% 90%;
  background-image: linear-gradient(120deg, transparent 40%, var(--nav-ico-glint) 50%, transparent 60%);
  background-size: 300% 300%; background-position: 100% 100%;
}

/* States. The icon lights on the current page, hover, keyboard focus and press; Claude Streaks keeps the
   Heroes section cue (underline at .55, see above) with a half-lit crown. */
header.nav .nav-pages [aria-current="page"] { --nav-ico-c: var(--nav-ico-on); }
:where(body[data-page="claude-streak"]) header.nav .nav-pages a.nav-heroes { --nav-ico-c: #4bd986; }
header.nav .nav-pages :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes):is(:focus-visible, :active, [data-nav-press]) { --nav-ico-c: var(--nav-ico-on); color: var(--ink); }
header.nav .nav-pages :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes):focus-visible::after { transform: scaleX(1); }
/* Pressed: a static cue that appears at once under the finger and fades out on release; it is the whole
   feedback when motion is held still. */
header.nav .nav-pages :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes):is(:active, [data-nav-press]) {
  background-color: rgba(57, 255, 136, .12); box-shadow: inset 0 0 0 1px rgba(57, 255, 136, .3); transition: none; }
header.nav .nav-pages :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes):is(:active, [data-nav-press])::before { transition: none; }
header.nav .nav-pages :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes):is(:active, [data-nav-press])::after { transform: scaleX(1); transition: none; }
@media (hover: hover) {
  header.nav .nav-pages :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes):hover { --nav-ico-c: var(--nav-ico-on); }
  header.nav .nav-pages :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes):hover::before { animation: var(--nav-ico-motion); }
}
header.nav .nav-pages :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes):is(:focus-visible, [data-nav-press])::before { animation: var(--nav-ico-motion); }
/* Held still: no animation and no transition on the links or their icon and underline; hover, focus and
   press keep their static cues. data-nav-still follows the visitor's Number effects → Off on every page
   (ui/nav-motion.mjs); Background effects stay independent of it. The ladder's Pause is per page and not
   stored. The FX-off hook has its own rule (:has() must not drop the others where unsupported). */
header.nav .nav-pages[data-nav-still] a, header.nav .nav-pages[data-nav-still] a::before, header.nav .nav-pages[data-nav-still] a::after,
html[data-presentation-paused] header.nav .nav-pages a, html[data-presentation-paused] header.nav .nav-pages a::before,
html[data-presentation-paused] header.nav .nav-pages a::after { animation: none !important; transition: none !important; }
header.nav:has(#fx-toggle[aria-pressed="false"]) .nav-pages a, header.nav:has(#fx-toggle[aria-pressed="false"]) .nav-pages a::before,
header.nav:has(#fx-toggle[aria-pressed="false"]) .nav-pages a::after { animation: none !important; transition: none !important; }

@keyframes nav-ico-flutter {
  0% { transform: none; animation-timing-function: cubic-bezier(.2, .7, .4, 1); }
  22% { transform: skewY(-14deg); animation-timing-function: ease-in-out; }
  48% { transform: skewY(9deg); animation-timing-function: ease-in-out; }
  74% { transform: skewY(-3.5deg); animation-timing-function: ease-out; }
  100% { transform: none; }
}
@keyframes nav-ico-tally {
  0% { -webkit-mask-position: 0 0, 0 0, 0 0, 0 0; mask-position: 0 0, 0 0, 0 0, 0 0; }
  18% { -webkit-mask-position: 0 0, 0 .28em, 0 .1em, 0 0; mask-position: 0 0, 0 .28em, 0 .1em, 0 0; }
  38% { -webkit-mask-position: 0 0, 0 -.06em, 0 .5em, 0 .2em; mask-position: 0 0, 0 -.06em, 0 .5em, 0 .2em; }
  58% { -webkit-mask-position: 0 0, 0 0, 0 -.06em, 0 .38em; mask-position: 0 0, 0 0, 0 -.06em, 0 .38em; }
  78% { -webkit-mask-position: 0 0, 0 0, 0 0, 0 -.05em; mask-position: 0 0, 0 0, 0 0, 0 -.05em; }
  100% { -webkit-mask-position: 0 0, 0 0, 0 0, 0 0; mask-position: 0 0, 0 0, 0 0, 0 0; }
}
@keyframes nav-ico-crown {
  0% { transform: none; background-position: 100% 100%; animation-timing-function: cubic-bezier(.2, .7, .4, 1); }
  32% { transform: translateY(-.1em) rotate(-9deg) scale(1.14); animation-timing-function: ease-in-out; }
  64% { transform: rotate(3deg) scale(.98); }
  100% { transform: none; background-position: 0 0; }
}

/* Desktop and tablet: the icon now separates the links, so their side padding narrows (10px to 7px) and the
   icons cost the bar about 60px, not 84px. Even rhythm in the two-row bar: the older -10px pull on Site Stats
   would sit its icon against "Company race". */
@media (min-width: 600px) {
  header.nav .nav-pages :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes) { padding: 0 7px; }
  header.nav .nav-pages :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes)::after { left: 7px; right: 7px; }
}
@media (min-width: 600px) and (max-width: 1279.98px) {
  header.nav .nav-pages { --nav-ico: 14px; --nav-ico-gap: 5px; }
  header.nav .nav-pages :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes) { padding: 0 6px; }
  header.nav .nav-pages :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes)::after { left: 6px; right: 6px; }
  header.nav .nav-pages a.nav-stats { margin-left: 0; }
}
/* The English ladder keeps the medium-desktop two-row header (1280–1599.98px, above) through 1879.98px:
   its single row needs about 1880px once the icons, a live clock, a signed-in name (the launcher's 190px
   cap) and a classic scrollbar are all present. Same rules as the medium layout, English ladder only. */
@media (min-width: 1600px) and (max-width: 1879.98px) {
  body[data-page="ladder"] header.nav:lang(en) { position: relative; grid-template-columns: max-content minmax(240px, 1fr); row-gap: 8px; }
  body[data-page="ladder"] header.nav:lang(en) .user-search { justify-self: end; }
  body[data-page="ladder"] header.nav:lang(en) .nav-links { grid-column: 1 / -1; justify-self: stretch; justify-content: flex-end; }
}
/* Phones keep all four links in one row: a smaller icon beside the label inside each 44px target. */
@media (max-width: 599.98px) {
  header.nav .nav-pages { --nav-ico: 14px; --nav-ico-gap: 4px; }
}
@media (max-width: 380px) {
  header.nav .nav-pages { --nav-ico: 13px; --nav-ico-gap: 3px; }
}
@media (forced-colors: active) {
  header.nav .nav-pages :is(a.nav-ladder, a.nav-companies, a.nav-stats, a.nav-heroes)::before { forced-color-adjust: none; background: LinkText; }
}

/* ---- Join (#join-open): a dark raised key, not a solid neon block ----
   Near-black green face with a soft top light, a crisp green hairline, light text and one small green
   "rank up" icon (two chevrons, the lower one dimmer) drawn in ::before as a masked SVG, so the
   data-i18n label (runtime textContent), the ID and the dialog wiring are untouched and the icon never
   enters the button's name. The ID outranks every generic .cta state, so the margin and the phone padding
   are restated here per layout. One short pass, never a loop: on hover (hover-capable pointers) and
   keyboard :focus-visible the lower chevron pushes up and the upper takes the step. Press is a static
   cue (sinks 1px, deeper face). Held still, static cues only, by prefers-reduced-motion (header rule
   above), Number effects → Off (.nav-pages[data-nav-still] sibling), the ladder's Pause and FX off. */
header.nav .nav-links #join-open {
  --join-ico: 13px; --join-gap: 6px;
  gap: var(--join-gap); padding: 0 11px 0 9px;
  border: 1px solid rgba(57, 255, 136, .42); border-radius: 5px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(0, 0, 0, .2)) #0f1f15;
  color: var(--ink); font-weight: 650; letter-spacing: .01em;
  box-shadow: inset 0 1px 0 rgba(150, 255, 195, .1), 0 1px 0 rgba(0, 0, 0, .55), 0 4px 12px -7px rgba(0, 0, 0, .9);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: border-color .15s, background-color .15s, color .15s, box-shadow .15s;
}
header.nav .nav-links #join-open::before {
  content: ""; flex: none; width: 1em; height: 1em; font-size: var(--join-ico);
  background: var(--accent);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1.6l5.6 5.6-1.4 1.4L8 4.4 3.8 8.6 2.4 7.2z'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill-opacity='.6' d='M8 7.4l5.6 5.6-1.4 1.4L8 10.2l-4.2 4.2L2.4 13z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1.6l5.6 5.6-1.4 1.4L8 4.4 3.8 8.6 2.4 7.2z'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill-opacity='.6' d='M8 7.4l5.6 5.6-1.4 1.4L8 10.2l-4.2 4.2L2.4 13z'/%3E%3C/svg%3E");
  -webkit-mask-position: 0 0, 0 0; -webkit-mask-size: 100% 100%; -webkit-mask-repeat: no-repeat;
  mask-position: 0 0, 0 0; mask-size: 100% 100%; mask-repeat: no-repeat;
}
header.nav .nav-links #join-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
header.nav .nav-links #join-open:is(:focus-visible, :active) { border-color: rgba(57, 255, 136, .8); color: #f2fff7; }
header.nav .nav-links #join-open:focus-visible::before { animation: join-rank-up .5s; }
@media (hover: hover) {
  header.nav .nav-links #join-open:hover { border-color: rgba(57, 255, 136, .8); background-color: #14291b; color: #f2fff7;
    box-shadow: inset 0 1px 0 rgba(150, 255, 195, .14), 0 1px 0 rgba(0, 0, 0, .55), 0 5px 14px -9px rgba(57, 255, 136, .3); }
  header.nav .nav-links #join-open:hover::before { animation: join-rank-up .5s; }
}
header.nav .nav-links #join-open:active { transform: translateY(1px); background-color: #0a150e;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .65); transition: none; }
header.nav .nav-pages[data-nav-still] ~ #join-open, header.nav .nav-pages[data-nav-still] ~ #join-open::before,
html[data-presentation-paused] header.nav #join-open, html[data-presentation-paused] header.nav #join-open::before { animation: none !important; transition: none !important; }
header.nav:has(#fx-toggle[aria-pressed="false"]) #join-open, header.nav:has(#fx-toggle[aria-pressed="false"]) #join-open::before { animation: none !important; transition: none !important; }
@keyframes join-rank-up {
  0% { -webkit-mask-position: 0 0, 0 0; mask-position: 0 0, 0 0; animation-timing-function: cubic-bezier(.3, .6, .4, 1); }
  30% { -webkit-mask-position: 0 0, 0 -.14em; mask-position: 0 0, 0 -.14em; }
  56% { -webkit-mask-position: 0 -.1em, 0 -.03em; mask-position: 0 -.1em, 0 -.03em; }
  80% { -webkit-mask-position: 0 .02em, 0 .01em; mask-position: 0 .02em, 0 .01em; }
  100% { -webkit-mask-position: 0 0, 0 0; mask-position: 0 0, 0 0; }
}
/* The icon costs about 4px over the old 16px sides; the single desktop row (the 1880px English ladder edge)
   takes 2px of it back from the gap to Radar sign-in. Two-row and phone bars keep their own margins. */
@media (min-width: 1280px) { header.nav .nav-links #join-open { margin-left: 4px; } }
@media (max-width: 599.98px) { header.nav .nav-links #join-open { padding: 0 12px 0 10px; } }
@media (max-width: 380px) { header.nav .nav-links #join-open { --join-gap: 5px; padding: 0 8px 0 7px; } }
@media (forced-colors: active) {
  header.nav .nav-links #join-open { border-color: ButtonText; }
  header.nav .nav-links #join-open::before { forced-color-adjust: none; background: ButtonText; }
}

/* ---- phones: the language link beside the identity; the action row holds actions (#388) ----
   On the four board pages the language link leaves the action row for the free right end of the identity
   row: left of the GitHub tool where the page has one, else the corner (as on Claude Streaks). Before, the
   ladder's action row (Radar sign-in, Join, both effect menus, language) always overflowed and left the
   language link alone on a third row, in Chinese and English, from 360 to 430px. Now the Chinese ladder keeps
   one action row on 375px and wider phones while signed out. Where the row must still wrap (English labels,
   narrower phones, a signed-in name) the two effect menus share their own row in equal halves instead of one
   hanging off the right end. Static layout only: same DOM and focus order, same 44px targets, no motion.
   Below 360px the identity row has no room for a second tool, so the older layout stays. */
@media (min-width: 360px) and (max-width: 599.98px) {
  body:is([data-page="ladder"], [data-page="stats"], [data-page="heroes"], [data-page="companies"]) header.nav #lang-switch {
    position: absolute; top: 8px; right: var(--gutter); margin: 0; }
  body:is([data-page="ladder"], [data-page="stats"], [data-page="heroes"], [data-page="companies"]) header.nav .hn-id {
    max-width: calc(100% - var(--hn-h) - 8px); }
  body:is([data-page="ladder"], [data-page="stats"], [data-page="heroes"], [data-page="companies"]) header.nav:has(.source-link) #lang-switch {
    right: calc(var(--gutter) + var(--hn-h) + 4px); }
  body:is([data-page="ladder"], [data-page="stats"], [data-page="heroes"], [data-page="companies"]) header.nav:has(.source-link) .hn-id {
    max-width: calc(100% - 2 * var(--hn-h) - 10px); }
  /* Ladder: the effect menus fill whatever row they land on; their label stays centred. */
  body[data-page="ladder"] header.nav .nav-links .background-effects { flex: 1 1 auto; }
  body[data-page="ladder"] header.nav .background-effects > summary { justify-content: center; padding: 0 6px; }
  /* Rows that cannot hold all four: both menus on their own row, half each (the 4px or 2px gap included);
     Join takes at least half of the row above, so a short label (English "Join in") never lets one menu
     squeeze in beside it and leave the other alone. */
  body[data-page="ladder"] header.nav:lang(en) .nav-links .background-effects,
  body[data-page="ladder"] header.nav .nav-links:has(.rr-launch-avatar:not([hidden])) .background-effects { flex: 1 1 calc(50% - 2px); }
  body[data-page="ladder"] header.nav:lang(en) .nav-links #join-open,
  body[data-page="ladder"] header.nav .nav-links:has(.rr-launch-avatar:not([hidden])) #join-open { flex-basis: 50%; }
}
/* Up to 430px the state word yields, as it already does at 400px; the data-active border colour still shows it. */
@media (min-width: 360px) and (max-width: 429.98px) {
  body[data-page="ladder"] header.nav :is(#background-effects-state, #number-effects-state) { display: none; }
}
@media (min-width: 360px) and (max-width: 374.98px) {
  body[data-page="ladder"] header.nav .nav-links:has(.rr-launch) .background-effects { flex: 1 1 calc(50% - 2px); }
  body[data-page="ladder"] header.nav .nav-links:has(.rr-launch) #join-open { flex-basis: 50%; }
}
