/* ========================================
   HEADER - Clean White Design
   Orange Main Accent
   ======================================== */
@layer base, layout, components, utilities, pages;

@layer components {

/* ========================================
   CSS Variables for Header
   ======================================== */
.im-header {
  --header-height: 88px;
  --header-bg: var(--color-surface);
  --header-bg-scrolled: rgba(255, 255, 255, 0.97);
  --header-border: var(--color-border);
  --header-text: var(--color-text-strong);
  --header-text-muted: var(--color-text-muted);
  --header-transition: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ========================================
   Main Header Container
   ======================================== */
.im-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  transition:
    background 0.4s var(--header-transition),
    box-shadow 0.4s var(--header-transition);
}

/* Top accent line - Orange dominant */
.im-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--color-secondary);
}

.im-header::after {
  content: none;
}

.im-header.is-scrolled {
  background: var(--header-bg-scrolled);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow:
    0 1px 0 var(--header-border),
    0 8px 32px rgba(0, 0, 0, 0.08);
}

/* ========================================
   Header Inner Container
   ======================================== */
.im-header__inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: clamp(32px, 4vw, 64px);
  min-height: var(--header-height);
}

/* ========================================
   Brand Section (Left)
   ======================================== */
.im-header__brand {
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  z-index: 10;
}

.im-header__logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  position: relative;
  padding: 4px 0;
}

.im-header__logo::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--color-secondary);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.5s var(--header-transition);
}

.im-header__logo:hover::before {
  transform: scaleX(1);
  transform-origin: left;
}

.im-header__logo img {
  display: block;
  height: clamp(36px, 4vw, 48px);
  width: auto;
  aspect-ratio: 2183 / 454;
  transition: opacity 0.3s ease;
}

.im-header__logo:hover img {
  opacity: 0.8;
}

/* Operator Badge */
.im-header__operator {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--color-surface-muted);
  border: 1px solid var(--header-border);
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.3s ease;
}

@media (min-width: 900px) {
  .im-header__operator {
    display: flex;
  }
}

.im-header__operator:hover {
  background: var(--color-secondary-soft);
  border-color: var(--color-secondary);
}

.im-header__operator-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--header-text-muted);
}

.im-header__operator-logo {
  height: 14px;
  width: auto;
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

.im-header__operator:hover .im-header__operator-logo {
  opacity: 1;
}

/* ========================================
   Controls Section (Right)
   ======================================== */
.im-header__controls {
  display: flex;
  align-items: center;
  gap: clamp(16px, 2vw, 32px);
  justify-content: flex-end;
}

/* ========================================
   Desktop Navigation
   ======================================== */
.im-header__nav-inline {
  display: none;
}

@media (min-width: 1100px) {
  .im-header__nav-inline {
    display: block;
  }
}

.im-header__menu-inline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: nowrap;
}

.im-header__menu-inline .menu-item {
  margin: 0;
  position: relative;
  display: flex;
  align-items: stretch;
}

.im-header__menu-inline a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px clamp(16px, 2vw, 28px);
  color: var(--header-text);
  text-decoration: none;
  transition: all 0.3s ease;
}

/* Bottom accent line on hover - Orange */
.im-header__menu-inline a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: var(--color-secondary);
  transition: width 0.3s var(--header-transition);
}

/* English label (top) - Orange */
.im-header__menu-inline .menu-item__en {
  display: block;
  font-family: 'DM Sans', sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-secondary);
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

/* Japanese label (bottom) */
.im-header__menu-inline .menu-item__ja {
  display: block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--header-text);
  transition: color 0.3s ease;
}

/* Hover state */
.im-header__menu-inline a:hover .menu-item__en {
  opacity: 1;
}

.im-header__menu-inline a:hover .menu-item__ja {
  color: var(--color-secondary);
}

.im-header__menu-inline a:hover::after {
  width: 100%;
}

/* Active state */
.im-header__menu-inline a[aria-current="page"] .menu-item__en {
  opacity: 1;
}

.im-header__menu-inline a[aria-current="page"] .menu-item__ja {
  color: var(--color-secondary);
}

