/* ============================================================
   PIPPIN — Header & Navigation Styles
   Axon-inspired mega menu design
   ============================================================ */

/* ── SITE HEADER ──────────────────────────────────────────── */
body {
  padding-top: 72px;
}

.site-header,
.mobile-nav {
  --teal:       #00c9a7;
  --teal-dim:   rgba(0, 201, 167, 0.15);
  --teal-dk:    #00a88c;
}

.site-header {
  background: var(--surface);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  border-bottom: 1px solid var(--border);
  transition: transform 0.3s ease;
}

.site-header.header-hidden {
  transform: translateY(-100%);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 40px;
  height: 72px;
}

/* ── LOGO ─────────────────────────────────────────────────── */
.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
}

.header-logo svg {
  height: 36px;
  width: auto;
}

.header-logo .wordmark {
  font-family: 'Inter Tight', var(--sys);
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.5px;
}

/* ── MAIN NAV ─────────────────────────────────────────────── */
.header-nav {
  display: flex;
  align-items: center;
  gap: 0;
  margin-left: 48px;
}

.nav-item {
  position: relative;
}

.nav-item > a,
.nav-item > button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 24px 20px;
  font-family: var(--sys);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s;
  white-space: nowrap;
}

.nav-item > a:hover,
.nav-item > button:hover,
.nav-item.is-open > button {
  color: var(--ink);
}

/* Active indicator bar */
.nav-item::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20px;
  right: 20px;
  height: 3px;
  background: var(--teal);
  transform: scaleX(0);
  transition: transform 0.2s ease;
}

.nav-item:hover::after,
.nav-item.is-open::after,
.nav-item.is-active::after {
  transform: scaleX(1);
}

/* Dropdown arrow */
.nav-item button .nav-arrow {
  width: 10px;
  height: 10px;
  transition: transform 0.2s ease;
}

.nav-item button .nav-arrow path {
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.nav-item.is-open button .nav-arrow {
  transform: rotate(180deg);
}

/* ── MEGA MENU ────────────────────────────────────────────── */
.mega-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  box-shadow: 0 20px 60px rgba(13, 27, 42, 0.15);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
  z-index: 1001;
}

.nav-item.is-open .mega-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Full-width mega menu */
.mega-menu.mega-menu--full {
  position: fixed;
  top: 72px;
  left: 0;
  right: 0;
  width: 100%;
}

.mega-menu-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px;
  display: grid;
  gap: 48px;
}

/* Product mega menu - with sidebar */
.mega-menu--product .mega-menu-inner {
  grid-template-columns: 200px 1fr 320px;
}

/* Solutions mega menu */
.mega-menu--solutions .mega-menu-inner {
  grid-template-columns: 200px 1fr;
}

/* ── FLAT LAYOUT (no sidebar) ─────────────────────────────── */
.mega-menu-inner.mega-flat {
  grid-template-columns: 1fr;
}

.mega-menu--product .mega-menu-inner.mega-flat {
  grid-template-columns: 1fr 260px;
}

.mega-flat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px;
}

.mega-flat-col .mega-section-title {
  margin-bottom: 12px;
}

/* ── ROLE CARDS (Solutions menu) ──────────────────────────── */
.mega-role-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.mega-role-card {
  display: flex;
  flex-direction: column;
  padding: 28px 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.mega-role-card:hover {
  border-color: var(--teal);
  box-shadow: 0 4px 20px rgba(0, 201, 167, 0.1);
  transform: translateY(-2px);
}

.mega-role-card[aria-current="page"] {
  border-color: var(--teal);
  background: rgba(0, 201, 167, 0.04);
  box-shadow: 0 4px 20px rgba(0, 201, 167, 0.1);
  pointer-events: none;
}

.mega-role-card[aria-current="page"] h4 {
  color: var(--teal-dk);
}

.mega-role-card[aria-current="page"] .mega-role-cta {
  opacity: 0;
}

.mega-role-icon {
  margin-bottom: 16px;
}

.mega-role-card h4 {
  font-family: var(--sys);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 8px 0;
}

.mega-role-card p {
  font-family: var(--lato);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-mid);
  margin: 0;
  flex: 1;
}

.mega-role-cta {
  display: inline-block;
  margin-top: 16px;
  font-family: var(--sys);
  font-size: 13px;
  font-weight: 600;
  color: var(--teal-dk);
}

