/* 名古屋市 暮らしの変化と兆し -- shared stylesheet (Design v2)
   Direction: a friendly neighborhood bulletin, not a government report.
   Bright, low-saturation color fields, big rounded cards, generous type. */

:root {
  --color-bg: #fbf3e7;
  --color-surface: #fffdf8;
  --color-surface-alt: #fff9ef;
  --color-border: #ecdfc9;
  --color-text: #332c22;
  --color-text-muted: #6b6152;
  --color-text-faint: #736957;
  --color-accent: #2f5d50;
  --color-accent-strong: #23473d;
  --color-accent-soft: #e3f0ea;
  --color-link: #2f5d50;

  --tint-mint: #dcefe3;
  --tint-mint-text: #2f5d50;
  --tint-blue: #dfeaf6;
  --tint-blue-text: #2b5170;
  --tint-yellow: #fbf0cf;
  --tint-yellow-text: #7a5c17;
  --tint-orange: #fbe3cd;
  --tint-orange-text: #8a5423;
  --tint-pink: #fbe1ea;
  --tint-pink-text: #8a3b56;

  /* "moved since the previous update" layer on the stage matrix: a calm
     blue, never a warning color -- an update is not a problem. */
  --color-changed-row: #f3f7fb;
  --color-changed-cell: #e2ecf7;
  --color-changed-ring: #7d9fc2;
  --color-changed-badge: #dfeaf6;
  --color-changed-badge-text: #2b5170;

  --font-serif: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic",
    "Noto Sans JP", "Helvetica Neue", Arial, sans-serif;
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --max-width: 1080px;
  --shadow-card: 0 2px 4px rgba(60, 45, 20, 0.05), 0 10px 24px rgba(60, 45, 20, 0.06);
  --shadow-card-hover: 0 6px 10px rgba(60, 45, 20, 0.08), 0 16px 30px rgba(60, 45, 20, 0.09);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #201c15;
    --color-surface: #29241b;
    --color-surface-alt: #2d271d;
    --color-border: #423a29;
    --color-text: #f2ece0;
    --color-text-muted: #cabfa9;
    --color-text-faint: #a89b83;
    --color-accent: #8fc3b1;
    --color-accent-strong: #a9d6c6;
    --color-accent-soft: #253a33;
    --color-link: #8fc3b1;

    --tint-mint: #24362d;
    --tint-mint-text: #a9d6c6;
    --tint-blue: #23323f;
    --tint-blue-text: #a9c9e0;
    --tint-yellow: #3a3220;
    --tint-yellow-text: #e6cf8c;
    --tint-orange: #3a2c1f;
    --tint-orange-text: #e6b98c;
    --tint-pink: #3a2530;
    --tint-pink-text: #e6a9c0;
    --color-changed-row: #232a31;
    --color-changed-cell: #2a3846;
    --color-changed-ring: #6f93b8;
    --color-changed-badge: #23323f;
    --color-changed-badge-text: #a9c9e0;
    --shadow-card: 0 2px 4px rgba(0, 0, 0, 0.3), 0 10px 24px rgba(0, 0, 0, 0.25);
    --shadow-card-hover: 0 6px 10px rgba(0, 0, 0, 0.32), 0 16px 30px rgba(0, 0, 0, 0.3);
  }
}
:root[data-theme="dark"] {
  --color-bg: #201c15;
  --color-surface: #29241b;
  --color-surface-alt: #2d271d;
  --color-border: #423a29;
  --color-text: #f2ece0;
  --color-text-muted: #cabfa9;
  --color-text-faint: #a89b83;
  --color-accent: #8fc3b1;
  --color-accent-strong: #a9d6c6;
  --color-accent-soft: #253a33;
  --color-link: #8fc3b1;

  --tint-mint: #24362d;
  --tint-mint-text: #a9d6c6;
  --tint-blue: #23323f;
  --tint-blue-text: #a9c9e0;
  --tint-yellow: #3a3220;
  --tint-yellow-text: #e6cf8c;
  --tint-orange: #3a2c1f;
  --tint-orange-text: #e6b98c;
  --tint-pink: #3a2530;
  --tint-pink-text: #e6a9c0;
  --color-changed-row: #232a31;
  --color-changed-cell: #2a3846;
  --color-changed-ring: #6f93b8;
  --color-changed-badge: #23323f;
  --color-changed-badge-text: #a9c9e0;
  --shadow-card: 0 2px 4px rgba(0, 0, 0, 0.3), 0 10px 24px rgba(0, 0, 0, 0.25);
  --shadow-card-hover: 0 6px 10px rgba(0, 0, 0, 0.32), 0 16px 30px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.9;
  -webkit-text-size-adjust: 100%;
}

