/* ============================================================
   WebGL版（index.html）固有のスタイル
   海中シーンの上に重なる計器類（HUD）とセクションパネル。
   ============================================================ */

/* このページはスクロールしない。スクロールはパネル内部だけで起こす */
body {
  overflow: hidden;
  overscroll-behavior: none;
}

/* パネル内のスクロールバーも海の色に寄せる */
.panel__scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--c-line-strong) transparent;
}
.panel__scroll::-webkit-scrollbar {
  width: 6px;
}
.panel__scroll::-webkit-scrollbar-thumb {
  background: var(--c-line-strong);
  border-radius: 999px;
}

/* WebGL キャンバス */
#scene {
  position: fixed;
  inset: 0;
  z-index: var(--z-scene);
}

#scene canvas {
  display: block;
}

/*
  粒状のオーバーレイ。均一なグラデーションに出るバンディングを隠しつつ、
  水中の浮遊物のような質感を足す。
*/
.grain {
  position: fixed;
  inset: 0;
  z-index: var(--z-grain);
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.32'/%3E%3C/svg%3E");
}

/*
  画面の縁を沈ませて、HUD や見出しと写真のコントラストを確保する。
  写真によっては（サメの砂地など）明るい面が来るため、左側のスクリムは
  文字の可読性を保証するために欠かせない。
*/
.vignette {
  position: fixed;
  inset: 0;
  z-index: var(--z-grain);
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 0%, transparent 40%, rgba(1, 10, 16, 0.55) 100%),
    linear-gradient(to bottom, rgba(1, 10, 16, 0.5) 0%, transparent 22%, transparent 62%, rgba(1, 10, 16, 0.78) 100%);
}

@media (min-width: 900px) {
  .vignette {
    background:
      linear-gradient(to right, rgba(1, 10, 16, 0.92) 0%, rgba(1, 10, 16, 0.72) 22%, transparent 46%),
      radial-gradient(120% 90% at 50% 0%, transparent 40%, rgba(1, 10, 16, 0.55) 100%),
      linear-gradient(to bottom, rgba(1, 10, 16, 0.5) 0%, transparent 24%, transparent 64%, rgba(1, 10, 16, 0.78) 100%);
  }
}

/* ---------- ローダー ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: var(--z-loader);
  display: grid;
  place-content: center;
  gap: var(--sp-5);
  padding: var(--gutter);
  background: var(--c-abyss);
  transition: opacity var(--dur-slow) var(--ease-out), visibility var(--dur-slow);
}

.loader.is-done {
  opacity: 0;
  visibility: hidden;
}

.loader__mark {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.loader__mark em {
  font-style: normal;
  color: var(--c-accent);
}

.loader__bar {
  width: min(320px, 70vw);
  height: 2px;
  background: var(--c-line);
  overflow: hidden;
}

.loader__fill {
  height: 100%;
  width: 0%;
  /* --c-warmは状態通知バッジ専用（05_共通設計.md 6.1）のためここでは使わない */
  background: var(--c-accent);
  transition: width 0.3s var(--ease-out);
}

.loader__status {
  display: flex;
  justify-content: space-between;
  width: min(320px, 70vw);
}


/* ---------- HUD（画面まわりの計器類） ---------- */
.hud {
  position: fixed;
  z-index: var(--z-hud);
}

/* パネルを開いている間、計器類とステージは退く（本文に集中させる） */
.is-panel-open .hud,
.is-panel-open .stage {
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out);
}

.hud__top {
  top: 0;
  left: 0;
  right: 0;
  height: var(--hud-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gutter);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
}

.brand__name {
  font-family: var(--f-jp);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.hud__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
}

.status {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* トップページ（縦長版）へ戻る導線。あちらの「WEBGL 版」ピルと対になる */
.hud__home {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid var(--c-line);
  border-radius: 999px;
  color: var(--c-muted);
  white-space: nowrap;
  transition: border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.hud__home:hover {
  border-color: var(--c-accent);
  color: var(--c-accent);
}

.hud__home span {
  transition: transform var(--dur) var(--ease-out);
}

.hud__home:hover span {
  transform: translateX(-3px);
}

/* @keyframes ping は components.css（S-001/S-002 共有）に定義 */
.status__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-accent);
  box-shadow: 0 0 0 0 var(--c-accent-soft);
  animation: ping 2.4s var(--ease-out) infinite;
}

