/* Dogo congestion calendar — one stylesheet, two themes (?site=dogo | ?site=inspires).
   Layout: base → dogo.jp theme → matsuyama-inspires theme → phones (≤750px) → very narrow (≤340px) → page states.
   Frame-height contract (vendors' fixed-height tags): PC 720px / phone 650px. Any change here → re-measure
   (calendar_service/README.md, tools/measure_height.mjs). */

/* =================================================================================================== base */
:root {
  --ink: #1e1e1e;
  --ink-sub: #645c5c;
  --ground: #fff;
  --beige: #f5eee4;
  --gold: #887e54;
  --rule: #ddd;
  --sun: #b0352b;
  --sat: #2f5d8a;
  --high: #a63a2e;
  --high-bg: #f6e1dc;
  --mid: #9a6b12;
  --mid-bg: #f8edcf;
  --low: #3f6e52;
  --low-bg: #e3efe6;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--ground); color: var(--ink); }
body {
  font-family: "Yu Mincho", YuMincho, "Hiragino Mincho ProN", "Hiragino Mincho Pro", "Noto Serif JP", serif;
  font-size: 15px;
  line-height: 1.8;
  -webkit-text-size-adjust: 100%;
}
.cal { max-width: 760px; margin: 0 auto; padding: 16px; }
/* the host page provides the visible heading; this one is for screen readers only */
.cal-title { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.cal-lead { margin: 0 0 12px; text-align: center; color: var(--ink-sub); font-size: 14px; }
.cal-preview { background: var(--gold); color: #fff; text-align: center; margin: 0 0 8px; font-size: 13px; }

/* legend */
.cal-legend { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px;
  margin: 0 0 12px; padding: 8px 12px; background: var(--beige); font-size: 13px; }
.cal-legend li { display: flex; align-items: center; gap: 6px; }

/* level badge (高/中/小); .lv-slot = invisible placeholder so the date never moves; .lv-none = "－" (no data yet) */
.lv { display: inline-flex; align-items: center; justify-content: center; width: 1.9em; height: 1.9em;
  border-radius: 50%; font-weight: 600; font-size: 14px; line-height: 1; color: #fff; }
.lv-high { background: var(--high); }
.lv-mid  { background: var(--mid); }
.lv-low  { background: var(--low); }
.lv.lv-slot { visibility: hidden; }
.lv.lv-none, .site-dogo .lv.lv-none, .site-inspires .lv.lv-none { background: none; color: #a0a0a0; font-weight: 400; }

/* month header + navigation (arrows are hidden without JS: all months are then listed) */
.cal-month-head { display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--gold); padding-bottom: 4px; margin-bottom: 4px; }
.cal-month-head h3 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: .06em; }
.cal-nav { visibility: hidden; font: inherit; font-size: 22px; line-height: 1; width: 40px; height: 36px;
  border: 1px solid var(--gold); background: var(--ground); color: var(--gold); cursor: pointer; border-radius: 2px; }
.cal-nav:disabled { opacity: .3; cursor: default; }
.js .cal-nav { visibility: visible; }
.js .cal-month { display: none; }
.js .cal-month.is-active { display: block; }
.cal-month + .cal-month { margin-top: 20px; }
.js .cal-month + .cal-month { margin-top: 0; }

/* grid */
.cal-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal-grid th { font-weight: 400; font-size: 13px; padding: 4px 0; color: var(--ink-sub); }
.cal-grid th.sun { color: var(--sun); }
.cal-grid th.sat { color: var(--sat); }
.cal-grid td { padding: 2px; vertical-align: top; height: 68px; }
.cal-grid td.past .day { background: var(--ground); border-color: #eee; }
.cal-grid td.past .d { color: #a0a0a0; }
.day { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; width: 100%; height: 100%; min-height: 64px; padding: 4px 2px; border: 1px solid var(--rule);
  background: var(--ground); border-radius: 2px; }
.day.nodata { background: #fafafa; }
.day.other { background: transparent; border-color: transparent; }
.day.other .d { color: #c8c8c8; }
.lvbg-high { background: var(--high-bg); }
.lvbg-mid  { background: var(--mid-bg); }
.lvbg-low  { background: var(--low-bg); }
.today .day { box-shadow: inset 0 0 0 2px var(--gold); }
.d { font-size: 13px; line-height: 1.2; }
.d.sun { color: var(--sun); }
.d.sat { color: var(--sat); }

/* footer: source credit (left) + 最終更新 (right), then the expandable 混雑レベルについて */
.cal-foot { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; align-items: start; margin-top: 10px; }
.cal-credit { grid-column: 1; margin: 0; font-size: 11px; color: var(--ink-sub); }
.cal-credit span { display: block; }
.cal-credit a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.cal-credit .ph { display: inline-block; }  /* lines break between phrases, never inside one */
.cal-updated { grid-column: 2; grid-row: 1; margin: 0; text-align: right; font-size: 11px; color: #666; white-space: nowrap; }
.cal-about { margin-top: 0; font-size: 13px; color: var(--ink-sub); }
/* ≥ 44px tap target across the full width */
.cal-about summary { cursor: pointer; color: var(--ink); padding: 10px 0; min-height: 44px; font-size: 14px; font-weight: 500; }
.cal-about ul { padding-left: 1.4em; margin: 4px 0; }
.cal-about p { margin: 4px 0; }

/* 準備中 / ただいま表示できません */
.cal-notice { text-align: center; padding: 48px 16px; background: var(--beige); }
.cal-notice-main { font-size: 26px; letter-spacing: .3em; margin: 0 0 12px; color: var(--gold); font-weight: 600; }
.cal-notice p { margin: 0; }

/* ========================================================================================== dogo.jp theme */
/* Mincho, beige/olive-gold, soft level badges (pale fill + coloured text, ≥ 4.5:1) on white cells, warm-grey rules */
body.site-dogo { --rule: #e3ddd2; }
.site-dogo .cal-legend { background: transparent; padding: 4px 0 6px; gap: 4px 18px; }
.site-dogo .cal-legend .lv { width: 1.6em; height: 1.6em; font-size: 12px; }
.site-dogo .lv-high { background: #F6E9E6; color: #9A4F45; }
.site-dogo .lv-mid  { background: #F5EEDC; color: #80621F; }
.site-dogo .lv-low  { background: #EAF1EB; color: #4E6D5A; }
.site-dogo .cal-month-head { justify-content: center; gap: 20px; }
.site-dogo .cal-nav { border: 0; background: transparent; color: var(--gold); font-size: 26px; }
.site-dogo .cal-nav:not(:disabled):hover { color: var(--ink); }
.site-dogo .cal-nav:focus-visible, .site-dogo .cal-about summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.site-dogo .lvbg-high, .site-dogo .lvbg-mid, .site-dogo .lvbg-low { background: var(--ground); }
.site-dogo .today .day { box-shadow: none; background: #f5f1e9; }
.site-dogo .cal-foot { border-top: 1px solid var(--rule); padding-top: 8px; }
.site-dogo .cal-credit { font-size: 12px; color: #5a5252; }
.site-dogo .cal-updated { color: #5a5252; }

/* ================================================================================ matsuyama-inspires theme */
/* copied verbatim from matsuyama-inspires.com (their page <style>) */
@font-face { font-family: "Noto Sans Fallback"; src: local('Arial'); ascent-override: 100.1833%;
  descent-override: 27.459%; size-adjust: 106.7044%; line-gap-override: 0%; }
/* sans-serif, monochrome: white cells on a 1px grid, level as coloured text (≥ 4.5:1), plain chevrons */
body.site-inspires {
  --ink: #202020;
  --ink-sub: #464e4c;
  --beige: #f4f4f4;
  --gold: #202020;
  --rule: #e2e2e2;
  --red: #e00e10;
  /* 高 = a calm deep red (the brand red #e00e10 was too strong): 5.9:1 on white, 5.3:1 on the "today" cell */
  --hi: #b33a32; --md: #8A6B24; --lo: #557A65; --sun-soft: #B5473F;
  --sat-soft: #4a6f96;  /* Saturday blue, muted to pair with --sun-soft (5.2:1 vs 5.3:1 on white) */
  /* EXACTLY matsuyama-inspires.com's declaration (computed style + their @font-face, verified 2026-11-16):
     Latin from the Noto Sans web font, "Noto Sans Fallback" = local Arial with their metric overrides, and no generic
     family — so Japanese falls back exactly as on their own pages, on every OS/browser */
  font-family: "Noto Sans", "Noto Sans Fallback";
}
.site-inspires .cal { max-width: 1040px; }
.site-inspires .cal-lead { color: var(--ink); }
.site-inspires .cal-preview { background: var(--red); }
.site-inspires .cal-legend { background: transparent; padding: 4px 0 8px; gap: 4px 20px; }
.site-inspires .cal-legend .lv { font-size: 14px; }
.site-inspires .lv { width: auto; height: auto; background: none; border-radius: 0; font-size: 16px; font-weight: 700; }
.site-inspires .lv-high { color: var(--hi); }
.site-inspires .lv-mid  { color: var(--md); }
.site-inspires .lv-low  { color: var(--lo); }
.site-inspires .cal-month-head { border-bottom: 0; margin: 4px 0 8px; justify-content: center; gap: 20px; }
.site-inspires .cal-month-head h3 { font-size: 26px; font-weight: 500; letter-spacing: .04em; line-height: 1.1; }
.site-inspires .cal-nav { width: 40px; height: 36px; border: 0; border-radius: 0; background: transparent;
  color: var(--ink); font-size: 26px; }
.site-inspires .cal-nav:disabled { color: #c8c8c8; opacity: 1; }
.site-inspires .cal-nav:focus-visible, .site-inspires .cal-about summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.site-inspires .cal-grid th { font-weight: 500; color: var(--ink-sub); }
.site-inspires .cal-grid th.sun { color: var(--sun-soft); }
.site-inspires .cal-grid th.sat { color: var(--sat-soft); }
.site-inspires .cal-grid td { padding: 0; border: 1px solid var(--rule); }
.site-inspires .day, .site-inspires .day.nodata, .site-inspires .cal-grid td.past .day,
.site-inspires .lvbg-high, .site-inspires .lvbg-mid, .site-inspires .lvbg-low { background: #fff; border: 0; border-radius: 0; }
.site-inspires .today .day { box-shadow: none; background: #f2f2f2; }
.site-inspires .d { font-size: 15px; font-weight: 500; }
.site-inspires .d.sun { color: var(--sun-soft); }
.site-inspires .d.sat { color: var(--sat-soft); }
.site-inspires .day.other .d { color: #c8c8c8; }
.site-inspires .cal-foot { border-top: 1px solid var(--rule); padding-top: 8px; }
.site-inspires .cal-credit { color: #666; }
.site-inspires .cal-about summary { list-style: none; }
.site-inspires .cal-about summary::-webkit-details-marker { display: none; }
.site-inspires .cal-about summary::before { content: "›"; display: inline-block; width: 1em; margin-right: 4px;
  color: var(--ink); transition: transform .15s; }
.site-inspires .cal-about[open] summary::before { transform: rotate(90deg); }
.site-inspires .cal-notice { background: #f4f4f4; }
.site-inspires .cal-notice-main { color: var(--ink); letter-spacing: .2em; font-weight: 700; }

/* inspires typography (2026-11-16 review): stronger hierarchy in the site's own font */
.site-inspires .cal-lead { font-size: 16px; font-weight: 500; }
.site-inspires .cal-legend { font-size: 14px; font-weight: 500; }
.site-inspires .cal-month-head h3 { font-size: 32px; font-weight: 600; letter-spacing: .02em; }
/* display numerals in the site's display face (Oswald, as on its English headings); 年/月 stay in the Japanese font */
.site-inspires .cal-month-head .ym { font-family: "Oswald", "Noto Sans", "Noto Sans Fallback"; font-weight: 500; font-size: 1.1em; letter-spacing: .02em; line-height: 1; }
.site-inspires .cal-grid th { font-size: 15px; font-weight: 600; }
.site-inspires .d { font-size: 16px; font-weight: 500; }
.site-inspires .lv { font-size: 17px; font-weight: 700; }
.site-inspires .cal-legend .lv { font-size: 15px; }
.site-inspires .cal-about summary { font-size: 16px; font-weight: 600; }
.site-inspires .cal-credit, .site-inspires .cal-updated { font-size: 12px; }
.site-inspires .cal-grid td { height: 65px; }  /* larger type → 2px shorter minimum rows keep 6-row months ≤ 720px */

/* ============================================================== phones (≤750px; dogo.jp's own breakpoint) */
/* spacing: intro→legend 16, legend→month 24, month→weekdays 18, calendar→credit 24; 44px arrow targets.
   Rows: 6-row months fit the 650px frame at 48px; 4–5-row months stretch to fill it (see "fill the frame"). */
@media (max-width: 750px) {
  body { font-size: 14px; }
  .cal { padding: 12px 8px; }
  .cal-lead { font-size: 13px; line-height: 1.6; margin: 0 0 16px; }
  .cal-legend, .site-dogo .cal-legend, .site-inspires .cal-legend { font-size: 12px; gap: 2px 12px; margin: 0 0 24px; padding: 0; }
  .cal-legend li { gap: 3px; }
  .site-dogo .cal-legend .lv, .site-inspires .cal-legend .lv { font-size: 12px; }
  .lv { font-size: 12px; width: 1.75em; height: 1.75em; }
  .site-dogo .lv { font-size: 13px; width: 1.7em; height: 1.7em; }
  .site-inspires .lv { font-size: 14px; font-weight: 600; }
  .cal-month-head, .site-dogo .cal-month-head, .site-inspires .cal-month-head { margin: 0 0 18px; padding-bottom: 0; }
  .cal-month-head h3, .site-inspires .cal-month-head h3 { font-size: 22px; }
  .cal-nav, .site-dogo .cal-nav, .site-inspires .cal-nav,
  .site-dogo .cal-nav:disabled, .site-inspires .cal-nav:disabled { width: 44px; height: 44px; }
  .cal-grid th { font-size: 12px; font-weight: 500; padding: 0 0 4px; }
  .cal-grid td { height: 48px; padding: 1px; }
  .day { min-height: 46px; padding: 3px 0; }
  .d { font-size: 12px; }
  .site-inspires .d { font-size: 13px; }
  .cal-foot, .site-dogo .cal-foot, .site-inspires .cal-foot { margin-top: 24px; }
  .cal-credit, .site-dogo .cal-credit, .site-inspires .cal-credit { font-size: 11px; }
  .cal-about summary { display: flex; align-items: center; gap: 6px; }
  .site-dogo .cal-about summary { list-style: none; }
  .site-dogo .cal-about summary::-webkit-details-marker { display: none; }
  .site-dogo .cal-about summary::before { content: "▸"; font-size: 12px; line-height: 1; color: var(--gold); transition: transform .15s; }
  .site-dogo .cal-about[open] summary::before { transform: rotate(90deg); }
  .site-inspires .cal-about summary::before { margin-right: 0; width: auto; line-height: 1; }
  .cal-notice br { display: none; }
  .site-inspires .cal-grid td { height: 48px; }  /* phone rows; overrides the inspires PC 66px rule */
  .site-inspires .cal-lead { font-size: 14px; }
  .site-inspires .cal-legend { font-size: 13px; }
  .site-inspires .cal-legend .lv { font-size: 13px; }
  .site-inspires .cal-month-head h3 { font-size: 24px; }
  .site-inspires .cal-grid th { font-size: 13px; font-weight: 600; }
  .site-inspires .d { font-size: 14px; }
  .site-inspires .lv { font-size: 15px; font-weight: 700; }
  .site-inspires .cal-about summary { font-size: 14px; font-weight: 600; }
  .site-inspires .cal-credit, .site-inspires .cal-updated { font-size: 11px; }
  /* dogo.jp phones use the inspires grid layout (one continuous 1px grid, flat cells) in dogo's own tone */
  .site-dogo .cal-grid td { padding: 0; border: 1px solid var(--rule); }
  .site-dogo .day, .site-dogo .day.nodata, .site-dogo .cal-grid td.past .day { border: 0; border-radius: 0; background: var(--ground); }
}

/* narrow phones (≤420px): 最終更新 on its own line so the credit gets the full width (fewer, cleaner line breaks) */
@media (max-width: 420px) {
  .cal-foot { grid-template-columns: 1fr; }
  .cal-updated { grid-column: 1; grid-row: auto; text-align: left; }
}

/* narrow frames (≤374px, where the intro wraps to 2 lines): trim spacing so 6-row months stay within the 650px phone frame */
@media (max-width: 374px) {
  .site-inspires .cal-lead { font-size: 13px; }
  .cal { padding-top: 6px; padding-bottom: 6px; }
  .cal-foot, .site-dogo .cal-foot, .site-inspires .cal-foot { margin-top: 18px; }
}

/* ============================================================================================ page states */
/* fill the vendor's fixed-height frame: the grid stretches so 4–5-row months get taller rows instead of blank space
   at the bottom (100vh = iframe height). Only with JS, where one month is shown at a time. */
html.js, html.js body { height: 100%; }
.js body:not(.page-notice) .cal { min-height: 100vh; display: flex; flex-direction: column; }
.js .cal-months { flex: 1; display: flex; flex-direction: column; }
.js .cal-month.is-active { flex: 1; display: flex; flex-direction: column; }
.js .cal-month.is-active .cal-grid { flex: 1; height: 100%; }

/* 準備中 / ただいま表示できません: the panel fills the whole frame */
html:has(body.page-notice), body.page-notice { height: 100%; }
body.page-notice .cal { min-height: 100vh; display: flex; flex-direction: column; }
body.page-notice .cal-notice { flex: 1; display: flex; flex-direction: column; justify-content: center; }
