/**
 * トップページ専用スタイル (assets/css/front-page.css)
 * ネイティブCSSネスト記法を使用
 * マークアップは patterns/front-*.php（コアブロック）
 */

/* ==========================================================================
   0. ブロックの既定余白リセット
   ========================================================================== */
.front-page-main {
  /* メイン・グループ直下のブロック間余白は各セクションで個別に指定する */
  &.wp-block-group > *,
  .wp-block-post-content > *,
  .wp-block-group > * {
    margin-block: 0;
  }

  .section-body > * + * {
    margin-top: 2em;
  }

  /* セクション間の余白（リセットより後に指定） */
  .referral-section {
    margin-top: 80px;
  }

  /* 紺背景セクションのリンク色 */
  .purpose-section,
  .works-section,
  .referral-section {
    --sb-link-color: var(--sb-color-white);
  }
}

/* ==========================================================================
   1. ファーストビュー (Hero Section)
   ========================================================================== */
.hero-section {
  --hero-ink: var(--sb-color-blue); /* ロゴのバーの色 */
  --hero-land: 1.95s;               /* 最も遅いバーが収まるまでの時間（光・見出しの開始時刻） */
  padding: 20px var(--sb-gutter) 52px;
  overflow: hidden;

  .hero-container {
    max-width: var(--sb-container);
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 554px);
    align-items: start;
    gap: 2rem;
  }

  /* 見出し：バーの集合に合わせてふわっと表示。左上のバーが後ろを通るので前面に出す */
  .hero-content {
    position: relative;
    z-index: 2;
    padding-top: 143px;
    animation: hero-copy-in 1s cubic-bezier(0.2, 0.7, 0.2, 1) var(--hero-land) both;
  }

  .hero-title {
    margin: 0;
    font-size: clamp(2.25rem, 5.19vw, 74.764px);
    font-weight: 700;
    line-height: 1.2;
    color: var(--sb-color-blue);
    white-space: nowrap;

    .hero-title-quote {
      letter-spacing: -0.17em;
    }
  }

  .hero-lead {
    margin-top: 41px;
    font-size: clamp(1.125rem, 1.73vw, 24.921px);
    font-weight: 700;
    color: var(--sb-color-black);
  }

  /* ロゴアニメーション：4本のバーが画面の端から集まり、集合後に光が時計回りに走る（JS不要） */
  .hero-visual {
    position: relative;
    width: 554px;
    max-width: 100%;
    aspect-ratio: 554 / 581;

    svg {
      position: absolute;
      inset: 0;
      display: block;
      width: 100%;
      height: 100%;
      overflow: visible;
    }
  }

  /* バー：--sx/--sy（画面基準 vw/vh）から --rot 傾いた状態で飛んでくる。--org は各バーの回転軸 */
  .hero-visual-bar {
    position: absolute;
    inset: 0;
    transform-origin: var(--org);
    will-change: transform;
    animation: hero-bar-in var(--dur) cubic-bezier(0.16, 1, 0.3, 1) both; /* 4本同時スタート、速度だけ違う */

    path {
      fill: var(--hero-ink);
    }
  }

  /* 光のレイヤー：集合が終わるまで非表示 */
  .hero-visual-light {
    opacity: 0;
    pointer-events: none;
    animation: hero-light-on 0.2s linear var(--hero-land) forwards;
  }

  /* 光の移動：5.6秒周期（一周0.9秒＋休み4.7秒）で無限ループ */
  .hero-visual-glow {
    animation: hero-glow-sweep 5.6s linear var(--hero-land) infinite;
  }
}

@keyframes hero-bar-in {
  0% {
    opacity: 0;
    transform: translate(var(--sx), var(--sy)) rotate(var(--rot));
  }
  5% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg);
  }
}

@keyframes hero-light-on {
  to {
    opacity: 1;
  }
}

