/* ========================================
   CSS変数
   ======================================== */

/* CSS Variables (Themes) */
:root {
  /* レスポンシブレイアウト設定 */
  --landscape-weather-width: 30%;  /* 横長時の天気の幅（3:7比率） */
  --divider-width: 5px;            /* 区切り線の幅 */

  /* Default theme: Dark */
  --color-text: #d4d4d4;
  --color-text-muted: #a9a9a9;
  --color-text-accent: #0a84ff;
  --color-text-inverse: #d4d4d4;
  --color-bg-page: linear-gradient(180deg, #1a1a1a 0%, #232323 100%);
  --color-bg-page-solid: #1e1e1e;
  --color-bg-header: #252526;
  --color-border-default: #3f3f46;
  --color-border-accent: #3f3f46;
}

/* Theme: Dark */
[data-theme="dark"] {
  --color-text: #d4d4d4;
  --color-text-muted: #a9a9a9;
  --color-text-accent: #0a84ff;
  --color-text-inverse: #d4d4d4;
  --color-bg-page: linear-gradient(180deg, #1a1a1a 0%, #232323 100%);
  --color-bg-page-solid: #1e1e1e;
  --color-bg-header: #252526;
  --color-border-default: #3f3f46;
  --color-border-accent: #3f3f46;
}

/* Theme: Light */
[data-theme="light"] {
  --color-text: #000000;
  --color-text-muted: #818181;
  --color-text-accent: #a40a0a;
  --color-text-inverse: #FFFFFF;
  --color-bg-page: linear-gradient(180deg, #f8f8f8 0%, #ffffff 100%);
  --color-bg-page-solid: #FFFFFF;
  --color-bg-header: #0062ff;
  --color-border-default: #818181;
  --color-border-accent: #0062ff;
}

/* ========================================
   基本要素
   ======================================== */

html {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--color-bg-page-solid);
}

body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--color-bg-page);
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "YuGothic", Meiryo, sans-serif;
}

table {
  border-collapse: collapse;
}

[data-theme="dark"] table {
  color: var(--color-text);
}

/* ========================================
   共通レイアウト要素
   ======================================== */

.body-parent {
  margin: 0px;
}

.body-child {
  margin: 0px 10px;
}

.header {
  background-color: var(--color-bg-header);
  border-color: var(--color-bg-header);
  font-weight: bold;
  padding: 4px;
  width: 100%;
  flex: 0 0 auto;
}

.header td {
  font-size: 1.3em;
}

.header .last-accessed {
  font-size: 1.3rem !important;
}

hr.divider {
  background-color: var(--color-border-accent);
  flex: 0 0 var(--divider-width);
  height: var(--divider-width);
  width: 100%;
  border: none;
  margin: 0;
}

.main-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

#weather {
  flex: 0 0 auto;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

#news {
  flex: 1 1 auto;
  overflow-y: auto;
}

/* ========================================
   UI要素
   ======================================== */

.last-accessed {
  color: var(--color-text-inverse);
  text-align: left;
  float: left;
  padding: 11px 13px;
}

.theme-checkbox {
  color: var(--color-text-inverse);
  text-align: right;
  padding: 11px 13px;
}

#btn-mode {
  transform: scale(1.3);
}

.error-message {
  text-align: center;
  font-size: 2em;
  color: red;
}

/* ========================================
   天気セクション
   ======================================== */

/* 共通パーツスタイル（色・構造のみ） */
.weather-container {
  padding: 13px 0 0 0;
  width: 100%;
}

.weather-icon-container {
  margin-bottom: 0;
}

.weather-icon {
  width: auto;
  height: 200px;
  max-width: 100%;
}

.weather-temps-box-container {
  display: flex;
  flex-direction: row;
  gap: 20px;
}

.temp-box-max {
  background-color: #ff6666;
}

.temp-box-min {
  background-color: #3399ff;
}

.temp-box-inner {
  text-align: center;
  line-height: 1.3;
}

.pops-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  text-align: center;
}

