/* back10-lab ローカルデザインシステム — 部品のスタイル（#130 で作成、#131 で本番に配置）
 *
 * 読み込み順: chunks/*.css → /ds/tokens.css → /ds/base.css → このファイル。
 * layouts/_shortcodes/ と layouts/_partials/ が .ds-* クラスを使い、design/components/*.html のプレビューも同じファイルを読む。
 * --ds-* 変数だけを参照する。値を直接書かない（トークンの正本は design/tokens/back10-lab.toml）。
 * フォーカス表示・強制カラーモードは DADS のコードスニペット
 * （digital-go-jp/design-system-example-components-html, MIT）に合わせている。
 *
 * 記事内の部品は .prose-article（コンパイル済み CSS、詳細度 0,1,1）の p / ul / table / th / td / h3 の指定を受ける。
 * 部品側では p・h3 を避けて div / span を使い、table と ul は親クラスを付けた詳細度の高い指定で上書きする。
 */

/* ---------------- ベース ---------------- */
.ds-root {
  font-family: var(--ds-font-sans);
  font-size: var(--ds-type-body-size);
  line-height: var(--ds-type-body-line-height);
  letter-spacing: var(--ds-type-body-tracking);
  color: var(--ds-color-text-body);
  background: var(--ds-color-surface);
}
.ds-root *, .ds-root *::before, .ds-root *::after { box-sizing: border-box; }

/* フォーカス表示（DADS。値を変えない） */
.ds-root :focus-visible {
  outline: 4px solid var(--ds-focus-outline);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--ds-focus-ring);
}

/* ---------------- 見出し・本文 ---------------- */
.ds-prose { max-width: var(--ds-content-max); }
.ds-prose h1, .ds-prose h2, .ds-prose h3, .ds-prose h4,
.prose-article h1, .prose-article h2, .prose-article h3, .prose-article h4 {
  font-family: var(--ds-font-heading);
  color: var(--ds-color-text-heading);
  margin: 0;
}
.ds-prose h1, .prose-article h1 { font-size: var(--ds-type-h1-size); line-height: var(--ds-type-h1-line-height); font-weight: var(--ds-type-h1-weight); letter-spacing: var(--ds-type-h1-tracking); margin-bottom: var(--ds-space-l); }
.ds-prose h2, .prose-article h2 { font-size: var(--ds-type-h2-size); line-height: var(--ds-type-h2-line-height); font-weight: var(--ds-type-h2-weight); letter-spacing: var(--ds-type-h2-tracking);
  margin: var(--ds-space-xxl) 0 var(--ds-space-m); padding-bottom: var(--ds-space-s); border-bottom: 1px solid var(--ds-color-border); }
.ds-prose h3, .prose-article h3 { font-size: var(--ds-type-h3-size); line-height: var(--ds-type-h3-line-height); font-weight: var(--ds-type-h3-weight); letter-spacing: var(--ds-type-h3-tracking); margin: var(--ds-space-xl) 0 var(--ds-space-s); }
.ds-prose h4, .prose-article h4 { font-size: var(--ds-type-h4-size); line-height: var(--ds-type-h4-line-height); font-weight: var(--ds-type-h4-weight); letter-spacing: var(--ds-type-h4-tracking); margin: var(--ds-space-l) 0 var(--ds-space-s); }
/* 本文の h2 は左の太線をやめ、下線 1px（案B） */
.prose-article h2 { border-left: 0; padding-left: 0; }
.prose-article h1 { margin-top: var(--ds-space-l); }

.ds-prose p, .ds-prose ul, .ds-prose ol {
  font-size: var(--ds-type-body-article-size);
  line-height: var(--ds-type-body-article-line-height);
  letter-spacing: var(--ds-type-body-article-tracking);
  margin: 0 0 var(--ds-space-l);
}
.ds-prose ul, .ds-prose ol { padding-left: 1.5em; }
.ds-prose li + li { margin-top: var(--ds-space-s); }
.ds-meta, .prose-article .ds-meta { font-size: var(--ds-type-small-size); line-height: var(--ds-type-small-line-height); color: var(--ds-color-text-sub); }

