/* ===============================================
   Header Component - Mobile First Approach
   Single breakpoint at 1200px
   =============================================== */

/* ===============================================
   Base styles (Mobile < 1200px)
   =============================================== */

/* Header container */
.site-header {
  background: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

/* Logo */
.site-header__logo {
  flex-shrink: 0;
  z-index: 1001;
}

.site-header__logo img {
  height: 36px;
  width: auto;
}

/* Japanese version logo - displays both image and text */
.site-header__logo--ja {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-header__logo--ja .site-header__logo-text {
  font-size: 1.25rem;
  color: #333;
  font-weight: 500;
}

/* Screen reader only text (used for Chinese version) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Hide desktop elements on mobile */
.desktop-nav,
.desktop-contact,
.desktop-search,
.site-header__language {
  display: none;
}

/* Mobile menu toggle button */
.mobile-menu-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 1001;
  transition: all 0.3s ease;
}

.mobile-menu-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background-color: #333;
  margin: 3px 0;
  transition: all 0.3s ease;
}

/* Toggle animation to X */
.mobile-menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}

.mobile-menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

/* Mobile menu container */
.mobile-menu {
  position: fixed;
  top: 60px;
  left: 0;
  width: 100%;
  height: calc(100vh - 60px);
  max-height: calc(100vh - 60px);
  background: white;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  padding: 20px 20px 40px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mobile-menu.active {
  transform: translateX(0);
}

/* Mobile menu list */
.mobile-menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mobile-menu-list li {
  border-bottom: 1px solid #eee;
}

.mobile-menu-list > li > a {
  display: block;
  padding: 16px 0;
  color: #333;
  text-decoration: none;
  font-weight: 500;
  font-size: 16px;
  transition: color 0.3s ease;
}

.mobile-menu-list > li > a:hover,
.mobile-menu-list > li > a:focus {
  color: var(--blue);
}

/* Mobile submenu */
.mobile-menu-list .sub-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  background: #f8f9fa;
  border-radius: 4px;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}

.mobile-menu-list .sub-menu li {
  border-bottom: none;
}

.mobile-menu-list .sub-menu a {
  display: block;
  padding: 12px 16px;
  color: #666;
  text-decoration: none;
  font-size: 14px;
  transition: all 0.3s ease;
}

.mobile-menu-list .sub-menu a:hover {
  background: var(--light-gray);
  color: var(--blue);
}

/* Expand icon for items with children */
.mobile-menu-list .menu-item-has-children > a::after {
  content: '+';
  float: right;
  font-size: 20px;
  line-height: 1;
  transition: transform 0.3s ease;
}

.mobile-menu-list .menu-item-has-children.active > a::after {
  transform: rotate(45deg);
}

/* Mobile contact info */
.mobile-contact {
  padding: 20px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #333;
  font-size: 16px;
}

/* Mobile search */
.mobile-search {
  padding: 20px 0 0;
  border-top: 1px solid #eee;
}

.mobile-search .search-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mobile-search .search-form input[type="search"] {
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 16px;
  width: 100%;
  box-sizing: border-box;
}

.mobile-search .search-form input[type="submit"] {
  padding: 12px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s ease;
}

.mobile-search .search-form input[type="submit"]:hover {
  background: #1d4ed8;
}

/* Prevent body scroll when menu is open */
body.mobile-menu-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

/* Small height device optimization */
@media (max-height: 600px) {
  .mobile-menu {
    padding: 16px 20px 20px;
  }

  .mobile-menu-list > li > a {
    padding: 12px 0;
  }

  .mobile-contact {
    padding: 12px 0;
  }

  .mobile-search {
    padding: 12px 0 0;
  }
}

/* iOS safe area */
@supports (padding: max(0px)) {
  .mobile-menu {
    padding-bottom: max(40px, env(safe-area-inset-bottom) + 20px);
  }
}

/* ===============================================
   Desktop styles (≥ 1200px)
   =============================================== */
@media (min-width: 1200px) {
  /* Header adjustments */
  .site-header {
    height: 70px;
    padding: 0 32px;
  }

  .site-header__logo img {
    height: 40px;
  }

  /* Hide mobile elements */
  .mobile-menu-toggle,
  .mobile-menu {
    display: none;
  }

  /* Show desktop elements */
  .desktop-nav,
  .desktop-contact,
  .desktop-search,
  .site-header__language {
    display: flex;
  }

  /* Desktop navigation */
  .site-header__nav {
    margin: 0 16px;
    flex-grow: 1;
    display: flex;
    justify-content: right;
  }

  .primary-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 1.5rem;
  }

  .primary-menu > li {
    position: relative;
    padding: 20px 0;
  }

  .primary-menu > li > a {
    color: #333;
    text-decoration: none;
    font-weight: 500;
    padding: 10px 0;
    transition: color 0.3s ease;
  }

  .primary-menu > li:hover > a {
    color: var(--blue);
  }

  /* Desktop submenu */
  .primary-menu .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    min-width: 200px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    list-style: none;
    padding: 8px 0;
    z-index: 100;
  }

  .primary-menu .sub-menu li {
    padding: 0;
  }

  .primary-menu .sub-menu a {
    color: #333;
    text-decoration: none;
    padding: 8px 20px;
    display: block;
    transition: background-color 0.2s;
  }

  .primary-menu > li:hover .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .primary-menu .sub-menu a:hover {
    background-color: var(--light-gray);
    color: var(--blue);
  }

  /* Desktop contact */
  .site-header__contact {
    margin: 0 16px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 4px;
  }

  /* Language switcher container */
  .site-header__language {
    margin: 0 8px;
  }

  /* Desktop search */
  .site-header__search {
    flex-shrink: 0;
  }

  .search-form {
    display: flex;
    align-items: center;
  }

  .search-form input[type="search"] {
    padding: 8px 12px;
    margin: 0 0 0 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 124px;
    font-size: 14px;
  }

  .search-form input[type="submit"] {
    padding: 8px 12px;
    margin-left: 8px;
    background: var(--blue);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
  }

  .search-form input[type="submit"]:hover {
    background: #1d4ed8;
  }
}