/* 比較表は日付と提供元の列幅を保ち、小さい画面では表の中だけを横に送る。 */
#forecastComparison,
#forecastHistory {
  min-width: 0;
  max-width: 100%;
}

#forecastComparison .compare-table-scroll,
#forecastHistory .compare-table-scroll {
  position: relative;
  isolation: isolate;
  min-width: 0;
  max-width: 100%;
  overflow: auto;
  overscroll-behavior-inline: contain;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  scrollbar-color: #94b8d7 var(--canvas);
}

#forecastComparison .compare-table-scroll { margin: 0 12px 12px; }

#forecastComparison .compare-table-scroll:focus-visible,
#forecastHistory .compare-table-scroll:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: -3px;
}

#forecastComparison .compare-table,
#forecastHistory .history-matrix {
  width: 100%;
  min-width: max(620px, calc(80px + var(--comparison-provider-count, 3) * 180px));
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}

#forecastComparison .compare-table th,
#forecastComparison .compare-table td,
#forecastHistory .history-matrix th,
#forecastHistory .history-matrix td {
  padding: 14px 12px;
  border-color: var(--line);
  vertical-align: top;
  text-align: center;
  overflow-wrap: anywhere;
}

#forecastComparison .compare-table .compare-provider,
#forecastHistory .history-matrix .compare-provider { width: auto; }

/* 固定列を不透明にし、横スクロールしても日付と予報の対応を見失わない。 */
#forecastComparison .compare-table th:first-child,
#forecastHistory .history-matrix th:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 80px;
  padding-inline: 8px;
  background: inherit;
  color: var(--blue-deep);
  box-shadow: 2px 0 0 rgba(8, 44, 109, .05);
  vertical-align: middle;
}

#forecastComparison .compare-table thead tr,
#forecastHistory .history-matrix thead tr { background: var(--canvas); }

#forecastComparison .compare-table thead th,
#forecastHistory .history-matrix thead th {
  background: var(--canvas);
  border-bottom: 2px solid var(--line);
  font-weight: 700;
}

#forecastComparison .compare-table thead th:first-child,
#forecastHistory .history-matrix thead th:first-child { z-index: 3; }

#forecastComparison .compare-table tbody tr,
#forecastHistory .history-matrix tbody tr { background: #fff; }

#forecastComparison .compare-table tbody tr:nth-child(even),
#forecastHistory .history-matrix tbody tr:nth-child(even) { background: var(--canvas); }

@media (hover: hover) {
  #forecastComparison .compare-table tbody tr:hover,
  #forecastHistory .history-matrix tbody tr:hover {
    background: #edf6ff;
    background: color-mix(in srgb, var(--blue) 8%, #fff);
  }
}

#forecastComparison .compare-table time,
#forecastHistory .history-matrix time {
  display: grid;
  gap: 2px;
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
}

#forecastComparison .compare-table time small,
#forecastHistory .history-matrix time small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

/* ヘッダーには提供元と比較の条件を残し、出典の説明は表の下にまとめる。 */
#forecastComparison .compare-provider > strong,
#forecastHistory .compare-provider > strong {
  display: block;
  color: var(--blue-deep);
  font-size: 14px;
  line-height: 1.6;
}

#forecastComparison .compare-accuracy,
#forecastHistory .compare-accuracy {
  display: block;
  margin-top: 5px;
  color: var(--blue-deep);
  color: color-mix(in srgb, var(--orange) 65%, var(--ink));
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
}

#forecastComparison .compare-issued,
#forecastComparison .compare-samples,
#forecastHistory .compare-issued,
#forecastHistory .compare-samples {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.6;
}

/* 天気、気温、降水確率の順で読めるよう、すべてのセルの配置をそろえる。 */
#forecastComparison .compare-weather,
#forecastHistory .compare-weather {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  color: var(--blue-deep);
}

#forecastComparison .compare-weather .weather-symbol,
#forecastHistory .compare-weather .weather-symbol {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  font-size: 24px;
}

#forecastComparison .compare-weather strong,
#forecastHistory .compare-weather strong {
  font-size: 12px;
  line-height: 1.6;
}

#forecastComparison .compare-values,
#forecastHistory .compare-values {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
}

#forecastComparison .compare-values > span,
#forecastHistory .compare-values > span {
  display: grid;
  gap: 2px;
  align-content: start;
}

#forecastComparison .compare-values b,
#forecastHistory .compare-values b {
  display: block;
  color: var(--blue-deep);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.5;
  white-space: nowrap;
}

#forecastComparison .compare-values > span:first-child b,
#forecastHistory .compare-values > span:first-child b {
  color: var(--blue-deep);
  color: color-mix(in srgb, var(--orange) 65%, var(--ink));
}

#forecastComparison .compare-rain,
#forecastHistory .compare-rain {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

#forecastComparison .compare-missing,
#forecastHistory .compare-missing {
  color: var(--muted);
  font-size: 12px;
  vertical-align: middle;
}

#forecastComparison .compare-ranking-note,
#forecastHistory .history-comparison-note {
  margin: 0;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: var(--canvas);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

