/* ============================================
   令和6年全国家計構造調査 統計表検索 スタイル
   ============================================ */

/* ===== 色の定義 ===== */
:root {
  --primary: #1f5a8c;        /* 青：白背景で約7:1 */
  --primary-deep: #16456d;
  --primary-soft: #eef4fa;
  --accent: #25664a;         /* 緑：白背景で約6.6:1 */
  --accent-deep: #1c5039;
  --accent-soft: #eaf5ef;
  --ink: #33404d;
  --ink-sub: #556170;        /* 補助文字：約6:1 */
  --line: #e4e9ef;
  --danger: #a93226;         /* 赤：淡赤背景で約6:1 */
}

* { box-sizing: border-box; }

/* ===== 全体 ===== */
body {
  font-family: "Segoe UI","Meiryo","Hiragino Sans",sans-serif;
  margin: 0;
  padding: 0 16px 40px;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--ink);
  background: linear-gradient(180deg, #f6f9fc 0%, #eef2f7 100%) fixed;
  font-feature-settings: "palt";
  letter-spacing: .01em;
}

/* ===== 見出し ===== */
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}
h1 {
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  padding: 4px 12px;
  margin: 6px 0 3px;
  border-radius: 9px;
  box-shadow: 0 3px 9px rgba(31,90,140,.18);
}
h1 span { letter-spacing: normal; }
.h1-note {
  display: inline-block;
  margin-left: 14px;
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: normal;
  color: #ffe6a0;
  vertical-align: middle;
}

/* ===== 説明枠 ===== */
.notice {
  margin: 4px 0;
  padding: 4px 2px;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--ink-sub);
}
.notice a { color: var(--primary); font-weight: 600; }

/* ===== 検索エリア ===== */
#searchArea {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 6px 0 5px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255,255,255,.6), 0 6px 18px rgba(31,90,140,.05);
}
.search-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-left: 1em;
  margin-top: 5px;
}
#searchBox {
  width: 45%;
  min-width: 260px;
  padding: 5px 14px;
  font-size: 0.9375rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid #8a96a3;
  border-radius: 10px;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(31,64,77,.04);
  transition: border-color .2s, box-shadow .2s;
}
#searchBox:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31,90,140,.2);
}

/* ===== 知りたい数字（メインボタン） ===== */
.mainBtns {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.mainBtns-label {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--accent);
  margin-right: 4px;
  letter-spacing: .04em;
}
.mainBtns button {
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 1px 16px;
  color: var(--accent);
  background: #fff;
  border: 1px solid var(--accent);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(37,102,74,.08);
  transition: all .2s cubic-bezier(.4,0,.2,1);
}
.mainBtns button:hover {
  background: var(--accent-soft);
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(37,102,74,.2);
}
.mainBtns button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 5px 14px rgba(37,102,74,.3);
}

/* ===== 条件で絞る（クイックボタン） ===== */
.quickWrap { margin-top: 4px; }
.quickBtns {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.quickBtns-label {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--primary);
  margin-right: 4px;
  letter-spacing: .04em;
}
.quickBtns button {
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 1px 14px;
  color: var(--primary);
  background: #fff;
  border: 1px solid #8fa8c2;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(31,90,140,.06);
  transition: all .2s cubic-bezier(.4,0,.2,1);
}
.quickBtns button:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(31,90,140,.16);
}
.quickBtns button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 5px 14px rgba(31,90,140,.3);
}
.quickBtns .clearBtn {
  background: #fdf3f3;
  color: var(--danger);
  border-color: #d9a8a2;
}
.quickBtns .clearBtn:hover {
  background: #fbe9e9;
  border-color: var(--danger);
  box-shadow: 0 5px 14px rgba(169,50,38,.18);
}

/* キーボード操作時のフォーカス表示 */
button:focus-visible,
a:focus-visible,
input[type="checkbox"]:focus-visible {
  outline: 3px solid #f0a020;
  outline-offset: 2px;
}

/* ===== ツールチップ（実要素：JSで生成） ===== */
.tip-wrap {
  position: relative;
  display: inline-block;
}
.tip {
  position: absolute;
  left: 50%;
  bottom: 130%;
  transform: translateX(-50%);
  z-index: 200;
  width: max-content;
  max-width: 320px;
  padding: 8px 14px;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.5;
  white-space: normal;
  color: #fff;
  background: var(--primary-deep);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(26,84,144,0.4);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s ease;
}
.mainBtns .tip { background: var(--accent-deep); }
.tip-wrap:hover .tip,
.tip-wrap:focus-within .tip {
  opacity: 1;
  visibility: visible;
}

/* ===== 用語メモ ===== */
.terms {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 20px;
  margin: 4px 0;
  padding: 4px 12px;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--ink-sub);
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(31,90,140,.05);
}
.terms-title {
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  border-radius: 999px;
  padding: 2px 12px;
}
.term-item b { color: var(--primary-deep); }

/* ===== フロート情報（件数・リンク・一括DL） ===== */
#floatInfo {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 100;
  padding: 3px 5px;
  text-align: center;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  border: 1px solid rgba(31,90,140,.35);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(31,90,140,.18);
}
#count {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--primary-deep);
}
.float-links {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed #b8c4d0;
  display: flex;
  gap: 10px;
  justify-content: center;
  font-size: 0.75rem;
}
.float-links a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.float-links a:hover { text-decoration: underline; }