img, svg {
  max-width: 100%;
}

a {
  color: var(--color-link);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-thickness: 2px;
}

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding-inline: 20px;
}

.icon {
  width: 1em;
  height: 1em;
  display: inline-block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- site header ---- */

.site-header {
  background: var(--color-surface);
  border-bottom: 3px solid var(--color-accent-soft);
}

.site-header__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.site-header__title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--color-accent-strong);
  text-decoration: none;
}

.site-header__title:hover {
  text-decoration: none;
  opacity: 0.85;
}

.site-nav {
  display: flex;
  gap: 8px;
  font-size: 0.98rem;
  font-weight: 600;
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--color-accent-strong);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.site-nav a:hover {
  background: var(--color-accent-soft);
}

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

.hero {
  padding: 44px 0 48px;
}

.hero__inner {
  display: flex;
  align-items: center;
  gap: 40px;
  flex-wrap: wrap;
}

.hero__text {
  flex: 1 1 340px;
  min-width: 0;
}

.hero__visual {
  flex: 1 1 320px;
  min-width: 0;
  max-width: 420px;
  margin-inline: auto;
}

.hero__visual img {
  width: 100%;
  height: auto;
  display: block;
}

.hero h1 {
  font-family: var(--font-sans);
  font-size: clamp(2rem, 5vw, 2.9rem);
  line-height: 1.35;
  margin: 0 0 14px;
  font-weight: 800;
  color: var(--color-accent-strong);
}

.hero__tagline {
  font-size: clamp(1.15rem, 2.6vw, 1.4rem);
  color: var(--color-text);
  margin: 0 0 18px;
  font-weight: 700;
  background: linear-gradient(transparent 60%, var(--tint-yellow) 60%);
  display: inline;
}

.hero__lead {
  max-width: 46ch;
  color: var(--color-text-muted);
  margin: 0;
  font-size: 1.05rem;
}

/* ---- section headings ---- */

.section {
  padding: 36px 0;
}

.section__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.section__heading h2 {
  font-size: 1.5rem;
  margin: 0;
  font-weight: 800;
  color: var(--color-accent-strong);
}

.section__note {
  color: var(--color-text-faint);
  font-size: 0.9rem;
}

.empty-state {
  color: var(--color-text-muted);
  font-size: 1rem;
  padding: 22px 24px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-md);
}

/* ---- signal cards (grid: this week) ----
   Deliberately minimal: a big image and a short title, nothing else. This
   index page is "look, then click if curious" -- summary, current status,
   domains and sources all live one click away on detail.html. A signal
   with an "image" in signals.json shows a large photo/illustration
   bleeding to the card's top corners; a signal without one falls back to
   the round icon badge (see signal-card__icon), so a future week can add
   signals with no artwork yet without breaking layout.
   Flexbox + justify-content:center (not CSS grid) is deliberate: with 5
   cards at 3-per-row, the leftover 2-card row centers itself instead of
   hugging the left edge with a lopsided gap on the right. */

.signal-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 26px;
}

.signal-card {
  display: flex;
  flex-direction: column;
  flex: 0 1 320px;
  width: 320px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.signal-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-3px);
  text-decoration: none;
}

