/* 鉄ナビ ポケスタ2026 3Dマップ — モバイルファースト */

:root {
  --bg: #f2f6f9;
  --surface: #ffffff;
  --ink: #22313c;
  --ink-soft: #5b6d7a;
  --brand: #00a5a8;
  --line: #d8e2e9;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(34, 49, 60, 0.12);
  --font-head: 'M PLUS Rounded 1c', 'Noto Sans JP', sans-serif;
  --font-body: 'Noto Sans JP', sans-serif;
  --tap: 44px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }

/* ---------- ポスター ---------- */
#poster {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 24px 20px 56px;
  overflow: hidden;
  background: linear-gradient(180deg, #dff0fa 0%, #f2f6f9 55%, #eef4f2 100%);
}
.poster-sky {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.poster-ribbons {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.poster-body {
  position: relative;
  max-width: 560px;
}
.poster-kicker {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--brand);
  margin: 0 0 8px;
}
.poster-title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(24px, 6.4vw, 38px);
  line-height: 1.3;
  margin: 0 0 12px;
}
.poster-lead {
  font-size: 14px;
  line-height: 1.9;
  color: var(--ink-soft);
  margin: 0 0 22px;
}
#launch-btn {
  min-height: 52px;
  min-width: 220px;
  padding: 14px 32px;
  border: none;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 17px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#launch-btn:hover { transform: translateY(-2px); }
#launch-btn:active { transform: translateY(0); }
#launch-btn:focus-visible { outline: 3px solid #1a7f82; outline-offset: 3px; }
.poster-note {
  font-size: 11.5px;
  color: var(--ink-soft);
  margin: 14px 0 0;
}
.poster-footer {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  font-size: 10.5px;
  color: var(--ink-soft);
}

/* ---------- ローディング（発車標「風」オリジナル） ---------- */
#loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #17222b;
  z-index: 50;
}
.board {
  width: min(92vw, 560px);
  border-radius: var(--radius);
  background: #0d151b;
  border: 1px solid #2a3a46;
  padding: 18px 16px;
  overflow: hidden;
}
.board-row {
  font-family: var(--font-head);
  font-weight: 700;
  white-space: nowrap;
}
.board-scroll {
  color: #7fe3d2;
  font-size: 18px;
  overflow: hidden;
}
.board-scroll span {
  display: inline-block;
  padding-left: 100%;
  animation: board-marquee 9s linear infinite;
}
.board-status {
  margin-top: 12px;
  color: #b9c8d2;
  font-size: 13px;
}
@keyframes board-marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

/* ---------- アプリ本体 ---------- */
#app {
  position: fixed;
  inset: 0;
}
#canvas-wrap {
  position: absolute;
  inset: 0;
}
#three-canvas {
  width: 100%;
  height: 100%;
  display: block;
  /* 埋め込み時: 1本指の縦スクロールはページに譲る（JSでモード切替） */
  touch-action: pan-y;
}
html[data-embed="0"] #three-canvas { touch-action: none; }

#gesture-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(23, 34, 43, 0.45);
  pointer-events: none;
  z-index: 5;
}
#gesture-hint-text {
  font-family: var(--font-head);
  font-weight: 700;
  color: #fff;
  background: rgba(23, 34, 43, 0.85);
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 15px;
}

#topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 84px 0 10px; /* 右は検索ボタンぶん空ける */
  z-index: 10;
}
#course-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#course-chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  min-height: var(--tap);
  padding: 10px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(34, 49, 60, 0.08);
}
.chip[aria-pressed="true"] {
  border-color: var(--chip-accent, var(--brand));
  background: var(--chip-accent, var(--brand));
  color: #fff;
}

#course-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  max-width: calc(100vw - 20px);
  background: rgba(255, 255, 255, 0.94);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-head);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(34, 49, 60, 0.08);
}
#course-banner button {
  min-height: 32px;
  border: 1.5px solid var(--line);
  background: #f2f6f9;
  border-radius: 999px;
  padding: 4px 12px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}

#toast {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  background: rgba(23, 34, 43, 0.92);
  color: #fff;
  font-size: 13.5px;
  border-radius: 999px;
  padding: 10px 18px;
  z-index: 20;
  max-width: 88vw;
}

/* ---------- ルート再生HUD ---------- */
#hud {
  position: absolute;
  left: 10px;
  bottom: 44px;
  z-index: 12;
  max-width: min(92vw, 380px);
}
#hud-toggle {
  min-height: var(--tap);
  padding: 10px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
#hud-toggle[aria-expanded="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
#hud-body {
  margin-top: 8px;
  background: rgba(255, 255, 255, 0.96);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  display: grid;
  gap: 10px;
}
#route-select {
  width: 100%;
  min-height: var(--tap);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  font-family: var(--font-body);
  font-size: 13px;
  background: #fff;
}
#hud-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
#hud-controls button {
  min-height: var(--tap);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: #f2f6f9;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
