/* ==========================================================================
   看護部データ インフォグラフィック
   nursing-data.css

   ■ 方針
     - すべてのセレクタを .nd- 接頭辞で名前空間化し、テーマCSSと衝突させない
     - 書体・基準文字サイズはテーマの指定をそのまま継承する
       （font-family は指定しない。font-size は em の相対指定のみ）
     - グラフ内の文字もHTML要素なので、テーマのフォント設定がそのまま効く
   ========================================================================== */

.nd {
  /* --- カラートークン（サイトのブランドカラーに合わせて変更可） --- */
  --nd-pink:   #e4728e;
  --nd-blue:   #58a6d8;
  --nd-green:  #a3c95c;
  --nd-purple: #8f90d1;
  --nd-orange: #f0a05c;
  --nd-navy:   #4a5aa8;

  --nd-ink:      #4a4a55;
  --nd-ink-sub:  #8a8a96;
  --nd-line:     #e6e6ec;
  --nd-track:    #f2f2f6;
  --nd-bg:       #ffffff;
  --nd-bg-soft:  #fbfafa;

  /* --- レイアウト --- */
  --nd-max: 1040px;
  --nd-radius: 14px;

  /* 書体・文字サイズ・行間はテーマの指定を継承します。
     font-family / font-size / line-height は意図的に指定していません。 */
  color: var(--nd-ink);
  max-width: var(--nd-max);
  margin-inline: auto;
}

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

/* --- セクション共通 ------------------------------------------------------ */
.nd-section { padding-block: clamp(32px, 6vw, 56px); }
.nd-section + .nd-section { border-top: 1px solid var(--nd-line); }

/* セクション見出し（h3・左揃え・改行なし）
   font-size / font-weight はテーマの h3 の指定をそのまま使います */
.nd-h3 {
  text-align: left;
  margin: 0 0 1em;
}
/* 英字サブタイトル（JSONに subtitle がある場合のみ出力）。改行せず同じ行に続ける */
.nd-h3 small {
  display: inline;
  font-size: .6em;
  font-weight: 500;
  color: var(--nd-ink-sub);
  letter-spacing: .08em;
  margin-left: .8em;
  white-space: nowrap;
}
.nd-lead {
  text-align: left;
  color: var(--nd-ink-sub);
  margin: 0 0 1.6em;
  max-width: 40em;
}
.nd-note {
  font-size: .85em;
  color: var(--nd-ink-sub);
  margin: 0;
}
.nd-updated {
  text-align: right;
  font-size: .8em;
  color: var(--nd-ink-sub);
  padding-block: 16px;
  margin: 0;
}

/* --- 年齢構成：部署タブ -------------------------------------------------- */
.nd-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;   /* 見出しの左揃えに合わせる */
  gap: 8px;
  margin-bottom: clamp(20px, 4vw, 28px);
}
.nd-tab {
  appearance: none;
  border: 1px solid var(--nd-line);
  background: var(--nd-bg);
  color: var(--nd-ink-sub);
  font-family: inherit;
  font-size: .9em;
  font-weight: 600;
  line-height: 1.6;
  padding: .5em 1.1em;
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
}
.nd-tab:hover { border-color: var(--nd-pink); color: var(--nd-pink); }
.nd-tab[aria-selected="true"] {
  background: var(--nd-pink);
  border-color: var(--nd-pink);
  color: #fff;
}
.nd-tab:focus-visible { outline: 3px solid var(--nd-blue); outline-offset: 2px; }