.signal-card__image {
  display: block;
  width: 100%;
  height: auto;
}

.signal-card__content {
  padding: 18px 22px 22px;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.signal-card__icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.signal-card__icon .icon {
  width: 30px;
  height: 30px;
}

.signal-card__title {
  font-size: 1.14rem;
  font-weight: 800;
  margin: 0;
  color: var(--color-text);
  line-height: 1.6;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-block;
  background: var(--color-accent-soft);
  color: var(--color-accent-strong);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  line-height: 1.6;
}

/* icon badge tint rotation, applied by app.js via data-tint */
.signal-card__icon[data-tint="mint"] { background: var(--tint-mint); color: var(--tint-mint-text); }
.signal-card__icon[data-tint="blue"] { background: var(--tint-blue); color: var(--tint-blue-text); }
.signal-card__icon[data-tint="yellow"] { background: var(--tint-yellow); color: var(--tint-yellow-text); }
.signal-card__icon[data-tint="orange"] { background: var(--tint-orange); color: var(--tint-orange-text); }
.signal-card__icon[data-tint="pink"] { background: var(--tint-pink); color: var(--tint-pink-text); }

/* ---- signal list (archive: past observations) ----
   Small thumbnail + short title, nothing else -- deliberately lighter and
   quieter than the "this week" cards above (smaller radius, no shadow, a
   thin border only) so the archive never competes for attention. auto-fill
   with a small minmax basis gives many columns on desktop and naturally
   narrows to 2 (or 1, at the very smallest phone widths) on mobile with no
   separate breakpoint needed. */

.signal-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 14px;
}

.signal-list .signal-card {
  flex-direction: column;
  width: auto;
  border-radius: var(--radius-sm);
  box-shadow: none;
}

.signal-list .signal-card:hover {
  box-shadow: var(--shadow-card);
  transform: translateY(-2px);
}

.signal-list .signal-card__icon {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  border-radius: 0;
  margin-bottom: 0;
}

.signal-list .signal-card__icon .icon {
  width: 26px;
  height: 26px;
}

.signal-list .signal-card__image {
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.signal-list .signal-card__body {
  min-width: 0;
  padding: 10px 12px 12px;
}

.signal-list .signal-card__date {
  display: block;
  font-size: 0.72rem;
  color: var(--color-text-faint);
  margin-bottom: 2px;
}

.signal-list .signal-card__title {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

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

.detail {
  padding: 36px 0 64px;
}

.detail__back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: 16px;
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--color-accent-strong);
  text-decoration: none;
}

.detail__back:hover {
  text-decoration: underline;
}

/* A signal with an "image" shows it here, full width, in place of the
   round icon badge below (detail__hero); no image falls back to the icon
   so older/future entries without artwork still render correctly. */
.detail__image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}

