/* Site header navigation, the same on every page (markup: scripts/lib/site-nav.mjs, behaviour: site-nav.js).
   Desktop (1100 px and wider): six links and "More" (a <details> list, works from the keyboard and without scripts).
   Narrower: a menu button; the menu opens as a panel under the header. Colours come from each page's tokens (both themes).
   Phones: the sticky "Build your kit" button at the bottom of the screen (home page and landing pages). */

.site-nav { margin-left: auto; }
.site-nav ul { list-style: none; margin: 0; padding: 0; }
.nav-list { display: flex; align-items: center; gap: 22px; }
.nav-list > li:empty { display: none; }
.site-nav a, .nav-more summary { color: var(--muted); text-decoration: none; font-size: 16px; font-weight: 600; line-height: 1.3; white-space: nowrap; }
.site-nav a:hover, .nav-more summary:hover, .site-nav a[aria-current="page"] { color: var(--text); }
.site-nav a:focus-visible, .nav-more summary:focus-visible, .nav-burger:focus-visible, .sh-sticky:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px;
}
.nav-m { display: none; }
.site-nav + .theme-switch { margin-left: 4px; }
/* an open menu or "More" is above the cookie banner (consent.js, z-index 80): the banner comes back when it closes */
header.top.nav-open, header.top:has(.nav-more[open]) { z-index: 90; }

/* "More" */
.nav-more { position: relative; }
.nav-more summary { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; list-style: none; }
.nav-more summary::-webkit-details-marker { display: none; }
.nav-more summary::after {
  content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg); transition: transform .15s ease;
}
.nav-more[open] summary { color: var(--text); }
.nav-more[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.nav-more ul {
  position: absolute; right: -12px; top: calc(100% + 16px); z-index: 60; min-width: 240px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .06), 0 18px 44px rgba(0, 0, 0, .16);
}
.nav-more ul a { display: block; padding: 10px 12px; border-radius: 10px; color: var(--text); }
.nav-more ul a:hover, .nav-more ul a:focus-visible { background: var(--surface-2, var(--bg)); outline-offset: -2px; }

/* "Demo" in the header */
header .button.site-demo {
  display: inline-flex; align-items: center; justify-content: center; flex: none; min-height: 40px; padding: 0 16px; border: 0;
  border-radius: 12px; background: var(--accent); color: var(--on-accent); font-size: 16px; font-weight: 650; text-decoration: none;
  box-shadow: none; white-space: nowrap;
}

/* Menu button: three bars that turn into a cross */
.nav-burger { display: none; }
.nav-burger span, .nav-burger span::before, .nav-burger span::after {
  display: block; width: 18px; height: 2px; border-radius: 2px; background: currentColor; transition: transform .2s ease, background-color .2s ease;
}
.nav-burger span { position: relative; }
.nav-burger span::before, .nav-burger span::after { content: ""; position: absolute; left: 0; }
.nav-burger span::before { top: -6px; }
.nav-burger span::after { top: 6px; }
.nav-burger[aria-expanded="true"] span { background-color: transparent; }
.nav-burger[aria-expanded="true"] span::before { transform: translateY(6px) rotate(45deg); }
.nav-burger[aria-expanded="true"] span::after { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 1099px) {
  header.top .wrap { gap: 8px; }
  .brand { margin-right: auto; }
  .site-nav + .theme-switch { margin-left: 0; }
  .nav-burger {
    display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border-radius: 12px; cursor: pointer;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
  }
  .theme-switch { width: 44px; height: 44px; }
  header .button.site-demo { min-height: 44px; }
  .nav-d { display: none; }
  .nav-m { display: block; }
  /* The panel: right under the header (the header is sticky, so it is always at the top of the screen), to the bottom of it. */
  .site-nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%; z-index: 49; margin: 0;
    height: calc(100vh - 64px); height: calc(100dvh - 64px); overflow-y: auto; overscroll-behavior: contain;
    padding: 8px clamp(16px, 3.4vw, 48px) calc(28px + env(safe-area-inset-bottom, 0px));
    background: var(--bg); border-top: 1px solid var(--border);
  }
  header.top.nav-open .site-nav { display: block; animation: sh-nav-in .18s ease-out; }
  header.top.nav-open { border-bottom-color: var(--border); }
  .nav-list { flex-direction: column; align-items: stretch; gap: 0; max-width: 560px; margin: 0 auto; }
  .nav-list > li > a { display: flex; align-items: center; min-height: 56px; padding: 6px 2px; border-bottom: 1px solid var(--border); color: var(--text); font-size: 20px; font-weight: 650; white-space: normal; }
  .nav-list > li > a[aria-current="page"] { color: var(--link); }
  .nav-list > li.nav-cta { margin-top: 22px; }
  .nav-list > li.nav-cta > a.site-demo { width: 100%; min-height: 52px; border-bottom: 0; color: var(--on-accent); font-size: 17px; justify-content: center; }
  html.nav-lock, html.nav-lock body { overflow: hidden; }
}
@media (max-width: 439px) { .nav-demo { display: none !important; } }
@keyframes sh-nav-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* Sticky "Build your kit" on phones (site-nav.js shows it: not over the first screen, the kit builder, the packages,
   the cookie banner or the open menu) */
