/**
 * Navigation Styles
 *
 * Header and navigation menu styles for the Onwords theme.
 * Uses BEM naming convention and CSS variables from variables.css.
 */

/* ========================================
   Header Container
   ======================================== */

.header {
  position: sticky;
  top: 0;
  width: 100%;
  max-width: 100%;
  background: var(--header-bg-color);
  padding: var(--header-padding-desktop);
  z-index: var(--header-z-index);

  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;

  border-bottom: 1px solid #dbdbdb;

  /* Fade-in animation on page load */
  opacity: 0;
  transform: translateY(-8px);
  animation: fadeInFromTop var(--transition-standard) forwards;
  animation-delay: 800ms;
}

@keyframes fadeInFromTop {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================
   Logo
   ======================================== */

.header__logo-link {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  text-decoration: none;
}

.header__logo {
  width: var(--logo-width-desktop);
  height: auto;
  max-width: 100%;
  display: block;
  flex-shrink: 0;
}

/* ========================================
   Desktop Navigation
   ======================================== */

.header__nav {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 25px;
  flex-shrink: 1;
}

.header__nav--desktop {
  display: flex;
}

.header__menu {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 25px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.header__menu li {
  position: relative;
}

.header__menu > li > a {
  color: var(--nav-link-color);
  text-decoration: none;
  transition: opacity var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 500;
  line-height: 28px;
}

.header__menu > li > a:hover {
  opacity: var(--nav-link-hover-opacity);
}

/* Static navigation links (採用情報 & お問い合わせ) */
.header__nav-link {
  color: var(--nav-link-color);
  text-decoration: none;
  font-size: 16px;
  font-weight: 400;
  line-height: 16px;
  white-space: nowrap;
  transition: opacity var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 4px;
}

.header__nav-link:hover {
  opacity: var(--nav-link-hover-opacity);
}

/* External link icon (採用情報) - Font Awesome 6 */
.header__nav-link--external::after {
  font-family: "Font Awesome 6 Free";
  font-weight: 900; /* Solid style */
  content: "\f08e"; /* fa-arrow-up-right-from-square */
  font-size: 14px;
  line-height: 1;
}

/* Contact button (お問い合わせ) - from STUDIO site (完全コピー - 2層構造) */
.header__nav-link--contact {
  position: relative;
  padding: 10px 16px;
  margin: 0;
  color: rgb(51, 51, 51); /* Dark gray text in normal state */
  background: rgb(231, 74, 74); /* Solid red in normal state */
  border-radius: 4px;
  font-size: 16px;
  font-weight: 400;
  line-height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden; /* Hide overflowing background layer */
  transition: all 0.3s cubic-bezier(0.4, 0.4, 0, 1);
}

/* Background layer - slides in from left on hover */
.header__nav-link-bg {
  position: absolute;
  top: 0;
  left: -260px; /* Start off-screen to the left */
  right: 86px;
  bottom: 0;
  background: rgb(231, 74, 74); /* Solid red in normal state */
  opacity: 0;
  z-index: 0;
  transition: all 0.3s cubic-bezier(0.4, 0.4, 0, 1);
}

/* Text layer - ensure it's above background */
.header__nav-link-text {
  position: relative;
  z-index: 1;
  color: rgb(255, 255, 255); /* White text - explicitly set on text element */
}

.header__nav-link--contact:hover .header__nav-link-bg {
  left: 0px; /* Slide in from left */
  right: -174px; /* Extend to the right */
  opacity: 1; /* Fade in */
  background: linear-gradient(75deg, rgb(230, 1, 18) 0%, rgb(238, 175, 15) 37%, rgb(248, 82, 30) 100%); /* Gradient angle changes to 75deg */
  transition-duration: 400ms; /* 0.4s */
  transition-timing-function: ease-in-out;
}

/* Dropdown arrow icon for parent menu items - Material Icons */
.header__menu .menu-item-has-children > a::after {
  font-family: "Material Icons";
  content: "\e5c5"; /* arrow_drop_down */
  font-size: 16px;
  line-height: 1;
}

/* Submenu (dropdown) */
.header__menu .sub-menu {
  position: absolute;
  top: 25px;
  left: 0;
  min-width: 176px;
  background: var(--header-bg-color);
  border: none;
  border-radius: 16px;
  box-shadow: none;
  list-style: none;
  margin: 0;
  padding: 20px;
  z-index: 1001;

  /* Flexbox layout for items */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 40px;

  /* Hidden by default */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity var(--transition-fast),
              visibility var(--transition-fast),
              transform var(--transition-fast);
}

/* Show submenu on parent hover */
.header__menu .menu-item-has-children:hover > .sub-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Submenu items */
.header__menu .sub-menu li {
  position: relative;
}

.header__menu .sub-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  color: var(--nav-link-color);
  font-size: 14px;
  font-weight: 500;
  line-height: 16.8px;
  letter-spacing: 0.7px;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity var(--transition-fast);
}

/* Submenu arrow icon - Material Icons */
.header__menu .sub-menu a::before {
  font-family: "Material Icons";
  content: "\e315"; /* keyboard_arrow_right */
  font-size: 18px;
  line-height: 18px;
  color: var(--nav-link-color);
}

.header__menu .sub-menu a:hover {
  opacity: var(--nav-link-hover-opacity);
}

/* ========================================
   Hamburger Menu Button (Mobile)
   ======================================== */

.header__hamburger-btn {
  display: none; /* Hidden by default, shown on mobile */
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: var(--hamburger-line-spacing);
  width: auto;
  height: 28px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.header__hamburger-btn:hover {
  opacity: 0.3;
}

.header__hamburger-line {
  height: var(--hamburger-line-height);
  background: var(--hamburger-line-color);
  border-radius: 100px;
  transition: all var(--transition-fast);
}

.header__hamburger-line--1 {
  width: 30px;
}

.header__hamburger-line--2 {
  width: 20px;
}

.header__hamburger-line--3 {
  width: 10px;
}

/* ========================================
   Mobile Menu
   ======================================== */

.header__mobile-menu {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgb(255, 255, 255);
  padding: 62px 20px 40px;
  overflow-y: auto;
  z-index: 1000;

  /* Hidden by default - use visibility for smooth animation */
  visibility: hidden;
  opacity: 0;
  transform: translateX(100%); /* 右から左へスライドイン */
  transition: opacity 0.3s cubic-bezier(0.4, 0.4, 0, 1),
              transform 0.3s cubic-bezier(0.4, 0.4, 0, 1),
              visibility 0s 0.3s; /* visibility changes after animation ends */
}

.header__mobile-menu.is-open {
  visibility: visible;
  opacity: 1;
  transform: translateX(0);
  transition: opacity 0.3s cubic-bezier(0.4, 0.4, 0, 1),
              transform 0.3s cubic-bezier(0.4, 0.4, 0, 1),
              visibility 0s 0s; /* visibility changes immediately when opening */
}

/* Logo in mobile menu (top left) */
.header__mobile-menu-logo-link {
  position: absolute;
  top: 20px;
  left: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  z-index: 2;
}

.header__mobile-menu-logo {
  width: 120px; /* Smaller than header logo */
  height: auto;
  display: block;
}

/* Close Button - matches STUDIO site (complete copy) */
.header__mobile-menu-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 30px;
  height: 28px;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 2;
  transition: opacity var(--transition-fast);
}

.header__mobile-menu-close:hover {
  opacity: 0.7;
}

/* Close button line 1 (×の1本目の線) */
.header__mobile-menu-close-line--1 {
  position: absolute;
  top: 13px;
  left: 1px;
  width: 28px;
  height: 2px;
  background-color: rgb(34, 34, 34);
  border-radius: 100px;
  transform: rotate(45deg);
  transform-origin: 14px 1px;
}

/* Close button line 2 (×の2本目の線) */
.header__mobile-menu-close-line--2 {
  position: absolute;
  top: 14px;
  left: 1px;
  width: 28px;
  height: 2px;
  background-color: rgb(34, 34, 34);
  border-radius: 100px;
  transform: rotate(-45deg);
  transform-origin: 14px 1px;
}

.header__mobile-menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.header__mobile-menu-list li {
  /* border moved to <a> elements */
}

.header__mobile-menu-list a:not(.header__mobile-menu-contact) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--mobile-menu-item-padding);
  color: var(--nav-link-color);
  text-decoration: none;
  font-size: var(--mobile-menu-font-size);
  font-weight: var(--mobile-menu-font-weight);
  line-height: var(--mobile-menu-line-height);
  border-bottom: 1px solid var(--mobile-menu-border-color);
}

