/* ==========================================================================
   Maihama Crowd Forecast – スタイルシート
   ========================================================================== */

/* ---- ベース ---- */

.mcf-app {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #333;
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
}

.mcf-app *,
.mcf-app *::before,
.mcf-app *::after {
  box-sizing: inherit;
}

.mcf-error {
  color: #c0392b;
}

/* ---- パーク切り替えタブ ---- */

.mcf-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 2px solid #ccc;
}

.mcf-tab {
  flex: 1;
  padding: 10px 8px;
  font-size: 0.95em;
  font-family: inherit;
  font-weight: bold;
  line-height: 1.4;
  cursor: pointer;
  border: 1px solid #ccc;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: #f0f0f0;
  color: #666;
  margin-right: 4px;
  transition: background 0.15s, color 0.15s;
}

.mcf-tab:last-child {
  margin-right: 0;
}

.mcf-tab--active,
.mcf-tab[aria-selected="true"] {
  background: #fff;
  color: #333;
  border-color: #ccc;
  border-bottom-color: #fff;
  margin-bottom: -2px;
  padding-bottom: 12px;
}

.mcf-tab:hover:not( [aria-selected="true"] ) {
  background: #e4e4e4;
  color: #444;
}

/* ---- 月送りナビゲーション ---- */

.mcf-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.mcf-nav__label {
  flex: 1;
  text-align: center;
  font-size: 1.1em;
  font-weight: bold;
  white-space: nowrap;
}

.mcf-nav__btn {
  flex-shrink: 0;
  padding: 6px 14px;
  font-size: 0.9em;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
  border: 1px solid #aaa;
  border-radius: 4px;
  background: #f5f5f5;
  color: #333;
}

.mcf-nav__btn:hover:not( :disabled ) {
  background: #e8e8e8;
}

.mcf-nav__btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* ---- カレンダー外枠 ---- */

/*
 * カレンダーグリッドは JS が描画するため、初期 HTML ではこの中が空になる。
 * 高さを確保しておかないと、グリッド挿入時に下の一覧・凡例がまとめて押し下げられる。
 *
 * 値は「曜日見出し行 + 日付セル 5 行」ぶん（.mcf-day の height 92px × 5 + 見出し約 26px）。
 * 6 行になる月だけは 1 行ぶん押し下げが残るが、5 行の月に 92px の空白を
 * 常時見せるよりは良いと判断した。折り返し行数は月によって変わるため、
 * どちらか一方でしか合わせられない。
 */
.mcf-calendar-wrap {
  min-height: 486px;
}

.mcf-calendar {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---- テーブル ---- */

.mcf-calendar__table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 280px;
}

.mcf-calendar__table th,
.mcf-calendar__table td {
  border: 1px solid #ddd;
  text-align: center;
  vertical-align: top;
  padding: 0;
}

.mcf-calendar__table th {
  padding: 6px 2px;
  font-size: 0.8em;
  background: #f5f5f5;
  font-weight: bold;
}

/* ---- 曜日カラー ---- */