.detail__hero {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.detail__icon {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.detail__icon .icon {
  width: 34px;
  height: 34px;
}

.detail__icon[data-tint="mint"] { background: var(--tint-mint); color: var(--tint-mint-text); }
.detail__icon[data-tint="blue"] { background: var(--tint-blue); color: var(--tint-blue-text); }
.detail__icon[data-tint="yellow"] { background: var(--tint-yellow); color: var(--tint-yellow-text); }
.detail__icon[data-tint="orange"] { background: var(--tint-orange); color: var(--tint-orange-text); }
.detail__icon[data-tint="pink"] { background: var(--tint-pink); color: var(--tint-pink-text); }

.detail h1 {
  font-family: var(--font-sans);
  font-size: clamp(1.5rem, 3.8vw, 2.1rem);
  line-height: 1.5;
  margin: 0 0 12px;
  font-weight: 800;
  color: var(--color-text);
}

.detail .tag-row {
  margin-bottom: 18px;
}

.detail__now {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--color-accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.98rem;
  padding: 10px 18px;
  border-radius: 999px;
  margin-bottom: 28px;
}

.detail__now::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fff;
  flex: none;
}

.detail__block {
  margin-bottom: 22px;
  padding: 24px;
  border-radius: var(--radius-lg);
}

.detail__block--change { background: var(--tint-yellow); color: var(--tint-yellow-text); }
.detail__block--status { background: var(--tint-mint); color: var(--tint-mint-text); }
.detail__block--undecided { background: var(--tint-orange); color: var(--tint-orange-text); }

.detail__block h2 {
  font-size: 1.05rem;
  margin: 0 0 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail__block p,
.detail__block ul {
  color: var(--color-text);
  font-size: 1rem;
}

.detail__block p {
  margin: 0;
}

.detail__list {
  margin: 0;
  padding-left: 1.3em;
}

.detail__list li {
  margin-bottom: 8px;
}

.detail__list li:last-child {
  margin-bottom: 0;
}

.detail__meta-block {
  margin-bottom: 28px;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.detail__meta-block strong {
  color: var(--color-text);
}

.detail__sources-heading {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--color-accent-strong);
  margin: 8px 0 16px;
}

.source-list {
  list-style: none;
  margin: 0 0 28px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.source-list li {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  background: var(--color-surface);
}

.source-list a {
  font-weight: 700;
  display: flex;
  align-items: center;
  min-height: 44px;
}

.source-list__page {
  display: block;
  color: var(--color-text-faint);
  font-size: 0.84rem;
  margin-top: 3px;
}

.detail__disclaimer {
  padding: 20px 22px;
  border-radius: var(--radius-lg);
  background: var(--color-surface-alt);
  border: 1px dashed var(--color-border);
}

.detail__disclaimer h2 {
  font-size: 0.98rem;
  margin: 0 0 8px;
  font-weight: 800;
  color: var(--color-text-muted);
}

.detail__disclaimer p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.92rem;
}

.detail__not-found {
  padding: 60px 0;
  text-align: center;
  color: var(--color-text-muted);
}

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

.about-hero {
  padding: 44px 0 8px;
}

.about-hero p {
  font-family: var(--font-sans);
  font-size: clamp(1.3rem, 3.4vw, 1.7rem);
  font-weight: 800;
  line-height: 1.6;
  color: var(--color-accent-strong);
  margin: 0 0 8px;
}

/* ch is unreliable for CJK width (the "0" glyph it's based on renders far
   narrower than a full-width Japanese character), so cap desktop width in
   px instead -- wide enough for the current one-line headline, still
   bounded on ultra-wide screens. Mobile wraps naturally: the container
   itself is already narrower than this. */
@media (min-width: 800px) {
  .about-hero p {
    max-width: 800px;
  }
}

.about-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  padding: 20px 0 44px;
}

.about-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
}

.about-card__icon {
  font-size: 1.8rem;
  margin-bottom: 10px;
  line-height: 1;
}

.about-card h2 {
  font-size: 1.05rem;
  margin: 0 0 8px;
  font-weight: 800;
  color: var(--color-accent-strong);
}

.about-card p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

.prose {
  padding: 8px 0 64px;
  max-width: 68ch;
}

.prose h2 {
  font-size: 1.15rem;
  margin: 30px 0 10px;
  font-weight: 800;
  color: var(--color-accent-strong);
}

.prose p {
  margin: 0 0 14px;
  color: var(--color-text);
}

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

.site-footer {
  border-top: 3px solid var(--color-accent-soft);
  padding: 28px 0 60px;
  color: var(--color-text-faint);
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--color-text-faint);
}

.site-footer__inner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---- responsive ---- */

@media (max-width: 720px) {
  .hero__inner {
    flex-direction: column;
    text-align: left;
  }

  .hero__visual {
    order: -1;
    max-width: 300px;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 16px;
  }

  .hero {
    padding: 32px 0 24px;
  }

  .section {
    padding: 26px 0;
  }

  .signal-grid .signal-card {
    width: 100%;
    flex-basis: 100%;
  }

  .signal-list {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
  }

  .detail__block {
    padding: 20px;
  }

  .about-cards {
    grid-template-columns: 1fr;
  }
}