/* Material Icons keyboard_arrow_right - added via JavaScript */
.header__mobile-menu-list a:not(.header__mobile-menu-contact) .material-icons {
  font-size: 28px; /* Matches STUDIO site */
  line-height: 1;
  color: var(--nav-link-color);
}

.header__mobile-menu-list a:not(.header__mobile-menu-contact):hover {
  opacity: var(--nav-link-hover-opacity);
}

/* Sub-menu items (children) - 親と同じ見た目で左に余白 */
.header__mobile-menu-list .sub-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.header__mobile-menu-list .sub-menu li {
  /* border inherited from parent .header__mobile-menu-list a rule */
}

.header__mobile-menu-list .sub-menu a {
  /* 親と同じフォントサイズと太さ */
  font-size: var(--mobile-menu-font-size);
  font-weight: var(--mobile-menu-font-weight);
  line-height: var(--mobile-menu-line-height);

  /* 左に余白を追加（インデント）、上下は親と同じ */
  padding: 15px 0 15px 32px; /* 上 右 下 左 */
}

/* Sub-menu arrow icons (same size as parent) */
.header__mobile-menu-list .sub-menu a .material-icons {
  font-size: 28px; /* 親と同じサイズ */
  line-height: 1;
  color: var(--nav-link-color);
}

