/* =====================================================================
   Site header — the floating island (HQ-1868, navbar-design skill).

   Self-contained: loaded on every shared-chrome page after the page's own
   stylesheets, it carries its own tokens and font (Geist, linked by every
   chrome page) so the header looks the same on the v1-skinned pages
   (styles.css) and the v2 pages (toys.css). The toy pages builds/<slug>/
   do not load it. Markup: partials/site-head.html. Behaviour: js/nav.js.

   Desktop: one dark island floating 12px below the top edge, centred —
   brand tile, three links, one lemon CTA. The current page is a filled putty
   key. Buttons share the --t-r-btn radius; the island is concentric with them.
   Below 760px the island spans the gutter and shows brand + «Menu»; the
   menu button (unhidden by nav.js) grows the island into a rounded sheet
   with big links and the CTA at the bottom. Without JavaScript the button
   stays hidden and the links sit in a second, scrollable row.

   «New» key and desk card (UX run-01, js/desk.js): a quiet key with a mint
   dot right after the brand; with news a mint count bubble sits on its
   corner (absolute, so the island never changes width). It opens one small
   dark card that hangs 8px under the island (left-aligned on desktop, full
   island width on phones, with a scrim): the newest items, mint «New» marks,
   «Mark all as read» and «All notes». Hidden when scripting is off.
   ===================================================================== */

:root {
  --nav-bg: #141414;
  --nav-ink: #f7f6f2;
  --nav-ink-2: rgba(247, 246, 242, 0.74);
  --nav-hover: rgba(247, 246, 242, 0.1);
  --nav-edge: rgba(255, 255, 255, 0.16);
  --nav-current: #ecebe6;
  --nav-lemon: #ffd23f;
  --nav-lemon-deep: #c79a00;
  --nav-cobalt: #2f55ff;
  --nav-cobalt-deep: #1a33b8;
  --nav-mint: #17c787;
  --nav-font: "Geist", ui-sans-serif, system-ui, sans-serif;
  --nav-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --nav-out: cubic-bezier(0.22, 1, 0.36, 1);
  --nav-top: 12px;
  --nav-h: 56px;
  /* Design-system button radius (DESIGN.md § Space, radius): every navbar
     button and the blog's Like / Boo / Share keys. Defined here because this
     is the one stylesheet every page loads. The island is concentric with its
     buttons: their radius plus its 6px padding. */
  --t-r-btn: 10px;
  --nav-pad: 6px;
  --nav-r: calc(var(--t-r-btn) + var(--nav-pad));
  /* Space a page reserves under the fixed header (styles.css and the page
     sheets read --header-h for body padding and scroll-padding). */
  --header-h: calc(var(--nav-top) + var(--nav-h) + 12px);
}

/* Only the v2 toys pages turn dark; there the island lifts off the dark
   putty. Light-only pages keep the ink island in dark mode. */
@media (prefers-color-scheme: dark) {
  body.v2 .site-head { --nav-bg: #262624; }
}

.site-head {
  position: fixed;
  inset: 0 0 auto;
  z-index: 60;
  padding: var(--nav-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  pointer-events: none;
  /* Reset the retired full-width bar styles (styles.css/page sheets). */
  height: auto;
  border: 0;
  background: none;
  backdrop-filter: none;
  color: var(--nav-ink);
  font-family: var(--nav-font);
}

.site-head .nav-island {
  position: relative;
  pointer-events: auto;
  width: max-content;
  max-width: 100%;
  min-height: var(--nav-h);
  margin: 0 auto;
  padding: var(--nav-pad);
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--nav-r);
  background: var(--nav-bg);
  /* Physical depth, not glass: a bottom lip plus a soft drop. */
  box-shadow:
    inset 0 0 0 1px var(--nav-edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -3px 0 rgba(0, 0, 0, 0.35),
    0 18px 36px -20px rgba(0, 0, 0, 0.55);
}

.site-head.is-scrolled .nav-island {
  box-shadow:
    inset 0 0 0 1px var(--nav-edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -3px 0 rgba(0, 0, 0, 0.35),
    0 22px 44px -18px rgba(0, 0, 0, 0.7);
}

.site-head a,
.site-head button {
  -webkit-tap-highlight-color: transparent;
}

.site-head a:focus-visible,
.site-head button:focus-visible {
  outline: 2px solid var(--nav-ink);
  outline-offset: 2px;
}

/* Brand: cobalt tile with a lip and a mint «online» dot. */
.site-head .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px 0 4px;
  border-radius: var(--t-r-btn);
  color: var(--nav-ink);
  font: 700 18px/1 var(--nav-font);
  font-variation-settings: "wdth" 92, "opsz" 24;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.site-head .brand-mark {
  position: relative;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  /* Concentric with the brand button: its radius minus the 4px the tile sits inside it. */
  border-radius: calc(var(--t-r-btn) - 4px);
  background: var(--nav-cobalt);
  color: #ffffff;
  box-shadow: inset 0 -4px 0 var(--nav-cobalt-deep);
  font: 800 20px/1 var(--nav-font);
  font-variation-settings: "wdth" 88, "opsz" 48;
}

.site-head .brand-live {
  position: absolute;
  right: -3px;
  bottom: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--nav-mint);
  box-shadow: 0 0 0 2.5px var(--nav-bg);
}

.site-head .site-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.site-head .nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-head .nav-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--t-r-btn);
  color: var(--nav-ink-2);
  font: 600 15px/1 var(--nav-font);
  font-variation-settings: "wdth" 96, "opsz" 16;
  text-decoration: none;
  white-space: nowrap;
}

