/* ============================================================
   「6月3日の夢」— スタイルシート
   graphiter.jp デザインシステム準拠
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500&family=Noto+Serif+JP:wght@400;700&display=swap');

/* ── CSS 変数 ─────────────────────────────────────────────── */
:root {
  --bg:           #1a1b1f;
  --bg-card:      #22232a;
  --bg-overlay:   rgba(26, 27, 31, 0.94);
  --border:       #2a2b33;
  --border-light: #33343e;
  --text:         #cccccc;
  --text-heading: #eeeeee;
  --text-muted:   #555555;
  --text-sub:     #888888;
  --accent:       #00c8e0;
  --accent-dim:   rgba(0, 200, 224, 0.15);
  --accent-dark:  #0d0d0d;
  --dream-color:  #8b7cf8;   /* 夢パート = 紫 */
  --dream-dim:    rgba(139, 124, 248, 0.12);
  --reality-color: #00c8e0;  /* 現実パート = シアン */
  --locked-color: #555555;

  --font-serif: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-sans:  "Noto Sans JP", "Hiragino Kaku Gothic ProN", sans-serif;

  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  16px;

  --transition: 0.2s ease;
  --nav-height: 56px;
}

/* ── リセット ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.8;
  min-height: 100dvh;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a   { color: var(--text); text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* ── ナビゲーション ──────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  z-index: 100;
}

.nav-back {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-sub);
  font-size: 0.875rem;
  padding: 8px 4px;
  transition: color var(--transition);
}
.nav-back:hover { color: var(--text); }
.nav-back svg   { flex-shrink: 0; }

.nav-title {
  flex: 1;
  font-family: var(--font-serif);
  font-size: 0.9rem;
  color: var(--text-heading);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-right { width: 60px; }

/* ── メインコンテナ ──────────────────────────────────────── */
.page {
  display: none;
  min-height: 100dvh;
}
.page.active { display: block; }

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── ホーム画面 ──────────────────────────────────────────── */
.home-hero {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 80px 20px 60px;
  max-width: 640px;
  margin: 0 auto;
  position: relative;
  z-index: 0;
}

/* ── ホーム背景画像 ──────────────────────────────────────── */
#page-home {
  position: relative;
}

#page-home::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url('images/bg.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.10;
  z-index: -1;
  pointer-events: none;
}

.home-label {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  color: #ffffff;
  text-transform: uppercase;
  margin-bottom: 24px;
}

