/**
 * WorkAndHire Enterprise Header
 * Visual target: legacy WorkAndHire marketplace header (pill nav, Start Listings, auth bar).
 * Uses design tokens from public/css/tokens.css — no duplicate token definitions.
 */

/* ------------------------------------------------------------------ layout */
.wah-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--color-bg, #fff);
}

.wah-header__accent {
  height: 6px;
  background: var(--color-primary, #8c0605);
}

.wah-header__main {
  border-bottom: 1px solid var(--color-border, #d0d0d0);
}

.wah-header .wah-header__inner.container {
  width: 100%;
  max-width: none;
  padding-inline: clamp(16px, 2vw, 32px);
}

.wah-header__inner {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0;
  min-height: 80px;
  padding-top: var(--space-2, 8px);
  padding-bottom: var(--space-2, 8px);
}

.wah-header__start,
.wah-header__end {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: nowrap;
  gap: 0;
}

.wah-header__start {
  /* Legacy: logo margin-left 10px; Start Listings ~40px after logo block */
  min-width: 0;
}

.wah-header__center {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  min-width: 0;
}

.wah-header__end {
  margin-left: auto;
  justify-content: flex-end;
}

/* Desktop: true 3-zone alignment — logo/start left, pills centered, auth far right */
@media (min-width: 1101px) {
  .wah-header__inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-areas: "start center end";
    align-items: center;
    column-gap: 16px;
  }

  .wah-header__start {
    grid-area: start;
    justify-self: start;
  }

  .wah-header__center {
    grid-area: center;
    justify-self: center;
    flex: none;
  }

  .wah-header__end {
    grid-area: end;
    justify-self: end;
    margin-left: 0;
  }

  /* Desktop: no How It Works, no Jobs dropdown — auth only on the right */
  .wah-secondary-nav {
    display: none !important;
  }
}

/* ------------------------------------------------------------------ logo */
.wah-logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
  margin-left: 10px;
  margin-right: 40px;
}

.wah-logo__image {
  display: block;
  width: auto;
  height: 48px;
  max-width: 140px;
}

/* ------------------------------------------------------------------ buttons */
.wah-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: var(--radius-sm, 4px);
  font-family: var(--font-base, 'Open Sans', sans-serif);
  font-size: var(--font-size-base, 1rem);
  font-weight: var(--font-weight-medium, 600);
  line-height: 1.25;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--transition-fast, 0.15s ease),
              color var(--transition-fast, 0.15s ease),
              border-color var(--transition-fast, 0.15s ease),
              box-shadow var(--transition-fast, 0.15s ease);
}

.wah-btn--start-listings {
  background: #000;
  color: #fff;
  border-color: #000;
  padding: 6px 12px;
  font-size: 18px;
  font-weight: 400;
  flex-shrink: 0;
}

.wah-btn--start-listings:hover,
.wah-btn--start-listings:focus-visible {
  background: #222;
  color: #fff;
}

.wah-btn--register {
  background: #ffa500;
  color: #fff;
  border-color: #ffa500;
  border-radius: var(--radius-lg, 20px);
  padding: 0 20px;
  height: 32px;
  line-height: 32px;
  font-size: 14px;
  font-weight: 500;
  flex-shrink: 0;
}

.wah-btn--register:hover,
.wah-btn--register:focus-visible {
  background: #e69500;
  border-color: #e69500;
  color: #fff;
}