.site-head .nav-links a:hover {
  color: var(--nav-ink);
  background: var(--nav-hover);
}

.site-head .nav-links a[aria-current="page"] {
  color: #141414;
  background: var(--nav-current);
}

.site-head .nav-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-left: 4px;
  padding: 0 20px 2px;
  border-radius: var(--t-r-btn);
  color: #141414;
  background: var(--nav-lemon);
  box-shadow: inset 0 -3px 0 var(--nav-lemon-deep);
  font: 700 15px/1 var(--nav-font);
  font-variation-settings: "wdth" 96, "opsz" 16;
  text-decoration: none;
  white-space: nowrap;
}

/* Higher specificity than the retired styles.css .nav-cta hover. */
.site-head .nav-cta:hover,
.site-head .nav-cta:focus-visible {
  color: #141414;
  background: #ffdc66;
  box-shadow: inset 0 -3px 0 var(--nav-lemon-deep);
}

.site-head .nav-cta:active {
  box-shadow: inset 0 -1px 0 var(--nav-lemon-deep);
}

/* Menu button: hidden unless nav.js runs and the viewport is narrow. */
.site-head .nav-toggle {
  display: none;
  align-items: center;
  gap: 10px;
  min-width: 44px;
  min-height: 44px;
  margin-left: auto;
  padding: 0 16px;
  border: 0;
  border-radius: var(--t-r-btn);
  color: var(--nav-ink);
  background: var(--nav-hover);
  font: 600 15px/1 var(--nav-font);
  cursor: pointer;
}

.site-head .nav-toggle-icon {
  position: relative;
  width: 16px;
  height: 10px;
}

.site-head .nav-toggle-icon i {
  position: absolute;
  left: 0;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.site-head .nav-toggle-icon i:first-child { top: 0; }
.site-head .nav-toggle-icon i:last-child { bottom: 0; }

.site-head.is-open .nav-toggle-icon i:first-child { top: 4px; transform: rotate(45deg); }
.site-head.is-open .nav-toggle-icon i:last-child { bottom: 4px; transform: rotate(-45deg); }

@media (prefers-reduced-motion: no-preference) {
  .site-head .nav-links a,
  .site-head .nav-toggle { transition: color 240ms ease, background-color 240ms ease; }
  .site-head .nav-cta { transition: transform 450ms var(--nav-spring), box-shadow 120ms ease, background-color 240ms ease; }
  .site-head .nav-cta:hover { transform: translateY(-1px); }
  .site-head .nav-cta:active { transform: translateY(1px); transition-duration: 120ms; }
  .site-head .nav-island { transition: box-shadow 240ms ease, border-radius 450ms var(--nav-out); }
  .site-head .nav-toggle-icon i { transition: transform 240ms var(--nav-out), top 240ms var(--nav-out), bottom 240ms var(--nav-out); }
  .site-head .brand-live { animation: nav-live 1.6s ease-in-out 3; }
  @keyframes nav-live {
    50% { box-shadow: 0 0 0 2.5px var(--nav-bg), 0 0 0 6px rgba(23, 199, 135, 0.35); }
  }
}

/* ---- «New» key and the desk card (js/desk.js) ---------------------------- */
.site-head .desk-key {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px 0 12px;
  border: 0;
  border-radius: var(--t-r-btn);
  color: var(--nav-ink);
  background: var(--nav-hover);
  font: 600 15px/1 var(--nav-font);
  font-variation-settings: "wdth" 96, "opsz" 16;
  white-space: nowrap;
  cursor: pointer;
}

.site-head .desk-key::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--nav-mint);
  flex: none;
}

.site-head .desk-key:hover,
.site-head .desk-key[aria-expanded="true"] {
  color: #141414;
  background: var(--nav-current);
}