/* --- 横バーチャート（年齢構成・勤続年数の共通部品） ---------------------- */
.nd-hbars {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 12px;
}
.nd-hbars li {
  display: grid;
  grid-template-columns: 7em 1fr 5em;
  align-items: center;
  gap: 14px;
}
.nd-hbars__name { font-weight: 600; white-space: nowrap; }
.nd-hbars__track {
  height: 1.2em; min-height: 16px;
  border-radius: 999px; background: var(--nd-track); overflow: hidden;
}
.nd-hbars__fill {
  display: block; height: 100%; width: 0; border-radius: 999px;
  transition: width .7s cubic-bezier(.4, 0, .2, 1);
}
.nd-hbars__val {
  font-weight: 700; text-align: right; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.nd-hbars__val i { font-style: normal; font-size: .8em; margin-left: .1em; }

/* --- 吹き出し ------------------------------------------------------------ */
.nd-balloon {
  position: relative;
  background: #fdf3f5;
  color: var(--nd-pink);
  font-weight: 700;
  text-align: center;
  padding: 1em 1.4em;
  border-radius: var(--nd-radius);
  margin: 0;
}
.nd-balloon::after {
  content: ""; position: absolute; top: -9px; left: 50%; translate: -50% 0;
  border: 9px solid transparent; border-top: 0; border-bottom-color: #fdf3f5;
}
.nd-balloon--left { text-align: left; }

/* --- 写真スロット -------------------------------------------------------- */
.nd-caprow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--nd-photo-w, 240px);
  align-items: center;
  gap: clamp(16px, 4vw, 32px);
  margin-top: clamp(24px, 5vw, 32px);
}
.nd-caprow--nophoto { grid-template-columns: 1fr; }

/* [nurse_balloon] で単体配置するとき（上の余白をリセット） */
.nd-caprow--solo { margin-top: 0; }

/* 写真を左・吹き出しを右に置く配置 */
.nd-caprow--photoleft {
  grid-template-columns: var(--nd-photo-w, 240px) minmax(0, 1fr);
}
/* 吹き出しの三角は、写真がある場合は右向きにする */
.nd-caprow:not(.nd-caprow--nophoto) .nd-balloon::after {
  top: 50%; left: auto; right: -9px; translate: 0 -50%;
  border: 9px solid transparent; border-right: 0; border-left-color: #fdf3f5;
}

/* 写真が左のときは三角も左向き（上の指定を打ち消すため後ろに置く） */
.nd-caprow--photoleft:not(.nd-caprow--nophoto) .nd-balloon::after {
  top: 50%; left: -9px; right: auto; translate: 0 -50%;
  border: 9px solid transparent; border-left: 0;
  border-right-color: #fdf3f5; border-bottom-color: transparent;
}

.nd-photo { margin: 0; width: 100%; max-width: var(--nd-photo-w, 240px); }
.nd-photo img {
  display: block; width: 100%; height: auto; border-radius: var(--nd-radius);
}
.nd-photo figcaption {
  font-size: .8em; color: var(--nd-ink-sub); text-align: center; margin-top: .6em;
}
/* 画像差し替え待ちのプレースホルダー */
.nd-photo__placeholder {
  aspect-ratio: 3 / 4;
  border: 2px dashed var(--nd-line);
  border-radius: var(--nd-radius);
  background: var(--nd-bg-soft);
  display: grid; place-content: center; gap: 4px; text-align: center;
  color: var(--nd-ink-sub);
}
.nd-photo__placeholder span { font-weight: 700; }
.nd-photo__placeholder small { font-size: .8em; }

/* --- 数値カード（KPI） --------------------------------------------------- */
.nd-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: clamp(12px, 3vw, 20px);
  margin-top: clamp(24px, 5vw, 32px);
}
.nd-kpi {
  display: flex; align-items: center; gap: 16px;
  padding: clamp(16px, 3vw, 22px);
  border-radius: var(--nd-radius);
  color: #fff;
}
.nd-kpi--pink { background: var(--nd-pink); }
.nd-kpi--blue { background: var(--nd-blue); }
.nd-kpi__icon { width: 2.8em; height: 2.8em; flex: none; }
.nd-kpi__icon svg { width: 100%; height: 100%; display: block; }
.nd-kpi__label { font-size: .9em; letter-spacing: .04em; opacity: .95; line-height: 1.5; }
.nd-kpi__value { font-size: 2em; font-weight: 700; line-height: 1.25; }
.nd-kpi__value i { font-style: normal; font-size: .5em; margin-left: .2em; }

/* --- 有給休暇取得率：ゲージ + 推移 --------------------------------------- */
.nd-gauge-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(20px, 5vw, 40px);
  align-items: center;
}

