/* ============================================================
   Audio Ear Trainer - style.css
   Onmonのデザイントークン・コンポーネントパターンに可能な限り統一
   (:root変数、pill型ボタン、.tag/.tag-list、.eyebrow、.link-button、
    .audio-oscilloscope、.now-playing、.comparison-grid 等はOnmonと同一)
   ============================================================ */

:root {
  --background: #f7f4ef;
  --surface: #ffffff;
  --text: #202124;
  --muted: #6b625a;
  --accent: #7c5cff;
  --accent-dark: #5a3fd2;
  --accent-secondary: #31d0c6;
  --border: #e6ded4;
  --shadow: 0 20px 60px rgba(32, 33, 36, 0.1);
  --radius: 24px;
  --header-height: 56px;
  font-family:
    Inter, "Hiragino Sans", "Meiryo", ui-sans-serif, system-ui,
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(124, 92, 255, 0.12), transparent 32rem),
    var(--background);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 32px;
}

.app-shell {
  width: min(560px, 100%);
  padding: 20px 20px 0;
}

/* ---------- Sticky compact header(Onmonと同一) ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header > * {
  width: min(560px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.logo-mark {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  color: var(--accent-dark);
}

.wordmark {
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.language-switcher button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 2px 4px;
  font: inherit;
  font-size: 0.85rem;
  border-radius: 0;
  cursor: pointer;
}

.language-switcher button:hover,
.language-switcher .language-option-active {
  background: transparent;
  color: var(--accent-dark);
  transform: none;
}

.language-switcher .language-option-active {
  font-weight: 800;
}

.language-divider {
  color: var(--border);
}

/* ---------- Card(Onmonと同一) ---------- */

.card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(20px, 4vw, 32px);
  margin-top: 20px;
}

.subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin: -4px 0 28px;
}

h2 {
  margin: 0 0 12px;
  line-height: 1.15;
  font-size: clamp(1.1rem, 3vw, 1.4rem);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ---------- 画面切り替え(Onmonと同一) ---------- */

.screen {
  display: none;
}

.screen-active {
  display: block;
}

section {
  margin-bottom: 24px;
}

#term-explanation, #study-term-description {
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
}

#question-text {
  font-size: 15px;
  margin-bottom: 16px;
  text-align: center;
}

/* ---------- ボタン共通(Onmonと同じpill型) ---------- */

.sound-buttons, .answer-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

button {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 12px 20px;
  transition: background 160ms ease, transform 160ms ease;
}

button:hover, button:focus-visible {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

button:active {
  transform: scale(0.97);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.sound-btn {
  flex: 1;
}

.answer-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  flex: 1 1 calc(50% - 6px);
  min-width: 90px;
  font-weight: bold;
}

.answer-btn:hover {
  background: #f0ecff;
}

#next-btn {
  width: 100%;
  margin-top: 12px;
}

#result-section {
  background-color: var(--background);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}

#result-text {
  font-weight: bold;
  margin-bottom: 8px;
}

#result-explanation {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

footer {
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

/* ---- カテゴリ選択・用語一覧画面(共通) ---- */

.section-title {
  font-size: 17px;
  margin-bottom: 20px;
  text-align: center;
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.category-btn {
  background-color: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-align: left;
  padding: 14px 18px;
  font-size: 15px;
  border-radius: 16px;
}

.category-btn:hover {
  border-color: var(--accent);
  background: #f0ecff;
}

.term-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.term-card .term-card-difficulty {
  font-size: 11px;
  color: var(--muted);
}

.link-button {
  display: block;
  margin: 10px auto 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 8px;
  text-decoration: underline;
}

.link-button:hover {
  background: transparent;
  color: var(--accent-dark);
  transform: none;
}

.back-btn {
  background: none;
  color: var(--muted);
  font-size: 13px;
  padding: 4px 0;
  margin-bottom: 16px;
}

.back-btn:hover {
  background: none;
  color: var(--accent-dark);
  transform: none;
}

/* ---- 進捗(可視化)画面 ---- */

.progress-row {
  margin-bottom: 18px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 6px;
}

.progress-track {
  background-color: #ece6dd;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.progress-fill {
  background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.progress-empty-note {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* ---- Onmon連携: おすすめバナー ---- */

.profile-banner {
  background-color: rgba(124, 92, 255, 0.08);
  border: 1px solid var(--accent);
  color: var(--accent-dark);
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
  text-align: center;
}

/* ---- 難易度バッジ・聴きどころ(Onmonの.tag/.tag-listと統一) ---- */

.term-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.term-heading h2 {
  margin: 0;
}

.difficulty-badge {
  font-size: 11px;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 999px;
  background-color: var(--background);
  color: var(--muted);
  border: 1px solid var(--border);
}

.difficulty-beginner { color: #1a8f5e; border-color: #1a8f5e; }
.difficulty-intermediate { color: #c98a12; border-color: #c98a12; }
.difficulty-advanced { color: #d1483f; border-color: #d1483f; }

.listening-points, .tag-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
}

.listening-points li, .tag-list li, .tag {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-dark);
  background-color: rgba(124, 92, 255, 0.1);
  padding: 4px 12px;
  border-radius: 999px;
}

/* ---- 数値入力UI(numeric_guessタイプ) ---- */

.numeric-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

#freq-guess-input {
  flex: 1;
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: inherit;
  min-width: 0;
}

#freq-guess-input:focus {
  outline: none;
  border-color: var(--accent);
}

#numeric-unit-label {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

/* ---- Audio UI(Onmonと同一クラス名) ---- */

.now-playing {
  margin: 0 0 6px;
  font-weight: 700;
  color: var(--accent-dark);
  min-height: 1.4em;
  text-align: center;
  font-size: 13px;
}

.audio-oscilloscope {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 140px;
  margin: 0 auto 16px;
  background: #f0ecff;
  border: 1px solid var(--border);
  border-radius: 12px;
}

/* ---- 用語学習ページ(term-study-screen)専用 ---- */

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.usage-box {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
}

.usage-box .usage-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 6px;
}

.usage-box ul {
  margin: 0;
  padding-left: 18px;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.5;
}

.usage-positive .usage-label { color: var(--accent-dark); }
.usage-negative .usage-label { color: #b5482f; }

.study-listen-panel {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  text-align: center;
}

.training-method-note {
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--background);
  border-radius: 12px;
  padding: 10px 14px;
  margin-top: 4px;
}

/* ---- Bottom nav(Onmonの.app-navと統一。用語間の前後移動) ---- */

.study-nav-buttons {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.app-nav-btn {
  flex: 1;
  background: var(--surface);
  color: var(--accent-dark);
  border: 1px solid var(--border);
}

.app-nav-btn:hover {
  background: #f0ecff;
}

@media (max-width: 640px) {
  .comparison-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- インタラクティブ探索ウィジェット共通 ---- */

.sound-descriptor {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.3;
}

.sound-btn-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.explorer-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  text-align: left;
}

.explorer-row label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  justify-content: space-between;
}

.explorer-readout {
  color: var(--accent-dark);
  font-weight: 800;
}

.explorer-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.explorer-select {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.explorer-select button {
  flex: 1 1 calc(33% - 8px);
  min-width: 90px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.82rem;
  padding: 8px 12px;
}

.explorer-select button.explorer-select-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.eq-curve-preview {
  width: 100%;
  max-width: 280px;
  height: 90px;
  margin: 8px auto 14px;
  display: block;
}

.eq-curve-preview path {
  fill: none;
  stroke: var(--accent-dark);
  stroke-width: 2.5;
}

.eq-curve-preview .eq-axis {
  stroke: var(--border);
  stroke-width: 1;
}