.site-head .desk-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.site-head .desk-count {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #141414;
  background: var(--nav-mint);
  box-shadow: 0 0 0 2.5px var(--nav-bg), inset 0 -2px 0 #0b8a5b;
  font: 800 12px/1 var(--nav-font);
  font-variant-numeric: tabular-nums;
}

.site-head .desk-count[hidden] { display: none; }

@media (scripting: none) {
  .site-head .desk-key { display: none; }
}

.site-head .desk-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: min(400px, calc(100vw - 24px));
  max-height: calc(100vh - var(--nav-top) - var(--nav-h) - 32px);
  max-height: calc(100dvh - var(--nav-top) - var(--nav-h) - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--nav-r);
  background: var(--nav-bg);
  color: var(--nav-ink);
  text-align: left;
  box-shadow:
    inset 0 0 0 1px var(--nav-edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -3px 0 rgba(0, 0, 0, 0.35),
    0 24px 48px -20px rgba(0, 0, 0, 0.6);
}

.site-head .desk-panel[hidden] { display: none; }

.site-head .desk-card { padding: 18px 12px 14px; }

.site-head .desk-kicker {
  margin: 0 6px 6px;
  color: var(--nav-ink-2);
  font: 600 12px/1.3 var(--nav-font);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.site-head .desk-title {
  margin: 0 6px 8px;
  color: var(--nav-ink);
  font: 800 26px/1.05 var(--nav-font);
  letter-spacing: -0.012em;
  text-wrap: balance;
}

.site-head .desk-title:focus { outline: none; }

.site-head .desk-note,
.site-head .desk-pace,
.site-head .desk-fine,
.site-head .desk-status {
  margin: 0 6px 10px;
  color: var(--nav-ink-2);
  font: 500 14px/1.4 var(--nav-font);
}

.site-head .desk-pace { margin-top: 10px; font-size: 13px; font-variant-numeric: tabular-nums; }
.site-head .desk-fine { margin: 10px 6px 0; font-size: 12px; }
.site-head .desk-status { margin: 4px 6px 0; font-size: 13px; color: var(--nav-mint); }
.site-head .desk-status:empty { display: none; }

.site-head .desk-list {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 2px;
}

.site-head .desk-link {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px;
  border-radius: var(--t-r-btn);
  color: var(--nav-ink);
  text-decoration: none;
}

.site-head .desk-link:hover { background: var(--nav-hover); }

.site-head .desk-text { display: grid; gap: 5px; min-width: 0; }

/* Picture tile: the note's picture or the toy's object; a quiet glyph when there is none. */
.site-head .desk-tile {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: var(--t-r-btn);
  background: var(--nav-hover);
  color: var(--nav-ink-2);
  font: 700 17px/1 var(--nav-font);
}

.site-head .desk-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.site-head .desk-tile-toy { background: var(--nav-current); }
.site-head .desk-tile-toy img { object-fit: contain; padding: 4px; }
.site-head .desk-tile-site { color: #ffffff; background: var(--nav-cobalt); box-shadow: inset 0 -4px 0 var(--nav-cobalt-deep); font-weight: 800; }

.site-head .desk-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--nav-ink-2);
  font: 600 12px/1.2 var(--nav-font);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.site-head .desk-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--nav-mint);
  flex: none;
}

.site-head .desk-new { color: var(--nav-mint); }

.site-head .desk-item-title {
  font: 600 16px/1.3 var(--nav-font);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.site-head .desk-link:not(.is-new) .desk-item-title { color: var(--nav-ink-2); }

.site-head .desk-foot {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--nav-edge);
}

.site-head .desk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 2px;
}

.site-head .desk-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--t-r-btn);
  color: var(--nav-ink);
  background: var(--nav-hover);
  font: 600 15px/1 var(--nav-font);
  text-decoration: none;
  cursor: pointer;
}

.site-head .desk-btn:hover { background: rgba(247, 246, 242, 0.18); }

.site-head .desk-btn-primary {
  color: #141414;
  background: var(--nav-current);
  box-shadow: inset 0 -3px 0 #bdbab1;
}