.wah-btn--outline {
  background: transparent;
  color: var(--color-text, #333);
  border-color: var(--color-border, #d0d0d0);
}

.wah-btn--block {
  width: 100%;
}

.wah-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border: 0;
  background: transparent;
  color: var(--color-text, #333);
  font-family: inherit;
  font-size: var(--font-size-sm, 0.875rem);
  font-weight: var(--font-weight-medium, 600);
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  border-radius: var(--radius-sm, 4px);
  transition: color var(--transition-fast, 0.15s ease);
}

.wah-link-btn:hover,
.wah-link-btn:focus-visible {
  color: #ffa500;
}

.wah-auth-bar__login {
  font-size: var(--font-size-base, 1rem);
  padding: 6px 8px;
  flex-shrink: 0;
}

/* ------------------------------------------------------------------ primary pill nav */
.wah-primary-nav__list {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.wah-primary-nav__item {
  flex-shrink: 0;
}

.wah-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: 2px solid #2045b5;
  border-radius: 14px;
  background: #fce5cd;
  box-shadow: 0 4px 0 #ffff00;
  color: #990000;
  font-family: var(--font-base, 'Open Sans', sans-serif);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color var(--transition-fast, 0.15s ease),
              box-shadow var(--transition-fast, 0.15s ease),
              transform var(--transition-fast, 0.15s ease);
}

.wah-pill-btn:hover,
.wah-pill-btn:focus-visible {
  background: #ffebcc;
  box-shadow: 0 6px 0 #ffcc00;
  color: #990000;
}

.wah-pill-btn.is-active {
  background: #fff5e6;
  outline: 2px solid var(--color-primary, #8c0605);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ secondary nav */
.wah-secondary-nav__list {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.wah-secondary-nav__item {
  position: relative;
}

/* ------------------------------------------------------------------ dropdowns */
.wah-dropdown {
  position: relative;
}

.wah-dropdown__menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  padding: 12px;
  background: var(--color-bg, #fff);
  border: 1px solid var(--color-border, #d0d0d0);
  border-radius: var(--radius-md, 8px);
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.12));
  z-index: 220;
}

.wah-dropdown__menu[hidden] {
  display: none !important;
}

.wah-dropdown__group {
  margin: 0 0 6px;
  font-size: 0.75rem;
  color: var(--color-text-muted, #6c6c6c);
}

.wah-dropdown__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 6px;
  color: var(--color-text, #333);
  text-decoration: none;
  border-radius: var(--radius-sm, 4px);
  font-size: 0.875rem;
}

.wah-dropdown__item:hover,
.wah-dropdown__item:focus-visible {
  background: var(--color-bg-subtle, #f3f3f3);
  color: var(--color-text, #333);
}

.wah-dropdown__item-label {
  font-weight: 700;
}

.wah-dropdown__item-desc {
  font-size: 0.75rem;
  color: var(--color-text-muted, #6c6c6c);
}

.wah-dropdown__divider {
  margin: 8px 0;
  border: 0;
  border-top: 1px solid var(--color-border, #d0d0d0);
}

.wah-logout-form {
  margin: 0;
  padding: 0;
}

.wah-logout-form--block {
  display: block;
}

.wah-logout-form__btn {
  display: flex;
  width: 100%;
  margin: 0;
  padding: 8px 6px;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.wah-mobile-nav__link.wah-logout-form__btn {
  padding: 10px 0;
}

.wah-logout-form__btn:hover,
.wah-logout-form__btn:focus-visible {
  background: var(--color-bg-subtle, #f3f3f3);
  color: var(--color-text, #333);
}

.wah-dropdown.is-open .wah-dropdown__trigger .wah-icon--chevron {
  transform: rotate(180deg);
}

/* ------------------------------------------------------------------ auth bar */
.wah-auth-bar {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  margin-right: 8px;
  flex-shrink: 0;
}

.wah-notifications--guest {
  display: none;
}

.wah-notifications,
.wah-messages {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  overflow: visible;
}

.wah-notifications__trigger,
.wah-messages__link {
  position: relative;
}

.wah-notifications__badge,
.wah-messages__badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--color-primary, #8c0605);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.wah-messages__link {
  overflow: visible;
}

.wah-messages .wah-messages__badge {
  top: -4px;
  right: -4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  line-height: 1;
  pointer-events: none;
  z-index: 1;
}

.wah-messages .wah-messages__badge[hidden],
.wah-mobile-nav__link.wah-mobile-nav__messages .wah-messages__badge[hidden] {
  display: none !important;
}

.wah-notifications__sound {
  width: auto;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border-radius: var(--radius-sm, 4px);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  color: var(--color-text, #333);
}

.wah-notifications__sound[aria-pressed="true"] {
  color: var(--color-primary, #8c0605);
}

.toast.toast--notify {
  border-left: 4px solid var(--color-primary, #8c0605);
  cursor: pointer;
  font-size: 0.875rem;
  line-height: 1.45;
}

.wah-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full, 100%);
  background: transparent;
  color: var(--color-text, #333);
  cursor: pointer;
}

.wah-icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.wah-icon {
  display: block;
  flex-shrink: 0;
}

.wah-icon--chevron {
  transition: transform var(--transition-fast, 0.15s ease);
}

/* ------------------------------------------------------------------ profile */
.wah-profile__trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border: 1px solid var(--color-border, #d0d0d0);
  border-radius: var(--radius-lg, 20px);
  background: var(--color-bg, #fff);
  color: var(--color-text, #333);
  font: inherit;
  cursor: pointer;
}

.wah-profile__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full, 100%);
  background: var(--color-primary, #8c0605);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 700;
}

.wah-profile__name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
  font-weight: 600;
}

.wah-profile__menu {
  right: 0;
  left: auto;
}

/* ------------------------------------------------------------------ mobile toggle */
.wah-mobile-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  border: 0;
  border-radius: var(--radius-sm, 4px);
  background: transparent;
  cursor: pointer;
}

.wah-mobile-toggle__bar {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--color-text, #333);
  transition: transform var(--transition-fast, 0.15s ease),
              opacity var(--transition-fast, 0.15s ease);
}

.wah-mobile-toggle[aria-expanded="true"] .wah-mobile-toggle__bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.wah-mobile-toggle[aria-expanded="true"] .wah-mobile-toggle__bar:nth-child(2) {
  opacity: 0;
}

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

/* ------------------------------------------------------------------ mobile nav */
.wah-mobile-nav {
  border-top: 1px solid var(--color-border, #d0d0d0);
  background: var(--color-bg, #fff);
  padding: var(--space-4, 16px);
}

.wah-mobile-nav[hidden] {
  display: none !important;
}

.wah-mobile-nav.is-open {
  display: block;
}

.wah-mobile-nav__section + .wah-mobile-nav__section {
  margin-top: var(--space-4, 16px);
  padding-top: var(--space-4, 16px);
  border-top: 1px solid var(--color-border, #d0d0d0);
}

.wah-mobile-nav__heading {
  margin: 0 0 var(--space-2, 8px);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted, #6c6c6c);
}

.wah-mobile-nav__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.wah-mobile-nav__link {
  display: block;
  padding: 12px 0;
  min-height: 44px;
  color: var(--color-text, #333);
  text-decoration: none;
  font-weight: 600;
}

.wah-mobile-nav__link:hover,
.wah-mobile-nav__link:focus-visible {
  color: var(--color-primary, #8c0605);
}

.wah-mobile-nav__link.wah-mobile-nav__messages {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wah-mobile-nav__link.wah-mobile-nav__messages .wah-messages__badge {
  position: static;
  top: auto;
  right: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  line-height: 1;
  pointer-events: none;
  flex-shrink: 0;
}

.wah-mobile-nav__section--auth {
  display: flex;
  flex-direction: column;
  gap: var(--space-2, 8px);
}

body.wah-nav-open {
  overflow: hidden;
}

/* ------------------------------------------------------------------ responsive */
/* Tighten pill padding on narrower desktops — keep single row through 1366px (5 pills) */
@media (min-width: 1101px) and (max-width: 1600px) {
  .wah-primary-nav__list {
    gap: 8px;
  }

  .wah-pill-btn {
    padding: 10px 16px;
    font-size: 15px;
  }

  .wah-logo {
    margin-right: 32px;
  }
}

@media (min-width: 1101px) and (max-width: 1440px) {
  .wah-pill-btn {
    padding: 10px 14px;
    font-size: 15px;
  }

  .wah-logo {
    margin-right: 28px;
  }
}

@media (min-width: 1101px) and (max-width: 1366px) {
  .wah-primary-nav__list {
    gap: 6px;
  }

  .wah-pill-btn {
    padding: 10px 11px;
    font-size: 14px;
  }

  .wah-logo__image {
    height: 44px;
    max-width: 130px;
  }

  .wah-btn--start-listings {
    font-size: 16px;
    padding: 6px 10px;
  }
}

@media (max-width: 1100px) {
  .wah-header__center {
    display: none;
  }

  .wah-secondary-nav {
    display: none;
  }

  .wah-mobile-toggle {
    display: inline-flex;
  }

  .wah-auth-bar__login,
  .wah-btn--register,
  .wah-profile,
  .wah-notifications,
  .wah-messages {
    display: none;
  }

  /* Mobile nav: fixed panel below header, scrollable */
  .wah-mobile-nav.is-open {
    display: block;
    position: fixed;
    top: var(--wah-mobile-nav-top, 70px);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 210;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: none;
    padding-bottom: calc(var(--space-6, 32px) + env(safe-area-inset-bottom, 0px));
  }

  .wah-header.wah-header--nav-open {
    z-index: 220;
  }
}

@media (max-width: 768px) {
  .wah-header__inner {
    min-height: 64px;
    flex-wrap: wrap;
  }

  .wah-header__start {
    flex: 1 1 auto;
  }

  .wah-btn--start-listings {
    display: none;
  }

  .wah-logo__image {
    height: 40px;
  }
}

@media (min-width: 769px) and (max-width: 1100px) {
  .wah-mobile-nav.is-open {
    display: block;
  }
}

@media (min-width: 1101px) {
  .wah-mobile-nav {
    display: none !important;
  }
}

@media (max-width: 480px) {
  .wah-header__inner {
    gap: var(--space-2, 8px);
  }

  .wah-logo__image {
    height: 36px;
    max-width: 110px;
  }
}

/* Focus visibility */
.wah-btn:focus-visible,
.wah-link-btn:focus-visible,
.wah-pill-btn:focus-visible,
.wah-mobile-toggle:focus-visible,
.wah-profile__trigger:focus-visible,
.wah-dropdown__trigger:focus-visible {
  outline: 2px solid var(--color-accent, #24b7e5);
  outline-offset: 2px;
}

/* Hide legacy header styles when enterprise header is active */
.wah-body .site-header {
  display: none;
}

/* ------------------------------------------------------------------ */
/* Accessibility: skip-to-content link.                               */
/* The skip-link markup lives in the shared layout header (rendered   */
/* on every public + member page). These rules keep it visually       */
/* hidden until it receives keyboard focus (WCAG 2.4.1). They live in */
/* header.css specifically because header.css is the one stylesheet   */
/* loaded by every page through views/layouts/header.php — pages that */
/* only load a per-page sheet (e.g. auth.css) would otherwise render  */
/* the link as permanently visible text.                             */
/* ------------------------------------------------------------------ */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 9999;
}

.skip-link:focus {
  left: 20px;
  top: 20px;
  width: auto;
  height: auto;
  overflow: visible;
  padding: 10px 16px;
  background: #b30000;
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
}

/* Live event popup (notifications-unread.js) — reuses the site's existing card/alert visual
   language and .btn button classes (see public/css/buttons.css, loaded globally via
   enterprise.css) rather than a new design system. Sized and weighted so a major event (new
   order, delivery, cancellation, acceptance) is genuinely hard to miss, not tiny bell-icon text. */
.wah-notif-toast {
  position: fixed;
  top: 84px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 380px;
  padding: 18px 36px 16px 18px;
  background: #fff;
  color: #222;
  border: 1px solid #e5e7eb;
  border-left: 5px solid var(--color-primary, #8c0605);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  animation: wah-notif-toast-in .2s ease-out;
}

.wah-notif-toast__title {
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
  color: var(--color-primary, #8c0605);
}

.wah-notif-toast__body {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: #333;
  overflow-wrap: anywhere;
}

.wah-notif-toast__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.wah-notif-toast__close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: 0;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: #999;
  cursor: pointer;
  padding: 4px;
}

.wah-notif-toast__close:hover {
  color: #333;
}

@keyframes wah-notif-toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
  .wah-notif-toast {
    left: 12px;
    right: 12px;
    max-width: none;
    top: auto;
    bottom: 12px;
  }
}