.pops-table th,
.pops-table td {
  border: 3px solid #ccc;
  padding: 8px 0;
}

.weather-source {
  color: gray;
}

/* 縦長レイアウト（デフォルト） */
.weather-layout-portrait {
  display: flex;
  flex-direction: row;
  width: 100%;
  align-items: center;
  box-sizing: border-box;
}

.weather-portrait-left {
  width: 40%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-left: 10px;
  box-sizing: border-box;
}

.weather-portrait-right {
  width: 60%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.weather-layout-portrait .weather-label-today {
  font-size: clamp(1.3em, 3vw, 3.2em);
  margin-bottom: 0;
}

.weather-layout-portrait .weather-date {
  font-size: clamp(1.8em, 3.8vw, 4.1em);
  font-weight: bold;
  margin-bottom: 0;
}

.weather-layout-portrait .weather-location {
  font-size: clamp(1.6em, 3.3vw, 3.6em);
  font-weight: bold;
  text-align: right;
  width: 100%;
  padding: 0 13px;
  margin-bottom: 13px;
  box-sizing: border-box;
}

.weather-layout-portrait .weather-icon-container {
  margin-bottom: 0;
}

.weather-layout-portrait .weather-telop {
  font-size: clamp(1.5em, 3.3vw, 3.6em);
  font-weight: bold;
  margin-bottom: 7px;
}

.weather-layout-portrait .temp-box {
  color: #fff;
  padding: clamp(8px, 1.5vw, 11px) clamp(15px, 3vw, 30px);
  border-radius: 7px;
  font-size: clamp(1.4em, 3vw, 3.3em);
  font-weight: bold;
  min-width: clamp(105px, 18vw, 200px);
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}

.weather-layout-portrait .weather-temps-box-container {
  margin-bottom: 20px;
}

.weather-layout-portrait .pops-table {
  font-size: clamp(1.2em, 2.6vw, 3em);
  margin-bottom: 27px;
  width: calc(100% - 20px);
  margin-left: 10px;
  margin-right: 10px;
}

.weather-layout-portrait .weather-source {
  font-size: clamp(0.9em, 1.7vw, 1.8em);
  text-align: right;
  width: 100%;
  padding: 0 13px;
  box-sizing: border-box;
}

/* 横長レイアウト（デフォルトは非表示） */
.weather-layout-landscape {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 0 13px;
  box-sizing: border-box;
}

.weather-landscape-header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  padding: 0 13px;
  box-sizing: border-box;
}

.weather-landscape-date {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.weather-layout-landscape .weather-label-today {
  font-size: clamp(1em, 2vw, 2.1em);
  margin-bottom: 0;
}

.weather-layout-landscape .weather-date {
  font-size: clamp(1.3em, 2.5vw, 2.7em);
  font-weight: bold;
  margin-bottom: 0;
}

.weather-layout-landscape .weather-location {
  font-size: clamp(1.2em, 2.2vw, 2.4em);
  font-weight: bold;
  text-align: right;
}

.weather-layout-landscape .weather-icon-container {
  margin-top: 3px;
}

.weather-layout-landscape .weather-telop {
  font-size: clamp(1.1em, 2.2vw, 2.4em);
  font-weight: bold;
  margin-bottom: 20px;
}

.weather-layout-landscape .temp-box {
  color: #fff;
  padding: clamp(5px, 1vw, 7px) clamp(10px, 2vw, 20px);
  border-radius: 7px;
  font-size: clamp(0.9em, 1.8vw, 1.9em);
  font-weight: bold;
  min-width: clamp(70px, 12vw, 133px);
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}

.weather-layout-landscape .weather-temps-box-container {
  margin: 20px 0;
}

.weather-layout-landscape .pops-table {
  font-size: clamp(0.8em, 1.5vw, 1.7em);
  margin-bottom: 27px;
}

.weather-layout-landscape .weather-source {
  font-size: clamp(0.6em, 1.1vw, 1.2em);
  text-align: right;
  width: 100%;
  padding: 0 13px;
  box-sizing: border-box;
}

/* ========================================
   ニュースセクション
   ======================================== */

/* 共通パーツスタイル（色・構造のみ） */
.news-table-container {
  width: 100%;
}

.news-rows {
  border-bottom: 1px solid var(--color-border-default);
}

.title {
  color: var(--color-text);
  font-weight: bold;
}

.category {
  color: var(--color-bg-page-solid);
  display: inline-block;
  margin-right: 9px;
  background-color: var(--color-text);
  border: 1px solid var(--color-text);
  border-radius: 4px;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  vertical-align: top;
}

.new {
  color: var(--color-text-inverse);
  display: inline-block;
  margin-right: 9px;
  background-color: var(--color-text-accent);
  border: 1px solid var(--color-text-accent);
  border-radius: 4px;
  font-weight: bold;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  vertical-align: top;
}

.date {
  color: var(--color-text-muted);
}

.news img {
  width: 100%;
  height: auto;
}

.news a {
  text-decoration: none;
  border-bottom: none;
}

colgroup#contents {
  width: auto;
}

