/* =============================================================================
 * FABLE ARENA — theme.css
 * デザイントークン(CSS 変数)と共通スタイル。
 * 全モジュールはここで定義した変数を参照すること(色のハードコード禁止)。
 * 担当: Claude Opus 4_8
 * ========================================================================== */

/* -----------------------------------------------------------------------------
 * デザイントークン
 * 各デモの canvas は色をハードコードせず、getComputedStyle でここの値を取得する。
 * -------------------------------------------------------------------------- */
:root {
  --bg: #0a0a12;          /* 背景 */
  --surface: #14141f;     /* カード背景 */
  --text: #e8e8f0;        /* 本文 */
  --text-dim: #8a8aa0;    /* 補助テキスト */
  --accent: #d97757;      /* メインアクセント(Fable オレンジ) */
  --accent-2: #6c8eef;    /* サブアクセント(比較対象・青) */
  --accent-3: #4fd1a5;    /* 成功・ハイライト(緑) */
  --radius: 12px;
  --font-display: "Hiragino Sans", "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", ui-monospace, monospace;

  /* 派生トークン(シェル用。設計書の必須トークンはすべて上に定義済み) */
  --surface-2: #1c1c2b;         /* 一段明るいカード/枠線ベース */
  --border: rgba(255, 255, 255, 0.08); /* 微細な境界線 */
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.6);
  --maxw: 1200px;               /* コンテンツ最大幅 */
  --nav-h: 64px;                /* 固定ナビの高さ */
}

/* -----------------------------------------------------------------------------
 * リセット / ベース
 * -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;      /* アンカーナビのスムーススクロール */
  scroll-padding-top: var(--nav-h);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3 {
  margin: 0;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.02em;
}

a {
  color: inherit;
  text-decoration: none;
}

canvas {
  display: block;
}

/* アクセシビリティ: モーション低減設定の尊重 */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* -----------------------------------------------------------------------------
 * 共通ユーティリティ
 * -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: clamp(20px, 5vw, 48px);
}

.eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.section-lead {
  color: var(--text-dim);
  font-size: 1.05rem;
  max-width: 60ch;
  margin: 12px 0 0;
}

/* グラデーションの効いた見出し文字 */
.gradient-text {
  background: linear-gradient(120deg, var(--text) 0%, var(--accent) 60%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* -----------------------------------------------------------------------------
 * トップナビ(固定)
 * -------------------------------------------------------------------------- */
.topnav {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: clamp(20px, 5vw, 48px);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.topnav .brand {
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 0.95rem;
}

.topnav .brand .dot {
  color: var(--accent);
}

.topnav nav {
  display: flex;
  gap: 6px;
}

.topnav nav a {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  color: var(--text-dim);
  transition: color 0.2s ease, background 0.2s ease;
}

.topnav nav a:hover {
  color: var(--text);
  background: var(--surface-2);
}

@media (max-width: 720px) {
  .topnav nav {
    display: none;   /* モバイルではヒーロー内アンカーに委ねる */
  }
}

/* -----------------------------------------------------------------------------
 * ヒーローセクション
 * canvas は js/hero.js が .hero-canvas 内に生成する。
 * -------------------------------------------------------------------------- */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
}

.hero-canvas {
  position: absolute;
  inset: 0;
  z-index: -2;
}

/* 背景の可読性を上げる暗幕グラデーション */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(120% 80% at 50% 30%, transparent 0%, color-mix(in srgb, var(--bg) 55%, transparent) 60%, var(--bg) 100%);
  pointer-events: none;
}

.hero-inner {
  text-align: center;
  padding: 120px 24px 80px;
  max-width: 900px;
}

.hero h1 {
  font-size: clamp(3rem, 12vw, 8rem);
  letter-spacing: -0.04em;
  margin: 0;
}

.hero .subcopy {
  margin-top: 20px;
  font-size: clamp(1.05rem, 2.4vw, 1.5rem);
  color: var(--text-dim);
}

/* FPS カウンタ(右上固定) */
.fps-meter {
  position: fixed;
  top: calc(var(--nav-h) + 12px);
  right: clamp(12px, 3vw, 24px);
  z-index: 90;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 6px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  border: 1px solid var(--border);
  color: var(--accent-3);
  backdrop-filter: blur(8px);
  user-select: none;
  pointer-events: none;
}

.fps-meter .fps-label {
  color: var(--text-dim);
  margin-right: 6px;
}

/* ヒーロー下部のデモアンカーナビ */
.hero-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 44px;
}

.hero-nav a {
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.hero-nav a:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: var(--surface-2);
}

.hero-nav a .idx {
  font-family: var(--font-mono);
  color: var(--accent);
  margin-right: 8px;
}

/* スクロールインジケータ */
.scroll-cue {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  animation: cue-bob 2s ease-in-out infinite;
}

@keyframes cue-bob {
  0%, 100% { transform: translate(-50%, 0); opacity: 0.6; }
  50%      { transform: translate(-50%, 6px); opacity: 1; }
}

/* -----------------------------------------------------------------------------
 * デモセクション(共通)
 * 各デモ JS は init(root) で .demo-mount 配下を構築する。
 * -------------------------------------------------------------------------- */
.demo {
  position: relative;
  padding: clamp(72px, 12vh, 140px) 0;
  border-top: 1px solid var(--border);
}

.demo:nth-of-type(even) {
  background:
    radial-gradient(80% 60% at 80% 0%, color-mix(in srgb, var(--accent-2) 6%, transparent) 0%, transparent 60%);
}

.demo-head {
  margin-bottom: 36px;
}

.demo-head h2 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
}

.demo-mount {
  position: relative;
  min-height: 320px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* 各デモ JS 読み込み前のプレースホルダ表示 */
.demo-mount:empty::before {
  content: "モジュール読み込み中…";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* -----------------------------------------------------------------------------
 * フッター
 * -------------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 48px 0 64px;
  color: var(--text-dim);
  font-size: 0.88rem;
}

.site-footer .credits {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.site-footer .credits span {
  color: var(--text);
}
