/*
 * The shared header — one component, used by every page of every one of these projects.
 *
 * Structure and class names are the ones AvaDevTools uses, so the two sites read as the same product
 * family: brand and the page's own links on the left, feedback and the outbound icons pushed to the
 * right. Nothing here names a colour. Every value comes from a custom property the host stylesheet
 * defines, which is why the identical markup renders in this site's green palette and in AvaDevTools'
 * blue one without a fork.
 *
 * Required from the host: --bg-alt --panel --line --text --dim --accent.
 *
 * Header geometry belongs here, independently of the content below it. Home, guides and API pages use
 * different content widths; letting them set the header width or height makes navigation jump between
 * pages. --bar is also available to the page's sticky panels and anchor offsets.
 *
 * The feedback popup is a <details>. Disclosure is something HTML already does, so the header needs no
 * script, including from a file:// URL.
 */

:root { --bar: 58px; }

/* A short page and a long page must centre the header on the same available width. */
html { scrollbar-gutter: stable; }

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.bar .nav {
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--bar);
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 28px;
}

.brand {
  display: flex;
  align-items: center;
  font-weight: 650;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

/* No gap on .brand — a name split across two spans is one word, and a gap would put a space inside it.
   The dot, where a site uses one, carries its own margin. */
.brand .dot {
  width: 10px;
  height: 10px;
  margin-right: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.brand span { color: var(--accent); }

.tag {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}

/* Direct children only. The popup hanging off the feedback button is full of prose that has to wrap,
   and it lives inside .links — so a descendant selector here would set nowrap on it and push it off
   the side of the screen. */
.bar .links { display: flex; align-items: center; gap: 18px; }
.bar .links > a { color: var(--dim); text-decoration: none; font-size: 13.5px; white-space: nowrap; }
.bar .links > a:hover { color: var(--text); }

.bar .tools { margin-left: auto; gap: 14px; }

.nav-ico { display: flex; align-items: center; color: var(--dim); }
.nav-ico svg { width: 18px; height: 18px; fill: currentColor; }
.nav-ico:hover { color: var(--text); }

/* ---- feedback ---- */

.fb { position: relative; }

.fb > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: 4px 12px;
  font-size: 13px;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.fb > summary::-webkit-details-marker { display: none; }
.fb > summary:hover, .fb[open] > summary { color: var(--text); border-color: var(--accent); }

.fb-pop {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 30;
  width: 274px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgb(0 0 0 / 35%);
}

.fb-pop a {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px 10px;
  border-radius: 7px;
  color: var(--text);
  font-size: 13.5px;
  text-decoration: none;
}

.fb-pop a:hover { background: var(--bg-alt); }
.fb-pop a > span { min-width: 0; }
.fb-pop svg { width: 17px; height: 17px; fill: var(--dim); flex: none; margin-top: 2px; }
.fb-pop a:hover svg { fill: var(--accent); }
.fb-pop b { display: block; font-weight: 600; line-height: 1.35; }
.fb-pop small { display: block; margin-top: 1px; color: var(--dim); font-size: 12px; line-height: 1.45; }

/* ---- narrow ----
   The page links drop to their own row; the brand and the outbound links stay on the first one, because
   those are the two things worth reaching without thinking. */

/* The same breakpoint and anchor offset apply on every page. */

@media (max-width: 860px) {
  :root { --bar: 96px; }
  .bar .nav { flex-wrap: wrap; height: auto; padding: 10px 16px; row-gap: 10px; }
  /* The centring is what a narrow screen has no room for: below this width the content column is the
     window, so the max-width would only take the padding back off again. */
  .bar .links:not(.tools) { order: 1; width: 100%; gap: 16px; flex-wrap: wrap; row-gap: 8px; }
  .fb-pop { width: min(274px, calc(100vw - 32px)); }
}
