@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+JP:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap");

:root {
  --bg: #ffffff;
  --ink: #14161a;
  --muted: #6b7280;
  --muted-2: #9aa1ab;
  --desc: #4a4f57;
  --desc-2: #8b929b;
  --line: #e3e5e8;
  --line-soft: #f0f1f3;
  --navy: #1b2a4a;
  --navy-soft: #3a4a6b;
  --amber: #e8a13d;
  --red: #d4482e;
  --actual: var(--navy);
  --forecast: var(--amber);
  --forecast-dashed: var(--amber);
  --hover-bg: #f6f8fb;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans JP", sans-serif;
  line-height: 1.6;
}

a { color: inherit; }

.mono {
  font-family: "IBM Plex Mono", monospace;
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

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

.site-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo { display: block; flex-shrink: 0; width: 40px; height: 40px; }

.brand-name {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: "IBM Plex Mono", monospace;
}

.brand-name-main { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.brand-name-slash { font-size: 13px; color: var(--amber); }

.brand-tag {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.24em;
  color: var(--muted-2);
  margin-top: 3px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.lang-toggle { display: flex; gap: 6px; }

.lang-btn {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted-2);
  cursor: pointer;
}

.lang-btn.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.site-nav {
  display: flex;
  gap: 18px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--muted);
}

.nav-current { color: var(--ink); }
.nav-link { color: var(--muted); text-decoration: none; }
.nav-link:hover { opacity: 0.7; }

/* ---- hero (開幕演出) ----
   通常のデータチャート(白地)と役割が違うことを示すため、ここだけ紺の
   計器パネル調。色は見通し/実績の区別のみで、善悪の示唆には使わない */

.hero {
  position: relative;
  margin-top: 20px;
  background: var(--navy);
  padding: 16px 18px 10px;
}

#hero-chart { display: block; width: 100%; height: auto; }

.hero-caption {
  margin-top: 2px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  text-align: right;
  letter-spacing: 0.04em;
}

.hero-copy {
  position: absolute;
  left: 6%;
  bottom: 13%;
  max-width: 72%;
  color: #f4f5f8;
  font-size: clamp(1.4rem, 4.4vw, 3rem);
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: 0.02em;
  white-space: pre-line;
  /* 折れ線と重なる位置でも読めるように、背景色でにじませて分離する */
  text-shadow: 0 0 18px rgba(27, 42, 74, 0.95), 0 0 6px rgba(27, 42, 74, 0.95);
}

.hero .zero-line { stroke: rgba(255, 255, 255, 0.35); }
.hero .axis-line { stroke: rgba(255, 255, 255, 0.1); }
.hero .grid-line-y { stroke: rgba(255, 255, 255, 0.07); }
.hero .axis-label { fill: rgba(255, 255, 255, 0.5); }
.hero .line-actual { stroke: #e6e9f0; }
.hero .end-label-actual { fill: #e6e9f0; }

/* 見通しも実線で描く(色は通常チャートと同じ琥珀/白の区別のみ) */
.hero .line-forecast { stroke-opacity: 0.9; stroke-dasharray: none; }

.hero-spark {
  fill: none;
  stroke: #e6e9f0;
  stroke-width: 1.5;
  transform-box: fill-box;
  transform-origin: center;
}

.hero-spark.on {
  animation: hero-spark-pulse 1.8s ease-out infinite;
}

@keyframes hero-spark-pulse {
  0% { transform: scale(1); opacity: 0.9; }
  75% { transform: scale(4.5); opacity: 0; }
  100% { transform: scale(4.5); opacity: 0; }
}

/* ---- lead / callout ---- */

.lead {
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--desc);
  margin: 18px 0 0;
}

.callout {
  display: flex;
  gap: 22px;
  align-items: flex-start;
  margin: 16px 0 0;
  border-left: 2px solid var(--amber);
  background: #fbfbfa;
  padding: 16px 22px;
  flex-wrap: wrap;
}

.callout-title {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--amber);
  white-space: nowrap;
  padding-top: 2px;
}

.callout-body {
  font-size: 13px;
  line-height: 1.8;
  color: var(--desc);
  margin: 0;
  max-width: 860px;
}

/* ---- indicators heading ---- */

.indicators-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 40px 0 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.indicators-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.indicators-latest {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--muted-2);
}