.im-header__menu-inline a[aria-current="page"]::after {
  width: 100%;
}

/* ========================================
   Header Actions (CTA Buttons)
   ======================================== */
.im-header__actions {
  display: none;
  gap: 10px;
}

@media (min-width: 1100px) {
  .im-header__actions {
    display: flex;
  }
}

.im-header__cta {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 12px 24px;
  white-space: nowrap;
  border-radius: 6px;
  transition: all 0.3s var(--header-transition);
  position: relative;
  overflow: hidden;
}

/* Secondary button (資料DL) - Orange outline */
.im-header__actions > .btn:not(.btn--primary) {
  background: transparent;
  color: var(--color-secondary);
  border: 2px solid var(--color-secondary);
}

.im-header__actions > .btn:not(.btn--primary):hover {
  background: var(--color-secondary);
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px var(--color-secondary-glow);
}

/* Primary button (お問い合わせ) - Orange filled */
.im-header__actions > .btn--primary {
  background: var(--color-secondary);
  color: #ffffff;
  border: none;
  box-shadow: 0 4px 12px var(--color-secondary-glow);
}

.im-header__actions > .btn--primary:hover {
  background: var(--color-secondary-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--color-secondary-glow);
}

/* ========================================
   Mobile Menu Toggle
   ======================================== */
.im-header__toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 52px;
  height: 52px;
  background: var(--color-secondary);
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  z-index: 1001;
}

@media (min-width: 1100px) {
  .im-header__toggle {
    display: none;
  }
}

.im-header__toggle:hover {
  background: var(--color-secondary-dark);
}

.im-header__burger {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 22px;
}

.im-header__burger span {
  display: block;
  width: 100%;
  height: 2px;
  background: #ffffff;
  transition: all 0.3s var(--header-transition);
  transform-origin: center;
}

/* Open state */
.im-header__toggle[aria-expanded="true"] {
  background: var(--color-secondary-dark);
}

.im-header__toggle[aria-expanded="true"] .im-header__burger span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.im-header__toggle[aria-expanded="true"] .im-header__burger span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.im-header__toggle[aria-expanded="true"] .im-header__burger span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ========================================
   Mobile Navigation Panel
   ======================================== */
.im-header__nav {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(100vw, 480px);
  background: var(--color-surface);
  z-index: 1000;
  transform: translateX(100%);
  transition: transform 0.5s var(--header-transition);
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.1);
}

/* Top accent line - Orange */
.im-header__nav::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--color-secondary);
}

.im-header__nav[aria-hidden="false"] {
  transform: translateX(0);
}

/* Close button */
.im-header__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 48px;
  height: 48px;
  background: var(--color-secondary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.3s ease;
}

.im-header__close:hover {
  background: var(--color-secondary-dark);
}

.im-header__close-icon {
  position: relative;
  width: 18px;
  height: 18px;
}

.im-header__close-icon span {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 2px;
  background: #ffffff;
  transition: all 0.3s ease;
}

.im-header__close-icon span:nth-child(1) {
  transform: translateY(-50%) rotate(45deg);
}

.im-header__close-icon span:nth-child(2) {
  transform: translateY(-50%) rotate(-45deg);
}

/* ========================================
   Mobile Menu Content
   ======================================== */
.im-menu {
  padding: 80px 24px 32px;
  position: relative;
  min-height: 100%;
  background: var(--color-surface);
}

.im-menu__media {
  display: none !important;
}

.im-menu__panel {
  position: relative;
  z-index: 1;
}

/* Menu Section */
.im-menu__section {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--header-border);
}

.im-menu__section:last-child {
  border-bottom: none;
}

.im-menu__section-title {
  margin: 0 0 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--color-secondary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.im-menu__section-title::before {
  content: '';
  width: 16px;
  height: 2px;
  background: var(--color-secondary);
}

.im-menu__section-text {
  display: block;
}

/* Menu List */
.im-menu__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.im-menu__item {
  margin: 0;
}

.im-menu__link {
  display: block;
  padding: 14px 16px;
  text-decoration: none;
  background: var(--color-surface);
  border-left: 3px solid transparent;
  border-radius: 0 8px 8px 0;
  transition: all 0.3s ease;
  position: relative;
}

.im-menu__link:hover,
.im-menu__link[aria-current="page"] {
  background: var(--color-secondary-soft);
  border-left-color: var(--color-secondary);
}

.im-menu__content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.im-menu__text-en {
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-secondary);
  opacity: 0.7;
  transition: color 0.3s ease;
}

