/* The site header — one stylesheet for every surface.
 *
 * The SPA's `impls/best/src/Header.svelte` and the generated static pages
 * (`~/llmrank/web/{template,deepseek}.html` via `siteparts.py`) render the same
 * markup and read this file, so the bar, the brand and the nav cannot drift
 * apart. Only the header lives here; page layout stays with its page.
 *
 * Markup:
 *   <header class="bar">
 *     <a class="skip" href="#main">Skip to content</a>
 *     <div class="inner">
 *       <div class="lead"> <a class="brand">…</a> <button class="icon" id="theme"></button> </div>
 *       <nav class="wide">…</nav>
 *       <div class="tools"><a class="cta" href="/#contact">Contact</a></div>
 *     </div>
 *   </header>
 */

.bar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  transition: box-shadow .18s ease;
}
.bar.scrolled { box-shadow: 0 6px 18px rgb(15 23 42 / .07); }
:root[data-theme="dark"] .bar.scrolled { box-shadow: 0 6px 18px rgb(0 0 0 / .45); }
.bar .skip {
  position: fixed; left: .75rem; top: .75rem; z-index: 30;
  padding: .5rem .9rem; border-radius: .5rem; text-decoration: none;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  font-size: .9rem; font-weight: 600;
  box-shadow: 0 6px 18px rgb(15 23 42 / .18);
  transform: translateY(calc(-1 * (var(--bar-h) + 1.5rem)));
  transition: transform .15s ease;
}
.bar .skip:focus-visible { transform: none; }
.bar .inner {
  display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1.25rem;
  max-width: 64rem; margin: 0 auto; min-height: var(--bar-h);
  padding: .5rem clamp(1rem, 3vw, 2.5rem);
}
.bar .lead { display: flex; align-items: center; gap: .5rem; }
.bar .brand {
  display: flex; align-items: center; gap: .5rem;
  color: var(--ink); text-decoration: none; font-weight: 700;
}
.bar .mark {
  display: grid; place-items: center; width: 1.9rem; height: 1.9rem;
  border-radius: .5rem; background: var(--accent); color: #fff; font-size: .72rem;
}
.bar .word em { font-style: normal; color: var(--accent-2); }
.bar nav.wide { display: flex; gap: .25rem; margin-left: auto; }
/* `nowrap`: the labels are short, so wrapping them inside their own pill
 * reads as broken text rather than a compact row. The row itself wraps. */
.bar nav a {
  padding: .4rem .7rem; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-size: .92rem;
  white-space: nowrap;
}
.bar nav a:hover, .bar nav a.on, .bar nav a[aria-current="page"] {
  color: var(--ink); background: var(--chip);
}
.bar .tools { display: flex; gap: .5rem; align-items: center; }
.bar .icon, .bar .cta {
  display: inline-flex; align-items: center; justify-content: center;
  height: 2.25rem; font: inherit; cursor: pointer; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
}
.bar .icon { width: 2.25rem; padding: 0; border: 0; background: transparent; color: var(--muted); }
/* Plain line icons drawn as a mask, so they take the button's colour and need
 * no font. The icon follows the theme the document is in. */
.bar .icon::before {
  content: ""; width: 1.05rem; height: 1.05rem; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z'/%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 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z'/%3E%3C/svg%3E") center / contain no-repeat;
}
:root[data-theme="dark"] .bar .icon::before {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4'/%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 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4'/%3E%3C/svg%3E") center / contain no-repeat;
}
.bar .icon:hover { color: var(--ink); }
.bar .cta {
  padding: 0 .95rem; background: var(--accent); color: #fff;
  border-color: transparent; font-weight: 600; text-decoration: none;
}
.bar .cta:hover { filter: brightness(1.06); }

/* Half-width windows: tighten the row so the CTA stays beside the nav instead
 * of dropping alone onto a second line. */
@media (max-width: 760px) {
  .bar .inner { gap: .4rem .6rem; padding: .5rem clamp(.75rem, 2.5vw, 1.25rem); flex-wrap: nowrap; }
  .bar .lead, .bar .tools { flex: 0 0 auto; }
  .bar nav.wide { min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .bar nav.wide::-webkit-scrollbar { display: none; }
  .bar .mark { width: 1.7rem; height: 1.7rem; }
  .bar .word { font-size: .95rem; }
  .bar nav a { padding: .4rem .5rem; font-size: .85rem; }
  .bar .icon, .bar .cta { height: 2.1rem; }
  .bar .cta { padding: 0 .7rem; }
}

/* Below this the row cannot hold brand + nav + CTA even compacted: the nav
 * takes its own line (and Contact stays with the brand), rather than the CTA
 * dropping alone. */
@media (max-width: 520px) {
  :root { --bar-h: 6.5rem; }
}
/* No burger: the row simply wraps when it cannot hold brand + nav + tools
 * (only the smallest phones), rather than hiding the nav behind a toggle. */
@media (max-width: 520px) {
  .bar .inner { gap: .5rem; flex-wrap: wrap; }
  .bar .word { font-size: .95rem; }
  .bar .tools { order: 2; margin-left: auto; }
  /* The destinations plus the brand and the CTA no longer fit one phone row:
   * the nav takes its own line and scrolls sideways if it has to. */
  .bar nav.wide {
    order: 3; width: 100%; margin-left: 0; gap: .1rem;
    overflow-x: auto; scrollbar-width: none;
  }
  .bar nav.wide::-webkit-scrollbar { display: none; }
  .bar nav a { padding: .4rem .5rem; font-size: .85rem; }
}

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