/* ── MEGA MENU SIDEBAR (Categories) ───────────────────────── */
.mega-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-right: 1px solid var(--border);
  padding-right: 32px;
}

.mega-sidebar-item {
  padding: 14px 16px;
  font-family: var(--sys);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-mid);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mega-sidebar-item:hover,
.mega-sidebar-item.is-active {
  background: var(--surface-alt);
  color: var(--ink);
}

.mega-sidebar-item.is-active {
  border-left: 3px solid var(--teal);
  margin-left: -3px;
  font-weight: 600;
}

.mega-sidebar-item svg {
  width: 16px;
  height: 16px;
  opacity: 0;
  transition: opacity 0.15s;
}

.mega-sidebar-item:hover svg,
.mega-sidebar-item.is-active svg {
  opacity: 0.5;
}

/* ── MEGA MENU CONTENT ────────────────────────────────────── */
.mega-content {
  display: none;
  padding-left: 16px;
}

.mega-content.is-active {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.mega-content-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
}

.mega-section-title {
  font-family: var(--sys);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 16px;
  padding-left: 4px;
}

.mega-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mega-link {
  display: block;
  padding: 10px 12px;
  font-family: var(--sys);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.mega-link:hover {
  background: var(--surface-alt);
  color: var(--teal-dk);
}

.mega-link[aria-current="page"] {
  background: var(--surface-alt);
  color: var(--teal-dk);
  pointer-events: none;
}

.mega-link-desc {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-soft);
  margin-top: 2px;
}

.mega-link--disabled {
  display: block;
  padding: 10px 12px;
  font-family: var(--sys);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-soft);
  border-radius: 8px;
  cursor: default;
  opacity: 0.7;
  position: relative;
  overflow: hidden;
}

.mobile-nav-link--disabled {
  color: var(--ink-soft);
  cursor: default;
  opacity: 0.7;
  position: relative;
  overflow: hidden;
}

/* ── MEGA MENU FEATURED ───────────────────────────────────── */
.mega-featured {
  background: var(--surface-alt);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.mega-featured-item {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mega-featured-thumb {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16/9;
  background: var(--navy);
}

.mega-featured-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mega-featured-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  background: var(--teal);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--white);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.mega-featured-play svg {
  width: 16px;
  height: 16px;
  margin-left: 2px;
}

.mega-featured-text {
  font-family: var(--lato);
  font-size: 13px;
  color: var(--ink-mid);
  line-height: 1.5;
}

.mega-featured-text a {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.mega-featured-text a:hover {
  color: var(--teal-dk);
}

/* ── HEADER RIGHT (Login + CTA) ───────────────────────────── */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-login {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  font-family: var(--sys);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  border-radius: 6px;
  transition: background 0.15s;
}

.header-login:hover {
  background: var(--surface-alt);
}

.header-login svg {
  width: 12px;
  height: 12px;
}

.header-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  font-family: var(--sys);
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
  background: var(--teal);
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}

.header-cta:hover {
  background: var(--teal-dk);
}

.header-cta:active {
  transform: scale(0.98);
}

/* ── MOBILE TOGGLE ────────────────────────────────────────── */
.header-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  margin-right: -8px;
  overflow: visible;
  min-width: 38px;
  min-height: 38px;
}

.header-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--ink);
  margin: 5px 0;
  border-radius: 1px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.header-toggle.is-active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.header-toggle.is-active span:nth-child(2) {
  opacity: 0;
}