.home-title {
  font-family: var(--font-serif);
  font-size: clamp(2.4rem, 8vw, 4rem);
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.25;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.home-subtitle {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  color: var(--text-sub);
  letter-spacing: 0.05em;
  margin-bottom: 40px;
}

.home-desc {
  font-size: 0.9rem;
  line-height: 2;
  color: var(--text);
  margin-bottom: 48px;
  border-left: 2px solid var(--border-light);
  padding-left: 16px;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.home-progress {
  margin-top: 60px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}

.home-progress-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

.progress-bar-wrap {
  background: var(--border);
  border-radius: 2px;
  height: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.progress-text {
  font-size: 0.8rem;
  color: var(--text-sub);
}

/* ── ボタン ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  letter-spacing: 0.03em;
  line-height: 1;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-dark);
}
.btn-primary:hover { opacity: 0.88; }

.btn-outline {
  border: 1px solid var(--border-light);
  color: var(--text-sub);
}
.btn-outline:hover { border-color: var(--text-sub); color: var(--text); }

.btn-ghost {
  color: var(--text-sub);
  padding: 10px 0;
}
.btn-ghost:hover { color: var(--text); }

.btn-dream {
  background: var(--dream-dim);
  color: var(--dream-color);
  border: 1px solid rgba(139, 124, 248, 0.3);
}
.btn-dream:hover { background: rgba(139, 124, 248, 0.2); }

.btn-block { width: 100%; }

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ── 章一覧 ──────────────────────────────────────────────── */
.chapter-list-page {
  padding-top: calc(var(--nav-height) + 24px);
  padding-bottom: 40px;
}

.part-header {
  padding: 32px 20px 16px;
  max-width: 640px;
  margin: 0 auto;
}

.part-title {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

.chapter-grid {
  padding: 0 20px;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chapter-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: all var(--transition);
  cursor: pointer;
  background: transparent;
  width: 100%;
  text-align: left;
  color: var(--text);
}

.chapter-item:hover {
  background: var(--bg-card);
  border-color: var(--border);
}

.chapter-item.locked {
  cursor: pointer;
  opacity: 0.7;
}

.chapter-item.locked:hover {
  background: var(--bg-card);
  border-color: var(--border);
  opacity: 1;
}

.chapter-item.locked:active {
  opacity: 0.8;
  transform: scale(0.985);
}

.chapter-item.read .chapter-num { color: var(--text-muted); }

/* 章番号バッジ */
.chapter-num {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 0.8rem;
  font-weight: 700;
}

.chapter-item.type-dream .chapter-num {
  background: var(--dream-dim);
  color: var(--dream-color);
  border: 1px solid rgba(139, 124, 248, 0.2);
}

.chapter-item.type-reality .chapter-num {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(0, 200, 224, 0.2);
}

.chapter-item.locked .chapter-num {
  background: rgba(85,85,85,0.15);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.chapter-status-chevron {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--transition);
}

.chapter-item.locked:hover .chapter-status-chevron {
  transform: translateX(3px);
  color: var(--text);
}

.chapter-info { flex: 1; min-width: 0; }

.chapter-item-title {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--text-heading);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chapter-item-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-status-icon { flex-shrink: 0; }

.badge-read {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 2px;
  background: rgba(85,85,85,0.2);
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.badge-type {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 2px;
  letter-spacing: 0.05em;
}
.badge-type.dream    { background: var(--dream-dim); color: var(--dream-color); }
.badge-type.reality  { background: var(--accent-dim); color: var(--accent); }

/* ── 章表示画面 ──────────────────────────────────────────── */
.chapter-page {
  padding-top: var(--nav-height);
  padding-bottom: 80px;
}

/* ヘッダー */
.chapter-header {
  padding: 40px 20px 32px;
  max-width: 640px;
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
}

.chapter-header-type {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.type-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.chapter-page.dream  .type-dot { background: var(--dream-color); }
.chapter-page.dream  .chapter-header-type { color: var(--dream-color); }
.chapter-page.reality .type-dot { background: var(--reality-color); }
.chapter-page.reality .chapter-header-type { color: var(--reality-color); }

.chapter-header-num {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.chapter-header-title {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.3;
  margin-bottom: 12px;
  letter-spacing: 0.03em;
}

.chapter-header-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.chapter-header-work {
  margin-top: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(0,200,224,0.2);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
}

/* ロック状態 */
.chapter-locked-area {
  padding: 40px 20px;
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
}

.lock-icon {
  width: 56px; height: 56px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.chapter-page.reality .lock-icon {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(0,200,224,0.2);
}

.chapter-page.dream .lock-icon {
  background: var(--dream-dim);
  color: var(--dream-color);
  border: 1px solid rgba(139,124,248,0.2);
}

.lock-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--text-heading);
  margin-bottom: 10px;
}

.lock-desc {
  font-size: 0.85rem;
  color: var(--text-sub);
  line-height: 1.9;
  margin-bottom: 32px;
}

.gps-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 16px;
  line-height: 1.7;
}

/* GPS 距離表示 */
.gps-distance-wrap {
  margin: 24px 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.gps-distance-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.gps-distance-value {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  color: var(--text-heading);
}

.gps-distance-value.near { color: var(--accent); }
.gps-distance-value.far  { color: var(--text-sub); }

.gps-status-text {
  font-size: 0.8rem;
  margin-top: 4px;
}
.gps-status-text.near { color: var(--accent); }
.gps-status-text.far  { color: var(--text-muted); }

/* 地図リンク */
.map-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-sub);
  margin-top: 16px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.map-link:hover { color: var(--text); }

/* ── 本文エリア ──────────────────────────────────────────── */
.chapter-content {
  padding: 40px 20px;
  max-width: 640px;
  margin: 0 auto;
}

.chapter-content p {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 2.1;
  color: var(--text);
  margin-bottom: 1.5em;
  letter-spacing: 0.02em;
}

.chapter-content p.quote {
  color: var(--text-heading);
  font-size: 1.05rem;
  border-left: 2px solid var(--border-light);
  padding-left: 16px;
  margin-left: 8px;
}

.chapter-page.dream  .chapter-content p.quote { border-left-color: var(--dream-color); }
.chapter-page.reality .chapter-content p.quote { border-left-color: var(--reality-color); }

/* ── 読了・次のアクション ────────────────────────────────── */
.chapter-actions {
  padding: 0 20px 40px;
  max-width: 640px;
  margin: 0 auto;
  border-top: 1px solid var(--border);
  padding-top: 32px;
}

/* 夢パート — 写真エリア */
.dream-photo-area {
  margin-bottom: 32px;
  padding: 20px;
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-md);
}

.dream-photo-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.dream-photo-desc {
  font-size: 0.85rem;
  color: var(--text-sub);
  line-height: 1.8;
  margin-bottom: 16px;
}

.photo-preview {
  position: relative;
  margin-bottom: 12px;
}

.photo-preview img {
  width: 100%;
  border-radius: var(--radius-sm);
  max-height: 300px;
  object-fit: cover;
}

.photo-remove {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(0,0,0,0.7);
  color: var(--text);
  border-radius: 50%;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
}

.photo-input { display: none; }

.share-hint {
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.share-hint strong { color: var(--accent); }

/* ── スピナー / ローディング ─────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── トースト通知 ────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 0.85rem;
  color: var(--text-heading);
  white-space: nowrap;
  z-index: 200;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: rgba(0,200,224,0.4); color: var(--accent); }
.toast.error   { border-color: rgba(255,80,80,0.3); color: #ff6060; }

/* ── アコーディオン（使い方） ───────────────────────────── */
.howto-section {
  padding: 40px 20px;
  max-width: 640px;
  margin: 0 auto;
}

.howto-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--text-heading);
  margin-bottom: 24px;
}

.howto-step {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.howto-step:last-child { border-bottom: none; }

.step-num {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-sub);
  font-size: 0.78rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-top: 2px;
}

.step-content h3 {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  color: var(--text-heading);
  margin-bottom: 6px;
  font-weight: 400;
}

.step-content p {
  font-size: 0.82rem;
  color: var(--text-sub);
  line-height: 1.8;
}

/* ── フェードイン ────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeUp 0.4s ease both; }

.fade-in:nth-child(2) { animation-delay: 0.06s; }
.fade-in:nth-child(3) { animation-delay: 0.12s; }
.fade-in:nth-child(4) { animation-delay: 0.18s; }
.fade-in:nth-child(5) { animation-delay: 0.24s; }

/* ── GPS未設定警告 ───────────────────────────────────────── */
.gps-tbd-note {
  padding: 12px 16px;
  background: rgba(255,200,0,0.07);
  border: 1px solid rgba(255,200,0,0.2);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: rgba(255,200,0,0.7);
  margin-bottom: 16px;
  line-height: 1.7;
}

/* ── 作品画像（現実パートロックエリア） ──────────────────── */
.artwork-image-wrap {
  width: 100%;
  max-width: 320px;
  margin: 0 auto 24px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
}
.artwork-image {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
}
.reality-photo-section {
  width: 100%;
  margin-bottom: 24px;
}
.reality-photo-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}
.reality-photo-desc {
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 14px;
  line-height: 1.6;
}
.gps-section {
  width: 100%;
}

/* ── 地図パスワードモーダル ──────────────────────────────── */
.map-pin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.map-pin-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  width: 100%;
  max-width: 300px;
  text-align: center;
}

.map-pin-title {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 20px;
}

.map-pin-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-heading);
  font-size: 1.5rem;
  text-align: center;
  letter-spacing: 0.3em;
  padding: 10px;
  margin-bottom: 8px;
  outline: none;
  font-family: var(--font-serif);
}

