/* ============================================================
   Function Gym - スタイルシート
   ダーク基調 + グラスモーフィズム + ネオングラデーションの
   テック系デザイン。Tailwindをベースに独自コンポーネントを追加。
   ============================================================ */

:root {
  --brand-linear: #6366f1;
  --brand-quadratic: #f43f5e;
  --brand-cubic: #10d9a3;
  --brand-trig: #b855f7;
  --brand-exponential: #ff8a3d;
  --brand-logarithmic: #22d3ee;

  --bg-base: #07070d;
  --bg-panel: rgba(255, 255, 255, 0.045);
  --bg-panel-strong: rgba(255, 255, 255, 0.07);
  --border-glass: rgba(255, 255, 255, 0.09);
  --border-glass-strong: rgba(255, 255, 255, 0.16);
  --text-primary: #eef0fb;
  --text-secondary: #9498b3;
  --text-faint: #5c6088;
}

* {
  font-family: 'Zen Kaku Gothic New', 'Space Grotesk', system-ui, -apple-system, sans-serif;
}

.font-display,
h1, h2, h3,
.gg-mono {
  font-family: 'Space Grotesk', 'Zen Kaku Gothic New', system-ui, sans-serif;
  letter-spacing: 0.01em;
}

.font-mono {
  font-family: 'JetBrains Mono', 'Space Grotesk', monospace !important;
}

html {
  background: var(--bg-base);
}

body {
  background:
    radial-gradient(ellipse 900px 500px at 12% -8%, rgba(99, 102, 241, 0.22), transparent 60%),
    radial-gradient(ellipse 800px 600px at 88% 8%, rgba(34, 211, 238, 0.14), transparent 55%),
    radial-gradient(ellipse 700px 700px at 50% 100%, rgba(184, 85, 247, 0.12), transparent 60%),
    var(--bg-base);
  min-height: 100vh;
  color: var(--text-primary);
  position: relative;
  overflow-x: hidden;
}

/* うっすらしたドットグリッドのテクスチャ */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px);
  background-size: 26px 26px;
  pointer-events: none;
  z-index: 0;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, black 40%, transparent 90%);
}

#app-root { position: relative; z-index: 1; }