/* ---- card grid ---- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

@media (max-width: 760px) {
  .card-grid { grid-template-columns: 1fr; }
}

.card {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  padding: 20px 20px 16px;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

a.card:hover {
  border-color: var(--navy);
  background: var(--hover-bg);
  box-shadow: 0 8px 22px rgba(27, 42, 74, 0.1);
  transform: translateY(-2px);
}

.card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.card-name {
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.card-fy {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--muted-2);
}

.card-desc {
  font-size: 11.5px;
  color: var(--desc-2);
  line-height: 1.55;
  margin-top: 9px;
  min-height: 36px;
}

.card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 12px 0 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  font-family: "IBM Plex Mono", monospace;
}

.card-stats > div:first-child { text-align: left; }
.card-stats > div:nth-child(2) { text-align: center; }
.card-stats > div:last-child { text-align: right; }

.stat-label {
  font-size: 10px;
  color: var(--muted-2);
  letter-spacing: 0.1em;
  text-align: left;
}

.stat-label-gap { color: var(--amber); }

.stat-value {
  font-size: 18px;
  margin-top: 2px;
}

.stat-value-gap { color: var(--amber); font-weight: 600; }

.card-spark {
  width: 100%;
  display: block;
  height: 56px;
}

.spark-forecast {
  fill: none;
  stroke: var(--forecast-dashed);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  stroke-opacity: 0.65;
}

.spark-actual {
  fill: none;
  stroke: var(--navy);
  stroke-width: 2;
}

.spark-forecast-dot { fill: var(--forecast-dashed); opacity: 0.65; }
.spark-actual-dot { fill: var(--navy); }

.card-note {
  font-size: 10.5px;
  color: var(--muted-2);
  margin-top: 10px;
}

.card-source-link {
  display: inline-block;
  margin-top: 6px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  color: var(--navy);
  text-decoration: none;
}
.card-source-link:hover { opacity: 0.7; }

.card-pending {
  border-style: dashed;
  color: var(--muted);
}

.card-note-fertility {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  font-family: "IBM Plex Mono", monospace;
}

.card-pending-badge {
  display: inline-block;
  margin-top: 16px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  border: 1px dashed var(--line);
  padding: 3px 8px;
}

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

.legend-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 22px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--muted);
}

.legend-item { display: flex; align-items: center; gap: 7px; }

.legend-swatch { width: 18px; height: 0; display: inline-block; }
.legend-swatch-forecast { border-top: 1.5px dashed var(--forecast-dashed); }
.legend-swatch-actual { height: 2px; background: var(--navy); }
.legend-swatch-vintage { border-top: 1.5px solid var(--amber); }

.fertility-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-top: 22px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--muted);
}

.site-footer-row {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  margin-top: 36px;
  padding-top: 16px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--muted-2);
}

.footer-about, .footer-src { text-decoration: none; }
.footer-about:hover, .footer-src:hover { opacity: 0.7; }

/* ==================== chart detail page ==================== */

.chart-back {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  display: inline-block;
  margin-top: 18px;
}
.chart-back:hover { opacity: 0.7; }

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.75rem;
  font-family: "IBM Plex Mono", monospace;
}

.stat-chip {
  display: flex;
  align-items: baseline;
  gap: 0.45em;
  font-size: 0.9rem;
}

.stat-chip-dot {
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  display: inline-block;
}

.stat-chip-dot-actual { background: var(--navy); }
.stat-chip-dot-forecast { background: var(--amber); }

.stat-chip-label { color: var(--muted); font-size: 0.75rem; }
.stat-chip-value { font-weight: 600; }

.stat-chip-diff .stat-chip-label,
.stat-chip-diff .stat-chip-value {
  color: var(--amber);
}
.stat-chip-diff .stat-chip-value { font-weight: 700; }

/* left/right padding is computed and set by chart.js at runtime — the slider's
   value range (years with a forecast) can start later than the chart's x-axis
   domain (years with any data), so the inset isn't a fixed constant */
.controls {
  margin-top: 0.85rem;
}

#year-select {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 2px;
  background: var(--line);
  outline: none;
  margin: 0;
}

#year-select::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--amber);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--amber);
  cursor: pointer;
}

#year-select::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--amber);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--amber);
  cursor: pointer;
}

#year-select::-moz-range-track {
  height: 2px;
  background: var(--line);
}

