/* stack.html だけが読むページ固有のスタイル。
 *
 * 土台は assets/doc-dark.css。読み込む順は style.css → doc-dark.css → このファイル。
 * 順を変えるとトークンの上書きが効かない。
 *
 * **リテラル色をここに書かないこと。** 色は doc-dark.css の .hx { } だけが持つ。
 * ここで直接 #hex を書くと、配色を直したときにこのページだけ取り残される。
 *
 * クラス名は st- 接頭辞。harness の hx- 固有部分・skills の sk-・loop の lp- と
 * 衝突させないため（共通部分の hx- はそのまま使う）。
 *
 * メディアクエリは**広い方から**書く（1100 → 900 → 640）。逆順だと 375px でも
 * 後ろの広い方の指定が勝つ。375px の実効描画幅は 343px。
 */

/* KPI は 5 枚を 1 行に。共通側の既定値（4）に黙って頼らず、ページ側で明示する。
   2 列は作らない（343px の半分では数字と説明が折れる）。 */
.hx-kpis { --hx-kpi-cols: 5; }

.st-intro { padding: 34px 0 0; }
.st-intro .hx-kpis { margin: 26px 0 0; }
.st-intro .hx-note { margin: 22px 0 0; }

/* 1 つの節に図やリストが 2 つ以上あるとき、2 つ目の前に置く導入文 */
.st-fig-lead,
.st-miss-lead { padding-top: 26px; }

.st-intro code,
.hx-sec-note code {
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: var(--hx-r-sm);
  background: var(--hx-sunken-soft);
  font-family: var(--hx-mono);
  font-size: 0.88em;
  color: var(--hx-body-2);
}

/* ---------- 図 1 母数の帯 ---------- */

.st-base {
  margin: 0;
  padding: 0;
  list-style: none;
}

.st-base-row {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 44px;
  gap: 4px 14px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.st-base-row:first-child { border-top: 0; }

.st-base-name {
  font-size: 13px;
  color: var(--hx-body-2);
}

.st-base-bar {
  display: flex;
  height: 14px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--hx-r-sm);
}
.st-base-bar i { background: var(--accent-soft); border-right: 1px solid var(--accent); }
/* 斜線＝測れていない・数えられなかった。破線（意図的に空）とは別の意味なので混ぜない */
.st-base-bar .is-gap { background: var(--hx-hatch); }

.st-base-n {
  font-size: 14px;
  font-weight: 700;
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.st-base-note {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--hx-subtle);
}

/* ---------- 図 2 役割別の横棒 ---------- */

.st-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.st-group {
  padding: 16px 18px 18px;
  border: 1px solid var(--border);
  border-radius: var(--hx-r-lg);
  background: var(--hx-card);
  box-shadow: var(--hx-shadow);
}

.st-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--hx-body-2);
}
.st-group-head .ms { font-size: 18px; color: var(--muted); }
.st-group-n {
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  color: var(--hx-subtle);
  font-variant-numeric: tabular-nums;
}

.st-bars {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.st-bar {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) 26px;
  gap: 10px;
  align-items: center;
}

.st-bar-name {
  overflow: hidden;
  font-size: 12px;
  color: var(--hx-body);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.st-bar-track {
  height: 9px;
  border-radius: var(--hx-r-sm);
  background: var(--hx-sunken-soft);
}
/* 棒はどれも同じ色。濃さで量を表さない（長さと隣の数字がその役をしている）。
   各役割でいちばん多い 1 本だけ差し色にする。 */
.st-bar-track i {
  display: block;
  height: 100%;
  min-width: 3px; /* 1 件でも消えないように */
  border-radius: var(--hx-r-sm);
  background: var(--border-strong);
}
.st-bar.is-top .st-bar-name { color: var(--text); font-weight: 500; }
.st-bar.is-top .st-bar-track i { background: var(--accent); }

.st-bar-n {
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  color: var(--hx-body-2);
  font-variant-numeric: tabular-nums;
}

.st-engine-note {
  display: flex;
  gap: 6px;
  margin: 16px 0 10px;
  padding: 10px 12px;
  border-radius: var(--hx-r-md);
  background: var(--hx-sunken-soft);
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--hx-subtle);
}
.st-engine-note .ms { flex: none; font-size: 15px; }
.st-engine-note b { color: var(--hx-body-2); font-weight: 500; }

.st-bars.is-engine .st-bar-track i { background: var(--hx-dash); }
.st-bars.is-engine .st-bar.is-top .st-bar-track i { background: var(--border-strong); }
.st-bars.is-engine .st-bar.is-top .st-bar-name { font-weight: 400; color: var(--hx-body); }

/* ---------- 図 3 役割ごとの偏り ---------- */

/* ⚠ このページで唯一、母数が作品の総数ではない図（その役割を台帳に書いている作品で割る）。
   図 2 の棒とは別の割合なので、棒を並べず帯 1 本に絞って、ひと目で別物と分かるようにしてある。 */
.st-conc {
  margin: 0;
  padding: 0;
  list-style: none;
}