/* 右上バー上端からスタート → 時計回り → 左上バー先端で停止（座標はロゴSVGの viewBox 基準） */
@keyframes hero-glow-sweep {
  0% {
    transform: translate(313px, 113px);
    opacity: 0;
  }
  1% {
    opacity: 1;
  }
  4% {
    transform: translate(530px, 332px);
  }
  4.3% {
    transform: translate(480px, 339px);
  }
  8.3% {
    transform: translate(258px, 559px);
  }
  8.6% {
    transform: translate(245px, 510px);
  }
  12.6% {
    transform: translate(22px, 289px);
  }
  12.9% {
    transform: translate(71px, 283px);
    animation-timing-function: cubic-bezier(0.1, 0.6, 0.3, 1); /* 最後だけ少し伸びて先端に収まる */
  }
  19%,
  100% {
    transform: translate(332px, 25px);
  }
}

@keyframes hero-copy-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ==========================================================================
   2. 目的を見据え、束ねる。 (Purpose Section)
   ========================================================================== */
.purpose-section {
  padding: 80px 0;
  color: var(--sb-color-white);
  background: #1c3645 url('../images/bg-purpose.svg') no-repeat center / 100% 100%;

  .section-body {
    margin-top: 39px;
  }
}

/* ==========================================================================
   3. 制度・システム・運用を、分けずに見る。 (Approach Section)
   ========================================================================== */
.approach-section {
  padding: 80px 0;
  overflow: hidden;

  .approach-container {
    display: grid;
    grid-template-columns: minmax(0, 695px) 450px;
    grid-template-rows: auto 1fr;
    justify-content: space-between;
    column-gap: 2rem;
  }

  .section-title {
    grid-column: 1;
    grid-row: 1;
  }

  .approach-text {
    grid-column: 1;
    grid-row: 2;
    margin-top: 41px;
  }

  .approach-diagram {
    position: relative;
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: start;
    width: 400px;
    margin-right: 50px;

    img {
      display: block;
      width: 100%;
      height: auto;
    }
  }

  /* 図解上のラベル */
  .approach-diagram-label {
    position: absolute;
    left: 49%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    white-space: nowrap;

    &.is-policy { top: 7.9%; }
    &.is-system { top: 41.3%; }
    &.is-operation { top: 74.5%; }

    .approach-diagram-name {
      margin-bottom: -4.821px;
      font-size: 23.14px;
      font-weight: 700;
      line-height: 1.8;
      color: var(--sb-color-blue);
    }

    .approach-diagram-desc {
      font-size: 13.498px;
      line-height: 1.2;
      color: var(--sb-color-grey);
    }
  }
}

/* ==========================================================================
   4. ご一緒する形 (Service Section)
   ========================================================================== */
.service-section {
  padding: 80px 0;

  .service-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px 18px;
    margin-top: 40px;
    padding-inline: var(--sb-indent);
  }

  .service-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-height: 257px;
    box-sizing: border-box;
    padding: 40px;
    background-color: #f8f8f8;
    border: 1px solid var(--sb-color-grey);
    color: var(--sb-color-black);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.35s cubic-bezier(0.4, 0, 0.2, 1);

    &:hover {
      transform: translateY(-6px);
      box-shadow: 0 16px 32px -12px rgba(44, 59, 71, 0.25);

      .service-card-head::after {
        transform: translate(2px, -2px);
      }
    }

    /* 見出し行：記号 / タイトル・サブ / 矢印アイコン（記号とアイコンは疑似要素） */
    .service-card-head {
      display: grid;
      grid-template-columns: 12px minmax(0, 1fr) 38px;
      align-items: center;
      column-gap: 4px;
      padding-bottom: 18px;
      border-bottom: 1px solid var(--sb-color-grey);

      &::before {
        content: '';
        grid-column: 1;
        grid-row: 1 / 3;
        align-self: start;
        width: 12px;
        height: 30px;
        background: url('../images/card-mark.svg') no-repeat center / 100% 100%;
      }

      &::after {
        content: '';
        grid-column: 3;
        grid-row: 1 / 3;
        width: 38px;
        height: 38px;
        background: url('../images/card-icon.svg') no-repeat center / 100% 100%;
        transition: transform 0.25s ease;
      }
    }

    .service-card-title {
      grid-column: 2;
      grid-row: 1;
      font-size: 20px;
      font-weight: 700;
      line-height: 1.4;
      letter-spacing: 0.05em;
      color: var(--sb-color-black);

      /* カード全体をクリック可能にする */
      a {
        color: inherit;
        text-decoration: none;

        &::after {
          content: '';
          position: absolute;
          inset: 0;
        }
      }
    }

    .service-card-sub {
      grid-column: 2;
      grid-row: 2;
      font-size: 14px;
      line-height: 1.6;
      letter-spacing: 0.07em;
    }

    .service-card-text {
      font-size: 14px;
      font-weight: 700;
      line-height: 1.6;
      letter-spacing: 0.07em;
    }
  }

  .service-message {
    margin-top: 40px;
    padding-left: var(--sb-indent);
    font-size: clamp(1.375rem, 2.5vw, 36px);
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: 0.05em;
    color: var(--sb-color-blue);
  }
}