/* ---- stage matrix page ----
   Prefixes .matrix- / .stage- / .filter- are used throughout so this
   section can be edited without touching any other page's styles. The
   matrix table is information-dense by nature; it favors readability over
   the cream/rounded-card look used elsewhere, while keeping the same
   color palette so it still reads as part of the same site. */

.matrix-page {
  padding: 36px 0 64px;
}

.matrix-hero {
  padding-bottom: 20px;
}

.matrix-hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  line-height: 1.5;
  margin: 0 0 14px;
  font-weight: 800;
  color: var(--color-accent-strong);
}

.matrix-hero__subtitle {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 14px;
}

.matrix-hero__lead {
  max-width: 60ch;
  color: var(--color-text-muted);
  margin: 0 0 10px;
}

.matrix-hero__aside {
  max-width: 60ch;
  color: var(--color-text-faint);
  font-size: 0.92rem;
  margin: 0 0 14px;
}

.matrix-hero__note {
  display: inline-block;
  color: var(--color-text-faint);
  font-size: 0.85rem;
  margin: 0;
  padding: 6px 14px;
  background: var(--color-surface-alt);
  border-radius: 999px;
}

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

.matrix-legend {
  padding: 4px 0 22px;
}

.matrix-legend__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
}

.matrix-legend__item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--color-text-muted);
}

.matrix-legend__guide-link {
  margin: 12px 0 0;
  font-size: 0.9rem;
  font-weight: 600;
}

/* ---- stage chips (used in legend, table cells, cards, modal) ----
   Shape/glyph differs per state, never color alone, so the meaning still
   reads in grayscale or for color-blind viewers. */

.stage-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  flex: none;
}

.stage-chip--current {
  background: var(--color-accent);
  color: #fff;
  font-size: 0.7rem;
}

/* "current stage" and "confirmed evidence" both true for the same stage,
   with no room to show ● and ✓ separately in one cell. Reuses the
   ●/current fill (this stage really is the current position) plus the
   ✓/confirmed border color as a ring, so it reads as "current, plus
   confirmed" rather than a brand-new unrelated color. The ◎ glyph itself
   is also a distinct shape from both ● and ✓, so the state is never
   color-only. */
.stage-chip--current-confirmed {
  background: var(--color-accent);
  color: #fff;
  font-size: 0.7rem;
  box-shadow: 0 0 0 2px var(--tint-mint-text);
}

.stage-chip--confirmed {
  background: var(--tint-mint);
  color: var(--tint-mint-text);
  border: 1px solid var(--tint-mint-text);
}

.stage-chip--unclear {
  background: var(--tint-orange);
  color: var(--tint-orange-text);
  font-weight: 800;
}

.stage-chip--empty {
  background: transparent;
  border: 1px dashed var(--color-border);
}

/* ---- filters ---- */

.matrix-filters {
  padding-bottom: 22px;
}

.filter-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.filter-quick__btn {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  min-height: 40px;
  cursor: pointer;
}

.filter-quick__btn:hover {
  background: var(--color-accent-soft);
}

.filter-quick__btn[aria-pressed="true"] {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 180px;
  min-width: 0;
}

.filter-field--search {
  flex: 2 1 260px;
}

.filter-field--reset {
  flex: 0 0 auto;
  justify-content: flex-end;
}

.filter-field label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-text-muted);
}

.filter-search,
.filter-select {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.95rem;
  font-family: inherit;
}

.filter-reset {
  min-height: 44px;
  padding: 8px 18px;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-accent-strong);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}

.filter-reset:hover {
  background: var(--color-accent-soft);
}

.filter-results {
  margin: 14px 2px 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--color-accent-strong);
}

/* ---- table legends (stage numbers, bureau letters, domain kana) ----
   All three desktop-table code systems get their own card so nothing is
   silently unlabeled; codes themselves are assigned in JS from the
   current dataset. Hidden on mobile (see breakpoint below) since mobile
   cards show full names directly and don't use these codes. The 3 cards
   don't need to match height -- 所管局 (17 values) naturally runs taller
   than 分野 (14) or ステージ (10). */

