/* ============================================================
   Shared top-nav menu — grouped dropdowns.
   Used by the homepage (linked in index.html) and every static
   page (via @import in compare.css). Extends the existing
   .nav / .nav-brand / .nav-cta rules; relies on shared tokens
   (--fg, --fg-3, --line, --brand, --sumi-900, --washi-50,
    --bg-elevated, --font-mono).
   ============================================================ */

.nav-menu {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
}

.navgroup {
  position: relative;
}

.navgroup-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 8px 12px;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--fg-3);
  transition: color 120ms ease;
}

.navgroup-label::after {
  content: "▾";
  font-size: 9px;
  line-height: 1;
  opacity: .55;
  transition: transform 120ms ease, opacity 120ms ease;
}

.navgroup-label[aria-expanded="true"] { color: var(--fg); }

.navgroup-label[aria-expanded="true"]::after {
  transform: rotate(180deg);
  opacity: .9;
}

/* Hover-open is a desktop-only enhancement; touch devices toggle via click
   (aria-expanded), so menus stay reachable where hover doesn't exist. */
@media (hover: hover) {
  .navgroup:hover .navgroup-label { color: var(--fg); }
  .navgroup:hover .navgroup-label::after { transform: rotate(180deg); opacity: .9; }
}

.navgroup-menu {
  position: absolute;
  top: calc(100% - 2px);
  left: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 188px;
  padding: 6px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--sumi-900);
  box-shadow: 4px 4px 0 var(--sumi-900);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
}

/* Right-align the menus that sit toward the right edge so they
   don't run off-screen. */
.navgroup.is-right .navgroup-menu { left: auto; right: 0; }

.navgroup-label[aria-expanded="true"] + .navgroup-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
@media (hover: hover) {
  .navgroup:hover .navgroup-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
}

.navgroup-menu a {
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--fg-2, var(--fg));
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background 110ms ease, color 110ms ease, border-color 110ms ease;
}

.navgroup-menu a:hover,
.navgroup-menu a:focus-visible {
  color: var(--brand);
  border-left-color: var(--brand);
  background: color-mix(in oklab, var(--brand) 12%, transparent);
  outline: none;
}

/* Keep brand on the left, menu centered, CTA on the right. */
.nav .nav-menu { margin: 0 auto; }

/* ---- Responsive: drop the menu onto its own row on narrow screens ---- */
@media (max-width: 860px) {
  .nav { flex-wrap: wrap; row-gap: 8px; }
  .nav .nav-menu {
    order: 3;
    width: 100%;
    margin: 0;
    justify-content: flex-start;
  }
  /* Anchor open menus to the nav rather than the group, and pin them to both
     edges so right-side groups ("Guides", "More") can't spill off-screen.
     Each opens as a full-width panel just under the nav. The homepage nav is
     position:fixed (from landing.css, loaded later) so it stays the anchor
     there; on static pages it's otherwise unpositioned, so anchor it here. */
  .nav { position: relative; }
  .navgroup { position: static; }
  .navgroup .navgroup-menu,
  .navgroup.is-right .navgroup-menu {
    left: var(--pad-x, 24px);
    right: var(--pad-x, 24px);
    width: auto;
    min-width: 0;
  }
}

@media (max-width: 460px) {
  .navgroup-label { padding: 7px 8px; letter-spacing: .1em; }
}

/* ---- Touch: comfortable 44px+ tap targets for the nav ---- */
@media (hover: none) {
  .navgroup-label { min-height: 44px; }
  .navgroup-menu a { padding: 12px 10px; }
}

/* ============================================================
   Anchor offset — keep section headings clear of the fixed nav
   when jumping to #hash targets (applies to smooth and instant).
   ============================================================ */
html { scroll-padding-top: 76px; }
@media (max-width: 860px) {
  /* nav wraps its menu onto a second full-width row here */
  html { scroll-padding-top: 128px; }
}

/* ============================================================
   Skip link — first tab stop, visible only on focus.
   ============================================================ */
.skip-link {
  position: absolute;
  left: var(--pad-x, 24px);
  top: 10px;
  z-index: 200;
  transform: translateY(-150%);
  padding: 10px 14px;
  background: var(--washi-50, #faf6ea);
  color: var(--sumi-900, #15140f);
  border: 1.5px solid var(--sumi-900, #15140f);
  box-shadow: 3px 3px 0 var(--sumi-900, #15140f);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  text-decoration: none;
  transition: transform 140ms ease;
}
.skip-link:focus,
.skip-link:focus-visible { transform: translateY(0); outline: none; }

/* ============================================================
   Keyboard focus — consistent brand ring on interactive elements.
   Uses outline (not shadow) so it never disturbs the hard-offset
   "cut" button shadows. Only shows for keyboard users.
   ============================================================ */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible,
input:focus-visible,
[contenteditable]:focus-visible {
  outline: 2px solid var(--brand, #2e6b46);
  outline-offset: 2px;
}