/* ==========================================================================
   5. これまでの主な支援 (Works Section)
   ========================================================================== */
.works-section {
  padding: 100px 0;
  color: var(--sb-color-white);
  background: #1c3645 url('../images/bg-works.svg') no-repeat center / 100% 100%;

  .section-body {
    margin-top: 40px;
  }
}

/* ==========================================================================
   6. 代表について (Profile Section)
   ========================================================================== */
.profile-section {
  padding: 80px 0;

  .section-body {
    margin-top: 41px;
  }

  .section-body .profile-name {
    margin-top: 40px;
    font-weight: 700;
    letter-spacing: 0;
  }
}

/* ==========================================================================
   7. 私たちの考え方 (Philosophy Section)
   ========================================================================== */
.philosophy-section {
  padding: 100px 0;
}

/* ==========================================================================
   8. ご紹介・ご検討にあたって (Referral Section)
   ========================================================================== */
.referral-section {
  position: relative;
  min-height: 488px;
  overflow: hidden;
  color: var(--sb-color-white);
  background-color: #1c3645;

  /* 斜めの紺オーバーレイ */
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    width: max(1021px, calc(50% + 301px));
    height: 100%;
    background: url('../images/referral-overlay.svg') no-repeat left top / 100% 100%;
    pointer-events: none;
  }

  .referral-photo {
    position: absolute;
    top: -31px;
    left: calc(50% - 24px);
    width: max(946px, calc(50% + 226px));
    height: calc(100% + 44px);

    img {
      width: 100%;
      max-width: none;
      height: 100%;
      object-fit: cover;
    }
  }

  .section-container {
    position: relative;
    z-index: 2;
  }

  .referral-content {
    padding: 132px 0 72px 48px;
  }

  .referral-title {
    font-size: clamp(1.625rem, 3.34vw, 48px);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.07em;
    color: var(--sb-color-white);
  }

  .referral-text {
    margin-top: 40px;
    font-size: 16px;
    line-height: 2;
    letter-spacing: 0.07em;
  }

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

/* ==========================================================================
   9. アニメーションを抑える設定 (Reduced Motion)
   ※CTA・スクロールフェードインは common.css
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  /* ロゴは完成形・光は先端で停止した状態で表示 */
  .hero-section {
    .hero-content,
    .hero-visual-bar {
      animation: none;
    }

    .hero-visual-light {
      animation: none;
      opacity: 1;
    }

    .hero-visual-glow {
      animation: none;
      transform: translate(332px, 25px);
    }
  }
}

/* ==========================================================================
   10. レスポンシブ (Tablet / Mobile)
   ========================================================================== */
