/* styles.css — ジム契約、その前に
 *
 * デザイントークン（design_doc.md §3）:
 *   表示用フォント: Fraunces（セリフ/イタリック）
 *   本文フォント:   Zen Maru Gothic（丸ゴシック）
 *   背景クリーム #FBF5EA / インク #2C2620 / オレンジ #E2613A / 緑 #3F6248 / 金 #E8A33D
 *   温かく続けたくなるトーン。ジムの「厳しさ」とはあえて逆の世界観。
 */

:root {
  --cream: #fbf5ea;
  --cream-deep: #f3e9d6;
  --ink: #2c2620;
  --ink-soft: #6b6155;
  --orange: #e2613a;
  --orange-deep: #c84e2b;
  --green: #3f6248;
  --gold: #e8a33d;
  --card-bg: #fffdf8;
  --shadow: 0 6px 20px rgba(44, 38, 32, 0.08);
  --radius: 18px;
  --maxw: 480px;

  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'Zen Maru Gothic', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

/* hidden 属性を確実に効かせる。
 * .onboarding や .btn など display を明示している要素では、
 * hidden 属性が与える display:none が CSS の display 指定に負けてしまう。
 * （これが「はじめる」を押してもオンボーディングが閉じない原因だった） */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  /* iOS のセーフエリア対応 */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---- ヘッダー ---- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 4px;
}

.app-title {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.01em;
}

.app-title em {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  color: var(--orange);
  font-size: 1.35rem;
}

.level-badge {
  flex-shrink: 0;
  background: var(--green);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---- カード共通 ---- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.card-title {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--ink);
}

/* ---- ストリークカード ---- */
.streak-card {
  text-align: center;
  background: linear-gradient(160deg, #fffdf8, #fdf3e6);
}

.streak-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.streak-flame {
  font-size: 2.4rem;
  filter: grayscale(1) opacity(0.35);
  transition: filter 0.3s ease, transform 0.3s ease;
}

.streak-flame.is-lit {
  filter: none;
  transform: scale(1.05);
}

.streak-count strong {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 3rem;
  line-height: 1;
  color: var(--orange);
}

.streak-unit {
  font-size: 1rem;
  margin-left: 4px;
  color: var(--ink-soft);
}

.streak-sub {
  margin: 8px 0 16px;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.streak-stats {
  display: flex;
  border-top: 1px solid var(--cream-deep);
  padding-top: 14px;
}

.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat + .stat {
  border-left: 1px solid var(--cream-deep);
}

.stat__num {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.6rem;
  color: var(--green);
}

.stat__label {
  font-size: 0.74rem;
  color: var(--ink-soft);
}

/* ---- 今日のメニュー ---- */
.menu-meta {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.menu-list {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
}

.menu-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 2px;
  border-bottom: 1px dashed var(--cream-deep);
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item__name {
  font-size: 0.95rem;
}

.menu-item__amount {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--orange-deep);
}

/* ---- ボタン ---- */
.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 14px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.2s ease, opacity 0.2s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: var(--orange);
  color: #fff;
  box-shadow: 0 4px 12px rgba(226, 97, 58, 0.3);
}

.btn--primary:hover {
  background: var(--orange-deep);
}

.btn--ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1.5px solid var(--cream-deep);
  font-weight: 500;
}

.btn--danger {
  background: transparent;
  color: var(--orange-deep);
  border: 1.5px solid #e9c9bd;
  font-weight: 500;
  font-size: 0.9rem;
  margin-top: 18px;
}

/* ---- ジム準備度 ---- */
.readiness-pct {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.4rem;
  color: var(--orange);
}

.readiness-track {
  position: relative;
  height: 14px;
  background: var(--cream-deep);
  border-radius: 999px;
  margin: 28px 0 18px;
}

.readiness-fill {
  position: absolute;
  inset: 0 auto 0 0;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--orange));
  border-radius: 999px;
  transition: width 0.5s ease;
}

.readiness-walker {
  position: absolute;
  top: -22px;
  transform: translateX(-50%);
  font-size: 1.3rem;
  transition: left 0.5s ease;
}

.readiness-goal {
  position: absolute;
  top: -22px;
  right: -6px;
  font-size: 1.3rem;
}

.milestones {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.milestone {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  border-radius: 12px;
  background: var(--cream);
  opacity: 0.55;
  transition: opacity 0.3s ease, background 0.3s ease;
}

.milestone.is-reached {
  opacity: 1;
  background: #eaf1ea;
}

.milestone__at {
  display: block;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  color: var(--green);
}

.milestone__label {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.readiness-msg {
  margin: 0;
  font-size: 0.9rem;
  background: #fdf3e6;
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--ink);
}

/* ---- カレンダー ---- */
.calendar-label {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-head {
  text-align: center;
  font-size: 0.72rem;
  color: var(--ink-soft);
  padding-bottom: 4px;
}

.cal-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  border-radius: 9px;
  color: var(--ink-soft);
}

.cal-cell--blank {
  background: transparent;
}

.cal-cell.is-done {
  background: var(--orange);
  color: #fff;
  font-weight: 700;
}

.cal-cell.is-today {
  box-shadow: inset 0 0 0 2px var(--green);
  color: var(--ink);
}

.cal-cell.is-today.is-done {
  box-shadow: inset 0 0 0 2px var(--green);
  color: #fff;
}

/* ---- 趣旨説明・設定 ---- */
.about-text {
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin: 0 0 18px;
}

.settings {
  background: var(--cream);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 4px;
}

.settings-title {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 700;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}

.setting-row + .setting-row {
  border-top: 1px solid var(--cream-deep);
}

.setting-label {
  font-size: 0.88rem;
}

.toggle {
  width: 46px;
  height: 26px;
  appearance: none;
  -webkit-appearance: none;
  background: #d8cdbb;
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.toggle:checked {
  background: var(--green);
}

.toggle:checked::after {
  transform: translateX(20px);
}

.time-input,
.num-input {
  font-family: var(--font-body);
  font-size: 0.95rem;
  border: 1.5px solid var(--cream-deep);
  border-radius: 10px;
  padding: 6px 10px;
  background: #fff;
  color: var(--ink);
}

.num-input {
  width: 72px;
  text-align: center;
}

.notify-hint {
  margin: 10px 0 0;
  font-size: 0.8rem;
  color: var(--orange-deep);
  background: #fdeee7;
  border-radius: 10px;
  padding: 10px 12px;
}

/* ---- フッター ---- */
.app-footer {
  text-align: center;
  font-size: 0.74rem;
  color: var(--ink-soft);
  margin-top: 4px;
}

.app-footer p {
  margin: 0;
}

/* ---- オンボーディング ---- */
.onboarding {
  position: fixed;
  inset: 0;
  background: rgba(44, 38, 32, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.onboarding__sheet {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 28px 24px 24px;
  max-width: var(--maxw);
  width: 100%;
  box-shadow: 0 -8px 30px rgba(44, 38, 32, 0.2);
  animation: sheet-up 0.32s ease;
}

@keyframes sheet-up {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.onboarding__title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.5rem;
}

.onboarding__lead {
  margin: 0 0 16px;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.onboarding__points {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.onboarding__points li {
  font-size: 0.9rem;
  background: var(--cream);
  border-radius: 12px;
  padding: 10px 12px;
}

.onboarding__ios {
  background: #fdf3e6;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 0.84rem;
}

.onboarding__ios p {
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