/* ---------------- リンク（DADS link と同じ振る舞い） ---------------- */
.ds-link:any-link, .ds-prose a:not([class]) {
  color: var(--ds-color-link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}
.ds-link:visited, .ds-prose a:not([class]):visited { color: var(--ds-color-link-visited); }
@media (hover: hover) {
  .ds-link:hover, .ds-prose a:not([class]):hover { color: var(--ds-color-link-hover); text-decoration-thickness: 3px; }
}
.ds-link:active, .ds-prose a:not([class]):active { color: var(--ds-color-link-active); text-decoration-thickness: 1px; }
.ds-link:focus-visible, .ds-prose a:not([class]):focus-visible { background: var(--ds-focus-ring); border-radius: var(--ds-radius-s); }
.ds-link__external { display: inline-block; width: 1em; height: 1em; margin-left: 0.15em; vertical-align: -0.15em; }

/* ---------------- ボタン（affiliate-button） ---------------- */
.ds-button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--ds-space-s);
  min-height: var(--ds-button-height); min-width: var(--ds-target-min); max-width: 100%;
  padding: var(--ds-space-s) var(--ds-space-l);
  border-radius: var(--ds-radius-m);
  font-family: var(--ds-font-sans);
  font-size: var(--ds-type-label-size); line-height: var(--ds-type-label-line-height);
  font-weight: var(--ds-type-label-weight); letter-spacing: var(--ds-type-label-tracking);
  text-decoration: none; text-underline-offset: 3px; cursor: pointer;
}
.ds-button--primary { background: var(--ds-color-key); color: var(--ds-color-text-on-fill); border: 4px double transparent; }
@media (hover: hover) { .ds-button--primary:hover { background: var(--ds-color-key-hover); text-decoration: underline; } }
.ds-button--primary:active { background: var(--ds-color-key-active); text-decoration: underline; }
.ds-button--secondary { background: var(--ds-color-surface); color: var(--ds-color-key); border: 1px solid currentColor; }
@media (hover: hover) { .ds-button--secondary:hover { background: var(--ds-color-key-tint); color: var(--ds-color-key-hover); text-decoration: underline; } }
.ds-button--secondary:active { background: var(--ds-color-key-tint-strong); color: var(--ds-color-key-active); text-decoration: underline; }
.ds-button--block { width: 100%; }
@media (min-width: 640px) { .ds-button--block { width: auto; } }
.ds-button__icon { width: 1em; height: 1em; flex: none; }

/* ---------------- バッジ ---------------- */
.ds-badge {
  display: inline-flex; align-items: center; gap: var(--ds-space-xs);
  padding: 0 var(--ds-space-s); border-radius: var(--ds-radius-s);
  font-size: var(--ds-type-small-size); line-height: 1.7; font-weight: 700;
  color: var(--ds-color-highlight); background: var(--ds-color-highlight-tint); border: 1px solid currentColor;
}
.ds-badge--key { color: var(--ds-color-key-active); background: var(--ds-color-key-tint); }
.ds-badge--neutral { color: var(--ds-color-text-sub); background: var(--ds-color-surface); border-color: var(--ds-color-border); }

/* ---------------- 記事カード（lab-card） ---------------- */
.ds-card {
  display: flex; gap: var(--ds-space-m); padding: var(--ds-space-m);
  background: var(--ds-color-surface); color: inherit; text-decoration: none;
  border: 1px solid var(--ds-color-border); border-radius: var(--ds-radius-m);
}
@media (hover: hover) {
  .ds-card:hover { box-shadow: var(--ds-elevation-hover); }
  .ds-card:hover .ds-card__title { text-decoration: underline; }
}
.ds-card--featured { padding: var(--ds-space-l); border: 2px solid var(--ds-color-key); }
.ds-card__thumb { flex: none; width: 128px; height: 96px; object-fit: cover; border-radius: var(--ds-radius-s); background: var(--ds-color-surface-band); }
.ds-card__body { display: flex; flex: 1; flex-direction: column; gap: var(--ds-space-xs); min-width: 0; }
.ds-card__title { font-size: var(--ds-type-h4-size); line-height: var(--ds-type-h4-line-height); font-weight: 700; color: var(--ds-color-text-heading); margin: 0; }
.ds-card__desc { font-size: var(--ds-type-body-size); line-height: var(--ds-type-body-line-height); color: var(--ds-color-text-sub); margin: 0; }
@media (max-width: 639.98px) { .ds-card--featured { padding: var(--ds-space-l); border: 2px solid var(--ds-color-key); }
.ds-card__thumb { width: 96px; height: 72px; } }