.matrix-table-legends {
  margin: 0 0 10px;
  display: grid;
  grid-template-columns: 1.1fr 1.4fr 1fr;
  gap: 14px;
  align-items: start;
}

.matrix-table-legends__card {
  padding: 10px 14px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.matrix-table-legends__heading {
  margin: 0 0 6px;
  font-weight: 800;
  color: var(--color-accent-strong);
}

.matrix-table-legends__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.matrix-table-legends__item {
  white-space: nowrap;
}

.matrix-table-legends__code {
  font-weight: 800;
  color: var(--color-accent-strong);
}

/* ---- desktop table ----
   table-layout: fixed + an explicit <colgroup> (built in JS) keeps every
   column from 事業名 to 詳細 inside the viewport at 1280-1440px with no
   horizontal scroll -- .matrix-table-wrap intentionally does NOT set
   overflow-x. */

.matrix-table-wrap {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.matrix-table {
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 0.85rem;
}

.matrix-table th,
.matrix-table td {
  padding: 11px 8px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matrix-table thead th {
  background: var(--color-surface-alt);
  color: var(--color-accent-strong);
  font-weight: 800;
  position: sticky;
  top: 0;
  z-index: 2;
}

.matrix-table__stage-head {
  writing-mode: horizontal-tb;
  font-size: 0.85rem;
  text-align: center;
  cursor: help;
}

.matrix-table__stage-cell {
  text-align: center;
}

/* Stage chips are slightly smaller inside the table only (legend/modal/
   card chips are untouched) so 10 numbered columns fit comfortably. */
.matrix-table__stage-cell .stage-chip {
  width: 20px;
  height: 20px;
  font-size: 0.62rem;
}

.matrix-table__sticky {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--color-surface);
  white-space: normal;
  overflow: visible;
}

/* 事業名 is fixed to 1 line so every row reads at the same height. Most
   titles fit at the table's base font-size as-is; longer ones are shrunk
   in JS (fitTableTitles(), measured against actual DOM width, never by
   character count) down to an 11px floor, and only a title that still
   doesn't fit at that floor falls back to this text-overflow:ellipsis.
   The full title is always available via the title attribute and in the
   detail modal. */
.matrix-table__sticky .matrix-row-title {
  display: block;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

/* 所管局/分野 are symbolized to A/B/C.../ア/イ/ウ... (see buildLegends());
   full names are always in the title attribute, the legends above the
   table, and the detail modal. */
.matrix-table__code-cell {
  text-align: center;
  font-weight: 700;
  cursor: help;
}

.matrix-table thead .matrix-table__sticky {
  z-index: 3;
  background: var(--color-surface-alt);
}

.matrix-row-btn {
  background: none;
  border: none;
  padding: 6px 4px;
  margin: -6px -4px;
  font: inherit;
  font-weight: 700;
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
  white-space: normal;
  border-radius: 6px;
}

.matrix-row-btn:hover {
  color: var(--color-accent-strong);
  text-decoration: underline;
}

.matrix-row-btn--ghost {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-accent-strong);
  white-space: nowrap;
}

/* 事業名: a plain, non-interactive-looking element (not a <button> --
   see matrix.js) that only triggers the 市民への変化 popover on
   hover/focus. Visual weight/size intentionally matches the old
   .matrix-row-btn look (bold, same padding so nothing visibly shifts),
   but with no pointer cursor and no link-style hover, since it has no
   click action to invite. */
.matrix-row-title {
  display: inline-block;
  padding: 6px 4px;
  margin: -6px -4px;
  font-weight: 700;
  color: var(--color-text);
  cursor: default;
  border-radius: 6px;
}

.matrix-table__action {
  text-align: center;
}

/* ---- mobile cards (hidden on desktop; table hidden on mobile below) ---- */

.matrix-cards {
  display: none;
}

.matrix-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 14px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-card);
}

