/**
 * 全ページ共通スタイル (assets/css/common.css)
 * ネイティブCSSネスト記法を使用
 */

/* ==========================================================================
   0. ベーススタイル (Base)
   ========================================================================== */
:root {
  --sb-color-blue: var(--wp--preset--color--primary, #2c3b47);
  --sb-color-black: var(--wp--preset--color--secondary, #333333);
  --sb-color-accent: var(--wp--preset--color--accent, #a77b0d);
  --sb-color-grey: var(--wp--preset--color--text-muted, #a6a6a6);
  --sb-color-white: #ffffff;
  --sb-font-sans: 'Noto Sans JP', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
  --sb-container: 1200px;
  --sb-gutter: clamp(1.25rem, 4vw, 2rem);
  --sb-indent: 50px;
}

body {
  margin: 0;
  font-family: var(--sb-font-sans);
  color: var(--sb-color-black);
  background-color: var(--sb-color-white);
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  height: auto;
}

/* ヘッダー・メイン・フッター間のブロック間余白を無効化 */
body .wp-site-blocks > * {
  margin-block: 0;
}

/* ==========================================================================
   1. サイトヘッダー (Site Header)
   ========================================================================== */
/* テンプレートパーツのラッパーごと追従させる */
header.wp-block-template-part {
  position: sticky;
  top: var(--wp-admin--admin-bar--height, 0px);
  z-index: 1000;
}

.site-header {
  position: relative;
  background-color: var(--sb-color-white);
  transition: box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  /* スクロール時の影付け */
  &.is-scrolled {
    box-shadow: 0 4px 20px -2px rgba(44, 59, 71, 0.12);
  }

  .header-inner {
    box-sizing: content-box;
    max-width: var(--sb-container);
    margin: 0 auto;
    padding: 20px var(--sb-gutter);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
  }

  /* ロゴ（マーク＋社名の横組みロゴ） */
  .site-logo {
    flex-shrink: 0;
    display: block;
    transition: opacity 0.2s ease;

    &:hover {
      opacity: 0.8;
    }

    img {
      display: block;
      width: 262px;
      height: auto;
    }
  }

  /* グローバルナビゲーション */
  .global-nav {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 24px;

    .global-nav-list {
      display: flex;
      align-items: center;
      gap: 16px;
      list-style: none;
      margin: 0;
      padding: 0;
    }

    .global-nav-item {
      display: flex;
      align-items: center;
      gap: 16px;

      /* 区切り線 */
      &::after {
        content: '';
        width: 15px;
        height: 1.5px;
        background: url('../images/nav-divider.svg') no-repeat center / 100% 100%;
        transform: rotate(90deg);
        margin-inline: -7.5px;
      }

      a {
        position: relative;
        display: inline-block;
        padding: 8px 0;
        font-size: 16px;
        font-weight: 700;
        line-height: 1.7;
        color: var(--sb-color-blue);
        text-decoration: none;
        white-space: nowrap;

        &::after {
          content: '';
          position: absolute;
          bottom: 4px;
          left: 0;
          width: 0;
          height: 1.5px;
          background-color: var(--sb-color-blue);
          transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        &:hover::after {
          width: 100%;
        }
      }
    }

    /* ドロワー内のみ表示 */
    .global-nav-copyright {
      display: none;
    }

    .header-actions {
      display: flex;
      align-items: center;
      gap: 16px;
    }
  }

  /* ヘッダーボタン */
  .header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 9px 13px 13px;
    border: 1.5px solid var(--sb-color-blue);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.7;
    text-decoration: none;
    white-space: nowrap;
    transition: opacity 0.25s ease, transform 0.25s ease;

    img {
      flex-shrink: 0;
      width: 24.344px;
      height: 24.344px;
    }

    &.is-outline {
      background-color: var(--sb-color-white);
      color: var(--sb-color-blue);
    }

    &.is-fill {
      background-color: var(--sb-color-blue);
      color: var(--sb-color-white);
    }

    &:hover {
      opacity: 0.85;
      transform: translateY(-2px);
    }
  }

  /* ハンバーガーボタン（SP時のみ表示） */
  .menu-toggle {
    display: none;
    position: relative;
    z-index: 2;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;

    .menu-toggle-bar {
      position: absolute;
      left: 10px;
      width: 24px;
      height: 2px;
      background-color: var(--sb-color-blue);
      transition: transform 0.3s ease, opacity 0.3s ease;

      &:nth-child(1) { top: 14px; }
      &:nth-child(2) { top: 21px; }
      &:nth-child(3) { top: 28px; }
    }

    &[aria-expanded="true"] .menu-toggle-bar {
      &:nth-child(1) { transform: translateY(7px) rotate(45deg); }
      &:nth-child(2) { opacity: 0; }
      &:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
    }
  }
}

/* ==========================================================================
   2. サイトフッター (Site Footer)
   ========================================================================== */
.site-footer {
  margin-top: auto;
  background-color: var(--sb-color-black);
  color: var(--sb-color-white);
  padding: 40px var(--sb-gutter);

  .footer-inner {
    max-width: var(--sb-container);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
  }

  .footer-top {
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 2rem;
  }

  .footer-logo {
    display: block;
    flex-shrink: 0;
    transition: opacity 0.2s ease;

    &:hover {
      opacity: 0.8;
    }

    img {
      display: block;
      width: 101.48px;
      height: 123.59px;
    }
  }

  /* 2列のフッターメニュー */
  .footer-nav {
    display: flex;
    align-items: flex-start;
    gap: 112px;
  }

  .footer-nav ul {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    list-style: none;
    margin: 0;
    padding: 0;

    a {
      display: inline-block;
      font-size: 14px;
      font-weight: 700;
      line-height: 1.6;
      letter-spacing: 0.07em;
      color: var(--sb-color-white);
      text-decoration: none;
      transition: opacity 0.2s ease, transform 0.2s ease;

      &:hover {
        opacity: 0.75;
        transform: translateX(4px);
      }
    }
  }

  .footer-line {
    display: block;
    width: 100%;
    height: 1px;
  }

  .footer-copyright {
    margin: 0;
    font-family: 'Amarna', var(--sb-font-sans);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.6;
  }
}

/* ==========================================================================
   3. 共通コンポーネント (Section / Heading / Link)
   ========================================================================== */
.section-container {
  box-sizing: border-box;
  max-width: calc(var(--sb-container) + var(--sb-gutter) * 2);
  margin: 0 auto;
  padding-inline: var(--sb-gutter);
}

/* 見出し（記号＋テキスト）：記号は疑似要素で表示 */
.section-title {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin: 0;
  font-size: clamp(1.625rem, 3.34vw, 48px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.07em;
  color: var(--sb-color-blue);

  &::before {
    content: '';
    flex-shrink: 0;
    width: 0.648em;
    height: 1.23em;
    background: url('../images/heading-mark-dark.svg') no-repeat center / 100% 100%;
  }

  &.is-light {
    color: var(--sb-color-white);

    &::before {
      background-image: url('../images/heading-mark-light.svg');
    }
  }
}

/* 見出し＋リンクの横並び */
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
}

/* 本文 */
.section-body {
  padding-left: var(--sb-indent);
  font-size: 16px;
  line-height: 2;
  letter-spacing: 0.07em;

  p {
    margin: 0;
  }
}

/* 本文中の強調（エディタの「ハイライト」で付与した帯） */
mark.has-inline-color {
  padding: 1px 3px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;

  /* スクロール連動：帯を左から右へ塗る（common.js で is-mark-ready / is-mark-revealed を付与） */
  &.is-mark-ready {
    background-color: transparent !important;
    background-image: linear-gradient(var(--mark-bg), var(--mark-bg));
    background-repeat: no-repeat;
    background-position: left center;
    background-size: 0% 100%;

    /* 塗られる前は周囲の本文と同じ文字色 */
    &:not(.is-mark-revealed) {
      color: inherit !important;
    }

    /* 文字色は帯が塗り終わる頃に切り替える */
    &.is-mark-revealed {
      background-size: 100% 100%;
      transition:
        background-size 0.8s cubic-bezier(0.65, 0, 0.35, 1) 0.2s,
        color 0.3s ease 0.6s;
    }
  }
}

/* 矢印付きテキストリンク（ボタンブロックのスタイル「矢印リンク」） */
.wp-block-button.is-style-link-arrow {
  width: 266px;
  max-width: 100%;

  .wp-block-button__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    padding: 0 0 8px;
    border: none;
    border-bottom: 1.5px solid currentColor;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: var(--sb-link-color, var(--sb-color-blue));
    font-size: 18px;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: 0.07em;
    text-align: left;
    text-decoration: none;

    &::after {
      content: '';
      flex-shrink: 0;
      width: 32px;
      height: 32px;
      background: url('../images/icon-arrow-box.svg') no-repeat center / 100% 100%;
      transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }

    &:hover::after {
      transform: translate(3px, -3px);
    }
  }
}

/* 矢印リンク・小（ボタンの追加CSSクラス「is-small」）：紺の小さい矢印、幅は文字に合わせる */
.wp-block-button.is-style-link-arrow.is-small {
  width: auto;

  .wp-block-button__link {
    justify-content: flex-start;
    gap: 16px;
    font-size: 14px;

    &::after {
      width: 23px;
      height: 23px;
      background-image: url('../images/icon-arrow-box-navy.svg');
    }
  }
}

/* ==========================================================================
   4. CTAセクション (Call To Action) ※patterns/cta.php。トップ・下層共通
   ========================================================================== */
.cta-section {
  --sb-link-color: var(--sb-color-white);
  padding: 100px var(--sb-gutter);

  .cta-container {
    position: relative;
    max-width: var(--sb-container);
    min-height: 372px;
    box-sizing: border-box;
    margin: 0 auto;
    padding: 88px 2rem 67px;
    overflow: hidden;
    text-align: center;
    color: var(--sb-color-white);
    background:
      url('../images/cta-bg-2.svg') no-repeat center / 100% 100%,
      #1c3645 url('../images/cta-bg-1.svg') no-repeat center / 100% 100%;
    box-shadow: 0 0 15px rgba(44, 59, 71, 0.75);

    /* 右側の装飾パターン */
    &::before {
      content: '';
      position: absolute;
      top: -32px;
      left: 63.75%;
      width: 418px;
      height: 436.062px;
      background: url('../images/cta-pattern.svg') no-repeat center / 100% 100%;
      -webkit-mask: url('../images/cta-pattern-mask.svg') no-repeat 0 32px / 418px 372px;
      mask: url('../images/cta-pattern-mask.svg') no-repeat 0 32px / 418px 372px;
      pointer-events: none;
    }

    > * {
      position: relative;
      z-index: 1;
    }

    /* 各ページのブロック余白リセットより優先させるため .cta-container を含めて指定 */
    .cta-title {
      margin: 0;
      font-size: clamp(1.5rem, 3.34vw, 48px);
      font-weight: 700;
      line-height: 1.2;
      letter-spacing: 0.07em;
      color: var(--sb-color-white);
    }

    .cta-desc {
      margin: 24px 0 0;
      font-size: 16px;
      line-height: 2;
      letter-spacing: 0.07em;
    }

    .wp-block-buttons {
      margin: 58px 0 0;
    }
  }
}

/* ==========================================================================
   5. スクロール監視フェードインアニメーション用クラス（common.js で is-revealed を付与）
   ========================================================================== */
.fade-in-trigger {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);

  &.is-revealed {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .fade-in-trigger {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ==========================================================================
   6. スクロールトップボタン (Back to top)
   ========================================================================== */
.btn-back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 48px;
  height: 48px;
  background-color: var(--sb-color-blue);
  color: var(--sb-color-white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 99;

  &.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  &:hover {
    background-color: var(--sb-color-accent);
    transform: translateY(-4px);
  }

  svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
  }
}

/* ==========================================================================
   7. レスポンシブ (Tablet / Mobile)
   ========================================================================== */
@media (max-width: 1200px) {
  .site-header {
    --sb-header-h: 90px;

    .header-inner {
      box-sizing: border-box;
      height: var(--sb-header-h);
      padding-block: 0;
    }

    /* ロゴ・閉じるボタンはドロワーより手前に表示 */
    .site-logo {
      position: relative;
      z-index: 2;
    }

    .menu-toggle {
      display: block;
    }

    /* ドロワーメニュー */
    .global-nav {
      position: fixed;
      inset: var(--wp-admin--admin-bar--height, 0px) 0 0;
      z-index: 1;
      flex-direction: column;
      align-items: stretch;
      justify-content: flex-start;
      gap: 0;
      padding: calc(var(--sb-header-h) + 16px) var(--sb-gutter) 32px;
      background-color: var(--sb-color-white);
      overflow-y: auto;
      opacity: 0;
      visibility: hidden;
      transition: opacity 0.3s ease, visibility 0.3s ease;

      .global-nav-list {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
      }

      .global-nav-item {
        display: block;
        border-bottom: 1px solid #dcdfe2;

        &::after {
          display: none;
        }

        a {
          display: flex;
          align-items: center;
          justify-content: space-between;
          padding: 22px 0;
          font-size: 18px;
          line-height: 1.4;
          letter-spacing: 0.07em;

          /* PCの下線アニメーションを矢印アイコンに置き換え */
          &::after {
            content: '';
            position: static;
            flex-shrink: 0;
            width: 32px;
            height: 32px;
            background: url('../images/icon-arrow-box.svg') no-repeat center / 100% 100%;
            transition: transform 0.25s ease;
          }

          &:hover::after {
            width: 32px;
            transform: translate(2px, -2px);
          }
        }
      }

      .header-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding-top: 32px;
      }

      .global-nav-copyright {
        display: block;
        margin: auto 0 0;
        padding-top: 32px;
        font-size: 12px;
        font-weight: 700;
        line-height: 1.6;
        text-align: center;
        color: var(--sb-color-blue);
      }
    }

    .header-btn {
      justify-content: space-between;
      height: 56px;
      padding: 0 16px 0 20px;
      border-width: 1px;
      font-size: 15px;
      line-height: 1.4;
      letter-spacing: 0.05em;

      /* ドロワー内は金色の矢印ボックスに差し替え */
      img {
        display: none;
      }

      &::after {
        content: '';
        flex-shrink: 0;
        width: 32px;
        height: 32px;
        background: url('../images/icon-arrow-box.svg') no-repeat center / 100% 100%;
      }

      &:hover {
        transform: none;
      }
    }

    /* 開いている時は閉じる（×）アイコン */
    .menu-toggle[aria-expanded="true"] .menu-toggle-bar {
      left: 8px;
      width: 28px;
    }

    &.is-menu-open .global-nav {
      opacity: 1;
      visibility: visible;
    }
  }
}

@media (max-width: 768px) {
  :root {
    --sb-indent: 0px;
  }

  /* ヘッダー */
  .site-header {
    --sb-header-h: 64px;

    .site-logo img {
      width: 149px;
    }

    /* 3本線の間隔 6px */
    .menu-toggle .menu-toggle-bar {
      &:nth-child(1) { top: 13px; }
      &:nth-child(2) { top: 21px; }
      &:nth-child(3) { top: 29px; }
    }

    .menu-toggle[aria-expanded="true"] .menu-toggle-bar {
      &:nth-child(1) { transform: translateY(8px) rotate(45deg); }
      &:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }
    }
  }

  /* フッター：ロゴ左・メニュー右（メニューは1列にまとめる） */
  .site-footer {
    padding: 48px var(--sb-gutter) 32px;

    .footer-inner {
      gap: 32px;
    }

    .footer-top {
      gap: 1.5rem;
    }

    .footer-logo img {
      width: 61px;
      height: auto;
    }

    .footer-nav {
      flex-direction: column;
      gap: 14px;

      ul {
        gap: 14px;
      }
    }

    .footer-line {
      opacity: 0.4;
    }

    .footer-copyright {
      font-size: 12px;
    }
  }

  /* 見出し */
  .section-title {
    gap: 10px;
    font-size: 24px;
    line-height: 1.25;
    letter-spacing: 0.05em;
    word-break: auto-phrase; /* 文節で改行 */

    &::before {
      height: 1.25em;
    }
  }

  /* 見出し＋リンクの横並びを解除（リンクはセクション末尾へ。並び順は front-page.css） */
  .section-head {
    display: contents;
  }

  /* 本文 */
  .section-body {
    font-size: 14px;
    line-height: 1.9;
    letter-spacing: 0.03em;
  }

  /* 強調の帯は独立した行にする（行ごとに帯を分割） */
  strong:has(> mark.has-inline-color) {
    display: block;
    margin-block: 4px;
    line-height: 2.4;
    word-break: auto-phrase;

    /* 直後の改行は不要（空行になるため） */
    & + br {
      display: none;
    }
  }

  mark.has-inline-color {
    padding: 3px 8px;
  }

  /* 矢印リンクは横幅いっぱい */
  .wp-block-button.is-style-link-arrow {
    width: 100%;
  }

  .wp-block-button.is-style-link-arrow.is-small {
    width: 100%;

    .wp-block-button__link {
      justify-content: space-between;
      font-size: 13px;
      letter-spacing: 0.03em;

      &::after {
        width: 32px;
        height: 32px;
      }
    }
  }

  .btn-back-to-top {
    bottom: 1.25rem;
    right: 1.25rem;
  }

  /* CTA */
  .cta-section {
    padding: 48px var(--sb-gutter) 64px;

    .cta-container {
      min-height: 0;
      padding: 48px 24px;
      background: linear-gradient(118.4deg, #1c3645 52.9%, rgba(28, 54, 69, 0.8) 98%), #1c3645;
      box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);

      &::before {
        top: 54.58%;
        left: 67.16%;
        width: 209px;
        height: 218px;
        -webkit-mask: none;
        mask: none;
      }

      .cta-title {
        font-size: 24px;
        line-height: 1.3;
        letter-spacing: 0.05em;
        word-break: auto-phrase;
      }

      .cta-desc {
        margin-top: 20px;
        font-size: 13px;
        line-height: 1.9;
        letter-spacing: 0.05em;
      }

      .wp-block-buttons {
        margin-top: 20px;
      }

      .wp-block-button.is-style-link-arrow {
        width: 266px;
      }
    }
  }
}