.header-toggle.is-active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ── MOBILE NAV ───────────────────────────────────────────── */
.mobile-nav {
  display: none;
  position: fixed;
  top: 73px;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  z-index: 999;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.mobile-nav.is-open {
  display: block;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

.mobile-nav-inner {
  padding: 0;
}

/* Mobile accordion items */
.mobile-nav-item {
  border-bottom: 1px solid var(--border);
}

.mobile-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  font-family: var(--sys);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}

.mobile-nav-header svg {
  width: 20px;
  height: 20px;
  transition: transform 0.2s ease;
}

.mobile-nav-item.is-open .mobile-nav-header svg {
  transform: rotate(180deg);
}

/* Simple link (no accordion) */
a.mobile-nav-header {
  text-decoration: none;
}

a.mobile-nav-header svg {
  transform: rotate(-90deg);
}

/* Mobile accordion content */
.mobile-nav-content {
  display: none;
  background: var(--surface-alt);
  padding: 8px 0;
}

.mobile-nav-item.is-open .mobile-nav-content {
  display: block;
}

.mobile-nav-section {
  padding: 16px 24px 8px;
}

.mobile-nav-section-title {
  font-family: var(--sys);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 12px;
}

.mobile-nav-links {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.mobile-nav-link {
  display: block;
  padding: 12px 0;
  font-family: var(--sys);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-mid);
  text-decoration: none;
}

.mobile-nav-link:hover {
  color: var(--teal-dk);
}

.mobile-nav-link[aria-current="page"] {
  color: var(--teal-dk);
  pointer-events: none;
}

.mobile-nav-header[aria-current="page"] {
  color: var(--teal-dk);
  pointer-events: none;
}

/* Mobile nav footer (login, CTA) */
.mobile-nav-footer {
  padding: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
}

.mobile-nav-login {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  font-family: var(--sys);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  border: 1.5px solid var(--border);
  border-radius: 8px;
}

.mobile-nav-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  font-family: var(--sys);
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
  background: var(--teal);
  border-radius: 8px;
  text-decoration: none;
}

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 1100px) {
  .header-inner {
    padding: 0 24px;
  }
  
  .header-nav {
    margin-left: 32px;
  }
  
  .nav-item > a,
  .nav-item > button {
    padding: 24px 14px;
    font-size: 15px;
  }
  
  .mega-menu--product .mega-menu-inner {
    grid-template-columns: 180px 1fr 280px;
    padding: 32px;
  }

  .mega-menu--product .mega-menu-inner.mega-flat {
    grid-template-columns: 1fr 220px;
    padding: 32px;
  }

  .mega-flat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
  }

  .mega-role-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }

  .mega-role-card {
    padding: 20px 18px;
  }

  .mega-role-card p {
    font-size: 13px;
  }
}

@media (max-width: 960px) {
  body {
    padding-top: 64px;
  }

  .header-nav {
    display: none;
  }

  .header-right {
    margin-left: auto;
  }

  .header-right .header-login,
  .header-right .header-cta {
    display: none;
  }
  
  .header-toggle {
    display: block;
    margin-left: 8px;
  }
  
  .header-inner {
    height: 64px;
  }
  
  .header-logo svg {
    height: 32px;
  }
  
  .header-logo .wordmark {
    font-size: 22px;
  }
  
  .mobile-nav {
    top: 65px;
  }
}

@media (max-width: 640px) {
  body {
    padding-top: 56px;
  }

  .header-inner {
    padding: 0 16px;
    height: 56px;
  }
  
  .header-logo svg {
    height: 28px;
  }
  
  .header-logo .wordmark {
    font-size: 20px;
  }
  
  .mobile-nav {
    top: 57px;
  }
  
  .mobile-nav-header {
    padding: 16px 20px;
  }
  
  .mobile-nav-section {
    padding: 12px 20px 8px;
  }
  
  .mobile-nav-footer {
    padding: 20px;
  }
}

/* ── OVERLAY WHEN MENU IS OPEN ────────────────────────────── */
.header-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(13, 27, 42, 0.4);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.header-overlay.is-visible {
  display: block;
  opacity: 1;
}

/* ── LOGO SVG — respects ink token for dark mode ─────────── */
.header-logo svg path {
  stroke: var(--ink);
}

/* ── THEME TOGGLE ───────────────────────────────────────── */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  color: var(--ink-mid);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
  padding: 0;
}

.theme-toggle:hover {
  background: var(--surface-alt);
  color: var(--ink);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Show/hide sun vs moon based on active theme */
/* No preference set yet + light OS → show moon (offer dark) */
html:not([data-theme="dark"]) .theme-icon--moon { display: block; }
html:not([data-theme="dark"]) .theme-icon--sun  { display: none; }
html[data-theme="dark"]       .theme-icon--moon { display: none; }
html[data-theme="dark"]       .theme-icon--sun  { display: block; }

/* When OS is dark but no manual preference → also show sun (already dark) */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not([data-theme="dark"]) .theme-icon--moon { display: none; }
  html:not([data-theme="light"]):not([data-theme="dark"]) .theme-icon--sun  { display: block; }
}
