/* cospa-board スタイル
   PLAN.md §9 デザイン指針に準拠:
   - 白背景 + 罫線ベースのテーブル主体(diskprices.com 型: データ密度・sticky header・価格色分け)
   - アクセント1色のみ(深緑 #1a5c3a)
   - 本文は system-ui スタック、数字のみ tabular-nums
   - グラデーション・絵文字・角丸大盛りカード・影の多用は禁止
   - レスポンシブ3段階: PC(>=1080px)/タブレット(720-1079px)/スマホ(<720px)
*/

:root {
  --accent: #1a5c3a;
  --text: #1a1a1a;
  --text-muted: #555;
  --border: #ccc;
  --border-strong: #888;
  --bg: #ffffff;
  --row-alt: #f7f7f5;
  --row-hover: #f0f4f1;
  --head-bg: #fafafa;

  /* 単価の安さ順5分位カラー(1=最安=濃緑 〜 5=最高=暗赤) */
  --q1: #0f5c34;
  --q2: #4d7c3f;
  --q3: #6b6b3a;
  --q4: #9c5a2e;
  --q5: #9c3b2e;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

/* ヘッダー: 1行コンパクト(左サイト名 / 右nav+PRチップ) */
header.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 2px solid var(--text);
  flex-wrap: wrap;
}

header.site-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}

header.site-header h1 a {
  color: inherit;
  text-decoration: none;
}

header.site-header nav {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
}

header.site-header nav a {
  color: var(--accent);
  text-decoration: none;
}

header.site-header nav a:hover {
  text-decoration: underline;
}

.pr-chip {
  display: inline-block;
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  padding: 3px 5px;
  cursor: help;
}

.fetched-at {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

main {
  padding: 8px 16px 32px;
}

/* PC: テーブル最大幅1280pxで中央寄せ */
@media (min-width: 1080px) {
  main {
    max-width: 1280px;
    margin: 0 auto;
  }
}

.table-scroll {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data-table th,
table.data-table td {
  border-bottom: 1px solid var(--border);
  padding: 5px 10px;
  text-align: left;
  vertical-align: middle;
}

table.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--head-bg);
  border-bottom: 2px solid var(--text);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  z-index: 1;
}

table.data-table thead th[data-sortable="false"] {
  cursor: default;
}

table.data-table thead th.sorted-asc,
table.data-table thead th.sorted-desc {
  color: var(--accent);
}

table.data-table thead th.sorted-asc::after {
  content: " \25B2";
}

table.data-table thead th.sorted-desc::after {
  content: " \25BC";
}

table.data-table tbody tr:nth-child(even) {
  background: var(--row-alt);
}

table.data-table tbody tr:hover {
  background: var(--row-hover);
}

table.data-table td.num,
table.data-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

td.unit-price {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  white-space: nowrap;
}

/* 単価の安さ順5分位の色分け(diskprices.com 型。excluded/suspiciousには適用しない) */
tr[data-quintile="1"] td.unit-price { color: var(--q1); }
tr[data-quintile="2"] td.unit-price { color: var(--q2); }
tr[data-quintile="3"] td.unit-price { color: var(--q3); }
tr[data-quintile="4"] td.unit-price { color: var(--q4); }
tr[data-quintile="5"] td.unit-price { color: var(--q5); }

td.item-name {
  max-width: 360px;
}

td.item-image img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: #f5f5f5;
}

td a.item-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

td a.item-link:hover {
  text-decoration: underline;
}

/* index.html カテゴリ一覧: レスポンシブカードグリッド(罫線ベースのフラットカード) */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.category-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}

.category-card:hover {
  border-color: var(--accent);
  background: var(--row-hover);
}

.category-card-name {
  font-size: 16px;
  font-weight: 700;
}

.category-card-count {
  font-size: 12px;
  color: var(--text-muted);
}

