/* style.css — S1: スクワットのリール画面（モバイルSafari前提） */

:root {
  /* --item-height は app.js（ITEM_HEIGHT）が起動時に注入する（単一ソース） */
  --bg: #101418;
  --fg: #f2f5f7;
  --fg-dim: #8b98a5;
  --accent: #2dd4bf;
  --accent-strong: #14b8a6;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* display指定を持つ要素でも hidden 属性を必ず勝たせる */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

.screen {
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 24px) 24px calc(env(safe-area-inset-bottom) + 24px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.screen-header {
  text-align: center;
}

.exercise-name {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.exercise-hint {
  margin-top: 6px;
  font-size: 13px;
  color: var(--fg-dim);
}

/* ---- リール ---- */

.reel {
  display: flex;
  align-items: center;
  gap: 12px;
  touch-action: none; /* フリックをスクロールに取られない */
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  outline: none;
}

.reel-window {
  position: relative;
  height: calc(var(--item-height) * 5);
  width: 180px;
  overflow: hidden;
}

.reel-items {
  position: absolute;
  inset: 0;
}

.reel-item {
  position: absolute;
  top: calc(50% - var(--item-height) / 2);
  left: 0;
  right: 0;
  height: var(--item-height);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  will-change: transform, opacity;
}

.reel-highlight {
  position: absolute;
  top: calc(50% - var(--item-height) / 2);
  left: 0;
  right: 0;
  height: var(--item-height);
  border-top: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  border-radius: 10px;
  pointer-events: none;
}

.reel-fade {
  position: absolute;
  left: 0;
  right: 0;
  height: calc(var(--item-height) * 1.6);
  pointer-events: none;
}

.reel-fade-top {
  top: 0;
  background: linear-gradient(to bottom, var(--bg), transparent);
}

.reel-fade-bottom {
  bottom: 0;
  background: linear-gradient(to top, var(--bg), transparent);
}

.reel-unit {
  font-size: 20px;
  font-weight: 600;
  color: var(--fg-dim);
}

/* ---- 当日成功バッジ ---- */

.success-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(45, 212, 191, 0.14);
  border: 1.5px solid var(--accent);
  color: var(--accent);
  font-size: 16px;
  font-weight: 700;
}

.success-badge-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-size: 14px;
}

/* 初成功の演出は表示中の画面側で再生（種目画面=バッジ／ホーム=ストリーク） */
.success-badge.pop,
.streak.pop {
  animation: badge-pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1);
}

@keyframes badge-pop {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

/* ---- 保存失敗の明示（画面共通の固定トースト・どの画面でも見える） ---- */

.save-error {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 50%;
  transform: translateX(-50%);
  width: min(432px, calc(100vw - 48px));
  z-index: 20;
  padding: 8px 16px;
  border-radius: 10px;
  background: rgba(248, 113, 113, 0.14);
  border: 1.5px solid #f87171;
  color: #fca5a5;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

/* ---- 完了 / トレーニング終了ボタン ---- */

.actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.done-button {
  width: 100%;
  padding: 18px;
  border: none;
  border-radius: 16px;
  background: var(--accent-strong);
  color: #06201c;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.2em;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.done-button:active {
  transform: scale(0.97);
}

/* トレーニング終了は非常口。主動線（完了）より控えめなゴースト調 */
.exit-button {
  width: 100%;
  padding: 14px;
  border: 1.5px solid var(--fg-dim);
  border-radius: 16px;
  background: transparent;
  color: var(--fg-dim);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.exit-button:active {
  transform: scale(0.97);
}

/* ---- 本ホーム（S4）：ストリーク → 今日の記録 → おかわり → メニュー ---- */

.home {
  justify-content: flex-start;
  gap: 22px;
}

.home-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

/* ストリーク：最上部・一番目立つ観測装置 */
.streak {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.streak-flame {
  font-size: 40px;
  line-height: 1;
  align-self: center;
}

.streak-count {
  font-size: 72px;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.streak-unit {
  font-size: 20px;
  font-weight: 700;
  color: var(--fg-dim);
}

.home-status {
  margin-top: 10px;
  font-size: 15px;
  color: var(--fg-dim);
  font-weight: 600;
  text-align: center;
}

.home-status.is-success {
  color: var(--accent);
}

.home-section {
  width: 100%;
}

.home-section-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--fg-dim);
  margin-bottom: 4px;
}

.home-summary {
  width: 100%;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.home-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 8px;
  border-bottom: 1px solid color-mix(in srgb, var(--fg-dim) 20%, transparent);
  font-size: 17px;
  font-weight: 600;
}

.home-count {
  font-variant-numeric: tabular-nums;
  color: var(--fg-dim);
}

/* おかわり：ホームからの再突入（追加記録・当日記録の修正を兼ねる） */
.okawari-button {
  width: 100%;
  padding: 16px;
  border: 1.5px solid var(--accent);
  border-radius: 16px;
  background: transparent;
  color: var(--accent);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.okawari-button:active {
  transform: scale(0.97);
}

/* ---- 週間/月間記録・設定への骨格メニュー ---- */

.home-menu {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu-link {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 8px;
  border: none;
  border-bottom: 1px solid color-mix(in srgb, var(--fg-dim) 20%, transparent);
  background: transparent;
  color: var(--fg);
  font-size: 16px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.menu-arrow {
  color: var(--fg-dim);
  font-size: 22px;
  line-height: 1;
}

.menu-link:active {
  background: color-mix(in srgb, var(--fg-dim) 10%, transparent);
}

/* ---- 週間記録（S6）：成功ドット × 種目別の今週/先週合計 ---- */

.weekly {
  justify-content: flex-start;
  gap: 22px;
}

/* 今週7日分の成功ドット（月曜始まり） */
.week-dots {
  width: 100%;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.week-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.week-day-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--fg-dim);
}

/* ドット3状態: 成功=塗り／未成功の過去日=中空の輪／未来日=破線の薄い輪 */
.week-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--fg-dim) 45%, transparent);
  background: transparent;
}

.week-dot.is-success {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 45%, transparent);
}

.week-dot.is-future {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--fg-dim) 28%, transparent);
}