/* Static mobile menu items (採用情報・お問い合わせ) */
.header__mobile-menu-list--static {
  margin-top: 0;
  padding-top: 0;
  /* border-topを削除 - 前のメニューのborder-bottomで境界線が表示される */
}

/* 採用情報の最初のliにmargin-topを追加して余白を確保 */
.header__mobile-menu-list--static > li:first-child {
  margin-top: 10px;
}

/* Recruitment link with external icon and arrow - matches STUDIO site */
.header__mobile-menu-recruitment {
  display: flex;
  align-items: center;
  justify-content: space-between; /* テキストグループと arrow を両端に配置 */
}

/* Text group (採用情報 + external icon) */
.header__mobile-menu-recruitment-text {
  display: flex;
  align-items: center;
  gap: 4px; /* 採用情報と外部リンクアイコンの距離 */
}

/* External link icon (small) - right after text */
.header__mobile-menu-recruitment-text::after {
  font-family: "Font Awesome 6 Free";
  font-weight: 900; /* Solid style */
  content: "\f08e"; /* fa-arrow-up-right-from-square */
  font-size: 18px; /* Smaller than arrow */
  line-height: 1;
}

/* Arrow icon (larger) - Material Icons added via JavaScript */
.header__mobile-menu-recruitment .material-icons {
  font-size: 32px; /* Larger than other arrows - matches STUDIO */
  line-height: 1;
  color: var(--nav-link-color);
}

.header__mobile-menu-contact {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 10px 16px 42px; /* STUDIO site: 上右下左 */
  margin-top: 20px;
  margin-bottom: 0;
  width: 320px; /* STUDIO site: fixed width */
  height: 56.5px; /* STUDIO site */
  color: rgb(255, 255, 255); /* STUDIO site: white text */
  background: linear-gradient(90deg, rgb(230, 1, 18) 0%, rgb(248, 82, 30) 100%); /* STUDIO site: 2-color gradient */
  border-radius: 4px;
  font-size: 16px; /* Parent font size */
  font-weight: 400; /* Parent font weight */
  line-height: 16px;
  overflow: hidden; /* STUDIO site */
  transition: all 0.3s cubic-bezier(0.4, 0.4, 0, 1);
  text-decoration: none;
}

/* Background layer - slides in from left on hover */
.header__mobile-menu-contact-bg {
  position: absolute;
  top: 0;
  left: -260px; /* Start off-screen to the left */
  right: 86px;
  bottom: 0;
  background: linear-gradient(75deg, rgb(230, 1, 18) 0%, rgb(238, 175, 15) 37%, rgb(248, 82, 30) 100%);
  opacity: 0;
  z-index: 0;
  transition: all 0.3s cubic-bezier(0.4, 0.4, 0, 1);
}

/* Text layer - ensure it's above background */
.header__mobile-menu-contact-text {
  position: relative;
  z-index: 1;
  font-size: 14px; /* STUDIO site */
  font-weight: 700; /* STUDIO site */
  line-height: 24.5px; /* STUDIO site */
  color: rgb(255, 255, 255); /* STUDIO site: white */
}

/* Arrow icon for contact button - Material Icons added via JavaScript */
.header__mobile-menu-contact .material-icons {
  font-size: 24px; /* STUDIO site: 24px (not 28px) */
  line-height: 1;
  color: rgb(255, 255, 255); /* STUDIO site: white */
  position: relative;
  z-index: 1;
}

.header__mobile-menu-contact:hover .header__mobile-menu-contact-bg,
.header__mobile-menu-contact:active .header__mobile-menu-contact-bg {
  left: 0px; /* Slide in from left */
  right: -174px; /* Extend to the right */
  opacity: 1; /* Fade in */
  background: linear-gradient(75deg, rgb(230, 1, 18) 0%, rgb(238, 175, 15) 37%, rgb(248, 82, 30) 100%); /* Gradient angle changes to 75deg */
  transition-duration: 400ms; /* 0.4s */
  transition-timing-function: ease-in-out;
}

/* ========================================
   Responsive Design
   ======================================== */

/* Tablet and below (< 1140px) */
@media screen and (max-width: 1140px) {
  .header__logo {
    width: var(--logo-width-tablet);
  }
}

/* Mobile and below (< 540px) */
@media screen and (max-width: 540px) {
  .header {
    padding: var(--header-padding-mobile-lg);
  }

  .header__logo {
    width: var(--logo-width-tablet);
  }

  /* Hide desktop navigation */
  .header__nav--desktop {
    display: none;
  }

  /* Show hamburger menu button */
  .header__hamburger-btn {
    display: flex;
  }
}

/* Small mobile (< 320px) */
@media screen and (max-width: 320px) {
  .header {
    padding: var(--header-padding-mobile-sm);
  }
}
