/* =========================================
   TOP PAGE
   ========================================= */

/* ===== Hero ===== */
/* セクション自体は通常の1ブロックとしてスクロールする。
   背景・スピーカー画像は background-attachment: fixed により
   ビューポートに対して常に同じ位置に留まって見え（ネイティブCSSの合成処理のため
   他要素と完全に同期し遅延が発生しない）、セクションの範囲でクリップされることで
   セクションに入ると現れ、抜けると自然に消える。 */
.p-top-hero {
  position: relative;
  background-color: #111111;
  height: calc(100vh - var(--header-height));
  max-height: 840px;
}

/* =========================================
   高さ制限 (1024px以上)
   ========================================= */
@media (min-width: 1024px) {
  .p-top-hero {
    max-height: min(840px, 100vw * 3 / 4);
  }
}

/* =========================================
   高さ制限 (1024px以上 縦向き / iPad Pro等)
   スピーカー画像がテキスト領域に重ならないよう、
   さらに高さを抑える
   ========================================= */
@media (min-width: 1024px) and (orientation: portrait) {
  .p-top-hero {
    max-height: min(840px, 57vw);
  }
}

/* =========================================
   高さ制限 (768px〜1023px 縦向き / iPad等)
   スピーカー画像が画面幅の3/4を超えないよう、
   高さを抑える
   ========================================= */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: portrait) {
  .p-top-hero {
    max-height: 75vw;
  }
}

/* 背景レイヤー：画像はビューポートに固定され、セクションの枠内にのみ表示される */
.p-top-hero__visual {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-color: #111111;
  background-image: url('../../img/top/bg_img.jpg');
  background-attachment: fixed;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

/* Marquee band — スピーカー画像の後ろに配置する */
.p-top-hero__marquee {
  position: absolute;
  top: 56px; /* ヘッダーから56px下 */
  left: 0;
  right: 0;
  z-index: 2; /* 背景（.p-top-hero__visual）より前面、スピーカー画像（.p-top-hero__mv-image）より背面 */
  overflow: hidden;
  pointer-events: none;
}

@media (min-width: 1340px) {
  .p-top-hero__marquee {
    top: 64px; /* ヘッダーから64px下 */
  }
}

.p-top-hero__marquee-track {
  display: flex;
  width: max-content;
  animation: hero-marquee 32s linear infinite;
  white-space: nowrap;
}

.p-top-hero__marquee-track span {
  font-size: 56px; /* ② PC: 56px固定 */
  font-weight: var(--font-weight-black);
  color: rgba(255, 255, 255, 0.92);
  letter-spacing: 0.02em;
  line-height: 1;
}

@keyframes hero-marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* スピーカー画像レイヤー — iOS Safariはbackground-attachment: fixedの相性が悪く
   （特にJSでbackground-size/positionを毎フレーム書き換える用途で再描画されず非表示になる）ため使わず、
   position: absoluteのまま、スクロール量をbackground-positionへ加算するJS（hero-speaker-animation.js）で
   「画面に固定されて見える」効果を再現している。ヒーローの箱の範囲でクリップされるのは
   通常のabsolute配置のままなので、元の見た目（ヒーローを抜けると自然に消える）も変わらない。 */
.p-top-hero__mv-image {
  position: absolute;
  inset: 0;
  z-index: 3;
  background-image: url('../../img/top/hero-speaker.png');
  background-size: auto 100%;
  background-position: left center;
  background-repeat: no-repeat;
  pointer-events: none;
}

/* テキストレイヤー：通常どおりスクロールし、画像の手前を通過していく */
.p-top-hero__mv-content {
  position: absolute;
  top: 0;
  left: 55%;
  width: 45%;
  height: 100%;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 60px 80px 40px;
}

.p-top-hero__mv-title {
  display: block;
  width: 479px;
  max-width: 100%;
  height: auto;
}

/* Latest news card — 右端フラッシュ、下から40px */
.p-top-hero__news-card {
  position: absolute;
  top: calc(100% - 40px - 112px); /* ビジュアル下端から40px上 */
  right: 0;
  z-index: 4;
  background: var(--color-bg-white);
  border-radius: 0;
  overflow: hidden;
}

.p-top-hero__news-link {
  display: flex;
  align-items: center;
  transition: opacity 0.2s ease;
}

.p-top-hero__news-link:hover {
  opacity: 0.85;
}

/* ① サムネイル周囲に16pxの余白 */
.p-top-hero__news-thumbnail {
  flex: 0 0 auto;
  padding: 16px 0 16px 16px; /* 上右下左: 右は body padding に委ねる */
  overflow: hidden;
}

.p-top-hero__news-thumbnail img {
  width: 130px;
  height: 80px;        /* Figma実測値 130×80 */
  object-fit: cover;
  display: block;
}

.p-top-hero__news-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
}

.p-top-hero__news-date {
  font-size: 16px;
  font-weight: 900;
  color: var(--color-text-dark);
  line-height: 1.8;
  margin: 0;
}