.im-menu__link:hover .im-menu__text-en,
.im-menu__link[aria-current="page"] .im-menu__text-en {
  opacity: 1;
}

.im-menu__text-ja {
  font-size: 15px;
  font-weight: 700;
  color: var(--header-text);
  letter-spacing: 0.01em;
}

.im-menu__link:hover .im-menu__text-ja {
  color: var(--color-secondary);
}

.im-menu__desc {
  font-size: 12px;
  color: var(--header-text-muted);
  line-height: 1.5;
  margin-top: 2px;
}

/* Featured menu item - 他のアイテムと同じスタイル */
.im-menu__item--featured .im-menu__link {
  background: var(--color-surface);
  border-left: 3px solid var(--color-secondary);
}

.im-menu__item--featured .im-menu__link:hover {
  background: var(--color-secondary-soft);
}

/* ========================================
   Mobile Quick Actions
   ======================================== */
.im-header__quick {
  padding: 20px 24px;
  background: var(--color-surface-muted);
  border-top: 1px solid var(--header-border);
  display: flex;
  gap: 10px;
}

.im-header__quick .btn {
  flex: 1;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  padding: 14px 20px;
  border-radius: 8px;
}

.im-header__quick .btn:not(.btn--primary) {
  background: var(--color-surface);
  border: 2px solid var(--color-secondary);
  color: var(--color-secondary);
}

.im-header__quick .btn--primary {
  background: var(--color-secondary);
  border: none;
  color: #fff;
}

/* ========================================
   Mobile Brand Panel (Footer of nav)
   ======================================== */
.im-header__brandpanel {
  padding: 24px;
  background: var(--color-secondary);
  color: #ffffff;
}

.im-header__brandpanel-logo {
  display: inline-block;
  margin-bottom: 16px;
}

.im-header__brandpanel-logo img {
  height: 40px;
  width: auto;
  aspect-ratio: 2183 / 454;
  filter: brightness(0) invert(1);
}

.im-header__brandpanel-name {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
}

.im-header__address {
  font-style: normal;
  font-size: 13px;
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 16px;
}

.im-header__contact {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.im-header__tel {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: none;
  border-radius: 8px;
  color: var(--color-secondary);
  font-size: 14px;
  font-weight: 700;
  padding: 12px 18px;
  text-decoration: none;
  transition: all 0.3s ease;
  align-self: flex-start;
}

.im-header__tel:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-2px);
}

.im-header__tel-label {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-secondary);
  opacity: 0.8;
}

.im-header__tel-number {
  font-family: 'DM Sans', sans-serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--color-secondary);
}

/* Operator section in panel */
.im-header__brandpanel-operator {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.im-header__brandpanel-operator-label {
  display: block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 10px;
}

.im-header__brandpanel-operator-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.3s ease;
}

.im-header__brandpanel-operator-link:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

.im-header__brandpanel-operator-link img {
  height: 20px;
  width: auto;
  filter: brightness(0) invert(1);
  opacity: 0.8;
}

.im-header__brandpanel-operator-link:hover img {
  opacity: 1;
}

.im-header__brandpanel-operator-link svg {
  color: rgba(255, 255, 255, 0.7);
  transition: all 0.3s ease;
}

.im-header__brandpanel-operator-link:hover svg {
  color: #ffffff;
  transform: translate(2px, -2px);
}

/* ========================================
   Overlay
   ======================================== */
.im-header__nav::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: -1;
}

.im-header__nav[aria-hidden="false"]::after {
  opacity: 1;
  pointer-events: auto;
}

/* ========================================
   Dropdown Menu
   ======================================== */
.menu-item--has-dropdown {
  position: relative;
}