.chart-section { margin-top: 1.5rem; }

.chart-title { margin: 0; font-size: 1.3rem; font-weight: 600; }

.chart-desc {
  margin: 0.3rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.chart-wrap {
  margin-top: 1rem;
  border: 1px solid var(--line);
  background: var(--bg);
}

#chart { display: block; width: 100%; height: auto; }

.readout {
  margin-top: 1.1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-end;
  gap: 0.6rem 1.5rem;
}

.readout-year {
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.axis-line { stroke: var(--line); stroke-width: 1; }
.axis-label { fill: var(--muted-2); font-size: 11px; font-family: "IBM Plex Mono", monospace; }
.grid-line-y { stroke: var(--line-soft); stroke-width: 1; }
.zero-line { stroke: var(--line); stroke-width: 1; }
.end-label { font-size: 11px; font-family: "IBM Plex Mono", monospace; font-weight: 600; }
.end-label-actual { fill: var(--navy); }
.end-label-forecast {
  fill: var(--amber);
  transition: transform 0.4s ease, opacity 0.3s ease;
}

.line-forecast {
  fill: none;
  stroke: var(--forecast-dashed);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  stroke-linejoin: round;
  stroke-linecap: round;
  stroke-opacity: 0.65;
}

.line-actual {
  fill: none;
  stroke: var(--navy);
  stroke-width: 1.75;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.line-actual-dot { fill: var(--navy); opacity: 0.6; }
.line-forecast-dot { fill: var(--amber); opacity: 0.65; }

.gap-label { fill: var(--muted-2); font-size: 10px; font-family: "IBM Plex Mono", monospace; }

.line-forecast-vintage {
  fill: none;
  stroke: var(--amber);
  stroke-width: 1.25;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.vintage-label { fill: var(--amber); font-size: 9px; font-family: "IBM Plex Mono", monospace; }

.line-forecast-point {
  fill: var(--amber);
  stroke: var(--bg);
  stroke-width: 2;
  transition: cx 0.4s ease, cy 0.4s ease, opacity 0.3s ease;
}
.line-actual-point {
  fill: var(--navy);
  stroke: var(--bg);
  stroke-width: 2;
  transition: cx 0.4s ease, cy 0.4s ease, opacity 0.3s ease;
}
.link-line {
  stroke: var(--amber);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0.5;
  transition: x1 0.4s ease, y1 0.4s ease, x2 0.4s ease, y2 0.4s ease, opacity 0.3s ease;
}

.readout-notes {
  margin-top: 0.6rem;
  min-height: 2.5rem;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--muted);
  text-align: right;
}

.readout-source {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line-soft);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  line-height: 1.7;
  color: var(--muted-2);
  word-break: break-all;
}

.readout-source a { color: var(--muted-2); }

/* ==================== about page ==================== */

.page-narrow { max-width: 760px; }

.about-body { margin-top: 2.5rem; }

.about-title {
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0 0 1.5rem;
}

.about-lead {
  font-size: 1rem;
  line-height: 1.9;
  color: var(--ink);
}

.about-more {
  margin-top: 1.75rem;
  border-top: 1px solid var(--line);
  padding-top: 1.25rem;
}

.about-more > summary {
  cursor: pointer;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  list-style: none;
}

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

.about-more > summary::before {
  content: "+ ";
  color: var(--amber);
}

.about-more[open] > summary::before {
  content: "− ";
}

.about-more-body {
  margin-top: 1.5rem;
}

.about-more-body p {
  font-size: 0.94rem;
  line-height: 1.9;
  color: var(--desc);
}

.about-more-body h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 2rem;
  color: var(--ink);
}

/* ==================== corrections page ==================== */

.correction-empty {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 2rem;
}

.correction-item {
  padding: 1.1rem 0;
  border-top: 1px solid var(--line);
}

.correction-item:last-child { border-bottom: 1px solid var(--line); }

.correction-date {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.correction-target {
  margin-top: 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.correction-diff {
  margin-top: 0.4rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
}

.correction-before { color: var(--muted); text-decoration: line-through; }
.correction-arrow { color: var(--muted-2); margin: 0 0.5em; }
.correction-after { color: var(--ink); font-weight: 600; }

.correction-reason {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--desc);
  line-height: 1.7;
}

.correction-link {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
