/* ============================================================
   Wiki「登録者数の推移」グラフの見た目（サイトの一番上に置く。wiki-subscribers.js とセット）
   グラフが出るページにだけ、build.mjs が自動で読み込む。
   色は、青・グレー・白系（目が疲れにくい、落ち着いた色）。線の青は、サイトの青（--accent-strong）を使う。
   枠と影は、ニュース・Wikiのカードと同じ値（news.css の --nw-rim と --nw-shadow）。
   ダークモードは、body.dark で切り替える。
   ============================================================ */

.wsh-block { display: grid; gap: 14px; margin: 8px 0 4px; }

/* ---- 1チャンネルぶんの枠 ---- */
.wsh-card {
  /* 色の部品（ここだけ変えれば、全体の色が変わる） */
  --wsh-line: var(--accent-strong, #2f5fa8);
  --wsh-fill: color-mix(in srgb, var(--wsh-line) 9%, transparent);
  --wsh-grid: rgba(100, 116, 139, .22);
  --wsh-axis: rgba(100, 116, 139, .45);
  --wsh-text: var(--text-sub, #64748b);
  --wsh-main: var(--text-main, #1e293b);
  --wsh-ui-border: rgba(100, 116, 139, .35);
  --wsh-ui-hover: rgba(100, 116, 139, .12);
  --wsh-sel-bg: color-mix(in srgb, var(--wsh-line) 13%, transparent);
  --wsh-tip-bg: rgba(255, 255, 255, .95);
  --wsh-tip-text: #1e293b;
  --wsh-ring: #fff;

  position: relative;
  padding: 14px 16px 12px;
  border-radius: 0;
  background: var(--glass-bg, rgba(255, 255, 255, .6));
  box-shadow:
    var(--nw-rim, inset 0 0 0 1px rgba(120, 140, 170, .35), inset 0 0 0 2.5px rgba(255, 255, 255, .65)),
    var(--nw-shadow, 0 6px 18px rgba(30, 50, 90, .08));
}
body.dark .wsh-card {
  --wsh-line: color-mix(in srgb, var(--accent, #5b8def) 55%, #fff);
  --wsh-grid: rgba(148, 163, 184, .20);
  --wsh-axis: rgba(148, 163, 184, .42);
  --wsh-text: var(--text-sub, #94a3b8);
  --wsh-main: var(--text-main, #e2e8f0);
  --wsh-ui-border: rgba(148, 163, 184, .35);
  --wsh-ui-hover: rgba(148, 163, 184, .16);
  --wsh-tip-bg: rgba(30, 38, 52, .96);
  --wsh-tip-text: #e6edf7;
  --wsh-ring: #1b2330;
}
.wsh-card [hidden] { display: none !important; }

/* ---- 上の行：チャンネル名と、増減数 ---- */
.wsh-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; margin: 0 0 10px; }
.wsh-ch { font-weight: 700; font-size: 15px; color: var(--wsh-main); }
.wsh-gains { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; padding: 0; }
.wsh-gain { display: flex; align-items: baseline; gap: 6px; margin: 0; }
.wsh-gain dt { margin: 0; font-size: 12px; color: var(--wsh-text); }
.wsh-gain dd { margin: 0; font-size: 14px; font-weight: 700; color: var(--wsh-main); }

/* ---- 操作の行：期間のタブ（左）と、◀ ▶（右） ---- */
.wsh-app { min-height: 170px; }
.wsh-ctl { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin: 0 0 6px; }
.wsh-tabs { display: flex; gap: 6px; }
.wsh-tab,
.wsh-btn {
  appearance: none; -webkit-appearance: none;
  font: inherit; line-height: 1.4; cursor: pointer;
  border: 1px solid var(--wsh-ui-border); border-radius: 0;
  background: transparent; color: var(--wsh-text);
}
.wsh-tab { padding: 4px 12px; font-size: 12px; }
.wsh-tab:hover,
.wsh-btn:hover:not(:disabled) { background: var(--wsh-ui-hover); }
.wsh-tab[aria-pressed="true"] {
  background: var(--wsh-sel-bg); border-color: var(--wsh-line); color: var(--wsh-line); font-weight: 700;
}
.wsh-tab:focus-visible,
.wsh-btn:focus-visible,
.wsh-plot:focus-visible { outline: 2px solid var(--wsh-line); outline-offset: 2px; }

.wsh-nav { display: flex; align-items: center; gap: 6px; }
.wsh-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 26px; padding: 0; }
.wsh-btn:disabled { opacity: .35; cursor: default; }
.wsh-range { font-size: 11px; color: var(--wsh-text); white-space: nowrap; }

/* ---- グラフ本体（SVGは wiki-subscribers.js が描く） ---- */
.wsh-plot {
  position: relative; cursor: crosshair;
  touch-action: pan-y;                       /* スマホで、横になぞると値が動き、縦になぞるとページがスクロールする */
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.wsh-canvas { min-height: 132px; }
.wsh-svg { display: block; width: 100%; }
.wsh-grid { stroke: var(--wsh-grid); stroke-width: 1; shape-rendering: crispEdges; }
.wsh-axis { stroke: var(--wsh-axis); stroke-width: 1; shape-rendering: crispEdges; }
.wsh-tick { stroke: var(--wsh-axis); stroke-width: 1; shape-rendering: crispEdges; }
.wsh-yl, .wsh-xl { fill: var(--wsh-text); font-size: 11px; font-family: inherit; }
.wsh-area { fill: var(--wsh-fill); stroke: none; }
.wsh-line { fill: none; stroke: var(--wsh-line); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.wsh-pt { fill: var(--wsh-line); opacity: .55; }
.wsh-dot, .wsh-focus { fill: var(--wsh-line); stroke: var(--wsh-ring); stroke-width: 2; }
.wsh-guide { stroke: var(--wsh-text); stroke-width: 1; stroke-dasharray: 3 3; }

/* ---- 値の吹き出し ---- */
.wsh-tip {
  position: absolute; z-index: 2; pointer-events: none;
  display: flex; flex-direction: column; gap: 2px;
  padding: 6px 10px; font-size: 12px; line-height: 1.35; white-space: nowrap;
  background: var(--wsh-tip-bg); color: var(--wsh-tip-text);
  box-shadow: inset 0 0 0 1px var(--wsh-ui-border), 0 4px 12px rgba(15, 23, 42, .12);
}
.wsh-tip-v { font-size: 14px; font-weight: 700; }

.wsh-note { margin: 8px 0 0; font-size: 11px; color: var(--wsh-text, var(--text-sub, #64748b)); }

/* ---- スマホ ---- */
@media (max-width: 600px) {
  .wsh-card { padding: 12px 12px 10px; }
  .wsh-range { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .wsh-tab, .wsh-btn { transition: none; }
}
