/*
 * =========================================================
 * OLYTIC SOLUTIONS - Navigation Header Styles
 * nav.css
 *
 * Covers:
 *   - Desktop sticky header with scroll-state transition
 *   - Logo wordmark + DM Mono brand label
 *   - Nav links with Teal active-page colour
 *   - Your Roadmap highlight + "Free" badge
 *   - Primary CTA button slot
 *   - Hamburger → X animated icon
 *   - Mobile slide-down menu
 *
 * Requires: tokens.css, typography.css, buttons.css
 * =========================================================
 */

/* ─── Header Shell ──────────────────────────────────────── */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-nav);
  height: var(--nav-height);          /* 72px desktop */

  /* Always-visible white header - no scroll-triggered transition */
  background-color: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
}

/*
 * .is-scrolled retained for JS compatibility but no longer
 * changes the visual state - header is always white.
 */
.site-header.is-scrolled {
  background-color: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow-sm);
}

/* For pages that start on a light background (retained for compatibility) */
.site-header--light-init {
  background-color: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow-sm);
}

/* ─── 2px Teal Rule - top of every page (brand spec) ─── */

.site-header::before {
  content: '';
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--color-teal);
  z-index: 1;
}

/* ─── Container ─────────────────────────────────────────── */

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-8);

  max-width: var(--max-width-xl);
  height: 100%;
  margin: 0 auto;
  padding: 0 var(--space-8);
}

/* ─── Logo ──────────────────────────────────────────────── */

.nav-logo {
  display: flex;
  flex-direction: row;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
  gap: 10px;
}

/* SVG mark inside nav - sized to match label cap-height */
.nav-logo__mark {
  display: block;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

/* Primary wordmark - DM Sans Bold, Obsidian */
.nav-logo__label {
  font-family: var(--font-sans);
  font-weight: var(--weight-bold);
  font-size: var(--text-base);
  color: var(--color-obsidian);
  letter-spacing: 0.08em;
  line-height: 1;
  transition: color var(--transition-fast);
}

.nav-logo:hover .nav-logo__label {
  color: var(--color-navy);
}

/* On-dark class retained for JS compatibility - logo always uses dark colours */
.site-header--on-dark .nav-logo__label {
  color: var(--color-obsidian);
}

/* ─── Nav Links ─────────────────────────────────────────── */

.nav-links {
  display: flex;
  align-items: center;
  margin-left: auto;   /* group links with the CTA on the right */
}

.nav-links ul {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links li {
  display: flex;
  align-items: center;
  margin: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-1);

  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-body-steel);
  text-decoration: none;
  white-space: nowrap;

  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  transition:
    color            var(--transition-fast),
    background-color var(--transition-fast);
}

.nav-link:hover {
  color: var(--color-obsidian);
  background-color: var(--color-surface);
}

/* Active page indicator - Teal text + gold underline bar */
/* Weight stays at weight-medium for all items so the flex row
   stays vertically aligned; colour + underline signal active state */
.nav-link[aria-current="page"] {
  color: var(--color-teal);
  position: relative;
}

.nav-link[aria-current="page"]::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: var(--space-3);
  right: var(--space-3);
  height: 2px;
  background-color: var(--color-gold);
  border-radius: 1px;
}

/* On-dark class retained for JS compatibility - links always use standard colours */
.site-header--on-dark .nav-link {
  color: var(--color-body-steel);
}

.site-header--on-dark .nav-link:hover {
  color: var(--color-obsidian);
  background-color: var(--color-surface);
}

.site-header--on-dark .nav-link[aria-current="page"] {
  color: var(--color-teal);
}

.site-header--on-dark .nav-link[aria-current="page"]::after {
  background-color: var(--color-gold);
}

/* ─── Your Roadmap (standard link - no badge or highlight) ─ */
/*
 * Your Roadmap is a standard nav link. Previously highlighted
 * with a Teal badge - removed per brand revision.
 */

/* ─── Nav Dropdown (e.g. Solutions) ─────────────────────── */

.nav-item--dropdown {
  position: relative;
}

.nav-link--dropdown {
  background: none;
  border: none;
  cursor: pointer;
}

