/* RecoFirst sticky nav + mobile drawer.
   Scoped under header.site.site-header. Load AFTER styles.css (and demo.css)
   so these rules can override the existing “hide nav under 800px” styles.
   Tokens: style-3-warm (--bg, --paper, --sand, --fg, --muted, --terra-d, --line, --focus).
   CTA and any white-on-accent text use --cta-bg / --terra-d (#6B3A52). */

/* The site sets overflow-x: hidden on html, body, which prevents position:sticky
   from sticking (the element scrolls away). clip still hides the decorative orbs. */
html, body { overflow-x: clip; }

html.nav-open,
html.nav-open body {
  overflow: hidden;
}

html {
  scroll-padding-top: 88px;
}
/* scroll-margin-top was omitted on purpose: it stacks with scroll-padding-top
   and would land hash targets ~176px down, so the spy never marked the clicked
   section current. scroll-padding-top alone clears the fixed header. */

/* In-flow when JS is off (compact wrap on mobile needs to push the page down).
   With JS: position:fixed + spacer. position:sticky fails when html/body use
   overflow-x: hidden (site default) or overflow: hidden (drawer scroll lock). */
header.site.site-header {
  position: relative;
  z-index: 50;
  display: block;
  flex-wrap: unset;
  padding: 0;
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: box-shadow 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
  /* No backdrop-filter on this element: it would trap the fixed drawer. */
}
html.js header.site.site-header {
  position: fixed;
  inset-inline: 0;
  top: 0;
  width: 100%;
}
html.js .site-header-spacer {
  height: var(--site-header-h, 68px);
}
html:not(.js) .site-header-spacer { display: none; }
header.site.site-header.is-scrolled {
  border-bottom-color: var(--line);
  box-shadow: 0 8px 24px rgba(80, 50, 20, 0.07);
}

.site-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 10px 0;
}

header.site.site-header .brand {
  position: relative;
  z-index: 72;
  flex: 0 0 auto;
}