.p-top-hero__news-title {
  font-size: 16px;
  font-weight: 900;
  color: var(--color-text-dark);
  line-height: 1.8;
  margin: 0;
}

/* ===== Introduction ===== */
.p-top-introduction {
  background: var(--color-bg-white);
  padding: 120px 0;
}

.p-top-introduction__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
  text-align: center;
}

.p-top-introduction__heading {
  font-size: var(--font-size-6xl);
  font-weight: var(--font-weight-black);
  color: var(--color-text-dark);
  line-height: 150%;
  letter-spacing: 0.08em;
  margin: 0;
}

.p-top-introduction__heading-br--xs {
  display: none;
}

.p-top-about__heading-br--460 {
  display: none;
}

.p-top-about__philosophy-heading-br--392 {
  display: none;
}

.p-top-introduction__description {
  font-size: 32px;
  font-weight: var(--font-weight-black);
  color: var(--color-text-dark);
  line-height: 200%;
  letter-spacing: 0.03em;
  margin: 0;
}

/* ===== Reasons ===== */
.c-reasons .c-section-heading__ja {
  color: var(--color-text-dark);
}

/* ===== About ===== */
.p-top-about {
  background: var(--color-bg-section);
  padding: 120px 0 0;
  border-radius: 0 200px 200px 0;
}

.p-top-about .c-section-heading {
  margin-bottom: 80px;
  gap: 12px;
}

.p-top-about .c-section-heading__lead {
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  max-width: 720px;
  padding-top: 24px;
}

/* Engineer profile */
.p-top-about__engineer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 80px;
  align-items: center;
  margin-bottom: 200px;
}

.p-top-about__engineer-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.p-top-about__engineer-role {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-black);
  color: var(--color-text);
  margin: 0;
  line-height: var(--line-height-tight);
}

.p-top-about__engineer-name {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-black);
  color: var(--color-text);
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.p-top-about__engineer-name-en {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
}

.p-top-about__engineer-bio {
  font-size: var(--font-size-base);
  color: var(--color-text);
  line-height: var(--line-height-relaxed);
  margin: 0;
}

.p-top-about__engineer-image {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 0;
}

.p-top-about__engineer-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Philosophy */
.p-top-about__philosophy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  text-align: center;
}

.p-top-about__philosophy-heading {
  font-size: var(--font-size-5xl);
  font-weight: var(--font-weight-black);
  color: var(--color-text);
  line-height: var(--line-height-normal);
  margin: 0;
}

.p-top-about__philosophy-subheading {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-black);
  color: var(--color-text);
  margin: 32px 0 0;
}

.p-top-about__philosophy-text {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  line-height: var(--line-height-relaxed);
  margin: 8px 0 0;
}

.p-top-about__philosophy-image {
  width: 100%;
  max-width: 760px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius-lg);
  margin-top: 40px;
}

.p-top-about__philosophy-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===== Company ===== */
.p-top-company {
  background: var(--color-bg-white);
  padding: 120px 0;
}

.p-top-company__inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 80px;
  align-items: center;
}