.menu-item__trigger {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 14px clamp(16px, 2vw, 28px);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--header-text);
  transition: all 0.3s ease;
  position: relative;
  font-family: inherit;
  line-height: inherit;
  vertical-align: middle;
}

.menu-item__trigger::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: var(--color-secondary);
  transition: width 0.3s var(--header-transition);
}

.menu-item__trigger .menu-item__en {
  display: block;
  font-family: 'DM Sans', sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-secondary);
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

.menu-item__trigger .menu-item__ja {
  display: inline;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--header-text);
  transition: color 0.3s ease;
}

.menu-item__arrow {
  display: inline-block;
  vertical-align: middle;
  width: 8px;
  height: 5px;
  color: var(--header-text-muted);
  transition: transform 0.3s ease, color 0.3s ease;
  margin-left: 4px;
  position: relative;
  top: -1px;
}

.menu-item__trigger:hover .menu-item__en,
.menu-item--has-dropdown.is-open .menu-item__trigger .menu-item__en {
  opacity: 1;
}

.menu-item__trigger:hover .menu-item__ja,
.menu-item--has-dropdown.is-open .menu-item__trigger .menu-item__ja {
  color: var(--color-secondary);
}

.menu-item__trigger:hover .menu-item__arrow,
.menu-item--has-dropdown.is-open .menu-item__trigger .menu-item__arrow {
  color: var(--color-secondary);
}

.menu-item__trigger:hover::after,
.menu-item--has-dropdown.is-open .menu-item__trigger::after {
  width: 100%;
}

.menu-item--has-dropdown.is-open .menu-item__arrow {
  transform: rotate(180deg);
}

/* Dropdown panel */
.menu-item__dropdown {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  min-width: 200px;
  background: var(--color-surface);
  border: 1px solid var(--header-border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  list-style: none;
  margin: 0;
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
  z-index: 100;
}

.menu-item__dropdown::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  height: 8px;
}

.menu-item--has-dropdown.is-open .menu-item__dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.menu-item__dropdown li {
  margin: 0;
}

.menu-item__dropdown a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.menu-item__dropdown a:hover,
.menu-item__dropdown a[aria-current="page"] {
  background: var(--color-secondary-soft);
}

.dropdown__en {
  font-family: 'DM Sans', sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-secondary);
  opacity: 0.7;
}

.menu-item__dropdown a:hover .dropdown__en,
.menu-item__dropdown a[aria-current="page"] .dropdown__en {
  opacity: 1;
}

.dropdown__ja {
  font-size: 14px;
  font-weight: 600;
  color: var(--header-text);
  transition: color 0.2s ease;
}

.menu-item__dropdown a:hover .dropdown__ja,
.menu-item__dropdown a[aria-current="page"] .dropdown__ja {
  color: var(--color-secondary);
}

/* ========================================
   Compact Mode (1100px - 1400px)
   Hides English labels, reduces padding
   ======================================== */
@media (min-width: 1100px) and (max-width: 1400px) {
  /* Hide English labels */
  .im-header__menu-inline .menu-item__en,
  .menu-item__trigger .menu-item__en {
    display: none;
  }

  /* Reduce menu item padding */
  .im-header__menu-inline a {
    padding: 14px clamp(10px, 1.2vw, 16px);
  }

  .menu-item__trigger {
    padding: 14px clamp(10px, 1.2vw, 16px);
  }

  /* Remove gap between lines since English is hidden */
  .im-header__menu-inline a,
  .menu-item__trigger {
    gap: 0;
  }

  /* Slightly larger Japanese text to compensate */
  .im-header__menu-inline .menu-item__ja,
  .menu-item__trigger .menu-item__ja {
    font-size: 14px;
  }

  /* Compact CTA buttons */
  .im-header__cta {
    padding: 10px 16px;
    font-size: 12px;
  }

  /* Reduce gap between controls */
  .im-header__controls {
    gap: clamp(12px, 1.5vw, 24px);
  }

  /* Reduce inner container gap */
  .im-header__inner {
    gap: clamp(20px, 2.5vw, 40px);
  }

  /* Hide operator badge to save space */
  .im-header__operator {
    display: none;
  }
}

}