.map-pin-input:focus {
  border-color: var(--accent);
}

.map-pin-error {
  font-size: 0.8rem;
  color: #f87171;
  min-height: 1.2em;
  margin-bottom: 16px;
}

.map-pin-actions {
  display: flex;
  gap: 10px;
}

.map-pin-actions .btn {
  flex: 1;
}

/* ── BGMボタン ───────────────────────────────────────────── */
.bgm-btn {
  position: fixed;
  bottom: 28px;
  right: 20px;
  z-index: 150;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(26, 27, 31, 0.75);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all var(--transition);
}

.bgm-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.bgm-btn.playing {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── テストモードバナー ──────────────────────────────────── */
.test-mode-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: #f59e0b;
  color: #1a1000;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  padding: 6px 12px;
  letter-spacing: 0.05em;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── レスポンシブ ────────────────────────────────────────── */
@media (min-width: 640px) {
  .home-hero { padding: 100px 40px 80px; }
  .chapter-header { padding: 48px 40px 40px; }
  .chapter-content { padding: 48px 40px; }
  .chapter-actions { padding: 0 40px 48px; padding-top: 32px; }
  .chapter-list-page .chapter-grid,
  .chapter-list-page .part-header { padding-left: 40px; padding-right: 40px; }
  .nav { padding: 0 32px; }
}

/* ── ダーク固定（ライトモード無効） ─────────────────────── */
@media (prefers-color-scheme: light) {
  :root {
    --bg:           #1a1b1f;
    --bg-card:      #22232a;
    --text:         #cccccc;
    --text-heading: #eeeeee;
  }
}