/* Specificity note: .nav-links ul { display: flex } (0,1,1) would otherwise
   beat a bare .nav-dropdown (0,1,0), so this must be qualified with the
   parent item class to actually hide by default. */
.nav-item--dropdown .nav-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: var(--space-2);
  min-width: 200px;
  padding: var(--space-2);
  /* Off-black: a shade lighter than --color-obsidian so the dropdown
     reads as its own surface instead of matching the page's dark bands. */
  background-color: #242424;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  list-style: none;
  z-index: var(--z-dropdown);
}

/* Services and Solutions both carry a title + description per item now,
   so they need more room than a plain single-line link list would.
   Qualified with the parent to match .nav-item--dropdown .nav-dropdown's
   specificity (0,2,0), otherwise that rule's min-width: 200px wins. */
.nav-item--dropdown .nav-dropdown--wide {
  min-width: 300px;
}

/* Transparent bridge across the margin-top gap so moving the cursor
   from the button onto the panel does not drop the :hover state. */
.nav-item--dropdown .nav-dropdown::before {
  content: '';
  position: absolute;
  top: calc(-1 * var(--space-2));
  left: 0;
  right: 0;
  height: var(--space-2);
}

/* Open on hover and on keyboard focus, plus the JS .is-open class
   (retained for click and touch, where hover is unavailable). */
.nav-item--dropdown:hover .nav-dropdown,
.nav-item--dropdown:focus-within .nav-dropdown,
.nav-item--dropdown.is-open .nav-dropdown {
  display: block;
}

.nav-dropdown__link {
  display: block;
  position: relative;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: rgba(255, 255, 255, 0.80);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--transition-fast);
}

/* Gold underline is the hover/focus indicator, no background fill.
   Wipes in from the left to mirror the active-page underline bar. */
.nav-dropdown__link::after {
  content: '';
  position: absolute;
  left: var(--space-3);
  right: var(--space-3);
  bottom: 5px;
  height: 2px;
  background-color: var(--color-gold);
  border-radius: 1px;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--transition-fast);
}

.nav-dropdown__link:hover,
.nav-dropdown__link:focus-visible {
  color: #FFFFFF;
  background-color: transparent;
}

.nav-dropdown__link:hover::after,
.nav-dropdown__link:focus-visible::after {
  transform: scaleX(1);
}

/* Services links: bold title + description stacked, no single-line
   underline (it doesn't suit a two-line block), a soft highlight
   on hover instead. */
.nav-dropdown__link--stacked {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3);
  white-space: normal;
}

/* No underline on the link itself (it would run under the
   description too); the title carries its own instead, below. */
.nav-dropdown__link--stacked::after {
  display: none;
}

/* Same selection state as the plain Solutions links: a gold
   underline wiping in from the left, no background fill. */
.nav-dropdown__link-title {
  position: relative;
  display: inline-block;
  /* Without this the title, as a child of a column flex container,
     stretches to the dropdown's full width, and the underline
     below (sized to 100% of the title) stretches with it. */
  align-self: flex-start;
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: #FFFFFF;
}

.nav-dropdown__link-title::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 2px;
  background-color: var(--color-gold);
  border-radius: 1px;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--transition-fast);
}

.nav-dropdown__link--stacked:hover .nav-dropdown__link-title::after,
.nav-dropdown__link--stacked:focus-visible .nav-dropdown__link-title::after {
  transform: scaleX(1);
}

.nav-dropdown__link-desc {
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  color: rgba(255, 255, 255, 0.55);
  line-height: var(--leading-body);
}

/* ─── Desktop CTA ───────────────────────────────────────── */

.nav-cta {
  flex-shrink: 0;
}

/* ─── Mobile Toggle (Hamburger) ─────────────────────────── */

.nav-mobile-toggle {
  display: none;   /* Hidden on desktop */
  color: var(--color-obsidian);
}

.site-header--on-dark .nav-mobile-toggle {
  color: var(--color-obsidian);
}

/* 3-line animated hamburger */
.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 22px;
  height: 16px;
  pointer-events: none;
}