.mcf-sun { color: #c0392b; }
.mcf-sat { color: #2980b9; }

/* ---- 日付セル ---- */

.mcf-day {
  height: 92px;
  position: relative;
}

.mcf-day--empty {
  background: #fafafa;
}

/* ---- データあり日付のボタン ---- */

.mcf-day__button {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: center;
  cursor: pointer;
}

.mcf-day__button:hover,
.mcf-day__button:focus-visible {
  outline: 2px solid #555;
  outline-offset: -2px;
  z-index: 1;
  position: relative;
}

.mcf-day__button.mcf-day--active {
  outline: 3px solid #222;
  outline-offset: -3px;
  z-index: 2;
  position: relative;
}

.mcf-day__date {
  display: block;
  font-size: 0.85em;
  padding: 4px 4px 2px;
  line-height: 1.2;
}

.mcf-day__level {
  display: block;
  font-size: 0.65em;
  line-height: 1.3;
  padding: 0 2px 2px;
  word-break: keep-all;
}

.mcf-day__price,
.mcf-day__hours {
  display: block;
  font-size: 0.6em;
  line-height: 1.2;
  padding: 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- 天気アイコン ---- */

.mcf-day__weather {
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 0.8em;
  line-height: 1;
  pointer-events: none;
}

/* ---- 休止アラートアイコン ---- */

.mcf-day__op-alert {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 0.75em;
  line-height: 1;
  pointer-events: none;
}

/* ---- 休止・注意情報セクション（詳細） ---- */

.mcf-detail__ops {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.mcf-detail__ops-title {
  margin: 0 0 6px;
  font-size: 0.9em;
  font-weight: bold;
  color: #c0392b;
}

.mcf-detail__ops-list {
  margin: 0;
  padding: 0 0 0 1.2em;
  list-style: disc;
  font-size: 0.85em;
  line-height: 1.6;
}

.mcf-ops-cat {
  color: #777;
  font-size: 0.9em;
}

.mcf-ops-name {
  font-weight: normal;
}

.mcf-ops-name.mcf-ops-impact--major {
  font-weight: bold;
  color: #c0392b;
}

.mcf-ops-reason {
  color: #888;
  font-size: 0.9em;
}

/* ---- 混雑レベル配色（セル・詳細共通） ---- */

.mcf-level-1 { background-color: #d9f2e3; color: #14532d; }
.mcf-level-2 { background-color: #bff0cf; color: #14532d; }
.mcf-level-3 { background-color: #e8f5b8; color: #4d5f00; }
.mcf-level-4 { background-color: #fff3b0; color: #7a5c00; }
.mcf-level-5 { background-color: #ffd59e; color: #7a3e00; }
.mcf-level-6 { background-color: #ffb3a7; color: #7a1f13; }
.mcf-level-7 { background-color: #f06b5f; color: #fff;    }
.mcf-level-8 { background-color: #b91c1c; color: #fff;    }

/* ---- 混雑レベル凡例 ---- */

.mcf-legend {
  margin-top: 16px;
  padding: 12px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background: #fafafa;
}

.mcf-legend__title {
  margin: 0 0 8px;
  font-size: 0.85em;
  font-weight: bold;
  color: #555;
}

.mcf-legend__list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mcf-legend__item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px 3px 6px;
  border-radius: 4px;
  font-size: 0.8em;
  white-space: nowrap;
}

.mcf-legend__num {
  font-weight: bold;
  font-size: 1em;
  min-width: 1em;
  text-align: center;
}

.mcf-legend__label {
  font-size: 0.95em;
}

/* ---- 免責注記 ---- */

.mcf-disclaimer {
  margin-top: 16px;
  padding: 10px 14px;
  font-size: 0.78em;
  line-height: 1.7;
  color: #666;
  border-left: 3px solid #ccc;
  background: #f8f8f8;
}

/* ---- データなし ---- */

.mcf-no-data {
  padding: 16px 0;
  color: #666;
}

/* ---- 詳細エリア ---- */

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

.mcf-detail__inner {
  border-radius: 6px;
  padding: 16px 20px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.mcf-detail__title {
  margin: 0 0 12px;
  font-size: 1.05em;
  font-weight: bold;
  border-bottom: 2px solid rgba(0, 0, 0, 0.15);
  padding-bottom: 8px;
}

.mcf-detail__list {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  align-items: baseline;
}

.mcf-detail__dt {
  font-weight: bold;
  font-size: 0.85em;
  white-space: nowrap;
  padding: 0;
  margin: 0;
}

.mcf-detail__dd {
  padding: 0;
  margin: 0;
  font-size: 0.95em;
  word-break: break-all;
}

.mcf-detail__reasons {
  margin: 0;
  padding: 0 0 0 1.2em;
  list-style: disc;
}

.mcf-detail__reasons li {
  margin: 0;
  padding: 0;
}

/* ---- サーバー出力の予想一覧（初期HTML本文）---- */

/*
 * includes/front-render.php が出す直近 31 日分の一覧。
 * JS 起動後もこの DOM は破棄されず、カレンダーの下にそのまま残る。
 * タブで別 park に切り替えたときだけ hidden が付く（mcfSyncSsrList）。
 */
.mcf-forecast-list[hidden] {
  display: none;
}

.mcf-forecast-list {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
}

.mcf-forecast-list__title {
  margin: 0 0 12px;
  font-size: 1em;
  font-weight: bold;
  color: #555;
}

.mcf-ssr-day {
  margin-bottom: 10px;
  padding: 12px 16px;
  border: 1px solid rgba( 0, 0, 0, 0.1 );
  border-radius: 6px;
}

.mcf-ssr-day__title {
  margin: 0 0 8px;
  font-size: 0.95em;
  font-weight: bold;
  border-bottom: 1px solid rgba( 0, 0, 0, 0.15 );
  padding-bottom: 6px;
}

.mcf-ssr-day__list {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  align-items: baseline;
}

.mcf-ssr-day__dt {
  margin: 0;
  padding: 0;
  font-weight: bold;
  font-size: 0.8em;
  white-space: nowrap;
}

.mcf-ssr-day__dd {
  margin: 0;
  padding: 0;
  font-size: 0.9em;
}

.mcf-ssr-day__reasons,
.mcf-ssr-day__ops {
  margin: 0;
  padding: 0 0 0 1.2em;
  list-style: disc;
}

.mcf-ssr-day__reasons li,
.mcf-ssr-day__ops li {
  margin: 0;
  padding: 0;
}

/* ---- 管理者デバッグパネル ---- */

.mcf-debug {
  margin-top: 16px;
  border: 1px dashed #999;
  border-radius: 4px;
  padding: 8px 12px;
  background: #fafafa;
  font-size: 0.82em;
  color: #444;
}

.mcf-debug__summary {
  cursor: pointer;
  font-weight: bold;
  color: #c0392b;
  user-select: none;
  list-style: disclosure-closed inside;
}

details[open] > .mcf-debug__summary {
  list-style-type: disclosure-open;
}

.mcf-debug__title {
  margin: 10px 0 4px;
  font-weight: bold;
  font-size: 0.95em;
  color: #555;
  border-bottom: 1px solid #ddd;
}

.mcf-debug__table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9em;
}

.mcf-debug__table th,
.mcf-debug__table td {
  padding: 2px 8px;
  text-align: left;
  border: 1px solid #ddd;
}

.mcf-debug__table th {
  background: #f0f0f0;
  width: 40%;
  font-weight: normal;
}

.mcf-debug__flags {
  margin: 0;
  word-break: break-all;
}

.mcf-debug__list {
  margin: 0;
  padding: 0 0 0 1.2em;
}

.mcf-debug__json {
  margin: 0;
  padding: 6px;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 3px;
  font-size: 0.85em;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: auto;
}

/* ---- 過去日（実績・予測表示）---- */

/* 彩度を落として将来予測と区別 */
.mcf-day--past {
  filter: saturate( 0.6 );
}

/* 予測レベル（過去日セル内サブ表示） */
.mcf-day__pred {
  display: block;
  font-size: 0.65em;
  line-height: 1.3;
  padding: 0 2px 1px;
}

/* 予測精度アイコン（過去日セル右上） */
.mcf-day__accuracy {
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 0.7em;
  line-height: 1;
  font-weight: bold;
  pointer-events: none;
}

.mcf-day__accuracy--hit  { color: #16a34a; }
.mcf-day__accuracy--near { color: #d97706; }
.mcf-day__accuracy--miss { color: #dc2626; }

/* 過去日詳細エリア：タイトルに「— 実績」を付加 */
.mcf-detail--past .mcf-detail__title::after {
  content: " — 実績";
  font-weight: normal;
  font-size: 0.8em;
  opacity: 0.65;
}

/* ---- スマホ対応 ---- */

@media ( max-width: 480px ) {
  .mcf-app {
    padding: 8px;
    font-size: 14px;
  }

  .mcf-tab {
    padding: 8px 4px;
    font-size: 0.9em;
  }

  .mcf-legend__list {
    gap: 4px;
  }

  .mcf-legend__item {
    font-size: 0.75em;
    padding: 2px 8px 2px 5px;
  }

  .mcf-nav__btn {
    padding: 5px 10px;
    font-size: 0.8em;
  }

  .mcf-nav__label {
    font-size: 1em;
  }

  .mcf-day {
    height: 78px;
  }

  /* 見出し行 + 日付セル 5 行ぶん（78px × 5 + 約 24px）*/
  .mcf-calendar-wrap {
    min-height: 414px;
  }

  .mcf-day__date {
    font-size: 0.8em;
    padding: 3px 2px 1px;
  }

  .mcf-day__level {
    font-size: 0.55em;
  }

  .mcf-day__pred {
    font-size: 0.5em;
  }

  .mcf-detail__list {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .mcf-detail__dt {
    margin-top: 8px;
  }
}
