/* ==========================================
   Bus Terminal Tourism Guide - Universal Design Edition
   ========================================== */

/* ---------- リセット ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---------- CSS変数 ---------- */
:root {
  /* カラーパレット */
  --primary-color: #2563eb;
  --primary-dark: #1e40af;
  --primary-light: #60a5fa;
  --secondary-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --bg-color: #f9fafb;
  --card-bg: #ffffff;
  --border-color: #e5e7eb;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
  
  /* サイズ */
  --border-radius: 16px;
  --border-radius-lg: 20px;
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
}

/* ---------- ベース ---------- */
body {
  font-family: 
    "BIZ UDPGothic", 
    "BIZ UDGothic", 
    "UD デジタル 教科書体 N-R", 
    "UD デジタル 教科書体 NK-R",
    "Hiragino Sans",
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic UI",
    "Meiryo",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  line-height: 1.75;
  color: var(--text-primary);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- レイアウト ---------- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--spacing-lg);
}

/* ---------- ヘッダー ---------- */
.header {
  background: var(--card-bg);
  padding: var(--spacing-lg);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: var(--spacing-xl);
  text-align: center;
}

.header h1 {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--spacing-sm);
}

.header .subtitle {
  font-size: 18px;
  color: var(--text-secondary);
}

.current-time {
  font-size: 24px;
  font-weight: 600;
  color: var(--primary-color);
  margin-top: var(--spacing-md);
}

/* ---------- メインコンテンツ ---------- */
.main-content {
  background: var(--card-bg);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow);
  padding: var(--spacing-xl);
  min-height: 500px;
}

/* ---------- 目的地グリッド ---------- */
.destination-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--spacing-lg);
}

.destination-btn {
  background: var(--card-bg);
  border: 3px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 50px 24px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-md);
  box-shadow: var(--shadow);
}

.destination-btn:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: currentColor;
}

.destination-btn:active {
  transform: translateY(-2px);
}

.destination-icon {
  font-size: 80px;
  margin-bottom: var(--spacing-sm);
}

.destination-name {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ---------- 結果セクション ---------- */
.results-section {
  display: none;
}

.results-section.active {
  display: block;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-xl);
  padding-bottom: var(--spacing-lg);
  border-bottom: 2px solid var(--border-color);
}

.destination-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.back-button {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 14px 28px;
  border-radius: var(--border-radius);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s ease;
}

.back-button:hover {
  background: var(--primary-dark);
}

/* ---------- ローディング ---------- */
.loading {
  display: none;
  text-align: center;
  padding: var(--spacing-xl);
}

.loading.active {
  display: block;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 5px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto var(--spacing-lg);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- 結果リスト ---------- */
.results {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

/* ---------- 結果カード ---------- */
.result-card {
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
  display: block;
  width: 100%;
}

.result-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--primary-light);
}

/* 主要情報 */
.result-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-lg);
  border-bottom: 2px dashed var(--border-color);
}

.departure-info {
  flex: 1;
}

.departure-label {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xs);
}

.departure-value {
  font-size: 64px;
  font-weight: 900;
  color: var(--primary-color);
  line-height: 1.1;
}

.platform-info {
  text-align: center;
  padding: var(--spacing-md);
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.platform-label {
  font-size: 16px;
  font-weight: 600;
  color: white;
  margin-bottom: var(--spacing-xs);
}

.platform-number-main {
  font-size: 56px;
  font-weight: 900;
  color: white;
  line-height: 1;
}

/* 経路名（系統） */
.route-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

/* 降車・到着情報 */
.result-details {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-lg);
  margin-top: var(--spacing-md);
}

.detail-item {
  flex: 1;
  min-width: 150px;
}

.detail-label {
  font-size: 14px;
  color: var(--text-tertiary);
  margin-bottom: var(--spacing-xs);
}

.detail-value {
  font-size: 16px;
  color: var(--text-secondary);
  font-weight: 500;
}

.stop-name {
  font-size: 16px;
  color: var(--text-secondary);
  font-weight: 500;
}

.arrival-value-secondary {
  font-size: 16px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ---------- エラー・空メッセージ ---------- */
.no-results,
.error-message {
  text-align: center;
  padding: var(--spacing-xl);
}

.no-results-icon,
.error-icon {
  font-size: 64px;
  margin-bottom: var(--spacing-md);
}

.no-results-text,
.error-text {
  font-size: 20px;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-sm);
}

.no-results-hint,
.error-hint {
  font-size: 16px;
  color: var(--text-tertiary);
}

/* ---------- フッター ---------- */
.footer {
  text-align: center;
  padding: var(--spacing-lg);
  margin-top: var(--spacing-xl);
  color: white;
  font-size: 14px;
}

/* ---------- アクセシビリティ ---------- */
button:focus-visible,
.destination-btn:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- 印刷対応 ---------- */
@media print {
  body {
    background: white;
  }
  .header,
  .main-content {
    box-shadow: none;
  }
  .back-button,
  .loading {
    display: none;
  }
}

/* ---------- レスポンシブ ---------- */
@media (max-width: 768px) {
  .container {
    padding: var(--spacing-md);
  }

  .header h1 {
    font-size: 26px;
  }

  .destination-grid {
    grid-template-columns: 1fr;
  }

  .destination-btn {
    min-height: 160px;
    padding: 40px 20px;
  }

  .destination-icon {
    font-size: 64px;
  }

  .destination-name {
    font-size: 22px;
  }

  .departure-value {
    font-size: 48px;
  }

  .platform-number-main {
    font-size: 42px;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-md);
  }

  .destination-title {
    font-size: 24px;
  }

  .result-main {
    flex-direction: column;
    gap: var(--spacing-md);
  }

  .platform-info {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .header h1 {
    font-size: 22px;
  }

  .current-time {
    font-size: 20px;
  }

  .main-content {
    padding: var(--spacing-md);
  }

  .departure-value {
    font-size: 40px;
  }

  .platform-number-main {
    font-size: 36px;
  }

  .route-name {
    font-size: 16px;
  }

  .detail-item {
    flex: 1 1 100%;
  }
}
