/**
 * public/css/header.css
 * --------------------------------------------------------------------------------
 * Edge-delivered site header.
 *
 * Prerendered Astro pages style the header through Header.astro's scoped <style>,
 * compiled into the hashed /_astro/BaseLayout.<hash>.css. Worker-served pages
 * (catalog axis + product pages) hand-emit the same class names but never load
 * that bundle, so they need these rules as a plain global stylesheet.
 *
 * Copied verbatim from src/components/common/Header.astro's <style>. Every rule
 * is already gated behind `@media (hover: hover) and (pointer: fine)`, so
 * check_hover_guard passes. This file is only linked from edge renderers, so it
 * cannot double-apply on prerendered pages.
 * --------------------------------------------------------------------------------
 */

/* Off-canvas drawer lives at translateX(100%) when parked. Mirrors BaseLayout's
   global guard so the parked drawer cannot widen the document. `clip`, not
   `hidden`: `hidden` would turn <html> into a scroll container and break the
   sticky header. */
html {
  overflow-x: clip;
}
body {
  overflow-x: clip;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #162a42;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
  gap: 32px;
}

/* Nav, search and the mobile toggle travel together on the right. */
.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

/* Branding */
.brand-link {
  text-decoration: none;
  display: flex;
  align-items: center;
}

.logo {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.logo-main {
  color: #ffffff;
}

.logo-accent {
  color: #f59e0b;
}

.logo-db {
  color: rgba(255, 255, 255, 0.78);
  font-weight: 400;
}

/* Desktop Navigation */
.desktop-nav {
  flex: 1;
  display: flex;
  justify-content: center;
}

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

.nav-item {
  position: relative;
}

.nav-item > a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nav-item.active > a {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

@media (hover: hover) and (pointer: fine) {
  .nav-item > a:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
  }
}

.nav-item.active > a {
  color: #f59e0b;
}

/* Dropdown */
.dropdown-trigger {
  cursor: pointer;
}

.dropdown-arrow {
  transition: transform 0.15s ease;
}

@media (hover: hover) and (pointer: fine) {
  .nav-item.has-dropdown:hover .dropdown-arrow {
    transform: rotate(180deg);
  }
}

.dropdown-panel {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  min-width: 280px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(15, 36, 64, 0.2), 0 4px 12px rgba(15, 36, 64, 0.1);
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 100;
}

@media (hover: hover) and (pointer: fine) {
  .nav-item.has-dropdown:hover .dropdown-panel {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
  }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.15s;
}

@media (hover: hover) and (pointer: fine) {
  .dropdown-item:hover {
    background: #f1f5f9;
  }
}

.dropdown-icon {
  width: 36px;
  height: 36px;
  background: #f1f5f9;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a3a5c;
  flex-shrink: 0;
}

@media (hover: hover) and (pointer: fine) {
  .dropdown-item:hover .dropdown-icon {
    background: #e0f2fe;
    color: #0284c7;
  }
}

.dropdown-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-title {
  font-size: 14px;
  font-weight: 600;
  color: #1a3a5c;
}

.dropdown-desc {
  font-size: 12px;
  color: #64748b;
}

/* Mobile Toggle */
.mobile-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  background: none;
  border: none;
  cursor: pointer;
}

.toggle-bar {
  width: 24px;
  height: 2px;
  background: #ffffff;
  border-radius: 2px;
  transition: all 0.15s;
}

/* Mobile Navigation */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 998;
  opacity: 0;
  transition: opacity 0.2s;
}

.mobile-nav-overlay.active {
  display: block;
  opacity: 1;
}

.mobile-nav {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  max-width: 85vw;
  height: 100vh;
  background: #ffffff;
  /* Must clear .site-header's z-index:1000 so the close button stays tappable. */
  z-index: 1001;
  transform: translateX(100%);
  transition: transform 0.3s ease, visibility 0.3s;
  overflow-y: auto;
  /* Parked drawer must not be focusable or hit-testable. */
  visibility: hidden;
}