.p-top-company__content {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.p-top-company .c-section-heading {
  gap: 4px;
}

.p-top-company__text {
  font-size: var(--font-size-base);
  color: var(--color-text);
  line-height: var(--line-height-relaxed);
  margin: 0;
}

.p-top-company__image {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 0;
}

.p-top-company__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* =========================================
   TABLET (912px)
   ========================================= */
@media (max-width: 912px) {
  .p-top-hero__mv-image {
    background-image: url('../../img/top/sp_speaker.png');
    background-size: auto 100%;
    background-position: left top;
  }
}

/* =========================================
   TABLET (840px)
   ========================================= */
@media (max-width: 840px) {
  /* Hero — SP/タブレットでは画像を全幅背景にし、タイトルを中央オーバーレイ表示する */
  .p-top-hero {
    /* 100dvhだとアドレスバーの開閉でリアルタイムに高さが変わり、
       background-size: auto 100%のスピーカー画像も一緒に拡大/縮小して見えてしまうため、
       アドレスバー表示時（小さい方）の高さに固定されるsvhを使う */
    height: calc(100svh - var(--header-height));
    overflow: hidden;
  }

  .p-top-hero__marquee {
    top: 20px; /* ヘッダーから20px下 */
  }

  .p-top-hero__mv-content {
    left: 0;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: flex-end;
    text-align: left;
    padding: 0 var(--container-padding);
  }

  .p-top-hero__mv-title {
    width: clamp(230px, 57vw, 320px);
  }

  .p-top-hero__news-thumbnail {
    flex: 0 0 88px;
    padding: 8px 0 8px 8px;
  }

  .p-top-hero__news-thumbnail img {
    width: 100%;
    height: auto;
    aspect-ratio: 130 / 80;
  }

  .p-top-hero__news-body {
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px;
  }

  .p-top-hero__news-date,
  .p-top-hero__news-title {
    font-size: 12px;
    white-space: normal;
  }

  /* About */
  .p-top-about__engineer {
    grid-template-columns: 1fr;
  }

  /* SP表示順: 見出し(役職) → 画像 → 氏名 → 説明文 */
  .p-top-about__engineer-body {
    display: contents;
  }

  .p-top-about__engineer-role {
    order: 1;
  }

  .p-top-about__engineer-image {
    order: 2;
  }

  .p-top-about__engineer-name {
    order: 3;
  }

  .p-top-about__engineer-bio {
    order: 4;
  }

  /* Company */
  .p-top-company__inner {
    grid-template-columns: 1fr;
  }

  /* SP表示順: 見出し → 画像 → 説明文 */
  .p-top-company__content {
    display: contents;
  }

  .p-top-company__content .c-section-heading {
    order: 1;
  }

  .p-top-company__image {
    order: 2;
  }

  .p-top-company__text {
    order: 3;
  }

  .p-top-company__content .c-arrow-button {
    order: 4;
  }
}

/* =========================================
   テキストサイズ (1024px)
   ========================================= */
@media (max-width: 1024px) {
  .p-top-introduction__heading {
    font-size: 25.6px;
  }

  /* 大小関係維持: PC 32px〜48pxの見出し系もレスポンシブ時は見出しトーン(25.6px)に統一 */
  .p-top-about__engineer-role,
  .p-top-about__philosophy-subheading {
    font-size: 25.6px;
  }

  .p-top-introduction__description {
    font-size: var(--font-size-base);
  }

  /* 見出しのジャンプ率を保つため、p-top-about__philosophy-heading は
     var(--font-size-5xl)（1024px以下で32px）のまま据え置く */

  /* Introduction */
  .p-top-introduction {
    padding: 40px 0;
  }

  .p-top-introduction__inner {
    gap: 24px;
  }

  /* About */
  .p-top-about {
    padding: 40px 0 0;
  }

  .p-top-about .c-section-heading {
    margin-bottom: 48px;
  }

  .p-top-about__engineer {
    gap: 32px;
    margin-bottom: 80px;
  }

  /* Company */
  .p-top-company {
    padding: 40px 0;
  }

  .p-top-company__inner {
    gap: 32px;
  }
}

/* =========================================
   SP (767px)
   ========================================= */
@media (max-width: 767px) {
  .p-top-about {
    border-radius: 0 100px 100px 0;
  }

  .p-top-about .c-section-heading.c-section-heading--center {
    margin-bottom: 64px;
  }

  .p-top-company {
    padding: 0 0 40px;
  }

  .p-top-company .c-section-heading.c-section-heading--left {
    padding-top: 64px;
  }

  /* 文章途中の<br>はモバイル幅では行わず、自然な折り返しに任せる */
  .p-top-introduction__description br,
  .c-section-heading__lead br,
  .p-top-about__philosophy-text br,
  .p-top-company__text br,
  .l-footer__rental-lead br,
  .l-footer__contact-lead br {
    display: none;
  }

  /* Hero */
  .p-top-hero__marquee-track span {
    font-size: 28px; /* SP: 56pxの半分 */
  }

  .p-top-hero__mv-content {
    padding: 32px var(--container-padding);
  }

  .p-top-introduction__heading {
    font-size: 25.6px;
  }

  .p-top-introduction__description {
    text-align: justify;
  }

  .p-top-about__engineer-bio,
  .p-top-about__philosophy-text {
    text-align: justify;
  }

  .p-top-about__philosophy-heading {
    font-size: 32px;
  }

  .p-top-about__philosophy-subheading {
    font-size: 18.29px;
    margin-top: 16px;
  }

  .p-top-about__philosophy-text {
    margin: 24px 0 0;
  }

  /* About engineer: 画像下/氏名下のみ16pxに調整（役職→画像の間隔は維持） */
  .p-top-about__engineer {
    gap: 0;
  }

  .p-top-about__engineer-role {
    margin-bottom: 32px;
  }

  .p-top-about__engineer-image,
  .p-top-about__engineer-name {
    margin-bottom: 16px;
  }

  .p-top-company__text {
    text-align: justify;
  }
}

/* =========================================
   SP (460px)
   ========================================= */
@media (max-width: 460px) {
  #about-title .p-top-about__heading-br--460 {
    display: inline;
  }

  .p-top-about__engineer-role {
    margin-bottom: 16px;
  }
}

/* =========================================
   SP (392px)
   ========================================= */
@media (max-width: 392px) {
  .p-top-about__philosophy-heading-br--392 {
    display: inline;
  }
}

/* =========================================
   SP (459px)
   ========================================= */
@media (max-width: 459px) {
  .p-top-hero__news-card {
    top: auto;
    bottom: 24px;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100% - var(--container-padding) * 2);
    width: calc(100% - var(--container-padding) * 2);
  }
}

/* =========================================
   SP (424px)
   ========================================= */
@media (max-width: 424px) {
  .p-top-introduction__heading-br--xs {
    display: inline;
  }
}