.st-conc-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 66px 46px 44px;
  gap: 4px 14px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.st-conc-row:first-child { border-top: 0; }

.st-conc-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--hx-body-2);
}
.st-conc-name .ms { font-size: 17px; color: var(--muted); }

.st-conc-bar {
  display: flex;
  height: 14px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--hx-r-sm);
}
.st-conc-bar i { background: var(--accent-soft); border-right: 1px solid var(--accent); }

.st-conc-n,
.st-conc-kinds {
  font-size: 12px;
  text-align: right;
  color: var(--hx-subtle);
  font-variant-numeric: tabular-nums;
}

.st-conc-pct {
  font-size: 14px;
  font-weight: 700;
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.st-conc-note {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--hx-subtle);
}

/* ---------- 図 4 マトリクス ---------- */

/* min-width は必ず**中の要素**が持つ。外側の .hx-scroll に置くと本文ごとはみ出す。 */
.st-matrix-inner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 980px;
}

.st-matrix-head,
.st-matrix-row {
  display: grid;
  /* 列数は台帳から数えて --st-cols で渡す。CSS に焼き込むと、よく使う技術が
     1 つ増えただけで見出しだけ増えて図が折り返す。 */
  grid-template-columns: 200px repeat(var(--st-cols, 10), minmax(0, 1fr)) 56px;
  gap: 4px;
  align-items: center;
}
.st-matrix-head { align-items: end; padding-bottom: 6px; }

.st-matrix-col {
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-align: center;
}

.st-matrix-name {
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--hx-body);
}

.st-matrix-row {
  padding: 5px 0;
  border-top: 1px solid var(--border);
}

.st-matrix-cell {
  font-size: 12px;
  text-align: center;
  color: var(--hx-dash);
}
.st-matrix-cell.is-on { color: var(--accent); }

.st-matrix-sum {
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.st-matrix-head .st-matrix-sum {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--hx-subtle);
}

/* ---------- 図 5 1 作品あたりの技術数の分布 ---------- */

.st-hist-bars {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  height: 160px;
  padding: 0 0 4px;
}

.st-hist-col {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
}

.st-hist-n {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--hx-body-2);
  font-variant-numeric: tabular-nums;
}

/* 月別の棒と違って min-height を持たせない。0 件の柱を 4px の線として残すと、
   実測の 0 が「わずかに 1 件ある」ように見えるため。 */
.st-hist-bar {
  width: 100%;
  border-radius: var(--hx-r-sm) var(--hx-r-sm) 0 0;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-bottom: 0;
}

.st-hist-label {
  padding: 6px 0 0;
  border-top: 1px solid var(--border-strong);
  width: 100%;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* 実測で 0 件だった柱。棒は消すが数字の 0 は残す（無かったことにしない） */
.st-hist-col.is-zero .st-hist-n { color: var(--hx-subtle); }
.st-hist-col.is-zero .st-hist-bar { border: 0; background: none; }

/* ---------- 図 6 いつも一緒に使うもの ---------- */

/* min-width は必ず**中の要素**が持つ。外側の .hx-scroll に置くと本文ごとはみ出す。 */
.st-pair-inner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 900px;
}

.st-pair-head,
.st-pair-row {
  display: grid;
  /* 列数は台帳から数えて --st-pair-cols で渡す（マトリクスと同じ理由） */
  grid-template-columns: 150px repeat(var(--st-pair-cols, 10), minmax(0, 1fr));
  gap: 4px;
  align-items: center;
}
.st-pair-head { align-items: end; padding-bottom: 6px; }

.st-pair-col {
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-align: center;
}

.st-pair-name {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.35;
  color: var(--hx-body);
}

.st-pair-row {
  padding: 6px 0;
  border-top: 1px solid var(--border);
}

/* セルは数字だけ。件数で濃さを変えない（隣に数字があるのに濃淡を足すと二重になり、
   読み手が数字より先に「濃い＝多い」を信じる）。塗り分けは斜めの 1 段だけ。 */
.st-pair-cell {
  font-size: 12.5px;
  text-align: center;
  color: var(--hx-body-2);
  font-variant-numeric: tabular-nums;
}
.st-pair-cell.is-self { font-weight: 700; color: var(--accent); }
.st-pair-cell.is-zero { color: var(--hx-dash); }

/* ---------- 図 7 月別の縦棒 ---------- */

.st-months-bars {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  height: 180px;
  padding: 0 0 4px;
}

.st-month {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
}

.st-month-n {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--hx-body-2);
  font-variant-numeric: tabular-nums;
}

.st-month-bar {
  width: 100%;
  min-height: 4px;
  border-radius: var(--hx-r-sm) var(--hx-r-sm) 0 0;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-bottom: 0;
}

.st-month-label {
  padding: 6px 0 0;
  border-top: 1px solid var(--border-strong);
  width: 100%;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* 作りはじめた月を書いていない作品。棒から黙って外さず、斜線の 1 本として立てる。 */
.st-month.is-unmeasured .st-month-bar {
  background: var(--hx-hatch);
  border-color: var(--border-strong);
}
.st-month.is-unmeasured .st-month-label { color: var(--hx-subtle); }

.st-months-axis,
.st-hist-axis {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--hx-subtle);
}

