/*
 * コース紹介ページ専用スタイル。
 * レイアウトの寸法は CSS 変数で持ち、main.js が getComputedStyle で同じ値を読む
 * （地図の中心オフセット計算に使うため、値を変えるときはここだけ直せばよい）。
 */
:root {
  --pane-width: 380px;        /* PC: 左ペインの幅 */
  --sheet-peek: 236px;        /* スマホ: ボトムシートを閉じたとき（初期表示）に見せる高さ。ハンドルだけの最小化はさらに下げられる */
  --sheet-max: 82dvh;         /* スマホ: ボトムシートを開いたときの高さ */
  --accent: #ff5f5f;
  --ink: #1c1c1f;
  --muted: #6f6f6f;
  --panel-bg: #ffffff;
  --motion: 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}

/* display:flex を持つ要素にも hidden 属性を効かせる */
[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: #f0f0f0;
  -webkit-text-size-adjust: 100%;
}

.course-site {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ---------- 地図 ---------- */
.map-area {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.map {
  width: 100%;
  height: 100%;
  background: #e9ecef;
  touch-action: none;
}

.map canvas {
  display: block;
}

.playback-blocker {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: transparent;
  touch-action: none;
}

.overlay-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10;
  pointer-events: none;
  max-width: calc(100% - 32px);
  text-align: center;
}

.overlay-msg.is-error {
  background: rgba(211, 47, 47, 0.88);
}

.map-fallback-note {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(28, 28, 31, 0.78);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  max-width: calc(100% - 120px);
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.compass-btn {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 16px);
  right: calc(env(safe-area-inset-right, 0px) + 16px);
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  z-index: 6;
  -webkit-tap-highlight-color: transparent;
}

.compass-img {
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.1s linear;
  will-change: transform;
}

.playback-btn {
  position: absolute;
  right: calc(env(safe-area-inset-right, 0px) + 16px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 26px);
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  z-index: 6;
  transition: transform 0.1s, bottom var(--motion);
  -webkit-tap-highlight-color: transparent;
}

.playback-btn:active {
  transform: scale(0.92);
}

.playback-btn .icon-stop { display: none; }
.course-site[data-playing="true"] .playback-btn .icon-play { display: none; }
.course-site[data-playing="true"] .playback-btn .icon-stop { display: block; }

/* ---------- 詳細パネル（共通） ---------- */
.detail-pane {
  position: absolute;
  z-index: 20;
  background: var(--panel-bg);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.16);
  display: flex;
  flex-direction: column;
  will-change: transform;
}

.detail-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 22px 24px;
}

/* ---------- アプリロゴ + 「アプリでコースを見る」導線 ---------- */
.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
}

.app-logo {
  display: block;
  height: 32px;
  width: auto;
  flex-shrink: 0;
}

.app-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 9px 12px 9px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(255, 95, 95, 0.35);
  transition: transform 0.1s, filter 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.app-link:hover {
  filter: brightness(0.95);
}

.app-link:active {
  transform: scale(0.97);
}

.app-link svg {
  flex-shrink: 0;
}

.detail-header {
  padding-top: 18px;
}

.course-name {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
  margin: 0;
}

