/* =========================================
   Hamburger Menu Component
   - SP（768px以下）のみ表示
   ========================================= */

/* ▼ SP時のスクロールオフセット（固定ヘッダー分） */
@media (max-width: 768px) {
  html {
    scroll-padding-top: 56px;
  }
  body {
    padding-top: 56px;
  }
}

/* =========================================
   SP Header（固定ヘッダー）
   ========================================= */
.sp-header {
  display: none;
}

@media (max-width: 768px) {
  .sp-header {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 56px;
    background: #fff;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    transition: box-shadow 0.3s ease;
  }

  .sp-header.is-scrolled {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  }

  .sp-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 16px;
  }

  .sp-header__logo {
    display: flex;
    align-items: center;
    text-decoration: none;
  }

  .sp-header__logo img {
    height: 28px;
    width: auto;
  }
/* ▼ ポチカメ装飾（パネル外側・左にはみ出し） */
  .sp-nav__character {
    position: absolute;
    right: min(80%, 320px);
    bottom: 23%;
    z-index: 0;
    pointer-events: none;
    visibility: hidden;
    opacity: 0;
    transform: translateX(100%);
    /* 閉じる時：パネルより先にポチカメが消える */
    transition: transform 0.25s ease,
                opacity 0.2s ease,
                visibility 0s linear 0.25s;
  }

  .sp-nav.is-open .sp-nav__character {
    visibility: visible;
    opacity: 1;
    transform: translateX(0);
    /* 開く時：パネルのスライド(0.35s)完了後にひょこっと登場 */
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.3s ease 0.35s,
                visibility 0s linear 0.35s;
    transition-delay: 0.35s;
  }

  .sp-nav__character-img {
    display: block;
    width: 150px;
    max-width: none;
    height: auto;
    transform: translateX(49%);
  }
}

/* =========================================
   Burger Button
   ========================================= */
.sp-header__burger {
  display: none;
}

@media (max-width: 768px) {
  .sp-header__burger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 1002;
  }

  .sp-header__burger-line {
    display: block;
    width: 22px;
    height: 2px;
    background: #333;
    border-radius: 1px;
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform-origin: center;
  }

  /* ▼ 開いた時の × アニメーション */
  .sp-header__burger.is-open .sp-header__burger-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  .sp-header__burger.is-open .sp-header__burger-line:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
  }

  .sp-header__burger.is-open .sp-header__burger-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }
}

/* =========================================
   Navigation Panel
   ========================================= */
.sp-nav {
  display: none;
}

@media (max-width: 768px) {
  .sp-nav {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    pointer-events: none;
  }

  .sp-nav.is-open {
    pointer-events: auto;
  }

  /* ▼ オーバーレイ */
  .sp-nav__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .sp-nav.is-open .sp-nav__overlay {
    opacity: 1;
  }

  /* ▼ スライドパネル（右から） */
  .sp-nav__panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 80%;
    max-width: 320px;
    height: 100%;
    background: #fff;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
  }

  .sp-nav.is-open .sp-nav__panel {
    transform: translateX(0);
  }

  /* ▼ パネルヘッダー */
  .sp-nav__panel-header {
    display: flex;
    align-items: center;
    height: 56px;
    padding: 0 20px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
  }

  .sp-nav__logo {
    height: 24px;
    width: auto;
  }

  /* ▼ ナビリスト */
  .sp-nav__list {
    list-style: none;
    margin: 0;
    padding: 12px 0;
    flex: 1;
  }

  .sp-nav__item {
    border-bottom: 1px solid #f0f0f0;
  }

  .sp-nav__link {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 16px 20px;
    padding-right: 52px;
    text-decoration: none;
    transition: background-color 0.2s ease;
    position: relative;
    /* stagger animation */
    opacity: 0;
    transform: translateX(20px);
  }

  /* ▼ 矢印アイコン */
  .sp-nav__link::after {
    content: '';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: #f5c800;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 6 15 12 9 18'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 14px 14px;
    flex-shrink: 0;
  }

  .sp-nav.is-open .sp-nav__link {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.2s ease;
  }

  .sp-nav.is-open .sp-nav__item:nth-child(1) .sp-nav__link { transition-delay: 0.08s; }
  .sp-nav.is-open .sp-nav__item:nth-child(2) .sp-nav__link { transition-delay: 0.14s; }
  .sp-nav.is-open .sp-nav__item:nth-child(3) .sp-nav__link { transition-delay: 0.20s; }
  .sp-nav.is-open .sp-nav__item:nth-child(4) .sp-nav__link { transition-delay: 0.26s; }

  .sp-nav__link:active {
    background-color: #f5f5f5;
  }

  .sp-nav__link-en {
    font-family: 'Krona One', sans-serif;
    font-size: 10px;
    letter-spacing: 0.08em;
    color: #2fa436;
    text-transform: uppercase;
  }

  .sp-nav__link-ja {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: #333;
    line-height: 1.4;
  }

  /* ▼ パネル下部 CTA */
  .sp-nav__cta {
    padding: 16px 20px 32px;
    flex-shrink: 0;
    /* stagger animation */
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.3s ease 0.32s, transform 0.3s ease 0.32s;
  }

  .sp-nav.is-open .sp-nav__cta {
    opacity: 1;
    transform: translateY(0);
  }

  .sp-nav__cta-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 16px 17px;
    background-color: var(--color-primary-blue);
    color: #fff;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
    border-radius: 60px;
    border: 3px solid #333;
    box-shadow: 0 8px 0 var(--color-text-primary), inset 0 0 0 2px #90A8F5;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
  }

  .sp-nav__cta-btn:active {
    transform: translateY(5px);
    box-shadow: 0 0 0 #333, inset 0 0 0 2.5px #5bbe6e;
  }

  .sp-nav__cta-icon {
    width: 28px;
    height: 28px;
  }

  /* ▼ body スクロールロック */
  body.is-nav-open {
    overflow: hidden;
  }
}