/* ---------- セクションナビ（右側の潜航ゲージ） ---------- */
.dive-nav {
  top: 50%;
  right: var(--gutter);
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.dive-nav__item {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
  min-height: 44px; /* タップターゲット確保 */
  color: var(--c-dim);
  transition: color var(--dur-fast) var(--ease-out);
}

.dive-nav__item:hover {
  color: var(--c-fg);
}

.dive-nav__label {
  font-family: var(--f-mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  opacity: 0;
  transform: translateX(6px);
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.dive-nav__item:hover .dive-nav__label,
.dive-nav__item[aria-current="true"] .dive-nav__label {
  opacity: 1;
  transform: translateX(0);
}

.dive-nav__tick {
  width: 22px;
  height: 1px;
  background: currentColor;
  transition: width var(--dur) var(--ease-out), background var(--dur) var(--ease-out);
}

.dive-nav__item[aria-current="true"] {
  color: var(--c-accent);
}

.dive-nav__item[aria-current="true"] .dive-nav__tick {
  width: 44px;
  background: var(--c-accent);
  box-shadow: 0 0 12px rgba(63, 208, 201, 0.6);
}

/* ---------- ステージ（中央の見出し） ---------- */
.stage {
  position: fixed;
  z-index: var(--z-stage);
  left: var(--gutter);
  bottom: calc(var(--gutter) + 76px);
  width: min(520px, calc(100vw - var(--gutter) * 2));
  pointer-events: none; /* 背後の写真をドラッグできるようにする */
}

.stage > * {
  pointer-events: auto;
}

.stage__meta {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.stage__meta::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--c-line);
}

.stage__label {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 8vw, 5rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  margin-bottom: var(--sp-3);
  text-wrap: balance;
}

.stage__ja {
  font-size: 0.85rem;
  letter-spacing: 0.28em;
  color: var(--c-accent);
  margin-bottom: var(--sp-4);
}

.stage__tagline {
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  font-weight: 400;
  line-height: 1.8;
  color: var(--c-fg);
  margin-bottom: var(--sp-6);
  text-wrap: balance;
}

/* 見出しの入れ替えアニメーション（カルーセル回転に同期） */
.stage__label,
.stage__ja,
.stage__tagline,
.stage__meta {
  animation: rise var(--dur) var(--ease-out) both;
}
.stage__ja { animation-delay: 0.04s; }
.stage__tagline { animation-delay: 0.08s; }

/* ---------- カルーセル操作 ---------- */
.stepper {
  bottom: var(--gutter);
  right: var(--gutter);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2);
  border: 1px solid var(--c-line);
  border-radius: 999px;
  background: rgba(7, 35, 49, 0.45);
  backdrop-filter: blur(10px);
}

.stepper__btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-content: center;
  border-radius: 50%;
  border: 1px solid transparent;
  color: var(--c-muted);
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.stepper__btn:hover {
  color: var(--c-accent);
  border-color: var(--c-line-strong);
  transform: scale(1.06);
}

.stepper__count {
  font-family: var(--f-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--c-dim);
  font-variant-numeric: tabular-nums;
  min-width: 3.4em;
  text-align: center;
}

.stepper__count b {
  color: var(--c-fg);
  font-weight: 500;
}

/* ---------- パネル（セクション本文） ---------- */
.panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-panel) - 1);
  background: rgba(1, 10, 16, 0.72);
  backdrop-filter: blur(10px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease-out), visibility var(--dur);
}

.panel-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.panel {
  position: fixed;
  inset: 0;
  z-index: var(--z-panel);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(24px);
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out), visibility var(--dur);
  /*
    ほぼ不透明な地を敷く。背後のシーンが透けると、ステージの大見出しが
    本文に重なって読めなくなるため。上部だけ水色を残して海中の気配は保つ。
  */
  background:
    radial-gradient(130% 70% at 18% 0%, rgba(11, 48, 64, 0.55), transparent 62%),
    linear-gradient(180deg, rgba(4, 24, 36, 0.975) 0%, rgba(1, 10, 16, 0.99) 100%);
}

.panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.panel__bar {
  flex-shrink: 0;
  height: var(--hud-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--c-line);
  background: rgba(4, 24, 36, 0.6);
  backdrop-filter: blur(12px);
}

.panel__id {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  min-width: 0;
}

.panel__id-no {
  font-family: var(--f-mono);
  font-size: 0.7rem;
  color: var(--c-accent);
  letter-spacing: 0.16em;
}

.panel__id-label {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.14em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel__close {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: 44px;
  padding: 0 var(--sp-3);
  font-family: var(--f-mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  color: var(--c-muted);
  transition: color var(--dur-fast) var(--ease-out);
}

.panel__close:hover {
  color: var(--c-fg);
}

.panel__close-x {
  display: grid;
  place-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--c-line-strong);
  border-radius: 50%;
  font-size: 0.9rem;
  line-height: 1;
  transition: border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.panel__close:hover .panel__close-x {
  border-color: var(--c-accent);
  transform: rotate(90deg);
}

.panel__scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.panel__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(48px, 9vh, 96px) var(--gutter) var(--sp-9);
}


/* 本文のスタガード表示（パネルが開いたら流す） */
.panel.is-open [data-reveal] {
  animation: rise var(--dur-slow) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 60ms + 120ms);
}


/* ---------- レスポンシブ ---------- */
@media (min-width: 900px) {
  .stage {
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
  }
}

/* 狭い画面では潜航ゲージのラベルを畳み、目盛りだけにする */
@media (max-width: 899px) {
  .dive-nav {
    right: max(12px, calc(var(--gutter) - 8px));
  }

  .dive-nav__label {
    display: none;
  }

  .stage {
    bottom: calc(var(--gutter) + 84px);
    width: calc(100vw - var(--gutter) * 2 - 40px);
  }
}

@media (max-width: 560px) {
  body {
    line-height: 1.85;
  }

  .stepper__count {
    display: none;
  }

  .panel__close span:not(.panel__close-x) {
    display: none;
  }

  /* 幅が足りないので、装飾の稼働ステータスより戻り導線を優先する */
  .status {
    display: none;
  }

  .hud__home {
    padding: 0 12px;
  }
}