/* ---------- ローディング画面 ---------- */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 1rem;
  color: #a5b4fc;
  background: var(--bg-base);
}
.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: #818cf8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  box-shadow: 0 0 24px rgba(99, 102, 241, 0.35);
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- ヘッダー ---------- */
.gym-header {
  background: rgba(9, 9, 16, 0.72);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--border-glass);
}
.gym-logo-mark {
  background: linear-gradient(135deg, #6366f1, #a855f7 55%, #22d3ee);
  box-shadow: 0 0 22px rgba(129, 140, 248, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* ---------- 共通グラスカード ---------- */
.gym-card {
  background: var(--bg-panel);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border-radius: 1.4rem;
  border: 1px solid var(--border-glass);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 20px 50px -20px rgba(0, 0, 0, 0.6);
  position: relative;
}

/* ---------- 関数種別カード(トップページ) ---------- */
.func-type-card {
  position: relative;
  cursor: pointer;
  transition: transform 0.22s cubic-bezier(.2,.8,.2,1), box-shadow 0.22s ease, border-color 0.22s ease;
  overflow: hidden;
  isolation: isolate;
}
.func-type-card::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(220px circle at 20% 0%, color-mix(in srgb, var(--accent, #6366f1) 22%, transparent), transparent 70%);
  opacity: 0.9;
  transition: opacity 0.25s ease;
}
.func-type-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent, #6366f1), transparent);
  opacity: 0.9;
}
.func-type-card:hover {
  transform: translateY(-6px);
  border-color: color-mix(in srgb, var(--accent, #6366f1) 55%, var(--border-glass));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 24px 46px -18px color-mix(in srgb, var(--accent, #6366f1) 45%, transparent),
    0 0 0 1px color-mix(in srgb, var(--accent, #6366f1) 30%, transparent);
}
.func-icon-badge {
  box-shadow: 0 0 18px -2px color-mix(in srgb, var(--accent, #6366f1) 70%, transparent), inset 0 1px 0 rgba(255,255,255,0.25);
}

/* ---------- ナビゲーション ---------- */
.gym-nav-btn {
  transition: all 0.18s ease;
  color: var(--text-secondary);
}
.gym-nav-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}
.gym-nav-btn.active {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  box-shadow: 0 4px 16px -4px rgba(99, 102, 241, 0.6);
}

/* ---------- グラデーションテキスト ---------- */
.text-gradient {
  background: linear-gradient(100deg, #a5b4fc 0%, #e0abfa 45%, #67e8f9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- ボタン ---------- */
.btn-primary-glow {
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
  box-shadow: 0 8px 24px -8px color-mix(in srgb, var(--accent, #6366f1) 70%, transparent);
}
.btn-primary-glow:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow: 0 12px 30px -8px color-mix(in srgb, var(--accent, #6366f1) 85%, transparent);
}
.btn-primary-glow:active { transform: translateY(0); }

.btn-outline-ghost {
  background: rgba(255, 255, 255, 0.03);
  transition: all 0.18s ease;
}
.btn-outline-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

.btn-dashed-ghost {
  background: rgba(255, 255, 255, 0.02);
  border: 2px dashed var(--border-glass-strong);
  color: var(--text-secondary);
  transition: all 0.18s ease;
}
.btn-dashed-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(165, 180, 252, 0.5);
  color: var(--text-primary);
}

/* ---------- グラフキャンバス(白背景を維持し、コントラストで浮かせる) ---------- */
.graph-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #fbfbfe;
  border-radius: 1.1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.02) inset,
    0 30px 60px -24px rgba(0, 0, 0, 0.55);
}
.graph-canvas-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- パラメータパネル ---------- */
.param-panel-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  border-radius: 0.9rem;
  padding: 0.85rem 1rem;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.param-panel-item:hover {
  border-color: var(--border-glass-strong);
  background: rgba(255, 255, 255, 0.05);
}

/* ---------- スライダー ---------- */
input[type="range"].gym-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,255,255,0.14), rgba(255,255,255,0.06));
  outline: none;
}
input[type="range"].gym-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent, #6366f1);
  cursor: pointer;
  border: 3px solid #0d0d18;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent, #6366f1) 60%, transparent), 0 2px 8px rgba(0,0,0,0.5);
}
input[type="range"].gym-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent, #6366f1);
  cursor: pointer;
  border: 3px solid #0d0d18;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent, #6366f1) 60%, transparent), 0 2px 8px rgba(0,0,0,0.5);
}

select.param-select {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-glass-strong) !important;
  color: var(--text-primary);
}
select.param-select option {
  background: #12121e;
  color: var(--text-primary);
}

/* ---------- クイズ ステートメント行 ---------- */
.statement-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-radius: 0.95rem;
  border: 1.5px solid var(--border-glass);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: all 0.16s ease;
}
.statement-row:hover {
  border-color: rgba(165, 180, 252, 0.45);
  background: rgba(99, 102, 241, 0.08);
}
.statement-row.selected-true {
  border-color: #818cf8;
  background: rgba(99, 102, 241, 0.14);
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.25), 0 8px 22px -10px rgba(99, 102, 241, 0.5);
}
.statement-row.result-correct {
  border-color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.25);
}
.statement-row.result-incorrect {
  border-color: #fb7185;
  background: rgba(244, 63, 94, 0.12);
  box-shadow: 0 0 0 1px rgba(251, 113, 133, 0.25);
}
.statement-checkbox {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 0.4rem;
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  color: var(--text-secondary);
  transition: all 0.16s ease;
}
.statement-row.selected-true .statement-checkbox {
  background: #6366f1;
  border-color: #6366f1;
  color: #fff;
}
.statement-row.result-correct .statement-checkbox {
  background: #10b981;
  border-color: #10b981;
  color: #fff;
}
.statement-row.result-incorrect .statement-checkbox {
  background: #f43f5e;
  border-color: #f43f5e;
  color: #fff;
}

/* ---------- 実践問題・総合問題: 選択肢ボタン ---------- */
.choice-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  padding: 0.9rem 1.1rem;
  border-radius: 0.95rem;
  border: 1.5px solid var(--border-glass);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  font-weight: 700;
  font-family: 'JetBrains Mono', 'Space Grotesk', monospace;
  cursor: pointer;
  transition: all 0.16s ease;
}
.choice-btn:hover:not(:disabled) {
  border-color: rgba(165, 180, 252, 0.45);
  background: rgba(99, 102, 241, 0.08);
  transform: translateY(-1px);
}
.choice-btn:disabled { cursor: default; }
.choice-btn .choice-letter {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 0.5rem;
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.choice-btn.choice-correct {
  border-color: #34d399;
  background: rgba(16, 185, 129, 0.14);
  box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.25);
}
.choice-btn.choice-correct .choice-letter { background: #10b981; border-color: #10b981; color: #fff; }
.choice-btn.choice-wrong-selected {
  border-color: #fb7185;
  background: rgba(244, 63, 94, 0.14);
  box-shadow: 0 0 0 1px rgba(251, 113, 133, 0.25);
}
.choice-btn.choice-wrong-selected .choice-letter { background: #f43f5e; border-color: #f43f5e; color: #fff; }
.choice-btn.choice-dim { opacity: 0.45; }

/* ---------- 総合問題タブごとのミニバッジ ---------- */
.exam-progress-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  transition: all 0.2s ease;
}
.exam-progress-dot.done-correct { background: #34d399; box-shadow: 0 0 6px #34d39999; }
.exam-progress-dot.done-wrong { background: #f43f5e; box-shadow: 0 0 6px #f43f5e99; }
.exam-progress-dot.current { background: #818cf8; box-shadow: 0 0 8px #818cf8cc; transform: scale(1.3); }

/* ---------- バッジ / レベル ---------- */
.level-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
}

/* ---------- テキストカラー(ダーク基調用ユーティリティ) ---------- */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-faint { color: var(--text-faint); }
.border-glass { border-color: var(--border-glass) !important; }
.border-glass-strong { border-color: var(--border-glass-strong) !important; }
.bg-glass { background: var(--bg-panel); }
.bg-glass-strong { background: var(--bg-panel-strong); }

.pill-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
}

/* ---------- アニメーション ---------- */
@keyframes popIn {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.pop-in { animation: popIn 0.25s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.shake { animation: shake 0.3s ease; }

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-slide-up { animation: fadeSlideUp 0.45s cubic-bezier(.2,.8,.2,1); }

@keyframes floatGlow {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.float-glow { animation: floatGlow 4.5s ease-in-out infinite; }

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.shimmer-text {
  background: linear-gradient(100deg, #a5b4fc 20%, #ffffff 40%, #67e8f9 60%, #a5b4fc 80%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 5s linear infinite;
}

/* ---------- スクロールバー ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(129, 140, 248, 0.35); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(129, 140, 248, 0.55); }

/* ---------- レスポンシブ調整 ---------- */
@media (max-width: 640px) {
  .graph-canvas-wrap { aspect-ratio: 1 / 1; }
}