.nav-toggle {
  display: none;
  position: relative;
  z-index: 72;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  font-family: inherit;
  align-items: center;
  justify-content: center;
}
.nav-toggle:hover { background: var(--sand); color: var(--terra-d); }
.nav-toggle:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
.nav-toggle__icon { display: block; }
.nav-toggle__icon--close { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle__icon--menu { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle__icon--close { display: block; }

.nav-backdrop {
  display: none;
}

header.site.site-header nav.primary {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px 18px;
}
header.site.site-header nav.primary a {
  color: var(--fg);
  text-decoration: none;
  font-weight: 600;
  font-size: 16px;
  padding: 6px 10px;
  border-radius: 999px;
  transition: color 0.2s ease, background-color 0.2s ease;
}
header.site.site-header nav.primary a:hover {
  color: var(--terra-d);
  background: transparent;
}
header.site.site-header nav.primary a[aria-current="page"],
header.site.site-header nav.primary a[aria-current="page"]:hover,
header.site.site-header nav.primary a[aria-current="page"]:focus-visible,
header.site.site-header nav.primary a[aria-current="location"],
header.site.site-header nav.primary a[aria-current="true"] {
  color: var(--nav-active-fg, #2A1F28);
  background-color: var(--nav-active-bg, #E6DAF5);
  background: var(--nav-active-bg, #E6DAF5);
}
header.site.site-header nav.primary a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  color: var(--terra-d);
}
header.site.site-header nav.primary a.btn,
header.site.site-header nav.primary a.btn:hover,
header.site.site-header nav.primary a.btn:focus-visible,
header.site.site-header nav.primary a.btn[aria-current="page"],
header.site.site-header nav.primary a.btn[aria-current="location"],
header.site.site-header nav.primary a.btn[aria-current="true"] {
  color: #fff;
  background: var(--terra-d);
  padding: 10px 18px;
}
header.site.site-header nav.primary a.btn:hover,
header.site.site-header nav.primary a.btn:focus-visible {
  background: var(--cta-hover, #542E40);
  color: #fff;
}

/* Legal links live in the footer on desktop; they belong in the mobile drawer. */
.site-header .nav-legal { display: none; }

@media (max-width: 1100px) and (min-width: 801px) {
  header.site.site-header nav.primary { gap: 4px 8px; }
  header.site.site-header nav.primary a { font-size: 15px; padding: 6px 8px; }
  header.site.site-header nav.primary a.btn { padding: 10px 14px; }
}

/* ---- Mobile: no-JS compact links; with JS, hamburger + RTL drawer from the right ---- */
@media (max-width: 800px) {
  /* Override styles.css hiding of nav links and the header CTA. */
  header.site.site-header nav.primary a:not(.btn),
  header.site.site-header nav.primary a.btn,
  header.site.site-header .btn {
    display: inline-flex;
    width: auto;
    text-align: center;
  }

  .site-header__bar { flex-wrap: wrap; }

  /* No-JS fallback: always-visible compact wrap under the brand. */
  html:not(.js) header.site.site-header nav.primary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    gap: 6px 4px;
    padding: 0 0 8px;
  }
  html:not(.js) header.site.site-header nav.primary a { font-size: 15px; }
  html:not(.js) header.site.site-header .nav-legal {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    width: 100%;
    padding: 4px 0 0;
    border-top: 1px solid var(--line);
  }
  html:not(.js) header.site.site-header .nav-legal a {
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
  }

  /* JS: hide in-flow nav, show the toggle, treat nav as a right-edge drawer. */
  html.js .nav-toggle { display: inline-flex; }
  html.js header.site.site-header nav.primary {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 4px;
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    width: min(320px, 88vw);
    z-index: 70;
    margin: 0;
    padding: 80px 20px calc(24px + env(safe-area-inset-bottom, 0px));
    background: var(--paper);
    border-inline-end: 1px solid var(--line);
    box-shadow: -8px 0 32px rgba(80, 50, 20, 0.12);
    transform: translateX(100%);
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.3s;
  }
  html.js.nav-open header.site.site-header nav.primary {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }
  html.js header.site.site-header nav.primary a {
    font-size: 18px;
    padding: 12px 14px;
    border-radius: 12px;
    min-height: 44px;
    align-items: center;
  }
  html.js header.site.site-header nav.primary a.btn {
    display: inline-flex;
    justify-content: center;
    width: 100%;
    margin-top: 8px;
    padding: 12px 18px;
    border-radius: 999px;
  }
  html.js header.site.site-header .nav-legal {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
  }
  html.js header.site.site-header .nav-legal a {
    color: var(--muted);
    font-size: 16px;
    font-weight: 600;
  }
  html.js header.site.site-header .nav-legal a:hover,
  html.js header.site.site-header .nav-legal a:focus-visible {
    color: var(--terra-d);
  }

  html.js .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(60, 42, 31, 0.4);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s;
  }
  html.js.nav-open .nav-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  /* Backdrop is a sibling inside the bar; it must escape the wrap. */
  html.js header.site.site-header .nav-backdrop {
    /* already position:fixed */
  }
}

@media (prefers-reduced-motion: reduce) {
  html.js header.site.site-header nav.primary,
  html.js .nav-backdrop {
    transition: none !important;
  }
  html.js header.site.site-header nav.primary {
    transform: none;
  }
}

/* Instant hide/show of the off-canvas drawer only. Must not apply at
   801px+, or the in-bar desktop menu disappears (QA 3a47d6c blocker). */
@media (prefers-reduced-motion: reduce) and (max-width: 800px) {
  html.js:not(.nav-open) header.site.site-header nav.primary {
    display: none;
    transform: none;
  }
  html.js.nav-open header.site.site-header nav.primary {
    display: flex;
    transform: none;
  }
}