/* 縦長時のニューススタイル設定（デフォルト） */
colgroup#image {
  width: clamp(180px, 29vw, 300px);
}

.news-img {
  padding: clamp(7px, 1.4vw, 10px) clamp(9px, 1.9vw, 13px) clamp(7px, 1.4vw, 10px) 0;
}

.news-contents {
  padding: clamp(9px, 1.9vw, 13px);
}

.category {
  padding: clamp(2px, 0.4vw, 3px) clamp(3px, 0.7vw, 5px);
  font-size: clamp(1rem, 2vw, 1.4rem);
}

.new {
  padding: clamp(2px, 0.4vw, 3px) clamp(3px, 0.7vw, 5px);
  font-size: clamp(1rem, 2vw, 1.4rem);
}

.date {
  font-size: clamp(1rem, 2vw, 1.4rem);
}

.news {
  font-size: clamp(1rem, 2vw, 1.4rem);
}

.news a {
  font-size: clamp(1rem, 2vw, 1.4rem);
}

.news .title {
  font-size: clamp(1.1rem, 2.1vw, 1.5rem);
}

/* ========================================
   メディアクエリ（横長レイアウト）
   ======================================== */

@media (min-aspect-ratio: 1/1) {
  /* レイアウト変更 */
  .main-content {
    flex-direction: row;
  }

  #weather {
    flex: 0 0 var(--landscape-weather-width);
    overflow-y: auto;
  }

  hr.divider {
    width: var(--divider-width);
    height: auto;
    flex: 0 0 var(--divider-width);
  }

  #news {
    flex: 1;
    overflow-y: auto;
  }

  /* 天気: 縦長レイアウトを非表示、横長レイアウトを表示 */
  .weather-layout-portrait {
    display: none;
  }

  .weather-layout-landscape {
    display: flex;
  }

  /* ニュース: 横長時のスタイル設定（縦長時の設定を上書き） */
  colgroup#image {
    width: clamp(180px, 20vw, 300px);
  }

  .news-img {
    padding: clamp(7px, 1vw, 10px) clamp(9px, 1.3vw, 13px) clamp(7px, 1vw, 10px) 0;
  }

  .news-contents {
    padding: clamp(9px, 1.3vw, 13px);
  }

  .category {
    padding: clamp(2px, 0.3vw, 3px) clamp(3px, 0.5vw, 5px);
    font-size: clamp(1rem, 1.4vw, 1.4rem);
  }

  .new {
    padding: clamp(2px, 0.3vw, 3px) clamp(3px, 0.5vw, 5px);
    font-size: clamp(1rem, 1.4vw, 1.4rem);
  }

  .date {
    font-size: clamp(1rem, 1.4vw, 1.4rem);
  }

  .news {
    font-size: clamp(1rem, 1.4vw, 1.4rem);
  }

  .news a {
    font-size: clamp(1rem, 1.4vw, 1.4rem);
  }

  .news .title {
    font-size: clamp(1.1rem, 1.5vw, 1.5rem);
  }
}
