/*
 * 共通ヘッダー CSS (Phase B)
 *
 * 設計:
 *   - DESIGN.md / global-design.css の token (--gold / --bg / --border) を継承
 *   - 各ツール側で上書き可能なトークンは 3 つに限定:
 *       --header-bg       : ヘッダー背景
 *       --header-border   : ヘッダー下境界
 *       --header-accent   : ハンバーガー bar / アクティブ表示 / hover
 *   - data-tool="<id>" 属性で scope override 可能 (basicloop / phonics 等)
 *
 * 例 (basicloop で warm 系を retain):
 *   .site-header[data-tool="basicloop"] {
 *     --header-bg: #faf8f3;
 *     --header-border: #e5dfd2;
 *     --header-accent: #d96c5e;
 *   }
 *
 * z-index 規定:
 *   .site-header        : 300
 *   .site-mobile-nav    : 301
 *   .site-hamburger     : 302
 *   .nav-dd-menu        : 310 (header 内 dropdown)
 *   .mobile-nav-close   : 303
 *   ツール固有の sticky CTA は 200 以下で揃える
 */

.site-header {
  --header-bg: rgba(246,243,236, 0.92);
  --header-border: #e5dfd2;
  --header-accent: #1d7f96;

  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 300;
  background: var(--header-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--header-border);
  padding: 10px 0;
  transition: padding 0.3s ease, box-shadow 0.3s ease;
}

.site-header.scrolled {
  padding: 6px 0;
  box-shadow: 0 1px 12px rgba(51,65,74, 0.08);
}

.site-header-spacer {
  height: var(--header-h, 54px);
}

.site-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-header-logo {
  font-size: 19px;
  font-weight: 900;
  letter-spacing: -0.4px;
  color: rgba(51,65,74, 0.92);
  text-decoration: none;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-header-logo svg {
  width: 23px;
  height: 23px;
  color: var(--header-accent);
}

.site-header-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.site-header-nav > a {
  font-size: 13px;
  font-weight: 500;
  color: rgba(51,65,74,0.7);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 10px;
  transition: all 0.2s ease;
  white-space: nowrap;
  position: relative;
}

.site-header-nav > a:hover {
  color: rgba(51,65,74, 0.88);
  background: rgba(51,65,74, 0.04);
}

.site-header-nav > a.active {
  color: var(--header-accent);
  font-weight: 700;
}

/* CTA: Pro（本命商品。ヘッダー内で唯一の塗りボタン） */
.nav-cta-pro {
  background: linear-gradient(135deg, #1d7f96, #186f83) !important;
  color: #fff !important;
  font-weight: 900 !important;
  padding: 7px 16px !important;
  border-radius: 9999px !important;
  font-size: 13px !important;
  box-shadow: 0 2px 8px rgba(29,127,150,0.3);
}

.nav-cta-pro:hover {
  filter: brightness(1.06);
  background: linear-gradient(135deg, #1d7f96, #186f83) !important;
}

.lang-toggle {
  font-size: 12px !important;
  color: rgba(51,65,74,0.7) !important;
}

/* Dropdown */
.nav-dd {
  position: relative;
}

.nav-dd-trigger {
  font-size: 13px;
  font-weight: 500;
  color: rgba(51,65,74,0.7);
  background: none;
  border: none;
  cursor: pointer;
  padding: 7px 12px;
  border-radius: 10px;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 3px;
  font-family: inherit;
}

.nav-dd-trigger:hover {
  color: rgba(51,65,74, 0.88);
  background: rgba(51,65,74, 0.04);
}

.nav-dd-trigger.active {
  color: var(--header-accent);
  font-weight: 700;
}

.dd-chevron {
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.nav-dd:hover .dd-chevron,
.nav-dd.open .dd-chevron {
  transform: rotate(180deg);
}

.nav-dd-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 180px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--header-border);
  box-shadow: 0 8px 32px rgba(51,65,74, 0.10), 0 2px 8px rgba(51,65,74, 0.04);
  padding: 6px;
  margin-top: 4px;
  z-index: 310;
}

.nav-dd:hover .nav-dd-menu,
.nav-dd.open .nav-dd-menu {
  display: block;
}

.nav-dd-menu a {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: rgba(51,65,74,0.74);
  text-decoration: none;
  padding: 9px 14px;
  border-radius: 8px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nav-dd-menu a:hover {
  color: rgba(51,65,74, 0.88);
  background: rgba(51,65,74, 0.04);
}

.nav-dd-menu a.active {
  color: var(--header-accent);
  font-weight: 700;
}

/* Hamburger */
.site-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  position: relative;
  z-index: 302;
}

.site-hamburger:hover {
  background: rgba(51,65,74, 0.04);
}

.site-hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: rgba(51,65,74, 0.88);
  margin: 4px auto;
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}

.site-hamburger.active span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.site-hamburger.active span:nth-child(2) {
  opacity: 0;
}

.site-hamburger.active span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* Mobile drawer */
.site-mobile-nav {
  display: flex;
  visibility: hidden;
  pointer-events: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.96);
  z-index: 301;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex-direction: column;
  /* スクロールは内側の .site-mobile-nav-scroll が担当する。
     drawer 自体をスクロールさせると、中の absolute な閉じるボタンが
     一緒に流れて下端で画面外に出てしまうため。 */
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.3s, visibility 0.3s;
}

.site-mobile-nav-scroll {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* 項目数が viewport を超えると justify-content:center は上側のあふれを
     スクロールで到達不能にする（0.3 等の上部項目が消えるバグ）。
     flex-start を基準にし、safe center を解する browser のみ中央寄せ。 */
  justify-content: flex-start;
  justify-content: safe center;
  gap: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 72px 0 calc(40px + env(safe-area-inset-bottom, 0px));
}

.site-mobile-nav.active {
  visibility: visible;
  pointer-events: auto;
  opacity: 1;
}

.site-mobile-nav a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 17px;
  font-weight: 600;
  padding: 14px 40px;
  border-radius: 14px;
  width: 260px;
  text-align: center;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.site-mobile-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.site-mobile-nav a.active {
  color: var(--header-accent);
}

.mobile-cta-pro {
  background: linear-gradient(135deg, #1d7f96, #186f83) !important;
  color: #fff !important;
  font-weight: 700 !important;
  border-radius: 9999px !important;
}

.lang-toggle-mobile {
  font-size: 14px !important;
  color: rgba(255, 255, 255, 0.5) !important;
}

.mobile-nav-label {
  color: rgba(255, 255, 255, 0.3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 0 2px;
  width: 260px;
  text-align: center;
}

.mobile-nav-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  cursor: pointer;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 303;
}

.mobile-nav-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 768px) {
  .site-header-nav {
    display: none;
  }
  .site-hamburger {
    display: block;
  }
}