/* SVGは円弧の形だけ。数字はHTMLで重ねるのでテーマの書体が効く */
.nd-gauge { position: relative; width: 100%; max-width: 340px; }
.nd-gauge__svg { display: block; width: 100%; height: auto; }
.nd-gauge__arc { transition: stroke-dasharray 1s cubic-bezier(.4, 0, .2, 1); }
.nd-gauge__text {
  position: absolute; left: 0; right: 0; bottom: 7%;
  display: grid; justify-items: center; gap: 2px;
  pointer-events: none;
}
.nd-gauge__num {
  font-size: 2.4em; font-weight: 700; line-height: 1;
  color: var(--nd-pink); font-variant-numeric: tabular-nums;
}
.nd-gauge__num i { font-style: normal; font-size: .45em; margin-left: .1em; }
.nd-gauge__lab { font-size: .85em; color: var(--nd-ink-sub); letter-spacing: .06em; }

.nd-vbars {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: clamp(10px, 3vw, 18px);
  align-items: end;
}
.nd-vbars__col { display: grid; justify-items: center; gap: 6px; }
.nd-vbars__val {
  font-size: .9em; font-weight: 700; color: var(--nd-ink);
  font-variant-numeric: tabular-nums; line-height: 1.4;
}
.nd-vbars__val i { font-style: normal; font-size: .8em; color: var(--nd-ink-sub); }
.nd-vbars__track {
  width: 100%; max-width: 56px; height: 130px;
  background: var(--nd-track); border-radius: 8px;
  display: flex; align-items: flex-end; overflow: hidden;
}
.nd-vbars__fill {
  width: 100%; height: 0; border-radius: 8px;
  transition: height .7s cubic-bezier(.4, 0, .2, 1);
}
.nd-vbars__name { font-size: .8em; color: var(--nd-ink-sub); white-space: nowrap; }

/* --- 離職率：折れ線 ------------------------------------------------------
   SVGは線だけを描き、目盛り・年度・数値はHTML要素を％位置に重ねる。
   これによりテーマの書体・文字サイズがそのまま適用される。
   -------------------------------------------------------------------------- */
.nd-linechart {
  display: grid;
  grid-template-columns: 2.6em 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  row-gap: 6px;
}
.nd-linechart__yaxis {
  position: relative;
  grid-column: 1; grid-row: 1;
  margin-block: 1.6em .2em;   /* プロット領域と同じ余白で高さを揃える */
}
.nd-linechart__ylabel {
  position: absolute; right: 0;
  translate: 0 50%;
  font-size: .78em; color: var(--nd-ink-sub);
  font-variant-numeric: tabular-nums; line-height: 1;
}
.nd-linechart__plot {
  position: relative;
  grid-column: 2; grid-row: 1;
  height: clamp(150px, 26vw, 210px);
  margin-block: 1.6em .2em;   /* 上下にはみ出す数値ラベルのための余白 */
}
.nd-linechart__grid {
  position: absolute; left: 0; right: 0; height: 1px;
  background: var(--nd-line);
}
.nd-linechart__svg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  overflow: visible;
}
/* vector-effect="non-scaling-stroke" により、領域を伸縮しても線幅は一定 */
.nd-linechart__path {
  stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
  opacity: 0; transition: opacity .6s ease-out;
}
.nd-linechart__path.is-shown { opacity: 1; }

.nd-linechart__dot {
  position: absolute;
  width: 11px; height: 11px; border-radius: 50%;
  translate: -50% 50%;
  border: 2.5px solid #fff;
}
.nd-linechart__dot--a { background: var(--nd-pink); }
.nd-linechart__dot--b { background: var(--nd-blue); }

.nd-linechart__val {
  position: absolute;
  translate: -50% -80%;
  font-size: .82em; font-weight: 700; line-height: 1;
  white-space: nowrap; font-variant-numeric: tabular-nums;
  background: none; border: 0; width: auto; height: auto; border-radius: 0;
}
.nd-linechart__val.nd-linechart__dot--a { color: var(--nd-pink); background: none; }
.nd-linechart__val.nd-linechart__dot--b { color: var(--nd-blue); background: none; }
/* 端の数値がグラフ外にはみ出さないよう寄せる */
.nd-linechart__val--start { translate: 0 -80%; }
.nd-linechart__val--end   { translate: -100% -80%; }

