/*
 * 幕張混雑予報 ポータル
 *
 * 配色は交通情報の慣習に合わせている（低=灰 / 中=黄 / 高=橙 / 非常に高=赤）。
 * 強い色は混雑レベルだけに使い、ブランド色（道路案内標識の青）は控えめに置く。
 * 時刻は等幅・等幅数字で並べ、桁を揃えて拾い読みできるようにしている。
 */

:root {
  --bg: #fafaf8;
  --bg-alt: #f1f2ef;
  --surface: #ffffff;
  --ink: #14181d;
  --ink-2: #444c56;
  --ink-3: #6b747f;
  --line: #dfe2dd;
  --line-strong: #c4c9c3;
  --accent: #17408b;
  --accent-on: #ffffff;

  --lv-low: #6b7686;
  --lv-medium: #a8710b;
  --lv-high: #cf5511;
  --lv-very_high: #bb1c2c;
  --lv-low-t: #eef0f3;
  --lv-medium-t: #fbf1dc;
  --lv-high-t: #fce9dd;
  --lv-very_high-t: #fbe3e5;

  --sans: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", system-ui,
    -apple-system, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --wrap: 68rem;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --bg-alt: #151920;
    --surface: #191e25;
    --ink: #e6eaee;
    --ink-2: #b3bcc6;
    --ink-3: #8b95a1;
    --line: #29313a;
    --line-strong: #3a444f;
    --accent: #8fb0f2;
    --accent-on: #0f1216;

    --lv-low: #97a2b0;
    --lv-medium: #e2ad46;
    --lv-high: #fb8f52;
    --lv-very_high: #f26b78;
    --lv-low-t: #212832;
    --lv-medium-t: #2e2718;
    --lv-high-t: #33231a;
    --lv-very_high-t: #331d21;
  }
}

:root[data-theme="light"] {
  --bg: #fafaf8;
  --bg-alt: #f1f2ef;
  --surface: #ffffff;
  --ink: #14181d;
  --ink-2: #444c56;
  --ink-3: #6b747f;
  --line: #dfe2dd;
  --line-strong: #c4c9c3;
  --accent: #17408b;
  --accent-on: #ffffff;
  --lv-low: #6b7686;
  --lv-medium: #a8710b;
  --lv-high: #cf5511;
  --lv-very_high: #bb1c2c;
  --lv-low-t: #eef0f3;
  --lv-medium-t: #fbf1dc;
  --lv-high-t: #fce9dd;
  --lv-very_high-t: #fbe3e5;
}

:root[data-theme="dark"] {
  --bg: #0f1216;
  --bg-alt: #151920;
  --surface: #191e25;
  --ink: #e6eaee;
  --ink-2: #b3bcc6;
  --ink-3: #8b95a1;
  --line: #29313a;
  --line-strong: #3a444f;
  --accent: #8fb0f2;
  --accent-on: #0f1216;
  --lv-low: #97a2b0;
  --lv-medium: #e2ad46;
  --lv-high: #fb8f52;
  --lv-very_high: #f26b78;
  --lv-low-t: #212832;
  --lv-medium-t: #2e2718;
  --lv-high-t: #33231a;
  --lv-very_high-t: #331d21;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
}

.inner {
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 1.15rem;
}

h2 {
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  margin: 0 0 0.2rem;
}

h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 2rem 0 0.5rem;
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: var(--wrap);
  margin-inline: auto;
  padding: 0.6rem 1.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.brand-mark {
  width: 0.72rem;
  height: 1.15rem;
  border-radius: 3px;
  background: linear-gradient(
    to bottom,
    var(--lv-low) 0 33%,
    var(--lv-high) 33% 66%,
    var(--lv-very_high) 66% 100%
  );
  flex: none;
}

.brand-name {
  font-size: 1.02rem;
  white-space: nowrap;
}

.updated {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  text-align: right;
  line-height: 1.4;
}

/* 狭い画面のトップバーでは更新時刻だけにして、情報取得時刻はフッタに任せる */
.topbar .upd-sub {
  display: none;
}

.site-footer .updated {
  font-size: 0.72rem;
}

/* ---------------------------------------------------------- hero */

.band {
  padding: 1.6rem 0;
}

.band-hero {
  background: var(--bg-alt);
}

.hero-verdict {
  margin: 0 0 0.7rem;
  font-size: 1.22rem;
  font-weight: 800;
  line-height: 1.45;
  letter-spacing: -0.005em;
  text-wrap: balance;
}

.hero.is-calm .hero-verdict {
  font-size: 1.1rem;
}

.hero-sub {
  margin: 0;
  color: var(--ink-3);
  font-size: 0.9rem;
}

.hero-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.hero-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.8rem;
}

.hero-list .dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--lv-low);
  flex: none;
  align-self: center;
}

.hero-when {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.02rem;
  font-weight: 700;
}

.hero-lv {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-3);
}

