/* ========================================================================
   DNSai Public Nav + Footer
   Shared chrome for every logged-out / marketing page and the auth pages.
   Extracted from landing.css so auth pages can load the nav without
   pulling in ~500 lines of hero/stat/feature-grid rules.

   Two variants:
     .landing-nav               overlay (fixed) — transparent over the hero,
                                turns solid on scroll. Used by landing.html.
     .landing-nav--sticky       in-flow (sticky) — always solid. Used by the
                                auth pages, where there is no hero to overlay
                                and a fixed nav would require a magic
                                padding-top on .auth-page.

   Class names intentionally match the originals in landing.css so existing
   selectors in landing.js keep resolving.
   ======================================================================== */

/* --- Nav shell --- */
.landing-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 32px;
  height: var(--nav-h);
  background: transparent;
  transition: background 0.3s, backdrop-filter 0.3s;
}

/* Solid background once the hero has scrolled past. */
.landing-nav.scrolled {
  background: var(--nav-bg-scrolled);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--nav-shadow-scrolled);
}

/* Auth-page variant: occupies layout space, so nothing below it needs to
   compensate with padding. Always solid — there is no hero behind it. */
.landing-nav--sticky {
  position: sticky;
  /* Inherited left/right:0 would become horizontal sticky thresholds. */
  left: auto;
  right: auto;
  background: var(--nav-bg-scrolled);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-default);
}

/* --- Logo (left) --- */
.landing-nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto; /* pushes links + actions to the right edge */
  text-decoration: none;
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 700;
  border-radius: 6px;
}

.landing-nav-logo img {
  width: 30px;
  height: 30px;
}

.landing-nav-logo .thin {
  font-weight: 300;
}

/* --- Links --- */
.landing-nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
}

.landing-nav-links a {
  /* theme.css defines --nav-link-color, not --nav-link. The original
     landing.css read var(--nav-link) — undefined, so links silently
     inherited body colour and dropped the shadow. */
  color: var(--nav-link-color);
  text-shadow: var(--nav-link-shadow);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: 4px;
  transition: color 0.2s;
}

.landing-nav-links a:hover,
.landing-nav-links a[aria-current="page"] {
  color: var(--nav-link-hover);
}

.landing-nav-links .nav-cta,
.landing-nav-links .nav-cta[aria-current="page"] {
  padding: 8px 20px;
  border-radius: 6px;
  background: var(--brand-gradient);
  color: #ffffff;
  text-shadow: none;
  font-weight: 600;
}

.landing-nav-links .nav-cta:hover {
  background: var(--brand-gradient-hover);
  color: #ffffff;
}

/* "Home" is redundant next to a clickable logo on desktop, but phones need it
   spelled out in the flyout. Shown only once the hamburger takes over. */
.nav-mobile-only {
  display: none;
}

/* Vertical hairline separating link groups (Main Site, auth actions). */
.nav-sep {
  width: 1px;
  height: 18px;
  background: var(--border-default);
  opacity: 0.7;
}

/* --- Right-hand actions (theme toggle + hamburger) --- */
.landing-nav-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* The theme toggle reuses .mode-switch from theme.css verbatim; theme.js
   binds every .mode-switch input on the page via querySelectorAll, so no
   JS change is needed to make it work here. */
.nav-mode-switch {
  display: flex;
  align-items: center;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --- Hamburger --- */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 102;
  border-radius: 6px;
  transition: background 0.2s;
}

.nav-hamburger:hover {
  background: var(--bg-surface);
}

.nav-hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}

.nav-hamburger[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-hamburger[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.nav-hamburger[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* --- Focus rings (keyboard only) --- */
.landing-nav-logo:focus-visible,
.landing-nav-links a:focus-visible,
.nav-hamburger:focus-visible,
.mode-switch input:focus-visible + label,
.landing-footer-links a:focus-visible {
  outline: 2px solid var(--brand-cyan);
  outline-offset: 3px;
}

/* ========================================================================
   Tablet + mobile — hamburger takes over at 900px.
   Raised from the old 768px because the bar now carries 8 items
   (5 links + Main Site + toggle + CTA) and crowds between 769-900px.
   ======================================================================== */
@media (max-width: 900px) {
  .landing-nav {
    padding: 0 20px;
  }

  .nav-hamburger {
    display: flex;
  }

  .nav-mobile-only {
    display: block;
  }

  .nav-sep {
    display: none;
  }

  .landing-nav-links {
    display: none;
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    box-sizing: border-box;
    max-height: calc(100vh - var(--nav-h)); /* fallback */
    max-height: calc(100dvh - var(--nav-h));
    overflow-y: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-default);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    padding: 8px 0;
    z-index: 101;
  }

  .landing-nav-links.open {
    display: flex;
  }

  .landing-nav-links a {
    /* >=48px tap target */
    padding: 15px 24px;
    font-size: 15px;
    text-shadow: none;
    border-radius: 0;
    border-bottom: 1px solid var(--border-default);
  }

  .landing-nav-links a:last-child {
    border-bottom: none;
  }

  .landing-nav-links a:hover {
    background: var(--bg-surface);
  }

  .landing-nav-links .nav-cta,
  .landing-nav-links .nav-cta[aria-current="page"] {
    margin: 12px 24px;
    padding: 14px 20px;
    text-align: center;
    border-radius: 6px;
    border-bottom: none;
  }
}

/* Prevent the page behind the mobile menu from scrolling. Toggled by landing.js. */
body.nav-open {
  overflow: hidden;
}

/* ========================================================================
   Footer
   ======================================================================== */
.landing-footer {
  padding: 40px 24px;
  text-align: center;
  background: var(--bg-footer);
  border-top: 1px solid var(--border-default);
}

.landing-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.landing-footer-copy {
  font-size: 13px;
  color: var(--text-muted);
}

.landing-footer-links {
  display: flex;
  gap: 16px;
  font-size: 13px;
  flex-wrap: wrap;
  justify-content: center;
}

.landing-footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 4px;
}

/* theme.css defines --link-color, not --link. The original landing.css read
   var(--link) — undefined, so the hover colour never applied. */
.landing-footer-links a:hover {
  color: var(--link-color);
}

@media (max-width: 640px) {
  .landing-footer {
    padding: 28px 20px;
  }

  .landing-footer-inner {
    flex-direction: column;
  }
}

/* ========================================================================
   Motion
   ======================================================================== */
@media (prefers-reduced-motion: reduce) {
  .landing-nav,
  .landing-nav-links a,
  .nav-hamburger,
  .nav-hamburger span,
  .mode-switch label,
  .mode-switch label::after {
    transition: none;
  }
}