/* 一括DLボタン */
.bulk-btn {
  display: block;
  margin-top: 6px;
  padding: 5px 12px;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  color: #fff !important;
  background: var(--accent);
  border-radius: 9px;
  box-shadow: 0 3px 10px rgba(37,102,74,.28);
  transition: transform .18s, box-shadow .18s, background .18s;
}
.bulk-btn:hover {
  background: var(--accent-deep);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37,102,74,.36);
}
.bulk-btn.disabled {
  background: #5f6b78;          /* 白文字で約5.4:1 */
  color: #fff !important;
  box-shadow: none;
  transform: none;
  pointer-events: none;
  cursor: default;
}

/* 対応表DLボタン */
.csv-btn {
  display: block;
  margin-top: 4px;
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  color: var(--primary) !important;
  background: #fff;
  border: 1px solid var(--primary);
  border-radius: 9px;
  cursor: pointer;
  transition: all .18s;
}
.csv-btn:hover {
  background: var(--primary);
  color: #fff !important;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(31,90,140,.28);
}
.csv-btn.disabled {
  background: #eef1f4;
  color: #4f5a66 !important;    /* 約6.5:1 */
  border-color: #8a96a3;
  transform: none;
  box-shadow: none;
  pointer-events: none;
  cursor: default;
}

/* ===== テーブル ===== */
table {
  width: 100%;
  margin-top: 8px;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(31,90,140,.06);
}
th, td {
  padding: 11px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #eef2f6;
}
th {
  padding-top: 1px;
  padding-bottom: 1px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: .05em;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  border-bottom: none;
}
tbody tr { transition: background-color .15s; }
tbody tr:last-child td { border-bottom: none; }
tr:nth-child(even) { background: #fafcfe; }
tbody tr:hover { background: #f0f6fc; }
tbody tr.checked-row { background: #fdf6e3 !important; }

/* チェックボックス列 */
.chk-cell { text-align: center; vertical-align: middle; }
.row-check, #checkAll {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* 表番号・表名 */
.tno {
  white-space: nowrap;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--primary-deep);
}
.name { line-height: 1.5; color: var(--ink); }

/* ファイル名（黒緑） */
.fname {
  display: block;
  width: fit-content;
  margin-top: 4px;
  padding: 2px 7px;
  font-family: monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: #1e4d3a;               /* 約8:1 */
  background: #e8f2ec;
  border: 1px solid #c9ddd1;
  border-radius: 6px;
}

/* Excel・DBボタン */
.btns { white-space: nowrap; }
.btn {
  display: inline-block;
  min-width: 120px;
  margin: 2px 0;
  padding: 6px 12px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-align: center;
  text-decoration: none;
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
  transition: transform .18s cubic-bezier(.4,0,.2,1), box-shadow .18s, background .18s;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 12px rgba(0,0,0,.18);
}
.btn-xls { background: var(--accent); }
.btn-xls:hover { background: var(--accent-deep); }
.btn-db { background: #5e2f91; }      /* 白文字で約9:1 */
.btn-db:hover { background: #4b2474; }
.btn-icon { margin-right: 5px; }

/* ===== フッター ===== */
footer {
  margin-top: 24px;
  font-size: 0.75rem;
  color: #3d4a57;
  text-align: center;
}
footer a { color: var(--primary); }
.footer-note { margin-bottom: 12px; }
.footer-org {
  padding-top: 12px;
  line-height: 1.7;
  color: #3d4a57;
  border-top: 1px solid #d7dde3;
}
#footer_nav {
  list-style: none;
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 8px 0 0;
  padding: 0;
}
#footer_nav a { font-size: 0.75rem; color: var(--primary); }

/* ===== スクロールバー ===== */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb {
  background: #cdd8e2;
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: #aab8c6;
  background-clip: padding-box;
}

/* ===== フェードイン ===== */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
table, .notice, .terms { animation: riseIn .35s ease both; }

/* 動きを減らす設定の利用者にはアニメーションを止める */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ===== 読み上げ専用（画面には表示しない） ===== */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== JavaScript無効時の案内 ===== */
.noscript-msg {
  margin: 10px 0;
  padding: 12px 16px;
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--ink);
  background: #fff;
  border: 2px solid #b03a2e;
  border-radius: 10px;
}
.noscript-msg p { margin: 4px 0; }
.noscript-msg noscript,
.noscript-msg strong {
  display: block;
  margin: 4px 0;
  font-weight: 700;
  color: #9e2a1f;               /* 約7:1 */
}
.noscript-msg a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
}

/* JavaScript有効時は案内を隠す／無効時は操作部品を隠す */
.js .noscript-msg { display: none; }
.no-js #searchArea,
.no-js #floatInfo,
.no-js #dataTable,
.no-js .terms { display: none; }

/* ===== 狭い画面（スマホ等） ===== */
@media (max-width: 640px) {
  #floatInfo { position: static; margin: 10px 0; }
  h1 { font-size: 1rem; }
  .h1-note { display: block; margin-left: 0; }
  #searchBox { width: 100%; min-width: 0; }
  .search-row { padding-left: 0; }
  th, td { padding: 8px 6px; }

  thead th:nth-child(4),
  tbody td:nth-child(4) { width: 90px !important; }

  .btns {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    white-space: normal;
  }
  .btn {
    display: block;
    width: 100%;
    min-width: 0;
    padding: 6px 4px;
    font-size: 0.75rem;
  }
  .tip { max-width: 240px; }
}