/* ---------------- 製品カード（product-card） ---------------- */
.ds-product {
  display: flex; align-items: center; gap: var(--ds-space-m); padding: var(--ds-space-m);
  background: var(--ds-color-surface); color: inherit; text-decoration: none;
  border: 1px solid var(--ds-color-border); border-top: 4px solid var(--ds-color-key); border-radius: var(--ds-radius-m);
}
@media (hover: hover) { .ds-product:hover { box-shadow: var(--ds-elevation-hover); } .ds-product:hover .ds-product__name { text-decoration: underline; } }
.ds-product__image { flex: none; width: 96px; height: 96px; object-fit: cover; border-radius: var(--ds-radius-s); background: var(--ds-color-surface-band); }
.ds-product__body { display: flex; flex: 1; flex-direction: column; gap: var(--ds-space-s); min-width: 0; }
.ds-product__name { font-size: var(--ds-type-h4-size); line-height: var(--ds-type-h4-line-height); font-weight: 700; color: var(--ds-color-text-heading); margin: 0; }
.ds-product__price { font-size: var(--ds-type-h3-size); line-height: 1.3; font-weight: 700; font-variant-numeric: tabular-nums; margin: 0; }
.ds-product__rank {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: var(--ds-target-min); height: var(--ds-target-min); border-radius: var(--ds-radius-full);
  background: var(--ds-color-header); color: var(--ds-color-text-on-fill); font-weight: 700; font-size: var(--ds-type-h4-size);
}
.ds-product .ds-product__points { display: flex; flex-wrap: wrap; gap: var(--ds-space-s); margin: 0; padding: 0; list-style: none; }
.ds-product .ds-product__points > li { margin: 0; }
.ds-product__points li { display: inline-flex; gap: var(--ds-space-xs); padding: 0 var(--ds-space-s); border-radius: var(--ds-radius-s);
  font-size: var(--ds-type-small-size); line-height: 1.7; color: var(--ds-color-key-active); background: var(--ds-color-key-tint); }
.ds-product--hero { flex-wrap: wrap; padding: var(--ds-space-l); }
.ds-product--compact { gap: var(--ds-space-s); padding: var(--ds-space-s); }
.ds-product--compact .ds-product__image { width: 64px; height: 64px; }
.ds-product--hero .ds-product__image { width: 160px; height: 160px; }
.ds-product--hero .ds-product__name { font-size: var(--ds-type-h3-size); line-height: var(--ds-type-h3-line-height); }
.ds-product--hero .ds-product__body { flex: 1 1 240px; }

/* ---------------- 注意書き（callout / note-small） ---------------- */
.ds-callout {
  margin: 0 0 var(--ds-space-l); padding: var(--ds-space-m);
  border: 1px solid var(--ds-color-border); border-left-width: 6px; border-radius: 0 var(--ds-radius-m) var(--ds-radius-m) 0;
}
.ds-callout__title { display: flex; align-items: center; gap: var(--ds-space-s); margin: 0 0 var(--ds-space-xs);
  font-size: var(--ds-type-label-size); line-height: 1.5; font-weight: 700; }
.ds-callout__title svg { width: 1.25em; height: 1.25em; flex: none; }
.ds-callout__body { margin: 0; font-size: var(--ds-type-body-size); line-height: var(--ds-type-body-line-height); }
/* 本文は markdown（p / ul など）。.prose-article の余白と文字サイズを打ち消す */
.ds-callout .ds-callout__body > * { margin-block: 0; font-size: inherit; line-height: inherit; }
.ds-callout .ds-callout__body > * + * { margin-top: var(--ds-space-s); }
.ds-callout--info { border-left-color: var(--ds-color-key); background: var(--ds-color-key-tint); }
.ds-callout--info .ds-callout__title { color: var(--ds-color-key-active); }
.ds-callout--warning { border-left-color: var(--ds-color-highlight); background: var(--ds-color-highlight-tint); }
.ds-callout--warning .ds-callout__title { color: var(--ds-color-highlight); }
.ds-callout--note { border-left-color: var(--ds-color-border-on-band); background: var(--ds-color-surface-band); }
.ds-callout--note .ds-callout__title { color: var(--ds-color-text-heading); }
.ds-note-small, .prose-article .ds-note-small { font-size: var(--ds-type-small-size); line-height: var(--ds-type-small-line-height); color: var(--ds-color-text-sub); margin: 0 0 var(--ds-space-m); }