/* ---------- 図 8 分野 × 動かし方 ---------- */

.st-cross {
  display: flex;
  flex-direction: column;
}

.st-cross-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr));
  gap: 4px;
  align-items: center;
  padding: 9px 0;
  border-top: 1px solid var(--border);
}
.st-cross-row.is-head {
  padding: 0 0 9px;
  border-top: 0;
  background: none;
}
.st-cross-row.is-sum { border-top: 1px solid var(--border-strong); }

.st-cross-name {
  font-size: 12.5px;
  color: var(--hx-body);
}
.st-cross-row.is-head .st-cross-name,
.st-cross-row.is-head .st-cross-cell {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--hx-subtle);
}

/* セルは数字だけ。塗り分けない（隣に数字があるのに濃さを足すと二重になる）。 */
.st-cross-cell {
  font-size: 13px;
  text-align: center;
  color: var(--hx-body-2);
  font-variant-numeric: tabular-nums;
}
.st-cross-cell.is-sum,
.st-cross-row.is-sum .st-cross-cell {
  font-weight: 700;
  color: var(--text);
}

/* 狭い画面で縦積みにしたときだけ出る、セルの中の見出し */
.st-td-label { display: none; }

/* ---------- 図 9 読めた値の帯 ---------- */

.st-cover-bar {
  display: flex;
  height: 22px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--hx-r-md);
}
.st-cover-bar > span { min-width: 2px; }

.st-cover-bar .is-hit,
.st-swatch.is-hit { background: var(--accent-soft); }
/* 斜線＝読んだが数えられなかった（量が読めない） */
.st-cover-bar .is-miss,
.st-swatch.is-miss { background: var(--hx-hatch); }
/* 破線＝意図的に空（「なし」と書いてある欄） */
.st-cover-bar .is-skip,
.st-swatch.is-skip {
  border: 1px dashed var(--hx-dash);
  background: none;
}

.st-cover-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
  color: var(--hx-subtle);
}
.st-cover-legend li { display: flex; align-items: center; gap: 7px; }
.st-cover-legend b {
  color: var(--hx-body-2);
  font-variant-numeric: tabular-nums;
}

.st-swatch {
  display: inline-block;
  width: 22px;
  height: 12px;
  border-radius: 2px;
}

.st-miss {
  margin: 0;
  padding: 0;
  list-style: none;
  min-width: 560px;
}
.st-miss li {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 12px;
  padding: 7px 0;
  border-top: 1px solid var(--border);
}
.st-miss-where {
  font-size: 11.5px;
  color: var(--hx-subtle);
}
.st-miss-text {
  font-family: var(--hx-mono);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--hx-body);
}

/* ---------- 畳み方（広い方から） ---------- */

@media (max-width: 1100px) {
  .hx-kpis { --hx-kpi-cols: 3; }
}

@media (max-width: 900px) {
  .st-groups { grid-template-columns: minmax(0, 1fr); }
  .st-base-row { grid-template-columns: 150px minmax(0, 1fr) 40px; }
  .st-conc-row { grid-template-columns: 118px minmax(0, 1fr) 60px 42px 40px; gap: 4px 10px; }
}

@media (max-width: 640px) {
  .hx-kpis { --hx-kpi-cols: 1; }

  .st-base-row {
    grid-template-columns: minmax(0, 1fr) 40px;
    row-gap: 8px;
  }
  .st-base-name { grid-column: 1 / -1; }

  .st-bar { grid-template-columns: 96px minmax(0, 1fr) 24px; gap: 8px; }

  /* 表は横に流さず縦に積む。隠した見出しの代わりに、各セルの中へラベルを出す
     （harness / loop の表と同じやり方）。 */
  .st-cross-row { grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 12px 0; }
  .st-cross-row.is-head { display: none; }
  .st-cross-name { font-weight: 700; color: var(--hx-body-2); }
  .st-cross-cell { display: flex; gap: 8px; text-align: left; }
  .st-td-label {
    display: inline;
    min-width: 108px;
    font-size: 11px;
    font-weight: 400;
    color: var(--hx-subtle);
  }

  .st-months-bars { height: 140px; gap: 3px; }
  .st-month-n { font-size: 11px; }
  .st-month-label { font-size: 10px; }

  /* 帯と名前を全幅にし、数字だけ 1 行に並べる（343px では 5 列が潰れる） */
  .st-conc-row {
    grid-template-columns: minmax(0, 1fr) 46px 44px;
    row-gap: 8px;
  }
  .st-conc-name,
  .st-conc-bar { grid-column: 1 / -1; }
  .st-conc-n { text-align: left; }

  .st-hist-bars { height: 130px; gap: 3px; }
  .st-hist-n { font-size: 11px; }
  .st-hist-label { font-size: 10px; }

  .st-miss li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .st-cover-legend { gap: 6px 14px; }
}