/* 履歴の判定は予報の数値と区切り、点数と状態が一塊で読めるようにする。 */
#forecastHistory .history-matrix-cell {
  display: grid;
  gap: 0;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

#forecastHistory .history-daily-result {
  display: grid;
  justify-items: start;
  gap: 5px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  text-align: left;
}

#forecastHistory .history-daily-score {
  color: var(--blue-deep);
  font-size: 13px;
  font-weight: 800;
}

#forecastHistory .history-hit {
  display: inline-flex;
  align-items: center;
  padding: 3px 7px;
  border: 1px solid currentColor;
  border-radius: 5px;
  font-size: 11px;
  line-height: 1.5;
}

#forecastHistory .history-hit.is-pending { color: var(--muted); }

#forecastHistory .history-issued {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  text-align: left;
}

#forecastComparison .compare-source-details,
#forecastHistory .compare-source-details {
  min-width: 0;
  margin: 0 12px 12px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

#forecastHistory .compare-source-details { margin-inline: 0; }

#forecastComparison .compare-source-details > summary,
#forecastHistory .compare-source-details > summary {
  padding: 12px;
  color: var(--blue-deep);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
  cursor: pointer;
}

#forecastComparison .compare-source-details > summary:focus-visible,
#forecastHistory .compare-source-details > summary:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: -3px;
  border-radius: 7px;
}

#forecastComparison .compare-source-details[open] > summary,
#forecastHistory .compare-source-details[open] > summary {
  border-bottom: 1px solid var(--line);
  background: var(--canvas);
}

#forecastComparison .compare-source-list,
#forecastHistory .compare-source-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 16px;
  min-width: 0;
  padding: 12px;
}

#forecastComparison .compare-source-item,
#forecastHistory .compare-source-item { min-width: 0; }

#forecastComparison .compare-source-item > strong,
#forecastHistory .compare-source-item > strong {
  color: var(--blue-deep);
  font-size: 12px;
  line-height: 1.6;
}

#forecastComparison .compare-source-details .source-attribution,
#forecastHistory .compare-source-details .source-attribution {
  display: block;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

#forecastComparison .compare-source-details a,
#forecastHistory .compare-source-details a {
  color: var(--blue-deep);
  text-decoration: underline;
  text-underline-offset: 3px;
}

#forecastComparison .comparison-scroll-hint,
#forecastHistory .comparison-scroll-hint {
  display: none;
  margin: 0;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  text-align: right;
}

@media (max-width: 760px) {
  /* 狭い画面でも数値を縮めず、横方向に比較できることを言葉で案内する。 */
  #forecastComparison .comparison-scroll-hint,
  #forecastHistory .comparison-scroll-hint { display: block; }

  #forecastComparison .compare-table th,
  #forecastComparison .compare-table td,
  #forecastHistory .history-matrix th,
  #forecastHistory .history-matrix td { padding-block: 12px; }

  #forecastComparison .compare-table-scroll { margin-inline: 8px; }
  #forecastComparison .compare-source-details { margin-inline: 8px; }
  #forecastComparison .compare-ranking-note,
  #forecastHistory .history-comparison-note { padding: 10px 12px; }
}

/* 欠測の説明は予報値と混ぜず、天気がないセルに晴雨の記号を出さない。 */
#forecastComparison .compare-value-note,
#forecastHistory .compare-value-note {
  margin: 0 12px 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.8;
}

#forecastHistory .compare-value-note { margin: 0; }

#forecastComparison .compare-weather.is-missing,
#forecastHistory .compare-weather.is-missing,
#navigation-route .compare-weather.is-missing { color: var(--muted); }

#forecastComparison .compare-weather.is-missing .weather-symbol,
#forecastHistory .compare-weather.is-missing .weather-symbol,
#navigation-route .compare-weather.is-missing .weather-symbol { display: none; }

.ranking-period-note .ranking-context {
  display: block;
  color: var(--blue-deep);
  font-weight: 700;
}

.ranking-period-note .ranking-explanation {
  display: block;
  margin-top: 5px;
  line-height: 1.8;
}

/* 詳細ページの表にも同じ文字・罫線・行の区別を使う。 */
#navigation-route .navigation-table {
  min-width: 0;
  max-width: 100%;
  overflow: auto;
  overscroll-behavior-inline: contain;
  border-color: var(--line);
  border-radius: 10px;
  background: #fff;
  scrollbar-color: #94b8d7 var(--canvas);
}

#navigation-route .navigation-table:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: -3px;
}

#navigation-route .navigation-table table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.7;
  font-variant-numeric: tabular-nums;
}

#navigation-route .navigation-table caption {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--blue-deep);
  font-size: 14px;
  line-height: 1.6;
  text-align: left;
}

#navigation-route .navigation-table :is(th, td) {
  min-width: 100px;
  padding: 13px 14px;
  border-top: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}

#navigation-route .navigation-table :is(th, td):last-child { border-right: 0; }
#navigation-route .navigation-table tbody tr:last-child > :is(th, td) { border-bottom: 0; }