.course-provider {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.stats {
  display: flex;
  gap: 32px;
  margin: 16px 0 0;
}

.stat {
  display: flex;
  flex-direction: column-reverse;
}

.stat-value {
  margin: 0;
  font-size: 30px;
  font-weight: 600;
  line-height: 1.1;
  color: #282828;
  font-variant-numeric: tabular-nums;
}

.stat-unit {
  font-size: 14px;
  font-weight: 400;
  margin-left: 2px;
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: #8d8d8d;
  margin-top: 4px;
}

.images {
  display: flex;
  gap: 8px;
  margin: 18px 0 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.image-button {
  flex-shrink: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 10px;
  overflow: hidden;
}

.image-thumb {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: cover;
  background: #eee;
}

.detail-section {
  margin-top: 20px;
}

.detail-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 8px;
}

.detail-section-text {
  font-size: 13.5px;
  color: #5f5d5d;
  line-height: 1.7;
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.course-error {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fdecec;
  color: #b3261e;
  font-size: 13px;
}

.detail-footer {
  margin-top: 28px;
  border-top: 1px solid #ececec;
  padding-top: 12px;
}

.credit {
  margin: 6px 0 0;
  font-size: 11px;
  color: #9b9b9b;
}

/* ---------- PC: 左ペイン ---------- */
.course-site[data-layout="pc"] .detail-pane {
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--pane-width);
  transform: translateX(0);
  transition: transform var(--motion);
}

.course-site[data-layout="pc"][data-pane="closed"] .detail-pane {
  transform: translateX(-100%);
}

.course-site[data-layout="pc"] .sheet-handle {
  display: none;
}

.course-site[data-layout="pc"] .detail-scroll {
  padding-top: 28px;
}

.pane-toggle {
  position: absolute;
  top: 50%;
  left: var(--pane-width);
  transform: translateY(-50%);
  width: 28px;
  height: 64px;
  padding: 0;
  border: none;
  border-radius: 0 10px 10px 0;
  background: var(--panel-bg);
  color: #555;
  box-shadow: 4px 0 12px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  z-index: 21;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: left var(--motion);
}

.pane-toggle svg {
  transition: transform var(--motion);
}

.course-site[data-pane="closed"] .pane-toggle {
  left: 0;
}

.course-site[data-pane="closed"] .pane-toggle svg {
  transform: rotate(180deg);
}

.course-site[data-layout="mobile"] .pane-toggle {
  display: none;
}

/* ---------- スマホ: ボトムシート ---------- */
.course-site[data-layout="mobile"] .detail-pane {
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--sheet-max);
  border-radius: 20px 20px 0 0;
  /* JS が --sheet-translate を更新する。閉じた状態が初期値 */
  transform: translateY(var(--sheet-translate, calc(var(--sheet-max) - var(--sheet-peek))));
  transition: transform var(--motion);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.course-site[data-layout="mobile"] .detail-pane.is-dragging {
  transition: none;
}

/* 全開以外は中身をスクロールさせず、ドラッグ操作と競合させない */
.course-site[data-layout="mobile"]:not([data-sheet="expanded"]) .detail-scroll {
  overflow-y: hidden;
}

.sheet-handle {
  flex-shrink: 0;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.sheet-grip {
  width: 40px;
  height: 5px;
  border-radius: 3px;
  background: #d5d5d5;
}

/* 再生ボタンはシートに隠れないよう、シートの見えている部分の上に出す（--sheet-visible は main.js が状態ごとに更新） */
.course-site[data-layout="mobile"] .playback-btn {
  bottom: calc(var(--sheet-visible, var(--sheet-peek)) + env(safe-area-inset-bottom, 0px) + 16px);
}

/* スマホ: ロゴは画面幅の 40% を目安にする。狭い画面ではボタンを優先してロゴ側を縮める */
.course-site[data-layout="mobile"] .app-logo {
  width: 40vw;
  height: auto;
  flex-shrink: 1;
  min-width: 0;
}

.course-site[data-layout="mobile"] .app-link {
  font-size: 12px;
  padding: 8px 10px 8px 12px;
}

.course-site[data-layout="mobile"] .detail-header {
  padding-top: 14px;
}

.course-site[data-layout="mobile"] .course-name {
  font-size: 17px;
}

.course-site[data-layout="mobile"] .stat-value {
  font-size: 26px;
}

.course-site[data-layout="mobile"] .image-thumb {
  width: 80px;
  height: 80px;
}

/* ---------- 画像拡大 ---------- */
.image-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.74);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 72px 16px 24px;
}

.image-modal-close {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 18px);
  left: 18px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: #6a6a6a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.image-modal-img {
  max-width: min(100%, 960px);
  max-height: 100%;
  object-fit: contain;
}

@media (prefers-reduced-motion: reduce) {
  .detail-pane,
  .pane-toggle,
  .pane-toggle svg,
  .playback-btn,
  .app-link {
    transition: none;
  }
}