.hamburger span {
  display: block;
  height: 1.5px;
  background-color: currentColor;
  border-radius: 1px;
  transform-origin: center;
  transition:
    transform  var(--transition-base),
    opacity    var(--transition-fast),
    top        var(--transition-base);
}

/* Hamburger → X transition when menu is open */
.nav-mobile-toggle[aria-expanded="true"] .hamburger span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

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

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

/* ─── Mobile Menu ───────────────────────────────────────── */

.nav-mobile-menu {
  display: none;   /* shown via JS toggle below */
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: #FFFFFF;
  border-top: var(--border-gold-rule);
  box-shadow: var(--shadow-md);
  padding: var(--space-6) var(--space-6) var(--space-8);
  z-index: var(--z-dropdown);

  /* Slide-down animation */
  transform-origin: top;
  animation: none;
}

.nav-mobile-menu.is-open {
  display: block;
  animation: slideDown var(--transition-base) ease forwards;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.nav-mobile-menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-6);
}

.nav-mobile-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  color: var(--color-body-steel);
  text-decoration: none;
  padding: var(--space-3) var(--space-2);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast),
              background-color var(--transition-fast);
  border-bottom: 1px solid #E4E4E2;
}

.nav-mobile-link:last-of-type {
  border-bottom: none;
}

.nav-mobile-link:hover,
.nav-mobile-link[aria-current="page"] {
  color: var(--color-obsidian);
  background-color: var(--color-surface);
}

/* .nav-mobile-link--highlight removed - Your Roadmap is a standard link */

/* ─── Mobile submenu (e.g. Solutions → FieldCraft) ───── */

.nav-mobile-label {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  padding: var(--space-3) var(--space-2) 0;
}

.nav-mobile-link--sub {
  font-size: var(--text-base);
  padding-left: var(--space-5);
}

.nav-mobile-cta {
  margin-top: var(--space-4);
}

/* ─── Breakpoints ───────────────────────────────────────── */

@media (max-width: 900px) {
  /* Hide desktop nav; show hamburger */
  .nav-links,
  .nav-cta {
    display: none;
  }

  .nav-mobile-toggle {
    display: flex;
  }

  .site-header {
    height: var(--nav-height-mobile);   /* 60px */
  }
}

@media (max-width: 480px) {
  .nav-container {
    padding: 0 var(--space-5);
  }

  .nav-logo__label {
    font-size: var(--text-sm);
  }
}

/* ─── Page offset for fixed header ─────────────────────── */
/*
 * Add this class to <body> or use the CSS variable
 * --nav-height as padding-top on your first page section.
 */

body.has-fixed-nav {
  padding-top: var(--nav-height);
}

@media (max-width: 900px) {
  body.has-fixed-nav {
    padding-top: var(--nav-height-mobile);
  }
}


/* ─────────────────────────────────────────────────────── */
/* MOBILE MENU DRILL-DOWNS (2026-07-11)                     */
/* Services and Solutions collapse behind tap-to-expand     */
/* group buttons so the menu stays short. JS adds           */
/* .nav-collapsed at init; without JS the flat list shows.  */
/* ─────────────────────────────────────────────────────── */

.nav-mobile-group {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  background: none;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  color: var(--color-body-steel);
  padding: var(--space-3) var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid #E4E4E2;
  transition: color var(--transition-fast),
              background-color var(--transition-fast);
}

.nav-mobile-group:hover,
.nav-mobile-group[aria-expanded="true"] {
  color: var(--color-obsidian);
}

.nav-mobile-group__chev {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.nav-mobile-group[aria-expanded="true"] .nav-mobile-group__chev {
  transform: rotate(180deg);
}

.nav-mobile-menu.nav-collapsed li[data-group] {
  display: none;
}

.nav-mobile-menu.nav-collapsed li[data-group].is-open {
  display: block;
}

/* ── "View all solutions" row at the foot of the dropdown ── */

.nav-item--dropdown .nav-dropdown__link--all {
  display: block;
  padding: var(--space-3) var(--space-4);
  margin-top: var(--space-1);
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-gold);
  text-decoration: none;
}

.nav-item--dropdown .nav-dropdown__link--all:hover,
.nav-item--dropdown .nav-dropdown__link--all:focus-visible {
  color: #FFFFFF;
}