.matrix-card__title {
  margin: 0 0 6px;
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--color-text);
}

.matrix-card__meta {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.matrix-card__now {
  display: inline-block;
  margin: 0 0 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-accent-strong);
  background: var(--color-accent-soft);
  padding: 4px 12px;
  border-radius: 999px;
}

.matrix-card__stagerow {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.matrix-card__stagechip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.matrix-card__stagechip .stage-chip {
  width: 20px;
  height: 20px;
  font-size: 0.68rem;
}

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

.matrix-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 24, 14, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 100;
}

.matrix-modal-backdrop[hidden] {
  display: none;
}

.matrix-modal {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  max-width: 640px;
  width: 100%;
  padding: 30px 26px;
  box-shadow: var(--shadow-card-hover);
}

.matrix-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  color: var(--color-text);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.matrix-modal__close:hover {
  background: var(--color-accent-soft);
}

.matrix-modal__title {
  margin: 0 40px 18px 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-accent-strong);
}

.matrix-modal__meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 0 0 20px;
  font-size: 0.92rem;
}

.matrix-modal__meta dt {
  font-weight: 700;
  color: var(--color-text-faint);
}

.matrix-modal__meta dd {
  margin: 0;
  color: var(--color-text);
}

.matrix-modal__section {
  margin-bottom: 18px;
}

.matrix-modal__section h3 {
  font-size: 0.95rem;
  margin: 0 0 8px;
  font-weight: 800;
  color: var(--color-accent-strong);
}

.matrix-modal__section p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--color-text);
}

.matrix-modal__stagelist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.matrix-modal__stagelist li {
  display: flex;
  align-items: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.matrix-modal__link a {
  font-weight: 700;
}

/* ---- title hover/focus popover (市民への変化 only) ----
   A single instance lives once in the DOM (see matrix.html) and is
   repositioned/relabeled per row by matrix.js, rather than clipping inside
   a table cell -- table cells here don't set overflow, but position:fixed
   + JS-measured placement is what keeps this from ever being cut off at
   a viewport edge, which a cell-relative absolute position could not
   guarantee. Deliberately smaller and quieter than .matrix-modal so the
   two are never confused: this is a glance-only aid, the modal is the
   full detail view. visibility (not display) is toggled so its size can
   be measured via getBoundingClientRect() before it's shown, avoiding a
   flash at the wrong position. */
.matrix-title-popover {
  position: fixed;
  z-index: 60;
  max-width: 420px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  opacity: 0;
  visibility: hidden;
  transition: opacity 130ms ease;
  pointer-events: none;
}

.matrix-title-popover.is-visible {
  opacity: 1;
  visibility: visible;
}

.matrix-title-popover__heading {
  margin: 0 0 6px;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--color-accent-strong);
}

.matrix-title-popover__body {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--color-text);
}

/* ---- "前回更新から動いた案件" layer (data/stage_matrix_changes.json) ----
   Sits on top of the stage symbols without touching them: ●/✓/◎/?/blank
   keep their own chip colors; only the row/cell/card background and a
   thin inset ring mark what moved. */

.filter-changed {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  margin: 12px 2px 0;
}

.filter-changed[hidden] {
  display: none;
}

.filter-changed__label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--color-text);
  cursor: pointer;
}

.filter-changed__checkbox {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--color-accent);
  cursor: pointer;
}

