/* Top navigation — shared chrome across index / pricing / account / detail pages.
   Single source of truth; no per-page inline copies.
   Behavior (lang switcher, .scrolled toggle, current-page mark, mobile drawer)
   is in nav.js. */

/* Skip-to-main-content link — invisible until focused, then jumps the user
   past the repeating nav. Required by WCAG 2.4.1 (Bypass Blocks). Pages
   that need it carry a `<main id="main-content">` landmark (or any other
   element with that id) for the link to target. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 10px 18px;
  background: #000;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border-radius: 0 0 8px 0;
  text-decoration: none;
}
.skip-link:focus,
.skip-link:focus-visible {
  left: 0;
  outline: 2px solid #fff;
  outline-offset: -4px;
}

/* --nav-clearance: viewport-top → "safely below the nav bar" distance (bar
   height + 8px breathing). Every sticky/scroll-margin consumer across the
   site (gallery rail, legal TOCs, docs side/toc/docbar, detail tabs, checkout
   summary, learn/seo templates) reads this var instead of hardcoding nav
   geometry. Verified against rendered geometry via puppeteer; re-measure if
   nav padding/height changes. */
:root { --nav-clearance: 66px; }

/* Pinned header, site-wide (2026-07-17 final direction — the floating-card
   iteration was rejected): the bar stays flush at the top at every scroll
   position, same style the theme detail pages always had. Its INNER content
   (logo / links / controls) is constrained to the 1.1x (1440px) centered
   column via side padding. Transparent over the page at rest; frosted white
   + bottom hairline once scrolled (nav.js toggles .scrolled at scrollY>4) so
   content stays readable. */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  /* min-height prevents a brief layout shift while nav.js injects content
     (each page has only <nav class="nav"></nav> as a placeholder, populated
     on DOMContentLoaded). 56px ≈ rendered bar height. */
  min-height: 56px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 16px;
  /* content column = min(100%, 1440px) centered */
  padding: 10px max(16px, calc((100% - 1440px) / 2));
  background: transparent;
  transition: box-shadow .18s ease, background .18s ease;
}
.nav.scrolled {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}
@media (prefers-reduced-motion: reduce) {
  .nav { transition: none; }
}

.brand { display: flex; align-items: center; gap: 4px; }
.brand .gem { height: 32px; width: auto; }
.brand .wordmark { height: 22px; width: auto; }

/* Links are horizontally centered in the box (user-decided layout,
   2026-07-17): absolutely centered so asymmetric brand/right-controls widths
   can't skew them. Markup order stays brand / sp / links / right — the
   spacer still pushes the right controls to the edge. */
.nav .links {
  display: flex;
  gap: 0;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
/* All four page links are plain black — deliberately NO current-page
   highlight (user direction 2026-07-17). markCurrentPage still stamps .on
   (the mobile drawer uses it), but the desktop bar doesn't style it. */
.nav .links a {
  padding: 8px 16px;
  font-size: 14px;
  color: #000;
  border-radius: 8px;
  transition: background 100ms, color 100ms;
  white-space: nowrap;
}

.nav .sp { flex: 1; }
.nav .right { display: flex; align-items: center; gap: 6px; }

.iconbtn {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #000;
  transition: background 100ms;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}
.iconbtn svg { width: 20px; height: 20px; stroke-width: 1.5; }

/* Language selector — borderless ghost button (matches the old globe's
   weight) showing the CURRENT language as a flag + code. Flags are inline
   SVGs in nav.js (FLAG_US / FLAG_CN; 日本語 row slots in when /ja/ ships). */
.langsel {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #000;
  cursor: pointer;
  font-family: inherit;
  transition: background 100ms;
}
.ls-flag, .lo-flag { display: inline-flex; flex-shrink: 0; }
.ls-flag > span { display: inline-flex; }
.ls-flag svg, .lo-flag svg {
  width: 19px;
  height: 13px;
  border-radius: 2px;
  /* faint ring so the US flag's white field doesn't dissolve into the bar */
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.10);
  display: block;
}
.langsel .ls-code {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.langsel .ls-chev { width: 9px; height: 6px; color: var(--ink-2); flex-shrink: 0; }
/* flag/code carry both languages as data-en/data-zh spans; the global
   html[data-lang] rules show exactly one. */
html[data-lang="ja"] [data-zh],
html[data-lang="ko"] [data-zh],
html[data-lang="es"] [data-zh] { display: none !important; }

.lang-wrap { position: relative; }
.lang-pop {
  position: absolute;
  top: 42px;
  right: 0;
  width: 200px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  z-index: 50;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 100ms, transform 100ms;
}
.lang-pop.open { opacity: 1; transform: none; pointer-events: auto; }
.lang-pop h6 {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-2);
  padding: 8px 10px 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}
