/* SpeechClock 基本スタイル
   モバイルファースト: 基本スタイル＝モバイル（縦積み＋タブ）、
   min-width: 768px で PC 2カラムに上書き（ADR-05, NFR-05） */

:root {
  --color-text: #222;
  --color-bg: #fff;
  --color-accent: #2b6cb0;
  --color-border: #ddd;
  --color-muted: #666;
  --focus-ring: 2px solid #d97706;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
}

/* キーボード操作時のフォーカスリングを明確に表示（NFR-07） */
:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---- ヘッダー / フッター ---- */

.site-header {
  padding: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.site-header h1 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--color-accent);
}

.tagline {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--color-muted);
}

/* 原稿非送信の常時表示（FR-09） */
.no-send-note {
  margin: 0.4rem 0 0;
  font-size: 0.75rem;
  color: #166534;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  display: inline-block;
}

.no-send-note:empty {
  display: none;
}

.site-footer {
  padding: 1rem;
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.footer-links {
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.footer-links a {
  color: var(--color-accent);
}

/* ---- 広告枠・アフィリエイト（CMP-12, ADR-06: 原稿DOMと分離） ---- */

.ad-box {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--color-border);
}

.ad-label {
  margin: 0 0 0.25rem;
  font-size: 0.7rem;
  color: var(--color-muted);
}

.ad-slot {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
  border: 1px dashed var(--color-border);
  border-radius: 4px;
}

.ad-placeholder {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.8rem;
}

.affiliate-links {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
}

.affiliate-links li {
  margin-top: 0.25rem;
  color: var(--color-muted);
}

.affiliate-links a {
  color: var(--color-accent);
}

/* ---- 時間別ページの導入ブロック（ADR-04） ---- */

.page-hero {
  padding: 1rem 1rem 0;
}

.page-hero h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.page-hero p {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--color-muted);
}

/* ---- 静的ページ（プライバシーポリシー等） ---- */

.static-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
}

.static-page h2 {
  font-size: 1.375rem;
  margin: 1rem 0 0.5rem;
}

.static-page h3 {
  font-size: 1.0625rem;
  margin: 1.25rem 0 0.375rem;
}

.static-page ul {
  padding-left: 1.25rem;
}

/* ---- 通知バー（非ブロッキング。保存失敗等の通知） ---- */

.notice-bar {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #fef3c7;
  border-bottom: 1px solid #f59e0b;
  font-size: 0.875rem;
}

.notice-bar[hidden] {
  display: none;
}

.notice-bar span {
  flex: 1;
}

#notice-close {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 0.25rem;
}

/* ---- タブ（モバイルのみ表示） ---- */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
}

.tab {
  flex: 1;
  padding: 0.75rem 0.5rem;
  font-size: 1rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  color: var(--color-muted);
}

.tab[aria-selected="true"] {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
  font-weight: bold;
}

/* ---- パネル（モバイル: アクティブのみ表示） ---- */

.panel {
  display: none;
}

.panel.is-active {
  display: block;
}

/* ---- カード ---- */

.main {
  padding: 1rem;
}

.card {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.125rem;
}

/* ---- 原稿エリア ---- */

#manuscript {
  width: 100%;
  font: inherit;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  resize: vertical;
}

.manuscript-actions {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
}

.manuscript-actions button,
#btn-practice-start {
  padding: 0.5rem 1rem;
  font: inherit;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: #f7f7f7;
  cursor: pointer;
}

.manuscript-actions button:disabled,
#btn-practice-start:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.char-count {
  margin: 0.5rem 0 0;
}

.char-count-note {
  font-size: 0.75rem;
  color: var(--color-muted);
}

.estimate-placeholder,
.practice-placeholder,
.history-placeholder {
  color: var(--color-muted);
}

/* ---- 用途・速度プリセット（CMP-05） ---- */

.usecase-tabs,
.speed-levels {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.preset-btn {
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: #f7f7f7;
  cursor: pointer;
}

.preset-btn .usecase-speed,
.preset-btn .speed-value {
  color: var(--color-muted);
  font-size: 0.75rem;
}

.preset-btn.is-selected {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.preset-btn.is-selected .usecase-speed,
.preset-btn.is-selected .speed-value {
  color: #dbeafe;
}

.badge {
  font-size: 0.7rem;
  background: #fef3c7;
  color: #92400e;
  border-radius: 4px;
  padding: 0 0.3rem;
}

/* ---- 読了時間・逆算表示（CMP-03/04） ---- */

.estimate-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.estimate-row.is-selected {
  background: #eff6ff;
  font-weight: bold;
}

.estimate-row .level-time {
  color: var(--color-accent);
}

.reverse-box {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: #f8fafc;
  border-radius: 6px;
}

.reverse-box h3 {
  margin: 0 0 0.25rem;
  font-size: 0.9375rem;
}

.reverse-box p {
  margin: 0;
}

/* ---- 練習モード（CMP-06: 大文字ガイド表示・進捗・ストップウォッチ） ---- */

.practice-stats {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: var(--color-accent);
}

#practice-elapsed {
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

#practice-diff {
  font-variant-numeric: tabular-nums;
  color: var(--color-muted);
}

.guide-viewport {
  position: relative;
  height: 45vh;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-bg);
}

/* 大文字表示（§5.2 練習仕様: clamp 指定・行間1.8） */
.guide-text {
  font-size: clamp(1.5rem, 3.5vw + 0.5rem, 2.25rem);
  line-height: 1.8;
  padding: 1rem;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  will-change: transform;
}

/* 既読部分（▼ラインより上）のグレーアウト */
.guide-read-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 30%;
  background: rgba(255, 255, 255, 0.65);
  pointer-events: none;
}

/* 現在読むべき位置の破線ライン＋▼マーカー */
.guide-marker {
  position: absolute;
  top: 30%;
  left: 0;
  right: 0;
  border-top: 2px dashed var(--color-accent);
  pointer-events: none;
}

.guide-marker span {
  position: absolute;
  left: 0.25rem;
  top: 0;
  transform: translateY(-55%);
  color: var(--color-accent);
  font-size: 0.875rem;
  background: var(--color-bg);
  line-height: 1;
}

/* ---- 練習履歴 ---- */

#history-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
}

#history-list li {
  padding: 0.4rem 0.25rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

#btn-history-clear {
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: #f7f7f7;
  cursor: pointer;
}

#btn-history-clear:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- 目標タイム入力 ---- */

.target-time {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.target-time input {
  width: 4rem;
  padding: 0.4rem;
  font: inherit;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  text-align: right;
}

/* ---- PCレイアウト: 768px以上で2カラム、タブ非表示（ADR-05） ---- */

@media (min-width: 768px) {
  .tabs {
    display: none;
  }

  .main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem;
  }

  /* PCでは両パネルを常時表示（タブによる出し分けはモバイルのみ） */
  .panel {
    display: block;
  }
}