.sh-sticky { display: none; }
@media (max-width: 979px) {
  .sh-sticky {
    display: flex; align-items: center; justify-content: center; position: fixed; z-index: 45;
    left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); max-width: 560px; margin: 0 auto;
    min-height: 52px; padding: 0 20px; border-radius: 16px; background: var(--accent); color: var(--on-accent);
    font-size: 17px; font-weight: 700; text-decoration: none; box-shadow: 0 8px 26px rgba(0, 0, 0, .22);
    transition: transform .22s ease, opacity .22s ease, visibility 0s linear .22s;
  }
  .sh-sticky:not(.is-on) { visibility: hidden; opacity: 0; transform: translateY(24px); pointer-events: none; }
  .sh-sticky.is-on { transition: transform .22s ease, opacity .22s ease, visibility 0s; }
  /* the end of the page is never under the button */
  body:has(> .sh-sticky) { padding-bottom: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  .nav-burger span, .nav-burger span::before, .nav-burger span::after, .nav-more summary::after { transition: none; }
  header.top.nav-open .site-nav { animation: none; }
  .sh-sticky, .sh-sticky.is-on { transition: none; transform: none; }
}

/* The App Store badge (scripts/lib/app-store.mjs): Apple's files as they are — black in the light theme, white in the dark one.
   Apple's rules: at least 40 px high on screen and clear space of a quarter of its height all around (the padding: 10 px at 40,
   12 px at 48). Never stretched: the height is set, the width follows the file. */
.sh-appstore { display: inline-block; padding: 10px; line-height: 0; border-radius: 12px; vertical-align: middle; }
.sh-appstore img { display: block; width: auto; height: 40px; max-width: none; }
.sh-appstore-lg { padding: 12px; }
.sh-appstore-lg img { height: 48px; }
.sh-appstore:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
/* in the footer the image lines up with the text on the left; the padding keeps the clear space, the gaps of the footer add to it */
footer .sh-appstore { margin: 0 -10px; }
.sh-appstore .sh-appstore-dark { display: none; }
:root[data-theme="dark"] .sh-appstore .sh-appstore-light { display: none; }
:root[data-theme="dark"] .sh-appstore .sh-appstore-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sh-appstore .sh-appstore-light { display: none; }
  :root:not([data-theme="light"]) .sh-appstore .sh-appstore-dark { display: block; }
}
/* Apple's trademark line (scripts/lib/app-store.mjs → trademark, the lawyers' words) — small, on its own line of the footer */
footer .sh-appstore-tm { flex: 1 1 100%; margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
