/* ==========================================================
   1. 基本変数
========================================================== */

:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;

  --danger-soft: #fff5f5;
  --danger-line: #fecaca;
  --danger-text: #991b1b;
}

/* 気温ページ専用テーマ */
body.theme-red {
  --accent: #c62828;
  --accent-dark: #991b1b;
  --accent-deep: #7f1d1d;
  --accent-light: #ef5350;
  --accent-soft: #fde8e8;
  --accent-pale: #fff7f7;
}


/* ==========================================================
   2. ページ全体
========================================================== */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Sans",
    "Yu Gothic",
    "YuGothic",
    Meiryo,
    sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

.container {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 56px;
}

body.data-page .container.page-main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 56px;
}


/* ==========================================================
   3. 共通パネル・カード
========================================================== */

.control-panel,
.card,
.summary-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}


/* ==========================================================
   4. コントロールパネル
========================================================== */

.control-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  padding: 16px;
  margin-bottom: 20px;
}

.control-panel label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  color: #475569;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

select,
button {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #ffffff;
  font: inherit;
}

select:focus,
button:focus {
  outline: 3px solid var(--accent-soft);
  outline-offset: 2px;
}

button {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: #b71c1c;
  border-color: #b71c1c;
}


/* ==========================================================
   5. 選択中の梅雨期間
========================================================== */

.selected-period {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-left: auto;
  min-width: 230px;
  padding: 7px 12px;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-pale);
  line-height: 1.35;
}

.selected-period-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.selected-period-value {
  display: inline-block;
  margin-right: 8px;
  color: var(--accent-dark);
  font-size: 15px;
  font-weight: 800;
}

.selected-period-days {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}


/* ==========================================================
   6. サマリーカード
========================================================== */

.summary-grid {
  display: block;
  margin-bottom: 20px;
}

.summary-row {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

.summary-row:last-child {
  margin-bottom: 0;
}

.summary-row-five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.summary-row-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.summary-card {
  min-width: 0;
  padding: 11px 14px;
}

.summary-card .label {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.summary-card .value {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.1;
}

.summary-card .unit {
  margin-left: 2px;
  color: var(--muted);
  font-size: 15px;
}

.summary-card .sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}


/* ==========================================================
   7. 平年比較カード
========================================================== */

.comparison-card {
  min-width: 250px;
}

.comparison-detail {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
  line-height: 1.65;
}

.comparison-detail p {
  margin: 2px 0;
}

.comparison-detail strong {
  margin-left: 5px;
  font-weight: 700;
}

.comparison-period {
  margin-bottom: 6px !important;
  color: var(--muted);
  font-size: 0.82rem;
}

.period-days {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}


/* ==========================================================
   8. データカード
========================================================== */

.tables-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.card {
  padding: 18px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 12px;
}

.card-header h2 {
  margin: 0;
  color: var(--accent-dark);
  font-size: 1.08rem;
}

.card-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}


/* ==========================================================
   9. テーブル
========================================================== */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  color: var(--accent-dark);
  background: var(--accent-soft);
  text-align: left;
  font-weight: 700;
}

td.number,
th.number {
  text-align: right;
}

tbody tr {
  transition: background-color 0.15s ease;
}

tbody tr:hover {
  background: var(--accent-pale);
}

/* ソート可能な見出し内にボタンがある場合 */
th button {
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: inherit;
  background: transparent;
  font-weight: inherit;
}

th button:hover {
  color: var(--accent-deep);
  background: transparent;
}


/* ==========================================================
   10. 順位表示
========================================================== */

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 800;
}


/* ==========================================================
   11. エラー表示
========================================================== */

.error {
  padding: 14px;
  border: 1px solid var(--danger-line);
  border-radius: 12px;
  color: var(--danger-text);
  background: var(--danger-soft);
}


/* ==========================================================
   12. 気温ページのヘッダー
========================================================== */

.site-header.theme-red {
  background:
    linear-gradient(
      135deg,
      #b71c1c 0%,
      #d32f2f 50%,
      #ef5350 100%
    );
}


/* ==========================================================
   13. タブレット表示
========================================================== */

@media (max-width: 860px) {
  .summary-row-five,
  .summary-row-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-header {
    display: block;
  }

  .card-header p {
    margin-top: 4px;
  }

  .selected-period {
    width: 100%;
    margin-left: 0;
  }
}


/* ==========================================================
   14. 小さい画面
========================================================== */

@media (max-width: 620px) {
  body.data-page .container.page-main {
    width: min(100% - 24px, 1180px);
    padding-top: 16px;
  }
}


/* ==========================================================
   15. スマートフォン表示
========================================================== */

@media (max-width: 560px) {
  .summary-row-five,
  .summary-row-two {
    grid-template-columns: 1fr;
  }

  .control-panel {
    align-items: stretch;
  }

  .control-panel label,
  .control-panel select,
  .control-panel button {
    width: 100%;
  }

  .selected-period {
    min-width: 0;
  }

  .summary-card .value {
    font-size: 1.45rem;
  }

  .card {
    padding: 14px;
  }

  th,
  td {
    padding: 9px 10px;
  }
}

/* ==========================================================
   気温グラフ
   ========================================================== */

.temperature-chart-section {
  display: grid;
  gap: 24px;
  margin-top: 28px;
  margin-bottom: 28px;
}

.temperature-chart-card {
  min-width: 0;
}

.temperature-chart-container {
  position: relative;
  height: 440px;
  margin-top: 18px;
}

.heat-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.heat-chart-card {
  min-width: 0;
}

.heat-chart-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.heat-chart-heading h3 {
  margin: 0;
  font-size: 20px;
}

.heat-chart-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.heat-chart-container {
  position: relative;
  height: 250px;
}

@media (max-width: 820px) {
  .heat-chart-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .temperature-chart-container {
    height: 350px;
  }

  .heat-chart-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* ==========================================================
   概要カード調整
========================================================== */

.summary-row-three {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.summary-row-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.summary-row-five {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.summary-row + .summary-row {
  margin-top: 18px;
}

.summary-card {
  min-width: 0;
  padding: 18px 16px;
  text-align: center;
}

.summary-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.summary-value {
  color: var(--text);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.summary-sub {
    margin-top: 6px;
    font-size: 0.82rem;
    font-weight: 400;
}

.summary-sub.comparison-positive {
  color: #dc2626;
}

.summary-sub.comparison-negative {
  color: #2563eb;
}

@media (max-width: 900px) {
  .summary-row-five {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .summary-row-three,
  .summary-row-two {
    grid-template-columns: 1fr;
  }

  .summary-row-five {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .summary-row-five {
    grid-template-columns: 1fr;
  }
}