.mobile-nav.open {
  transform: translateX(0);
  visibility: visible;
}

.mobile-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #e2e8f0;
}

.mobile-logo {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: #1a3a5c;
}

.mobile-close {
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
}

.mobile-nav-content {
  padding: 16px;
  padding-bottom: max(16px, calc(16px + env(safe-area-inset-bottom, 0px)));
}

.mobile-link {
  display: block;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #1a3a5c;
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.15s;
}

@media (hover: hover) and (pointer: fine) {
  .mobile-link:hover {
    background: #f1f5f9;
  }
}

.mobile-link.mobile-sub {
  padding-left: 32px;
  font-size: 14px;
  color: #475569;
}

.mobile-section {
  margin-top: 8px;
}

.mobile-section-title {
  display: block;
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Desktop Language Switcher */
.lang-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.lang-switcher.open .lang-btn {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
}

@media (hover: hover) and (pointer: fine) {
  .lang-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.3);
  }
}

.lang-arrow {
  transition: transform 0.15s ease;
}

.lang-switcher.open .lang-arrow {
  transform: rotate(180deg);
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 290px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 12px 28px -5px rgba(0, 0, 0, 0.22);
  padding: 8px;
  display: none;
  grid-template-columns: repeat(2, minmax(135px, 1fr));
  gap: 4px;
  z-index: 1050;
}

/* Open state is driven solely by `.open` on the wrapper (set by the script). */
.lang-switcher.open .lang-dropdown {
  display: grid;
}

.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  transition: background 0.15s;
}

@media (hover: hover) and (pointer: fine) {
  .lang-option:hover {
    background: #f1f5f9;
    color: #0284c7;
  }
}

.lang-option.active {
  background: #e0f2fe;
  color: #0369a1;
}

.lang-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #64748b;
}

.lang-option.active .lang-tag {
  background: #bae6fd;
  color: #0369a1;
}

/* Mobile Language Options Grid */
.mobile-lang-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 6px 16px 16px;
}

.mobile-lang-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  text-decoration: none;
  color: #1e293b;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s;
}

@media (hover: hover) and (pointer: fine) {
  .mobile-lang-chip:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
  }
}

.mobile-lang-chip.active {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff;
}

.mobile-lang-sub {
  font-size: 10px;
  opacity: 0.75;
  font-weight: 700;
}

/* Search entry point */
.header-search {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 14px;
  padding: 7px 13px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.header-search.active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.38);
  color: #fff;
}

@media (hover: hover) and (pointer: fine) {
  .header-search:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.38);
    color: #fff;
  }
}

/* Responsive */
@media (min-width: 1025px) and (max-width: 1240px) {
  .header-inner {
    gap: 16px;
  }
  .nav-item > a {
    padding: 8px 10px;
    font-size: 13px;
    gap: 4px;
  }
}

@media (max-width: 1024px) {
  .header-inner {
    gap: 12px;
  }

  .desktop-nav {
    display: none;
  }

  .header-actions {
    gap: 8px;
  }

  .mobile-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
  }

  .header-search-text {
    display: none;
  }
  .header-search {
    margin-left: auto;
    margin-right: 0;
    min-width: 42px;
    min-height: 42px;
    padding: 8px 10px;
    justify-content: center;
  }

  .lang-btn {
    min-height: 38px;
    padding: 6px 10px;
  }
}

@media (max-width: 380px) {
  .header-inner {
    gap: 8px;
  }

  .logo {
    font-size: 19px;
  }

  .header-actions {
    gap: 6px;
  }

  .header-search {
    margin-right: 0;
    padding: 8px;
    min-width: 38px;
    min-height: 38px;
  }

  .lang-btn {
    padding: 5px 8px;
    gap: 4px;
    font-size: 11.5px;
    min-height: 36px;
  }

  .mobile-toggle {
    min-width: 40px;
    min-height: 40px;
    padding: 8px 6px;
  }
}
