/* 昨日の米国株 ── 静的ページの見た目
 *
 * デザインの差し替えはこのファイルだけで足りるように、
 * 色・角丸・間隔はすべて :root の変数に寄せてある。
 * 値は /crystal/ /kintoku/ と同じ体系にそろえてある。
 * チャートの目盛りの文字色も --chart-font-color を board.js が読んで Chart.js に渡す。
 */

:root {
  --bg: #f5f5f5;         /* サイト共通の地の色 */
  --surface: #ffffff;
  --border: #d6dbe2;
  --text: #222222;
  --text-muted: #555555;
  --text-faint: #777777;

  /* 意味のある色。ここだけは data の色分けなので残す */
  --up: #15803d;
  --down: #b91c1c;
  --flat: #78909c;

  --chart-font-color: #555555;

  --radius: 14px;
  --gap: 16px;
  --section-gap: 34px;
  --max-width: 1240px;

  --font: "Noto Sans JP","Hiragino Kaku Gothic ProN","Hiragino Sans",Meiryo,sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 28px 20px 56px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.board {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ── ヘッダー ───────────────────────────── */
.board__header { margin-bottom: var(--section-gap); }
.board__title { margin: 0; font-size: 2rem; font-weight: 700; letter-spacing: .01em; }
/* このページがどの取引日のものかは、いちばん先に伝わってほしい情報なので
   「最終更新」より大きく、本文寄りの濃さで出す */
.board__session { margin: 6px 0 0; font-size: .95rem; color: var(--text-muted); font-weight: 600; }
.board__updated { margin: 2px 0 0; font-size: .8rem; color: var(--text-faint); }
/* いつ次が来るのか分からないと、朝いちばんに開いた人が
   更新が止まったと受け取ってしまう。更新の周期をここで伝える */
.board__cycle { display: block; }

/* ── 共通のカード・見出し ────────────────── */
/* 表が器より広いときは、表の中だけ横に流す。
   これが無いとページ全体が横に揺れる */
.scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.section { margin-bottom: var(--section-gap); }
.section__title,
.row__title {
  margin: 0 0 10px;
  font-size: 1.12rem;
  font-weight: 700;
}

.note {
  margin: 10px 0 0;
  font-size: .78rem;
  line-height: 1.55;
  color: var(--text-muted);
}

/* ── 表示期間の切り替え ─────────────────── */
.ranges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 var(--gap);
}

.range {
  padding: 7px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.range:hover { border-color: #9fb0c4; color: var(--text); }

.range[aria-pressed="true"] {
  background: var(--text);
  border-color: var(--text);
  color: var(--surface);
}

/* ── 1・2段目：タイル ───────────────────── */
.row { margin-bottom: var(--section-gap); }

.row__tiles {
  /* 1列。期間を切り替えて形を読むには、2列だと図が小さすぎる */
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px 8px;
}

.tile__label {
  margin: 0;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-muted);
}

.tile__price {
  margin: 2px 0 0;
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.tile__change {
  margin: 0;
  font-size: .9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tile__chart { height: 180px; margin-top: auto; padding-top: 4px; }

/* その期間の高値と安値。図から目盛りで読むより速い */
.tile__range {
  margin: 6px 0 0;
  font-size: .78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.tile__range b { font-weight: 600; }
.tile__range .when { color: var(--text-faint); }
.tile__range .sep { margin: 0 .5em; color: var(--border); }

.tile__session {
  margin: 2px 0 0;
  font-size: .72rem;
  color: var(--text-faint);
}

/* 上げ／下げの色。data-direction は board.js が付ける */
[data-direction="1"] .tile__change,
.up { color: var(--up); }
[data-direction="-1"] .tile__change,
.down { color: var(--down); }
[data-direction="0"] .tile__change,
.flat { color: var(--flat); }

/* ── 3段目：円建てS&P500 ─────────────────── */
.yenspx {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(280px, 2.4fr);
  gap: 24px;
  align-items: start;
}

.yenspx__stats { padding-top: 4px; }

/* 注記は図と数字の下、器いっぱいに敷く。
   ここを指定しないと、2段組みの左の列に押し込まれて細長くなる */
.yenspx .note { grid-column: 1 / -1; margin: 4px 0 0; }

/* 「米国株 +12.97%」で1かたまり。折り返すならかたまりの境目で。
   2つ並ぶぶん場所を取るので、他の数字より一段落とす。
   ここが一番大きく見えると、主役の「年初来」より目立ってしまう */
.yenspx__parts { font-size: 1.05rem; line-height: 1.45; }
.yenspx__parts span { display: inline-block; white-space: nowrap; }
.yenspx__times { margin: 0 .35em; color: var(--text-muted); font-weight: 400; }
.yenspx__rule { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.yenspx__chart { height: 300px; min-width: 0; }

.stat + .stat { margin-top: 12px; }
.stat__label { margin: 0; font-size: .8rem; color: var(--text-muted); }
.stat__value {
  margin: 0;
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stat__value--sm { font-size: 1.5rem; }
.stat__value--xs { font-size: 1.2rem; }
.stat__unit { font-size: 1.1rem; margin-left: 2px; }
.stat__change { margin: 2px 0 0; font-size: 1rem; font-weight: 600; }
.stat__note { margin: 2px 0 0; font-size: .74rem; color: var(--text-faint); }

/* ── 4段目：ドローダウン ─────────────────── */
.chart--wide { height: 360px; }

/* ── 5段目：センチメント ─────────────────── */
.sentiment {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--gap);
}

.meter__history { display: flex; justify-content: space-around; margin-top: 4px; }
.meter__history-item { text-align: center; }
.meter__history-label { display: block; font-size: .72rem; color: var(--text-muted); }
.meter__history-value { display: block; font-size: 1rem; font-weight: 600; }

/* ── フッター ───────────────────────────── */
.board__footer {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  color: var(--text-muted);
  font-size: .78rem;
}
.footer__title { margin: 0 0 6px; font-size: .85rem; font-weight: 700; color: var(--text); }
.sources { margin: 0 0 10px; padding-left: 1.2em; }
.disclaimer { margin: 0; color: var(--text-faint); }

.board__error {
  margin-top: 20px;
  padding: 12px 14px;
  border: 1px solid var(--down);
  border-radius: var(--radius);
  color: var(--down);
  font-size: .85rem;
}

/* ── 画面幅が狭いとき ───────────────────── */
@media (max-width: 1000px) {
  .yenspx { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  body { padding: 20px 14px 40px; }
  .board__title { font-size: 1.5rem; }
  .stat__value { font-size: 2rem; }

  /* --sm / --xs はこの上に書いてあるので、ここで書き直さないと
     .stat__value の 2rem に上書きされ、大きさの序列が消える */
  .stat__value--sm { font-size: 1.5rem; }
  .stat__value--xs { font-size: 1.2rem; }
  .yenspx__parts { font-size: 1.05rem; }
}

/* ── Chart.js / SVG に移したときに足したもの ───────────── */

/* canvas は器いっぱいに広げる。高さは上の .tile__chart などが決める */
.tile__chart canvas,
.yenspx__chart canvas,
.chart canvas { width: 100% !important; height: 100% !important; }

/* Fear & Greed の数値と区分。以前は図の中に描いていた */
.meter__value {
  margin: 6px 0 0;
  font-size: 34px;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
}

.meter__band {
  margin: 2px 0 10px;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}

/* ドローダウンの最大値。以前は図の中の注釈だった */
.dd-maxes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* 変化率が2行に折り返したタイルだけ図が下がって、
   横に並んだ図の高さがそろわないので、図から下を底に寄せる */
.tile { display: flex; flex-direction: column; }

/* ── Fear & Greed（メーターと1年チャート） ─────────── */

.fg {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(280px, 1fr);
  gap: var(--gap);
  align-items: center;
}

.fg__meter { min-width: 0; text-align: center; }
.fg__chart { min-width: 0; height: 260px; }

.gauge svg { width: 100%; height: auto; display: block; }

/* ── VIX ──────────────────────────────────── */

.vix__head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-bottom: 8px;
}

.vix__value { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.vix__change { font-size: 15px; font-weight: 700; }
.vix__band { font-size: 15px; font-weight: 700; }

/* ── ヒートマップ ───────────────────────────── */

.heat__summary {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 14px;
}

.heat {
  position: relative;
  width: 100%;
}

.heat__sector {
  position: absolute;
  padding: 0 1px 1px 0;
}

.heat__sector-name {
  height: 16px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
}

.heat__tile {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 1px solid var(--surface);
  color: #fff;
  overflow: hidden;
  line-height: 1.15;
}

/* 日本語名は長いものがあるので、はみ出したら省略する */
.heat__ja {
  max-width: 96%;
  font-size: 10.5px;
  opacity: 0.95;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.heat__symbol { font-size: 12px; font-weight: 700; }
.heat__change { font-size: 11px; opacity: 0.92; }

@media (max-width: 700px) {
  .fg { grid-template-columns: 1fr; }
  .fg__chart { height: 220px; }
  .heat__ja { font-size: 9.5px; }
  .heat__symbol { font-size: 11px; }
  .heat__change { font-size: 10px; }
}

/* 図の高さは器の幅で決める。右レールが出ると本文が860pxから580pxまで
   狭まるので、画面幅のメディアクエリでは決められない */
.board__rows { container-type: inline-size; }

/* 右レールが出ているときの本文幅（580px）でも高いほうを使う。
   引っかかるのは携帯だけ */
@container (min-width: 480px) {
  .tile__chart { height: 240px; }
}

/* ── S&P500の月ごとの騰落 ─────────────────── */

.monthly {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.monthly th,
.monthly td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

.monthly th {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.monthly th:first-child,
.monthly .monthly__label {
  text-align: left;
  font-weight: 700;
}

.monthly .monthly__num { font-variant-numeric: tabular-nums; }
.monthly tbody tr:hover { background: #f7f8fa; }
.monthly tbody tr:last-child td { border-bottom: 0; }

.monthly .up { color: var(--up); font-weight: 700; }
.monthly .down { color: var(--down); font-weight: 700; }
.monthly .flat { color: var(--text-muted); }