.week-day-num {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}

/* 今日の列を強調（P2わかりやすさ） */
.week-day.is-today .week-day-label,
.week-day.is-today .week-day-num {
  color: var(--accent);
}

/* 種目別の今週合計と先週合計 */
.week-totals {
  width: 100%;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.week-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 8px;
  border-bottom: 1px solid color-mix(in srgb, var(--fg-dim) 20%, transparent);
}

.week-total-name {
  font-size: 16px;
  font-weight: 700;
}

.week-total-nums {
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-variant-numeric: tabular-nums;
}

.week-total-current {
  font-size: 17px;
  font-weight: 800;
  color: var(--fg);
}

.week-total-prev {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-dim);
}

/* ---- 月間記録（S7）：草カレンダー × 月合計 × 月切替 ---- */

.monthly {
  justify-content: flex-start;
  gap: 20px;
}

/* 月切替：前月‹ ・ 月ラベル ・ 次月›（未来月は次月ボタンを不活性に） */
.month-nav {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.month-nav-btn {
  width: 40px;
  height: 40px;
  border: 1.5px solid color-mix(in srgb, var(--fg-dim) 40%, transparent);
  border-radius: 12px;
  background: transparent;
  color: var(--fg);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.month-nav-btn:active {
  transform: scale(0.94);
}

/* 未来月へは進めない：不活性を明示（クリックも無効） */
.month-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.month-label {
  min-width: 128px;
  text-align: center;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

/* 月合計回数（全種目合計）：ページ内で最も目立つ数値 */
.month-total-wrap {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}

.month-total-caption {
  font-size: 14px;
  font-weight: 700;
  color: var(--fg-dim);
}

.month-total {
  font-size: 44px;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.month-total-unit {
  font-size: 18px;
  font-weight: 700;
  color: var(--fg-dim);
}

/* 草カレンダー本体 */
.month-calendar {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.month-weekdays,
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

/* ol/li のリスト構造（週間ドットと一貫）なのでマーカーを消す */
.month-grid {
  list-style: none;
}

.month-weekdays span {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--fg-dim);
}

/* 日セル：正方形。成功=色付き（草）／未成功の過去=くすみ／未来=空表示（実績と区別） */
.month-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  /* 既定＝未成功の過去日（くすみ） */
  background: color-mix(in srgb, var(--fg-dim) 12%, transparent);
  color: var(--fg-dim);
}

/* 前後の月＝空パディング（枠も数字も出さない） */
.month-cell.is-pad {
  background: transparent;
}

/* 成功日＝草。色の濃さで「やった日」を一目で分からせる（P2わかりやすさ） */
.month-cell.is-success {
  background: var(--accent);
  color: #06201c;
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 40%, transparent);
}

/* 未来日＝空表示（極薄・実績と区別）。数字だけ薄く残す */
.month-cell.is-future {
  background: color-mix(in srgb, var(--fg-dim) 5%, transparent);
  color: color-mix(in srgb, var(--fg-dim) 55%, transparent);
}

/* 今日の枠を強調（成功済みでも未成功でも位置が分かる） */
.month-cell.is-today {
  outline: 2px solid var(--fg);
  outline-offset: -2px;
}

/* ---- 準備中プレースホルダ（設定=S3の遷移先の骨格） ---- */

.placeholder {
  justify-content: center;
  gap: 28px;
}

/* 汎用の主要アクションボタン（おかわりボタンとは独立のルール。見た目の連動を持たない） */
.primary-button {
  width: 100%;
  padding: 16px;
  border: 1.5px solid var(--accent);
  border-radius: 16px;
  background: transparent;
  color: var(--accent);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.primary-button:active {
  transform: scale(0.97);
}

/* ---- 成功演出のパーティクル ---- */

.burst {
  position: fixed;
  top: 50%;
  left: 50%;
  pointer-events: none;
  z-index: 10;
}

.particle {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: particle-fly 0.9s ease-out var(--delay, 0ms) forwards;
  opacity: 0;
}

.particle:nth-child(3n) { background: #fbbf24; }
.particle:nth-child(3n + 1) { background: #f472b6; }

@keyframes particle-fly {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}