.filter-changed__period {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.matrix-table__row--changed td,
.matrix-table__row--changed .matrix-table__sticky {
  background: var(--color-changed-row);
}

.matrix-table__row--changed td.matrix-table__stage-cell--changed {
  background: var(--color-changed-cell);
  box-shadow: inset 0 0 0 2px var(--color-changed-ring);
  cursor: help;
}

.matrix-card--changed {
  background: var(--color-changed-row);
  border-color: var(--color-changed-ring);
}

.matrix-card__badge {
  display: inline-block;
  margin: 0 0 8px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  background: var(--color-changed-badge);
  color: var(--color-changed-badge-text);
  border: 1px solid var(--color-changed-ring);
}

.matrix-card__stagechip--changed .stage-chip {
  box-shadow: 0 0 0 2px var(--color-changed-ring);
}

/* ---- responsive: switch table to cards under 720px ---- */

@media (max-width: 720px) {
  .matrix-table-wrap {
    display: none;
  }

  .matrix-table-legends {
    display: none;
  }

  .matrix-cards {
    display: block;
  }

  .filter-bar {
    padding: 16px;
  }

  .filter-field {
    flex: 1 1 100%;
  }

  .filter-field--reset {
    justify-content: stretch;
  }

  .filter-reset {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .matrix-page {
    padding: 24px 0 48px;
  }

  .matrix-modal {
    padding: 24px 18px;
  }
}

/* ---- matrix guide page ("進捗図の見方") ----
   Reuses the site's card/tint language (about-card, stage-chip) rather
   than inventing a new visual style, so this explainer reads as part of
   the same site instead of a separate "documentation" skin. */

.guide-page {
  padding: 36px 0 64px;
}

.guide-backlink {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: 8px;
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--color-accent-strong);
  text-decoration: none;
}

.guide-backlink:hover {
  text-decoration: underline;
}

.guide-backlink--bottom {
  margin-top: 8px;
}

.guide-hero {
  padding: 16px 0 8px;
}

.guide-hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  line-height: 1.5;
  margin: 0 0 16px;
  font-weight: 800;
  color: var(--color-accent-strong);
}

.guide-hero__lead {
  max-width: 62ch;
  color: var(--color-text-muted);
  margin: 0 0 12px;
}

.guide-hero__lead:last-child {
  margin-bottom: 0;
}

.guide-section {
  padding: 28px 0;
}

.guide-section h2 {
  font-size: 1.35rem;
  margin: 0 0 18px;
  font-weight: 800;
  color: var(--color-accent-strong);
}

/* ---- symbol cards (●, ✓, 空欄) ---- */

.guide-symbols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.guide-symbol-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
}

.guide-symbol-card__glyph {
  width: 34px;
  height: 34px;
  font-size: 1rem;
  margin-bottom: 12px;
}

.guide-symbol-card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--color-text);
}

.guide-symbol-card p {
  margin: 0 0 8px;
  font-size: 0.92rem;
  color: var(--color-text-muted);
}

.guide-symbol-card p:last-child {
  margin-bottom: 0;
}

.guide-symbol-card__warn {
  font-weight: 700;
  color: var(--tint-orange-text);
}

/* ---- "not an official 10-step scale" note ---- */

.guide-note {
  background: var(--color-surface-alt);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin: 0 0 22px;
}

.guide-note p {
  margin: 0 0 8px;
  font-size: 0.88rem;
  color: var(--color-text-muted);
}

.guide-note p:last-child {
  margin-bottom: 0;
}

/* ---- 1-10 stage cards: 2 columns desktop, 1 column mobile ---- */

.guide-stages {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.guide-stage-card {
  display: flex;
  gap: 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}

.guide-stage-card__num {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.guide-stage-card__body h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 800;
  color: var(--color-text);
}

.guide-stage-card__body p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

/* ---- "how to read it" examples ---- */

.guide-examples {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.guide-example {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}

.guide-example__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.guide-example__chips li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--color-text);
}

.guide-example__text {
  margin: 0;
  font-size: 0.92rem;
  color: var(--color-text-muted);
}

.guide-footnote {
  padding-top: 6px;
}

.guide-footnote p {
  max-width: 62ch;
  color: var(--color-text-muted);
  font-size: 0.92rem;
  margin: 0 0 10px;
}

.guide-footnote p:last-child {
  margin-bottom: 0;
}

@media (max-width: 720px) {
  .guide-stages {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .guide-page {
    padding: 24px 0 48px;
  }
}