/* .lang-option covers both shapes of a language row: the JS-fallback
   <button> and the SSR <a href> (inject-chrome-ssr.mjs bakes the
   other-language option as a real link so crawlers can follow it). */
.lang-pop .lang-option {
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  text-decoration: none;
  box-sizing: border-box;
  line-height: normal;
}
.lang-pop .lang-option small { font-size: 12px; color: var(--ink-2); margin-left: auto; }
.lang-pop .lang-option .check { color: #000; opacity: 0; }
.lang-pop .lang-option.on .check { opacity: 1; }

.signin {
  height: 36px;
  padding: 0 18px;
  background: #000;
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.015em;
  transition: background 100ms;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}

/* Hover states — only on devices that actually have hover.
   Wrapped to prevent sticky hover after tap on touch devices. */
@media (hover: hover) {
  .nav .links a:hover { background: var(--bg-sub); color: #000; }
  .iconbtn:hover { background: var(--bg-sub); }
  .langsel:hover { background: var(--bg-sub); }
  .lang-pop .lang-option:hover { background: var(--bg-sub); }
  .signin:hover { background: #333; }
}

/* Burger button + mobile drawer — hidden on desktop. nav.js injects the DOM
   for these unconditionally; the @media block below toggles visibility. */
.nav-burger { display: none; }
.nav-drawer { display: none; }

/* Tablet: tighter spacing, keep desktop layout. Range: 768–1023px. */
@media (max-width: 1023px) {
  .nav { padding: 10px 12px; gap: 12px; }
  .nav .links a { padding: 8px 12px; font-size: 13px; }
}

/* Mobile: collapse just the nav links (Home / Gallery / Pricing) into a
   slide-down drawer. The lang switcher + sign-in (or avatar when logged
   in) stay visible on the nav bar itself. Burger goes on the LEFT via
   flex order so the layout reads [☰] [Brand] [spacer] [Lang] [Sign in]. */
@media (max-width: 767px) {
  .nav { padding: 8px 10px; gap: 6px; min-height: 54px; }
  .nav .links { display: none; }
  /* .lang-wrap / .signin / .curio-user-wrap stay visible — no display:none. */
  /* 375px budget: burger 40 + brand ~92 + langsel ~46 + signin ~70 + gaps.
     The code label is the give — glyph alone still says which language. */
  .langsel .ls-code { display: none; }

  .nav-burger {
    display: inline-flex;
    order: -1; /* push burger to the leftmost flex slot */
    width: 40px; height: 40px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: #000;
    padding: 0;
    font-family: inherit;
  }
  .nav-burger svg {
    width: 22px; height: 22px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
  }

  /* Trim the sign-in button so brand + lang + signin fit at 375px. */
  .nav .signin { padding: 0 14px; font-size: 13px; }

  .nav-drawer {
    display: block;
    /* Anchored to the pinned nav bar (nav is sticky = positioned): a
       full-width panel flush under it. position:absolute is NOT trapped by
       the nav's backdrop-filter the way fixed was — nav.js no longer
       reparents the drawer to <body>. */
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    /* Fully opaque so hero / page content doesn't bleed through. */
    background: #fff;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.14);
    z-index: 49;
    padding: 8px;
    transform: translateY(-6px);
    transition: transform 180ms ease, opacity 180ms ease;
    opacity: 0;
    pointer-events: none;
  }
  .nav-drawer.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .nav-drawer a,
  .nav-drawer .drawer-btn {
    display: block;
    width: 100%;
    padding: 13px 16px;
    border-radius: 8px;
    font-size: 16px;
    color: #000;
    background: transparent;
    border: 0;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    text-decoration: none;
    box-sizing: border-box;
  }
  .nav-drawer a.on { font-weight: 600; }
  .nav-drawer .sep {
    height: 1px;
    background: var(--line);
    margin: 8px 4px;
  }
  .nav-drawer .lang-row {
    display: flex;
    gap: 8px;
    padding: 8px;
  }
  .nav-drawer .lang-row .lang-option {
    flex: 1;
    padding: 11px 12px;
    text-align: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 13px;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    color: #000;
    text-decoration: none;
    box-sizing: border-box;
    line-height: normal;
  }
  .nav-drawer .lang-row .lang-option.on {
    background: #000;
    color: #fff;
    border-color: #000;
    font-weight: 600;
  }
  .nav-drawer .signin-mobile {
    background: #000;
    color: #fff;
    font-weight: 600;
    text-align: center;
    margin: 8px 4px 4px;
    padding: 14px;
  }

  /* Lang switcher + sign-in live on the nav bar at mobile (see top of this
     @media block), so the drawer only carries the 3 page links. Hide the
     drawer's lang-row + separator + signin-mobile to avoid duplication. */
  .nav-drawer .sep,
  .nav-drawer .lang-row,
  .nav-drawer .signin-mobile { display: none; }
}