.hero-list .lv-medium .dot {
  background: var(--lv-medium);
}
.hero-list .lv-medium .hero-lv {
  color: var(--lv-medium);
}
.hero-list .lv-high .dot {
  background: var(--lv-high);
}
.hero-list .lv-high .hero-lv {
  color: var(--lv-high);
}
.hero-list .lv-very_high .dot {
  background: var(--lv-very_high);
}
.hero-list .lv-very_high .hero-lv {
  color: var(--lv-very_high);
}

/* ---------------------------------------------------------- layout */

.layout {
  display: grid;
  gap: 2.2rem;
  padding-block: 2rem 1rem;
}

.section-note {
  margin: 0 0 0.9rem;
  font-size: 0.83rem;
  color: var(--ink-3);
}

/* ---------------------------------------------------------- calendar */

/* 罫線は週の区切りだけ。縦罫は曜日見出しの整列で代替できる */
.cal {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.cal th {
  padding: 0 0 0.45rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

.cal th.is-sun {
  color: var(--lv-very_high);
}
.cal th.is-sat {
  color: var(--accent);
}

.cal td {
  height: 4.2rem;
  padding: 0.1rem 0.1rem 0.35rem;
  vertical-align: top;
  border-top: 1px solid var(--line);
}

.dnum {
  display: block;
  padding: 0.15rem 0.2rem 0.15rem;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-2);
  text-align: left;
}

.daycell.is-outside .dnum {
  color: var(--ink-3);
  opacity: 0.4;
}

.daycell.is-sun .dnum {
  color: var(--lv-very_high);
}
.daycell.is-sat .dnum {
  color: var(--accent);
}

.daycell.is-today .dnum::after {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-left: 3px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 0.22em;
}

.daybtn {
  /* button の既定は内容を垂直中央に置くので、flex で明示的に上寄せする */
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  width: 100%;
  height: 100%;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 6px;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.daybtn:hover {
  background: var(--bg-alt);
}

/* 選択日は枠ではなく面で示す */
.daycell.is-active .daybtn {
  background: var(--accent);
}

.daycell.is-active .dnum,
.daycell.is-active .mark .mt {
  color: var(--accent-on);
}

.daycell.is-active .dnum::after {
  background: var(--accent-on);
}

.marks {
  display: grid;
  gap: 2px;
  padding-inline: 0.2rem;
}

.mark {
  display: block;
  height: 5px;
  border-radius: 2px;
  background: var(--lv-low);
}

.mark.lv-medium {
  background: var(--lv-medium);
}
.mark.lv-high {
  background: var(--lv-high);
}
.mark.lv-very_high {
  background: var(--lv-very_high);
}

/* 狭い画面では時刻とレベル名を出さず、色の帯だけで示す */
.mark .mt,
.mark .ml,
.marks .more {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------------------------------------------------------- Google カレンダー埋め込み */

.gcal-wrap {
  position: relative;
}

.gcal {
  display: block;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
}

/* 月表示は狭い画面で読めないため、幅で出し分ける（非表示側は lazy で読み込まれない） */
.gcal.is-month {
  display: none;
  height: 34rem;
}

.gcal.is-agenda {
  height: 26rem;
}

@media (min-width: 46rem) {
  .gcal.is-month {
    display: block;
  }
  .gcal.is-agenda {
    display: none;
  }
}

/* ---------------------------------------------------------- legend */

.legend-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-top: 0.9rem;
}

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.95rem;
  font-size: 0.78rem;
  color: var(--ink-2);
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.32rem;
  white-space: nowrap;
}

.legend-more {
  font-size: 0.78rem;
  color: var(--ink-3);
  text-decoration-color: var(--line-strong);
  white-space: nowrap;
}

.swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 3px;
  background: var(--lv-low);
  flex: none;
}

.swatch.lv-medium {
  background: var(--lv-medium);
}
.swatch.lv-high {
  background: var(--lv-high);
}
.swatch.lv-very_high {
  background: var(--lv-very_high);
}

/* ---------------------------------------------------------- detail */

.day-detail {
  margin-bottom: 2rem;
}

/* JS が有効なときだけ選択日に絞る（無効なら全日そのまま読める） */
.js .day-detail {
  display: none;
}

.js .day-detail.is-active {
  display: block;
}

.day-title {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  margin: 0 0 1.6rem;
  font-size: 1.05rem;
}

.day-md {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.42rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.day-wd {
  font-size: 0.85rem;
  color: var(--ink-3);
  font-weight: 700;
}

/* 予報どうしは枠ではなく、たっぷりの余白で分ける */
.win {
  margin-bottom: 2.8rem;
}

.win:last-child {
  margin-bottom: 0;
}

.win-level {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.15rem;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--lv-low);
}

.win.lv-medium .win-level {
  color: var(--lv-medium);
}
.win.lv-high .win-level {
  color: var(--lv-high);
}
.win.lv-very_high .win-level {
  color: var(--lv-very_high);
}

.win-level .dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.win-time {
  margin: 0;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.62rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.win-events {
  margin: 0.45rem 0 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.55;
}

.win-where {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-3);
}

