/* ふるさと納税還元率ナビ のスタイル。ビルド時に内容のハッシュ付きの名前で /assets/ に置かれる */
:root {
  --fg: #1f2933;
  --muted: #667085;
  --line: #e4e7ec;
  --bg: #f4f6f8;
  --card: #fff;
  --soft: #eaf6f4;
  --accent: #1a9c8c;
  --accent-dark: #147a6e;
  --rakuten: #bf0000;
  --rakuten-dark: #9a0000;
  --danger: #bf0000;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif; color: var(--fg); background: var(--bg); line-height: 1.55; font-size: 15px; }
a { color: inherit; }
img { max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
a, button { -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
.inner { max-width: 1280px; margin: 0 auto; padding: 0 16px; }

/* ヘッダー */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.site-header .inner { display: flex; align-items: center; gap: 16px; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { text-decoration: none; display: flex; flex-direction: column; line-height: 1.2; border-left: 4px solid var(--accent); padding-left: 10px; }
.brand-name { font-size: 20px; font-weight: 800; letter-spacing: 0.02em; }
.brand-tag { font-size: 11px; color: var(--muted); margin-top: 2px; }
.search { display: flex; flex: 1 1 260px; max-width: 480px; }
.search input { flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px 0 0 8px; background: var(--bg); }
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: #fff; }
.search button { padding: 8px 14px; border: 0; border-radius: 0 8px 8px 0; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }
.search button:hover { background: var(--accent-dark); }
.site-nav { display: flex; gap: 4px; margin-left: auto; }
.site-nav a { text-decoration: none; padding: 8px 10px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.site-nav a:hover { background: var(--soft); }

main { max-width: 1280px; margin: 0 auto; padding: 16px; }
.results { scroll-margin-top: 80px; }

/* 一覧の2カラム */
.list-layout { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.results { min-width: 0; }
.results-head { margin-bottom: 12px; }
.page-title { font-size: 20px; font-weight: 800; }
.lead { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }
.sorts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sorts-label { font-size: 13px; color: var(--muted); font-weight: 700; margin-right: 4px; }
.sorts .sort { text-decoration: none; font-size: 13px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; background: #fff; white-space: nowrap; }
.sorts .sort.on { background: var(--soft); border-color: var(--accent); color: var(--accent-dark); font-weight: 700; }
.filters-toggle { display: none; align-items: center; gap: 5px; padding: 6px 12px; border: 1px solid var(--accent); border-radius: 999px; background: #fff; color: var(--accent-dark); font-weight: 700; cursor: pointer; white-space: nowrap; }
.filters-toggle .icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.filters-toggle.active { background: var(--accent); color: #fff; }
/* 画面下に浮く「絞り込む」（スマホでツールバーが画面外のときだけ list.js が hidden を外す） */
.filters-fab, .filters-fab[hidden] { display: none; }
.genre-bar { display: none; }
.count { margin: 12px 4px 8px; font-size: 14px; color: var(--muted); }
.empty { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px 16px; text-align: center; color: var(--muted); }

/* 絞り込みパネル */
.filters { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.filters-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.filters h2 { font-size: 17px; font-weight: 800; }
.filters-close { display: none; border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
.filter { padding: 12px 0; border-top: 1px solid var(--line); }
.filter h3 { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 13px; text-decoration: none; cursor: pointer; line-height: 1.3; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.range { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.range input { width: 100%; min-width: 0; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.range input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.filters select { width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.filter-actions { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
body.filters-open::after { content: ""; position: fixed; inset: 0; background: rgba(16, 24, 40, 0.45); z-index: 29; }

/* ボタン */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; text-align: center; padding: 9px 8px; border-radius: 8px; text-decoration: none; font-weight: 700; font-size: 14px; border: 2px solid transparent; cursor: pointer; line-height: 1.3; white-space: nowrap; min-width: 0; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.btn .icon { flex: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--muted); }
.btn-gift { background: var(--accent); color: #fff; }
.btn-gift:hover { background: var(--accent-dark); }
.btn-market { background: var(--rakuten); color: #fff; }
.btn-market:hover { background: var(--rakuten-dark); }
.btn-detail { background: #fff; border-color: var(--fg); color: var(--fg); }
.btn-detail:hover { background: var(--bg); }

/* カード */
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; display: grid; grid-template-columns: 96px 1fr auto; grid-template-rows: 1fr auto auto; grid-template-areas: "img head badge" "note note note" "actions actions actions"; gap: 8px 12px; }
.card-img { grid-area: img; display: flex; align-items: center; justify-content: center; width: 96px; height: 96px; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: contain; }
.noimg { color: #aab; font-size: 12px; }
.card-head { grid-area: head; min-width: 0; }
.card-src { margin: 0; font-size: 11px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; white-space: nowrap; }
.card-genre { background: var(--soft); color: var(--accent-dark); padding: 1px 6px; border-radius: 4px; font-weight: 700; }
.card-name { font-size: 15px; font-weight: 700; line-height: 1.35; margin: 2px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.7em; }
.card-name a { text-decoration: none; }
.card-name a:hover { text-decoration: underline; }
.card-shop { margin: 0 0 4px; font-size: 12px; color: var(--muted); }
.card-facts { margin: 0; display: grid; gap: 4px; }
.card-facts div { display: flex; flex-direction: column; }
.card-facts dt { font-size: 11px; color: var(--muted); }
.card-facts dd { margin: 0; font-size: 16px; font-weight: 800; line-height: 1.2; white-space: nowrap; }
.card-facts div:nth-child(2) dd { color: var(--danger); }
.badge { grid-area: badge; width: 84px; height: 84px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--rakuten); align-self: center; line-height: 1.1; }
.badge-label { font-size: 10px; font-weight: 700; }
.badge-value { font-size: 20px; font-weight: 800; margin: 1px 0; }
.badge small { font-size: 8px; opacity: 0.9; transform: scale(0.9); }
.card-note { grid-area: note; margin: 0; font-size: 11px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 6px; }
.card-actions { grid-area: actions; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-self: end; }
.card-actions .btn { font-size: 12px; padding: 9px 4px; gap: 4px; }
.card-actions .sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.btn .icon { width: 15px; height: 15px; }
.card-actions .btn-detail { grid-column: 1 / -1; }

/* ページ送り */
.pager { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 20px 0; font-size: 14px; flex-wrap: wrap; }
.pager a, .pager span { text-decoration: none; }
.pg-prev, .pg-next { padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.pg-prev.off, .pg-next.off { color: #bbb; }
.pg-nums { display: flex; gap: 4px; }
.pg { min-width: 34px; padding: 6px 8px; text-align: center; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.pg.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.pg-gap { padding: 6px 2px; color: var(--muted); }

/* 詳細 */
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: grid; grid-template-columns: 1fr; gap: 16px; }
.detail-media { display: flex; align-items: center; justify-content: center; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.detail-media img { width: 100%; max-width: 400px; height: auto; aspect-ratio: 1; object-fit: contain; }
.detail-name { font-size: 22px; font-weight: 800; margin: 4px 0 8px; }
.detail-facts { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: center; margin: 16px 0; }
.fact { display: flex; flex-direction: column; }
.fact span { font-size: 12px; color: var(--muted); }
.fact b { font-size: 24px; font-weight: 800; line-height: 1.2; }
.fact:nth-child(2) b { color: var(--danger); }
.fact small { font-size: 11px; color: var(--muted); }
.detail-facts .badge { width: 104px; height: 104px; }
.detail-facts .badge-value { font-size: 26px; }
.detail-facts .badge-label { font-size: 11px; }
.detail-facts .badge small { font-size: 9px; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.detail-actions .btn { padding: 12px 10px; font-size: 15px; }
.detail-sections { display: grid; gap: 16px; margin-top: 16px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel h2 { font-size: 16px; font-weight: 800; border-left: 4px solid var(--accent); padding-left: 10px; margin-bottom: 12px; }
dl.facts { margin: 0; display: grid; gap: 8px; }
dl.facts div { display: grid; grid-template-columns: 7em 1fr; gap: 8px; font-size: 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
dl.facts small { display: block; color: var(--muted); font-size: 12px; }
.formula { font-weight: 700; background: var(--soft); padding: 10px 12px; border-radius: 8px; margin: 0 0 12px; word-break: break-word; }
.notes { margin: 0; padding-left: 1.2em; font-size: 13px; color: var(--muted); }
.notes li { margin-bottom: 4px; }
.more { margin: 12px 0 0; font-size: 14px; }
.more a { color: var(--accent-dark); font-weight: 700; }
.shop-name { margin: 0; font-size: 18px; font-weight: 700; }
details.caption { font-size: 14px; }
details.caption summary { cursor: pointer; color: var(--accent-dark); font-weight: 700; }
details.caption pre { white-space: pre-wrap; word-break: break-word; font-family: inherit; margin: 8px 0 0; font-size: 13px; }

/* 説明ページ */
.prose { max-width: 800px; margin: 0 auto; font-size: 15px; }
.prose h1 { font-size: 22px; font-weight: 800; margin-bottom: 16px; }
.prose h2 { font-size: 17px; margin: 24px 0 8px; }
.prose p, .prose li { line-height: 1.75; }

/* フッター */
.site-footer { margin: 32px 0 0; padding: 20px 0; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); background: var(--card); }
.site-footer p { margin: 0 0 8px; }
.credit a { font-weight: 700; color: var(--fg); }
.copyright { font-weight: 700; }

/* タブレット以下: ヘッダーは 2 段、絞り込みパネルは画面下から出るシート、カテゴリは結果の上に横スクロール */
@media (max-width: 899px) {
  .site-header .inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; min-height: 0; }
  .site-nav { margin-left: 0; justify-self: end; }
  .search { grid-column: 1 / -1; max-width: none; }
  .results { scroll-margin-top: 108px; }
  .toolbar .filters-toggle { display: inline-flex; }
  .genre-bar { display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 10px; padding: 2px 16px; }
  .genre-bar::-webkit-scrollbar { display: none; }
  .genre-bar .chip { flex: none; }
  .filters { position: fixed; inset: auto 0 0 0; max-height: 88vh; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain; z-index: 30; border: 0; border-radius: 16px 16px 0 0; transform: translateY(100%); visibility: hidden; transition: transform 0.25s ease, visibility 0s 0.25s; box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.2); }
  .filters.open { transform: none; visibility: visible; transition: transform 0.25s ease; }
  .filters-head { position: sticky; top: 0; z-index: 1; background: var(--card); margin: -16px -16px 0; padding: 12px 16px 8px; }
  .filters-close { display: block; padding: 4px 8px; }
  .filters .chip { padding: 8px 12px; font-size: 14px; }
  .filters select, .range input { padding: 10px 8px; }
  .filter-actions { position: sticky; bottom: 0; flex-direction: row-reverse; background: var(--card); margin: 0 -16px -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .filter-actions .btn-primary { flex: 2; }
  .filter-actions .btn-ghost { flex: 1; }
  .filter-actions .btn { padding: 11px 8px; }
  body.filters-open { overflow: hidden; }
}

/* スマホ */
@media (max-width: 560px) {
  body { font-size: 14px; }
  .site-header { position: static; }
  .site-header .inner { gap: 6px 8px; padding-top: 8px; padding-bottom: 10px; }
  .brand { border-left-width: 3px; padding-left: 8px; }
  .brand-name { font-size: 17px; }
  .brand-tag { font-size: 10px; }
  .site-nav a { padding: 6px 8px; font-size: 13px; }
  .search input, .search button { font-size: 16px; padding: 9px 12px; }
  .search button { padding-left: 12px; padding-right: 12px; }
  .range input, .filters select { font-size: 16px; }
  main { padding: 12px 12px 88px; }
  .results { scroll-margin-top: 8px; }
  .results-head { margin-bottom: 8px; }
  .page-title { font-size: 18px; }
  .lead { font-size: 12px; }
  .genre-bar { margin: 0 -12px 8px; padding: 2px 12px; }
  .toolbar { flex-wrap: nowrap; padding: 6px 8px; gap: 8px; }
  .sorts { flex: 1; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; min-width: 0; }
  .sorts::-webkit-scrollbar { display: none; }
  .sorts-label { display: none; }
  .sorts .sort { flex: none; padding: 7px 12px; }
  .filters-toggle { padding: 7px 12px; }
  .filters-fab:not([hidden]) { display: inline-flex; position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20; padding: 11px 20px; font-size: 15px; box-shadow: 0 4px 16px rgba(16, 24, 40, 0.25); background: var(--accent); color: #fff; border-color: var(--accent); }
  .filters-fab.active { background: var(--accent-dark); border-color: var(--accent-dark); }
  .count { margin: 8px 2px 6px; font-size: 13px; }
  /* カード: 画像と商品名を横に並べ、その下に寄付金額・最安値・還元率を 1 段にまとめる */
  .cards { gap: 10px; }
  .card { padding: 10px; gap: 6px 10px; grid-template-columns: 84px minmax(0, 1fr) auto; grid-template-rows: auto auto 1fr auto auto; grid-template-areas: "img src src" "img name name" "img shop shop" "facts facts badge" "actions actions actions"; }
  .card-head { display: contents; }
  .card-img { width: 84px; height: 84px; align-self: start; }
  .card-src { grid-area: src; }
  .card-name { grid-area: name; min-height: 0; font-size: 14px; }
  .card-shop { grid-area: shop; margin: 0; align-self: start; }
  .card-facts { grid-area: facts; display: flex; gap: 10px; align-self: center; background: var(--bg); border-radius: 8px; padding: 6px 10px; }
  .card-facts div { flex: 1; min-width: 0; }
  .card-facts dd { font-size: 15px; white-space: normal; }
  .badge { grid-area: badge; width: 68px; height: 68px; align-self: center; }
  .badge-label { font-size: 9px; }
  .badge-value { font-size: 17px; }
  .badge small { display: none; }
  .card-note { display: none; }
  .card-actions { gap: 6px; }
  .card-actions .btn { padding: 10px 4px; }
  .card-actions .btn-detail { padding: 6px 4px; border-width: 1px; border-color: var(--line); font-weight: 600; }
  .pager { gap: 6px; }
  .pg { min-width: 40px; padding: 9px 8px; }
  .pg-prev, .pg-next { padding: 9px 12px; }
  /* 詳細: 寄付・楽天市場のボタンを画面下に固定する */
  .crumbs { margin-bottom: 8px; }
  .detail { padding: 12px; gap: 12px; }
  .detail-media { padding: 4px; }
  .detail-media img { max-width: 240px; }
  .detail-name { font-size: 18px; }
  .detail-facts { grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 0; }
  .fact b { font-size: 20px; }
  .detail-facts .badge { grid-column: 1 / -1; width: auto; height: auto; flex-direction: row; justify-content: space-between; gap: 8px; padding: 8px 14px; border-radius: 8px; box-shadow: none; }
  .detail-facts .badge-label { font-size: 13px; }
  .detail-facts .badge-value { font-size: 24px; margin: 0; }
  .detail-facts .badge small { display: none; }
  .detail-actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -2px 12px rgba(16, 24, 40, 0.12); }
  .detail-actions .btn { padding: 11px 6px; font-size: 13px; white-space: normal; line-height: 1.25; }
  .detail-sections { gap: 12px; margin-top: 12px; }
  .panel { padding: 14px 12px; }
  dl.facts div { grid-template-columns: 1fr; gap: 0; }
  .prose { font-size: 14px; }
  .site-footer { margin-top: 24px; }
}
@media (min-width: 640px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { grid-template-columns: 88px 1fr; grid-template-rows: auto 1fr auto auto; grid-template-areas: "img head" "badge head" "note note" "actions actions"; }
  .card-img { width: 88px; height: 88px; }
  .badge { width: 80px; height: 80px; align-self: start; justify-self: center; }
}
@media (min-width: 900px) {
  .list-layout { grid-template-columns: 260px minmax(0, 1fr); }
  .filters { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; }
  .detail { grid-template-columns: 360px 1fr; }
  .detail-sections { grid-template-columns: 1fr 1fr; }
  .detail-sections .panel:first-child { grid-column: 1 / -1; }
}
@media (min-width: 1280px) {
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