.category-card-price {
  margin-top: 4px;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.category-card-price small {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

footer.site-footer {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  font-size: 12px;
  color: var(--text-muted);
}

footer.site-footer .pr-notice {
  margin: 0 0 8px;
}

footer.site-footer nav.footer-nav {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
}

footer.site-footer a {
  color: var(--accent);
}

.methodology-body h2 {
  font-size: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.methodology-body code,
.methodology-body pre {
  background: var(--row-alt);
  font-size: 13px;
}

.excluded-row {
  color: var(--text-muted);
}

/* form factorファミリータブ(microSD/SDカード/その他)。仕様2026-07-06:
   既存フィルタチップより視覚的に強く(下線タブ型)。diskprices型の実用感維持のため
   グラデーション不使用。 */
.family-tabs {
  display: flex;
  gap: 4px;
  margin: 10px 0 4px;
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
}

.family-tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 14px 7px;
  cursor: pointer;
  white-space: nowrap;
  margin-bottom: -2px;
}

.family-tab:hover {
  color: var(--text);
}

.family-tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.family-tab-count {
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.family-tab.is-active .family-tab-count {
  color: var(--accent);
}

/* タイプ列(規格チップより小さく。form_factorの詳細表示、仕様§3) */
.type-cell {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* フィルタバー(容量帯・速度クラス): ピル型、モバイルは横スクロール1行バー */
.filter-bar {
  margin: 8px 0 12px;
}

.filter-group {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
  font-size: 13px;
  gap: 6px;
}

.filter-label {
  color: var(--text-muted);
  margin-right: 2px;
  white-space: nowrap;
}

.filter-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 99px;
  cursor: pointer;
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: var(--border-strong);
}

.filter-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.filter-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* 商品名リンク(単価表と同様の色。下線はホバー時のみ) */
a.item-link-name {
  color: var(--text);
  text-decoration: none;
}

a.item-link-name:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* 規格チップ(C10・U3・V30・A2 等を小さく並べる。ソート不要のため data-sortable="false") */
.spec-chips {
  white-space: nowrap;
}

.spec-chip {
  display: inline-block;
  font-size: 11px;
  line-height: 1;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px 5px;
  margin-right: 3px;
  font-variant-numeric: tabular-nums;
}

/* suspicious(単価異常値)折りたたみ枠 */
.suspicious-box {
  margin-top: 24px;
  border: 1px solid var(--border);
  padding: 8px 12px;
}

.suspicious-box summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted);
}

.suspicious-note {
  font-size: 13px;
  color: var(--text-muted);
  margin: 8px 0 12px;
}

table.data-table--suspicious td,
table.data-table--suspicious th {
  font-size: 13px;
}

/* 汎用フォーカスリング(キーボード操作の可視化) */
a:focus-visible,
button:focus-visible,
th:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ===== タブレット(720〜1079px): スコア・レビュー列を非表示 ===== */
@media (max-width: 1079px) {
  table.data-table .col-tablet-hide {
    display: none;
  }
}

/* ===== スマホ(<720px): タイプ列は非表示(タブで大分類済み・チップに規格を集約) ===== */
@media (max-width: 719px) {
  table.data-table .col-mobile-hide {
    display: none;
  }
}

/* ===== スマホ(<720px): テーブルをCSSのみでカード型リストに変換 ===== */
@media (max-width: 719px) {
  .filter-bar {
    display: flex;
    flex-direction: column;
  }

  .filter-group {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }

  /* メインテーブルのみカード化(suspicious別枠テーブルは通常の横スクロールテーブルのまま) */
  table.data-table#main-table thead {
    display: none;
  }

  table.data-table#main-table,
  table.data-table#main-table tbody,
  table.data-table#main-table tr {
    display: block;
    width: 100%;
  }

  table.data-table#main-table tbody tr {
    display: grid;
    grid-template-columns: 48px 1fr;
    grid-template-rows: auto auto auto auto;
    column-gap: 10px;
    row-gap: 2px;
    padding: 8px 4px;
    border-bottom: 1px solid var(--border);
  }

  table.data-table#main-table tbody tr:hover {
    background: var(--row-hover);
  }

  table.data-table#main-table td {
    border-bottom: none;
    padding: 0;
  }

  /* 画像: 左列・全行を縦にまたぐ */
  table.data-table#main-table td.item-image {
    grid-column: 1;
    grid-row: 1 / 5;
    align-self: start;
  }

  table.data-table#main-table td.item-image img {
    width: 48px;
    height: 48px;
  }

  /* 商品名: 右上・2行clamp */
  table.data-table#main-table td.item-name {
    grid-column: 2;
    grid-row: 1;
    max-width: none;
  }

  table.data-table#main-table td.item-name a {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 13px;
  }

  /* 単価+実売価格+容量: 右中段 */
  table.data-table#main-table td.unit-price {
    grid-column: 2;
    grid-row: 2;
    font-size: 18px;
    text-align: left;
  }

  table.data-table#main-table td.num[data-value],
  table.data-table#main-table td.col-optional {
    text-align: left;
  }

  /* 実売価格・容量を単価の右に小さく並べる */
  table.data-table#main-table td:nth-child(4),
  table.data-table#main-table td:nth-child(5) {
    grid-column: 2;
    grid-row: 2;
    display: inline-block;
    font-size: 11px;
    color: var(--text-muted);
    margin-right: 6px;
  }

  /* 規格チップ(7列目、タイプ列の次): 単価・価格・容量の下段に表示(仕様§3: スマホは規格チップを表示) */
  table.data-table#main-table td:nth-child(7) {
    grid-column: 2;
    grid-row: 3;
  }

  /* タイプ列(6列目)・形態・スコア・レビューは非表示(カードに収まらないため。
     タイプ列はcol-mobile-hideで非表示済みだが、grid配置からも明示的に外す) */
  table.data-table#main-table td:nth-child(6),
  table.data-table#main-table td:nth-child(8),
  table.data-table#main-table td.col-tablet-hide {
    display: none;
  }

  /* ショップ名: 右下段・小さく */
  table.data-table#main-table td.col-shop {
    grid-column: 2;
    grid-row: 4;
    max-width: none;
    font-size: 11px;
    color: var(--text-muted);
  }

  td.unit-price {
    font-size: 18px;
  }

  .category-grid {
    grid-template-columns: 1fr;
  }
}

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