/* ---------------- 広告表記（ad-disclosure） ---------------- */
.ds-disclosure { display: flex; flex-wrap: wrap; gap: var(--ds-space-s); align-items: baseline; padding: var(--ds-space-m);
  border: 1px solid var(--ds-color-border-on-band); border-radius: var(--ds-radius-m); background: var(--ds-color-surface-band);
  font-size: var(--ds-type-small-size); line-height: var(--ds-type-small-line-height); color: var(--ds-color-text-body); }

/* ---------------- 比較表（comparison-table） ---------------- */
/* .prose-article table / th / td の指定に勝つよう、.ds-table-wrap を前に付ける */
.ds-table-wrap { overflow-x: auto; margin: 0 0 var(--ds-space-l); border: 1px solid var(--ds-color-border); border-radius: var(--ds-radius-m); background: var(--ds-color-surface); }
.ds-table-wrap .ds-table { border-collapse: collapse; width: 100%; min-width: 560px; margin: 0; font-size: var(--ds-type-body-size); line-height: 1.6; font-variant-numeric: tabular-nums; }
.ds-table-wrap .ds-table caption { text-align: left; padding: var(--ds-space-s) var(--ds-space-m); font-size: var(--ds-type-small-size); color: var(--ds-color-text-sub); }
.ds-table-wrap .ds-table th, .ds-table-wrap .ds-table td { padding: var(--ds-space-s) var(--ds-space-m); text-align: left; vertical-align: top; border: 0; border-top: 1px solid var(--ds-color-border); color: var(--ds-color-text-body); }
.ds-table-wrap .ds-table thead th { border-top: 0; background: var(--ds-color-header); color: var(--ds-color-text-on-fill); font-weight: 700; }
.ds-table-wrap .ds-table tbody th { background: var(--ds-color-surface-band); color: var(--ds-color-text-heading); font-weight: 700; width: 8em; min-width: 6em; }
/* 1 列目（項目名）は横スクロール中も見えるように固定する */
.ds-table-wrap .ds-table tr > :first-child { position: sticky; left: 0; z-index: 1; }
.ds-table-wrap .ds-table .is-main { background: var(--ds-color-highlight-tint); font-weight: 700; }
.ds-table-wrap .ds-table thead .is-main { background: var(--ds-color-header); box-shadow: inset 0 -4px 0 var(--ds-color-highlight-on-dark); }
.ds-table__main-label { display: block; font-size: var(--ds-type-small-size); color: var(--ds-color-highlight-on-dark); }

/* ---------------- FAQ（faq / faq-item） ---------------- */
.ds-faq { border-top: 1px solid var(--ds-color-border); margin: 0 0 var(--ds-space-l); }
.ds-faq details { border-bottom: 1px solid var(--ds-color-border); }
.ds-faq summary {
  display: flex; align-items: center; gap: var(--ds-space-s); min-height: var(--ds-target-min);
  padding: var(--ds-space-s) 0; cursor: pointer; list-style: none;
  font-size: var(--ds-type-h4-size); line-height: var(--ds-type-h4-line-height); font-weight: 700; color: var(--ds-color-text-heading);
}
.ds-faq summary::-webkit-details-marker { display: none; }
.ds-faq summary::before { content: "Q"; flex: none; display: inline-flex; align-items: center; justify-content: center; width: 1.75em; height: 1.75em;
  border-radius: var(--ds-radius-s); background: var(--ds-color-key); color: var(--ds-color-text-on-fill); font-size: var(--ds-type-body-size); }
.ds-faq summary::after { content: "＋"; margin-left: auto; color: var(--ds-color-key); }
.ds-faq details[open] summary::after { content: "－"; }
@media (hover: hover) { .ds-faq summary:hover { text-decoration: underline; } }
.ds-faq__answer { white-space: pre-line; margin: 0 0 var(--ds-space-m); padding-left: calc(1.75em + var(--ds-space-s)); font-size: var(--ds-type-body-size); line-height: var(--ds-type-body-line-height); }

/* ---------------- 強制カラーモード ---------------- */
@media (forced-colors: active) {
  .ds-button--primary { border-color: ButtonText; }
  .ds-badge, .ds-card, .ds-product, .ds-product__points li, .ds-callout, .ds-disclosure, .ds-table-wrap { border-color: CanvasText; }
  .ds-table-wrap .ds-table thead .is-main { box-shadow: none; border-bottom: 4px solid CanvasText; }
  .ds-faq summary::before, .ds-product__rank { border: 1px solid CanvasText; }
  .ds-root :focus-visible { outline-color: Highlight; }
}