.nd-linechart__xaxis {
  position: relative; height: 1.6em;
  grid-column: 2; grid-row: 2;
}
.nd-linechart__xlabel {
  position: absolute; top: 0;
  translate: -50% 0;
  font-size: .78em; color: var(--nd-ink-sub); white-space: nowrap; line-height: 1.4;
}
.nd-linechart__xlabel--start { translate: 0 0; }
.nd-linechart__xlabel--end   { translate: -100% 0; }

.nd-serieslegend {
  list-style: none; margin: 14px 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 8px 20px;
}
.nd-serieslegend li {
  display: flex; align-items: center; gap: 8px; font-size: .9em;
}
.nd-serieslegend__dot { width: 12px; height: 12px; border-radius: 4px; flex: none; }

.nd-turnover {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: clamp(20px, 5vw, 40px);
  align-items: center;
}
.nd-highlight {
  background: var(--nd-bg-soft);
  border: 1px solid var(--nd-line);
  border-radius: var(--nd-radius);
  padding: clamp(18px, 4vw, 26px);
  text-align: center;
}
.nd-highlight__years {
  display: inline-block; background: var(--nd-pink); color: #fff;
  font-size: .78em; font-weight: 700; letter-spacing: .06em;
  padding: .3em 1em; border-radius: 999px; margin-bottom: .8em;
  line-height: 1.6;
}
.nd-highlight__label { font-size: .9em; color: var(--nd-ink-sub); margin: 0; }
.nd-highlight__value {
  font-size: 3em; font-weight: 700;
  color: var(--nd-pink); line-height: 1.1; margin: .1em 0 0;
}
.nd-highlight__value i { font-style: normal; font-size: .35em; margin-left: .1em; }

/* ==========================================================================
   モバイル（〜767px）
   ========================================================================== */
@media (max-width: 767px) {
  .nd-turnover   { grid-template-columns: 1fr; }
  .nd-gauge-wrap { grid-template-columns: 1fr; }
  .nd-gauge      { margin-inline: auto; }
  .nd-hbars li   { grid-template-columns: 5.6em 1fr 4.4em; gap: 8px; }
  .nd-vbars__track { height: 104px; }
  .nd-linechart  { grid-template-columns: 2.2em 1fr; }

  /* 写真は吹き出しの下に回し、幅を抑える */
  .nd-caprow,
  .nd-caprow--photoleft { grid-template-columns: 1fr; justify-items: center; }
  /* 写真左指定でも、スマホでは吹き出しが上・写真が下になるよう順序を入れ替える */
  .nd-caprow--photoleft .nd-balloon { order: 1; }
  .nd-caprow--photoleft .nd-photo   { order: 2; }
  .nd-caprow--photoleft:not(.nd-caprow--nophoto) .nd-balloon::after {
    top: auto; bottom: -9px; left: 50%; right: auto; translate: -50% 0;
    border: 9px solid transparent; border-bottom: 0;
    border-top-color: #fdf3f5; border-right-color: transparent;
  }
  .nd-photo  { max-width: min(200px, var(--nd-photo-w, 240px)); }
  .nd-caprow:not(.nd-caprow--nophoto) .nd-balloon::after {
    top: auto; bottom: -9px; left: 50%; right: auto; translate: -50% 0;
    border: 9px solid transparent; border-bottom: 0;
    border-top-color: #fdf3f5; border-left-color: transparent;
  }

  /* タブは折り返さず横スクロール */
  .nd-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .nd-tabs::-webkit-scrollbar { display: none; }
  .nd-tab { flex: none; scroll-snap-align: start; }
}

/* --- アクセシビリティ ---------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .nd * { transition: none !important; animation: none !important; }
}
.nd-visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- 印刷 ---------------------------------------------------------------- */
@media print {
  .nd-tabs { display: none; }
  .nd-section { break-inside: avoid; }
  .nd-linechart__path { opacity: 1 !important; }
}