#hud-controls button:disabled {
  opacity: 0.45;
  cursor: default;
}
#hud-controls button[aria-pressed="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
#hud-time {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  flex-wrap: wrap;
}
#hud-time label { font-weight: 700; }
#depart-select {
  min-height: 36px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 4px 6px;
  background: #fff;
}
#hud-clock {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 20px;
  color: var(--ink);
  margin-left: auto;
}
#hud-note {
  margin: 0;
  font-size: 10.5px;
  color: var(--ink-soft);
}

#app-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
  font-size: 10px;
  line-height: 1.5;
  color: var(--ink-soft);
  background: linear-gradient(0deg, rgba(242, 246, 249, 0.95), rgba(242, 246, 249, 0));
  z-index: 8;
  pointer-events: none;
}
#app-footer a { pointer-events: auto; color: inherit; }

/* ---------- 右上ツール ---------- */
#corner-tools {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 11;
  display: flex;
  flex-direction: column; /* モバイルは縦積み */
  align-items: flex-end;
  gap: 8px;
}
@media (min-width: 768px) {
  #corner-tools { flex-direction: row; }
}
#corner-tools button {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 10px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(34, 49, 60, 0.08);
}

/* ---------- 駅パネル（モバイル=ボトムシート／PC=右パネル） ---------- */
#panel {
  position: absolute;
  z-index: 30;
  background: var(--surface);
  box-shadow: 0 -6px 30px rgba(34, 49, 60, 0.18);
  display: flex;
  flex-direction: column;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 62vh;
  border-radius: 18px 18px 0 0;
  transform: translateY(102%);
  transition: transform 0.28s ease;
}
#panel.open { transform: translateY(0); }
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 6px;
}
.panel-header h2 {
  margin: 0;
  font-family: var(--font-head);
  font-size: 20px;
}
.panel-close {
  min-width: var(--tap);
  min-height: var(--tap);
  border: none;
  background: #eef3f6;
  border-radius: 999px;
  font-size: 20px;
  cursor: pointer;
  color: var(--ink-soft);
}
.panel-body {
  overflow-y: auto;
  padding: 4px 16px calc(16px + env(safe-area-inset-bottom));
  display: grid;
  gap: 12px;
}
.badge-row { display: flex; gap: 6px; flex-wrap: wrap; }
.course-badge {
  color: #fff;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 12px;
  border-radius: 999px;
  padding: 4px 12px;
}
.line-row { display: flex; gap: 6px; flex-wrap: wrap; }
.line-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}
.line-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.info-block h3 {
  margin: 0 0 4px;
  font-family: var(--font-head);
  font-size: 13.5px;
  color: var(--ink-soft);
}
.info-block p { margin: 0; font-size: 14.5px; }
.stamp-place { font-weight: 700; }
.hours-badge {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  border-radius: 999px;
  padding: 3px 10px;
  background: #eef3f6;
  color: var(--ink-soft);
}
.hours-badge.exception {
  background: #fff1de;
  color: #a05a00;
  font-weight: 700;
}
.guide-fig { margin: 0; }
.guide-fig img {
  width: 100%;
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.guide-fig figcaption {
  font-size: 11.5px;
  color: var(--ink-soft);
  margin-top: 4px;
}
.guide-placeholder {
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  padding: 28px 12px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  background: #f7fafb;
}
.article-block { display: grid; gap: 8px; }
.article-pending {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}
.article-btn {
  display: block;
  text-align: center;
  min-height: var(--tap);
  padding: 13px 16px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 15px;
}
.article-btn.secondary {
  background: #eef3f6;
  color: var(--ink);
}

/* 検索 */
#search-input {
  width: 100%;
  min-height: var(--tap);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: var(--font-body);
}
.search-list { display: grid; gap: 4px; }
.search-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: var(--tap);
  border: none;
  background: #f7fafb;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14.5px;
  font-family: var(--font-body);
  cursor: pointer;
  text-align: left;
}
.search-item small { color: var(--ink-soft); }
.search-empty { color: var(--ink-soft); font-size: 13px; }

/* ---------- レスポンシブ ---------- */
@media (min-width: 768px) {
  .poster-lead { font-size: 15px; }
  #topbar { padding: 14px 14px 0; }
}

/* PC: パネルは右サイドに */
@media (min-width: 1024px) {
  #panel {
    left: auto;
    top: 0;
    bottom: 0;
    width: 360px;
    max-height: none;
    border-radius: 18px 0 0 18px;
    transform: translateX(105%);
    transition: transform 0.28s ease;
  }
  #panel.open { transform: translateX(0); }
}

/* ---------- アクセシビリティ ---------- */
@media (prefers-reduced-motion: reduce) {
  .board-scroll span { animation: none; padding-left: 0; }
  #launch-btn { transition: none; }
}