.site-head .desk-btn-primary:hover { background: #ffffff; }

@media (prefers-reduced-motion: no-preference) {
  .site-head .desk-key { transition: color 240ms ease, background-color 240ms ease; }
  .site-head .desk-key.has-news .desk-count { animation: desk-pop 450ms var(--nav-spring) 300ms backwards; }
  .site-head .desk-key.has-news::before { animation: desk-live 1.6s ease-in-out 3; }
  .site-head.desk-open .desk-panel { animation: desk-in 450ms var(--nav-out); }
  .site-head.desk-open .desk-item { animation: nav-item 450ms var(--nav-spring) backwards; }
  .site-head.desk-open .desk-item:nth-child(2) { animation-delay: 40ms; }
  .site-head.desk-open .desk-item:nth-child(3) { animation-delay: 80ms; }
  .site-head.desk-open .desk-item:nth-child(4) { animation-delay: 120ms; }
  .site-head.desk-open .desk-item:nth-child(n + 5) { animation-delay: 160ms; }
  .site-head .desk-link { transition: background-color 240ms ease; }
  @keyframes desk-pop { from { transform: scale(0.2); } }
  @keyframes desk-live { 50% { box-shadow: 0 0 0 5px rgba(23, 199, 135, 0.35); } }
  @keyframes desk-in { from { clip-path: inset(0 0 100% 0 round var(--nav-r)); } to { clip-path: inset(0 0 0 0 round var(--nav-r)); } }
  @keyframes nav-item { from { transform: translateY(-10px); } }
}

/* Mid widths: tighten before folding. */
@media (max-width: 900px) {
  .site-head .nav-links a { padding: 0 12px; }
  .site-head .nav-cta { padding-inline: 16px; }
  .site-head .desk-key { padding: 0 12px 0 10px; }
}

/* Phones. */
@media (max-width: 760px) {
  .site-head .nav-island {
    width: 100%;
    max-width: 520px;
    flex-wrap: wrap;
    border-radius: var(--nav-r);
  }

  /* No JavaScript: the links and CTA sit in one scrollable row under the
     brand (fixed height; the reserved space grows below). */
  .site-head .site-nav {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .site-head.has-menu .nav-toggle { display: inline-flex; }

  .site-head.has-menu .site-nav { display: none; }

  .site-head.has-menu.is-open .site-nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
  }

  .site-head.has-menu .nav-links {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 12px 4px 0;
  }

  .site-head.has-menu .nav-links a {
    width: 100%;
    min-height: 60px;
    padding: 0 16px;
    border-radius: var(--t-r-btn);
    color: var(--nav-ink);
    font-size: 26px;
    font-weight: 700;
    font-variation-settings: "wdth" 88, "opsz" 48;
    letter-spacing: -0.012em;
  }

  .site-head.has-menu .nav-links a[aria-current="page"] {
    color: #141414;
  }

  .site-head.has-menu .nav-cta {
    margin: 14px 4px 4px;
    min-height: 56px;
    font-size: 17px;
  }

  /* The open sheet never outgrows the viewport (short landscape phones):
     it scrolls inside the island instead. */
  .site-head.is-open .nav-island {
    max-height: calc(100vh - var(--nav-top) - 12px);
    max-height: calc(100dvh - var(--nav-top) - 12px);
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: var(--nav-r);
  }

  html.nav-open { overflow: hidden; }

  /* The desk card spans the island on phones, with the same scrim. */
  .site-head .desk-panel { right: 0; width: auto; }
  html.desk-open { overflow: hidden; }
  .site-head.desk-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: rgba(20, 20, 20, 0.42);
    pointer-events: auto;
  }

  /* Scrim behind the open sheet; a tap on it closes the menu (nav.js). */
  .site-head.is-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: rgba(20, 20, 20, 0.42);
    pointer-events: auto;
  }
}

/* Narrow phones (320 px): brand, «New» and «Menu» still share one row. */
@media (max-width: 360px) {
  .site-head .brand { padding-right: 8px; }
  .site-head .desk-key { gap: 6px; padding: 0 10px 0 8px; }
  .site-head .nav-toggle { gap: 8px; padding: 0 12px; }
}

/* No JavaScript on a phone: the island has two rows, so pages reserve more. */
@media (max-width: 760px) and (scripting: none) {
  :root { --header-h: calc(var(--nav-top) + var(--nav-h) + 56px); }
  /* The home hero sits under the fixed header instead of below it. */
  .hero-copy { padding-top: calc(var(--header-h) + 8px); }
}

@media (max-width: 760px) and (prefers-reduced-motion: no-preference) {
  .site-head.is-open .site-nav { animation: nav-sheet 450ms var(--nav-out); }
  .site-head.is-open .nav-links li,
  .site-head.is-open .nav-cta { animation: nav-item 450ms var(--nav-spring) backwards; }
  .site-head.is-open .nav-links li:nth-child(2) { animation-delay: 40ms; }
  .site-head.is-open .nav-links li:nth-child(3) { animation-delay: 80ms; }
  .site-head.is-open .nav-cta { animation-delay: 120ms; }
  @keyframes nav-sheet { from { clip-path: inset(0 0 100% 0 round var(--nav-r)); } to { clip-path: inset(0 0 0 0 round var(--nav-r)); } }
  @keyframes nav-item { from { transform: translateY(-10px); } }
}