@media (max-width: 1100px) {
  .approach-section {
    .approach-container {
      grid-template-columns: minmax(0, 1fr);
      grid-template-rows: auto;
    }

    .approach-text {
      grid-row: 2;
    }

    .approach-diagram {
      grid-column: 1;
      grid-row: 3;
      justify-self: center;
      max-width: 100%;
      margin: 48px 0 0;
    }
  }

  .service-section .service-grid {
    grid-template-columns: minmax(0, 1fr);
    max-width: 640px;
  }
}

@media (max-width: 992px) {
  .hero-section {
    .hero-container {
      grid-template-columns: minmax(0, 1fr);
    }

    .hero-content {
      padding-top: 48px;
    }

    .hero-title {
      white-space: normal;
    }

    .hero-visual {
      justify-self: center;
      width: min(420px, 80%);
    }
  }

  /* 写真を上、テキストを下に */
  .referral-section {
    display: flex;
    flex-direction: column;
    min-height: 0;

    &::before {
      display: none;
    }

    .referral-photo {
      position: static;
      width: 100%;
      height: auto;
      aspect-ratio: 390 / 220;
    }

    .referral-content {
      padding: 48px 0 56px;
    }
  }
}

@media (max-width: 768px) {
  /* ---- 共通：セクション内は縦並び・間隔32px、リンクはセクション末尾 ---- */
  .front-page-main {
    .purpose-section,
    .approach-section,
    .service-section,
    .works-section,
    .profile-section {
      padding: 64px 0;
    }

    .philosophy-section {
      padding: 24px 0 64px;
    }

    .section-container {
      display: flex;
      flex-direction: column;
      gap: 32px;
    }

    .section-container > *,
    .section-head > * {
      margin-top: 0;
    }

    .section-head .wp-block-buttons {
      order: 1;
    }

    .section-body > * + * {
      margin-top: 1em;
    }

    .referral-section {
      margin-top: 0;
    }
  }

  /* ---- ファーストビュー ---- */
  .hero-section {
    padding: 40px var(--sb-gutter) 56px;

    .hero-container {
      gap: 32px;
    }

    .hero-content {
      padding-top: 0;
    }

    .hero-title {
      font-size: 36px;
    }

    .hero-lead {
      margin-top: 12px;
      font-size: 16px;
      line-height: 1.5;
    }

    .hero-visual {
      width: 277px;
    }
  }

  /* ---- 制度・システム・運用 ---- */
  .approach-section {
    .approach-diagram {
      align-self: center;
      width: 348px;
      max-width: 100%;
    }

    .approach-diagram-label {
      .approach-diagram-name {
        margin-bottom: -4.242px;
        font-size: 20.363px;
      }

      .approach-diagram-desc {
        font-size: 11.878px;
      }
    }
  }

  /* ---- ご一緒する形 ---- */
  .service-section {
    .service-grid {
      gap: 16px;
      max-width: none;
      padding-inline: 0;
    }

    .service-card {
      gap: 16px;
      min-height: 0;
      padding: 15px;

      .service-card-head {
        align-items: start;
        row-gap: 2px;
        padding-bottom: 16px;
      }

      .service-card-title {
        font-size: 18px;
      }

      .service-card-sub {
        font-size: 12px;
        line-height: 1.5;
        letter-spacing: 0.05em;
      }

      .service-card-text {
        line-height: 1.75;
        letter-spacing: 0.03em;
      }
    }

    .service-message {
      order: 2;
      font-size: 20px;
      line-height: 1.5;
    }
  }

  /* ---- 代表について ---- */
  .profile-section .section-body .profile-name {
    margin-top: 18px;
    font-size: 13px;
    line-height: 1.6;
  }

  /* ---- ご紹介・ご検討にあたって ---- */
  .referral-section {
    .referral-title {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      font-size: 24px;
      line-height: 1.25;
      letter-spacing: 0.05em;

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

    .referral-text {
      margin-top: 24px;
      font-size: 14px;
      line-height: 1.9;
      letter-spacing: 0.03em;
    }

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