#navigation-route .navigation-table thead th {
  border-bottom-width: 2px;
  background: var(--canvas);
  color: var(--blue-deep);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.7;
  white-space: normal;
}

#navigation-route .navigation-table tbody tr { background: #fff; }
#navigation-route .navigation-table tbody tr:nth-child(even) { background: var(--canvas); }

#navigation-route .navigation-table :is(th, td).is-numeric {
  text-align: right;
  white-space: nowrap;
}

#navigation-route .navigation-table td.is-numeric { font-weight: 600; }

@media (hover: hover) {
  #navigation-route .navigation-table tbody tr:hover {
    background: #edf6ff;
    background: color-mix(in srgb, var(--blue) 8%, #fff);
  }
}

/* 履歴の高さ制限は既存の68vhを使い、日付列と見出しをスクロール中も保つ。 */
#navigation-route .navigation-history-matrix { isolation: isolate; }

#navigation-route .navigation-history-matrix table {
  min-width: max(620px, calc(80px + var(--comparison-provider-count, 3) * 180px));
  table-layout: fixed;
}

#navigation-route .navigation-history-matrix :is(th, td) {
  min-width: 0;
  padding: 14px 12px;
  text-align: center;
}

#navigation-route .navigation-history-matrix th:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 80px;
  min-width: 80px;
  max-width: 80px;
  padding-inline: 8px;
  background: inherit;
  color: var(--blue-deep);
  box-shadow: 2px 0 0 rgba(8, 44, 109, .05);
  vertical-align: middle;
}

#navigation-route .navigation-history-matrix thead tr { background: var(--canvas); }

#navigation-route .navigation-history-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  width: auto;
  background: var(--canvas);
}

#navigation-route .navigation-history-matrix thead th:first-child {
  z-index: 4;
  width: 80px;
}

#navigation-route .navigation-history-matrix thead th > strong {
  display: block;
  font-size: 14px;
  line-height: 1.6;
}

#navigation-route .navigation-history-matrix thead th > small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.6;
}

#navigation-route .navigation-history-matrix time {
  display: grid;
  gap: 2px;
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
}

#navigation-route .history-matrix-cell {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

#navigation-route .history-matrix-weather {
  color: var(--blue-deep);
  font-size: 14px;
  line-height: 1.6;
}

#navigation-route .history-matrix-weather.is-missing { color: var(--muted); }

#navigation-route .history-matrix-result {
  display: grid;
  justify-items: start;
  gap: 5px;
  margin-top: 5px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  text-align: left;
}

#navigation-route .history-matrix-score {
  color: var(--blue-deep);
  font-size: 13px;
  font-weight: 800;
}

#navigation-route .history-matrix-hit {
  display: inline-flex;
  align-items: center;
  padding: 3px 7px;
  border: 1px solid currentColor;
  border-radius: 5px;
  font-size: 11px;
  line-height: 1.5;
}

#navigation-route .history-matrix-hit.is-pending { color: var(--muted); }

#navigation-route .history-matrix-cell > small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  text-align: left;
}

#navigation-route .history-matrix-missing {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 640px) {
  #navigation-route .navigation-table caption { padding: 12px; }
  #navigation-route .navigation-table :is(th, td) { padding: 12px; }
  #navigation-route .navigation-history-matrix th:first-child { padding-inline: 8px; }
}

/* 詳細ランキングの出典を狭い列へ押し込まず、列幅を保って横に比較する。 */
#navigation-route .navigation-ranking-table { isolation: isolate; }

#navigation-route .navigation-ranking-table table {
  width: 100%;
  min-width: 1220px;
  table-layout: fixed;
}

#navigation-route .navigation-ranking-table :is(th, td) { min-width: 0; }
#navigation-route .navigation-ranking-table :is(th, td):nth-child(1) { width: 56px; }
#navigation-route .navigation-ranking-table :is(th, td):nth-child(2) { width: 240px; }
#navigation-route .navigation-ranking-table :is(th, td):nth-child(3) { width: 88px; }
#navigation-route .navigation-ranking-table :is(th, td):nth-child(4) { width: 104px; }
#navigation-route .navigation-ranking-table :is(th, td):nth-child(5) { width: 150px; }
#navigation-route .navigation-ranking-table :is(th, td):nth-child(6) { width: 160px; }
#navigation-route .navigation-ranking-table :is(th, td):nth-child(7) { width: 182px; }
#navigation-route .navigation-ranking-table :is(th, td):nth-child(8) { width: 240px; }

#navigation-route .navigation-ranking-table thead tr { background: var(--canvas); }

#navigation-route .navigation-ranking-table :is(th, td):first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  padding-inline: 8px;
  background: inherit;
  color: var(--blue-deep);
  box-shadow: 2px 0 0 rgba(8, 44, 109, .05);
}

#navigation-route .navigation-ranking-table thead th:first-child { z-index: 3; }

#navigation-route .navigation-ranking-table thead th.is-numeric { white-space: normal; }
