/* ==========================================================================
   nav.css — Shared site navigation
   --------------------------------------------------------------------------
   Single source of truth for the top navigation bar across all pages.
   Linked from each page's <head>; the corresponding markup pattern lives
   in /partials/nav.html (assembled into pages via tools/build-includes.js).

   DEPENDS ON these CSS variables being defined in each page's :root —
     --navy, --navy-mid, --teal, --orange, --white, --white-dim
   This file does NOT redeclare them.

   PAIRS WITH /js/mobile-nav.js (drawer toggle, dropdown open/close,
   backdrop click-to-close).
   ========================================================================== */

/* ── NAV ── */
/* NOTE: do NOT add backdrop-filter to <nav>. It creates a CSS containing
   block for fixed-positioned descendants, which collapses the mobile drawer
   (the drawer's top:0/bottom:0 then resolve to the nav bar's ~80px height
   instead of the viewport). The 0.96 alpha background reads as effectively
   opaque against the dark site bg without needing the blur. */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 3rem;
  background: rgba(13,27,42,0.96);
  border-bottom: 1px solid rgba(61,191,191,0.12);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.k-mark {
  width: 36px;
  height: 36px;
  position: relative;
  flex-shrink: 0;
}
.k-mark svg { width: 100%; height: 100%; }

.logo-text {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--white);
  line-height: 1;
}
.logo-text span { color: var(--teal); }

nav ul {
  list-style: none;
  display: flex;
  gap: 2.5rem;
}
nav ul a {
  color: var(--white-dim);
  text-decoration: none;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: color 0.2s;
}
nav ul a:hover { color: var(--teal); }

.nav-cta {
  background: var(--teal);
  color: var(--navy) !important;
  padding: 0.55rem 1.25rem;
  font-weight: 700 !important;
  transition: background 0.2s !important;
}
.nav-cta:hover { background: var(--orange) !important; color: var(--white) !important; }

/* ── NAV DROPDOWN ── */
.nav-dropdown { position: relative; }
.nav-dropdown-toggle {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.nav-caret {
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 0.9em;
}
.nav-dropdown.open .nav-caret,
.nav-dropdown:hover .nav-caret {
  transform: rotate(180deg);
}
.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.85rem);
  right: 0;
  min-width: 200px;
  background: var(--navy-mid);
  border: 1px solid rgba(61,191,191,0.2);
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  list-style: none;
  padding: 0.35rem 0;
  margin: 0;
  display: none;
  flex-direction: column;
  gap: 0;
  z-index: 101;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu {
  display: flex;
}
.nav-dropdown-menu li { width: 100%; }
.nav-dropdown-menu a {
  display: block;
  padding: 0.85rem 1.25rem;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  border-bottom: 1px solid rgba(61,191,191,0.08);
}
.nav-dropdown-menu li:last-child a { border-bottom: none; }
.nav-dropdown-menu a:hover { background: rgba(61,191,191,0.08); color: var(--teal); }

/* ── HAMBURGER BUTTON (hidden on desktop) ── */
.nav-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  width: 44px;
  height: 44px;
  padding: 0;
  position: relative;
  z-index: 110;
}
.nav-hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--teal);
  margin: 5px auto;
  transition: transform 0.3s ease, opacity 0.3s ease;
  transform-origin: center;
}
body.nav-open .nav-hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.nav-open .nav-hamburger span:nth-child(2) { opacity: 0; }
body.nav-open .nav-hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── MOBILE DRAWER + BACKDROP ── */
@media (max-width: 900px) {
  .nav-hamburger { display: block; }

  /* Backdrop dimmer behind the drawer — prevents page content
     from visually bleeding through, regardless of panel translucency */
  .nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(8, 15, 24, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 95;
  }
  body.nav-open .nav-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  nav ul {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 85%;
    max-width: 340px;
    background-color: #0d1b2a; /* explicit hex — no fallback risk */
    border-left: 1px solid rgba(61,191,191,0.15);
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 0;
    padding: 6rem 2rem 2rem;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    box-shadow: -10px 0 30px rgba(0,0,0,0.5);
    overflow-y: auto;
    z-index: 105;
  }
  body.nav-open nav ul { transform: translateX(0); }
  body.nav-open { overflow: hidden; }
  nav ul li {
    width: 100%;
    padding: 1rem 0;
    border-bottom: 1px solid rgba(61,191,191,0.08);
  }
  nav ul li:last-child { border-bottom: none; padding-top: 1.5rem; }
  nav ul li a { font-size: 1rem; display: block; }
  nav ul li a.nav-cta {
    padding: 0.9rem 1.5rem;
    display: inline-block;
  }

  /* Mobile dropdown — always expanded, flat, indented */
  .nav-dropdown-menu {
    position: static;
    display: flex;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0.5rem 0 0 1rem;
    margin-top: 0.5rem;
    clip-path: none;
    flex-direction: column;
  }
  .nav-dropdown-menu li {
    border-bottom: none !important;
    padding: 0.6rem 0;
  }
  .nav-dropdown-menu a {
    font-size: 0.9rem;
    color: var(--white-dim);
    padding: 0;
    border-bottom: none;
    letter-spacing: 0.06em;
  }
  .nav-caret { display: none; }
}

/* ── NARROW SCREENS ── */
@media (max-width: 700px) {
  nav { padding: 1rem 1.5rem; }
}

/* ── ACTIVE-PAGE HIGHLIGHT ──
   Each page sets <body data-page="X"> and the matching nav link
   gets the teal highlight. Replaces the old inline `style="color:var(--teal);"`
   pattern that lived per-page. */
body[data-page="now"]            #main-nav a[href="/now/"],
body[data-page="moving"]         #main-nav a[href="/move-to-knightdale/"],
body[data-page="neighborhoods"]  #main-nav a[href="/neighborhoods/"],
body[data-page="schools"]        #main-nav a[href="/schools/"],
body[data-page="commute"]        #main-nav .nav-dropdown-menu a[href="/commute/"],
body[data-page="things-to-do"]   #main-nav .nav-dropdown-menu a[href="/things-to-do/"],
body[data-page="history"]        #main-nav .nav-dropdown-menu a[href="/history/"] {
  color: var(--teal);
}