.win-note {
  margin: 0.75rem 0 0;
  font-size: 0.86rem;
  color: var(--ink-2);
  line-height: 1.7;
}

.win-note b {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.win-areas {
  margin: 0.75rem 0 0;
  font-size: 0.86rem;
  color: var(--ink-2);
  line-height: 1.7;
}

.lbl,
.sub-lbl {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--ink-3);
}

.sub-lbl {
  margin: 0.9rem 0 0.2rem;
}

.why {
  margin-top: 1rem;
}

.why > summary {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--ink-3);
  cursor: pointer;
  list-style: none;
  padding: 0.1rem 0;
}

.why > summary::-webkit-details-marker {
  display: none;
}

.why > summary::before {
  content: "＋ ";
  font-family: var(--mono);
}

.why[open] > summary::before {
  content: "− ";
}

.why > summary:hover {
  color: var(--ink-2);
}

.factors {
  margin: 0;
  font-size: 0.83rem;
  color: var(--ink-2);
  line-height: 1.75;
}

.sources {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.15rem;
  font-size: 0.78rem;
}

.sources a {
  color: var(--ink-2);
  word-break: break-all;
}

.win-score {
  margin: 0.9rem 0 0;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.73rem;
  color: var(--ink-3);
}

.empty {
  padding: 2.5rem 0;
  color: var(--ink-3);
  margin: 0;
}

/* ---------------------------------------------------------- about */

.band-about {
  background: var(--bg-alt);
  margin-top: 2rem;
  padding-block: 2.6rem;
}

.prose {
  max-width: 42rem;
}

.prose p {
  margin: 0 0 0.85rem;
  font-size: 0.92rem;
  color: var(--ink-2);
}

.prose .caveat {
  margin-top: 1.6rem;
  font-size: 0.85rem;
  color: var(--ink-3);
}

.table-scroll {
  overflow-x: auto;
  margin-bottom: 0.5rem;
}

.levels {
  border-collapse: collapse;
  font-size: 0.86rem;
  min-width: 22rem;
  width: 100%;
}

.levels th {
  text-align: left;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--ink-3);
  padding: 0.3rem 0.7rem 0.5rem 0;
}

.levels td {
  padding: 0.45rem 0.7rem 0.45rem 0;
  color: var(--ink-2);
  vertical-align: middle;
}

.levels td:first-child {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}

.levels .num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------------------------------------------------------- subscribe */

.subscribe {
  padding-block: 2.4rem 1rem;
}

.channels {
  list-style: none;
  margin: 1.2rem 0 0;
  padding: 0;
  display: grid;
  gap: 1.25rem;
}

.ch a {
  font-weight: 700;
  font-size: 0.96rem;
}

.ch p {
  margin: 0.1rem 0 0;
  font-size: 0.83rem;
  color: var(--ink-3);
}

/* ---------------------------------------------------------- footer */

.site-footer {
  padding: 2rem 0 3rem;
  background: var(--bg-alt);
}

.site-footer .updated {
  text-align: left;
  margin-bottom: 0.4rem;
}

.disclaimer {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-3);
  max-width: 42rem;
}

/* ---------------------------------------------------------- 画面が広いとき */

@media (min-width: 40rem) {
  .cal td {
    height: 5.4rem;
  }

  .dnum {
    font-size: 0.9rem;
    padding: 0.3rem 0.45rem 0.15rem;
  }

  /* 帯だけの表示をやめ、時刻とレベル名を出す */
  .marks {
    gap: 3px;
    padding-inline: 0.28rem;
  }

  .mark {
    height: auto;
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
    padding: 0.05rem 0.34rem;
    border-radius: 4px;
    background: var(--lv-low-t);
    overflow: hidden;
  }

  .mark::before {
    content: "";
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: var(--lv-low);
    flex: none;
    align-self: center;
  }

  .mark.lv-medium {
    background: var(--lv-medium-t);
  }
  .mark.lv-medium::before {
    background: var(--lv-medium);
  }
  .mark.lv-high {
    background: var(--lv-high-t);
  }
  .mark.lv-high::before {
    background: var(--lv-high);
  }
  .mark.lv-very_high {
    background: var(--lv-very_high-t);
  }
  .mark.lv-very_high::before {
    background: var(--lv-very_high);
  }

  .mark .mt,
  .marks .more {
    position: static;
    width: auto;
    height: auto;
    overflow: hidden;
    clip-path: none;
    font-size: 0.66rem;
    line-height: 1.5;
  }

  .mark .mt {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--ink-2);
    flex: none;
  }

  .marks .more {
    display: block;
    padding-left: 0.3rem;
    font-size: 0.65rem;
    color: var(--ink-3);
  }

  .hero-verdict {
    font-size: 1.35rem;
  }

  .topbar .upd-sub {
    display: inline;
  }
}

@media (min-width: 64rem) {
  .layout {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 2.6rem;
    align-items: start;
  }

  .col-cal {
    position: sticky;
    top: 3.6rem;
  }

  .cal td {
    height: 5.8rem;
  }

  .band {
    padding: 2rem 0;
  }
}
