/*
 * トップページ（と 404）の見た目。配色は shared/theme.css と同じ（クリーム地・細い枠・緑のアクセント）。
 * 見せ場は検索欄: 太い枠と下に付いた影で、最初に触る場所だと分かるようにする。
 * それ以外（ジャンル・カード・見出し）は静かに。ジャンルの色は見出しとカードの細部にだけ使う。
 */
:root {
  --bg: #fbf6ea;
  --surface: #fffdf8;
  --paper: #ffffff;
  --text: #3b2f2f;
  --muted: #7a6a5f;
  --border: #ebe1cf;
  --border-strong: #d9ccb4;
  --radius: 20px;
  --brand: #1f7a5a;
  --brand-soft: #e7f3ec;
  --logo-blue: #2b7bd6;
  --focus: 0 0 0 3px rgba(31, 122, 90, 0.35);
  --soft-shadow: 0 1px 2px rgba(120, 95, 50, 0.06), 0 4px 14px rgba(120, 95, 50, 0.07);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Maru Gothic ProN", "Zen Maru Gothic", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ===== ヘッダー: ロゴの右にサイト名とキャッチコピー ===== */
.site-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 20px 0;
}
.site-header h1 {
  margin: 0;
  color: var(--logo-blue);
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0.06em;
}
.site-logo { width: 68px; height: 68px; }
.site-logo svg { display: block; width: 100%; height: 100%; }
.site-logo svg > rect:first-child { fill: transparent; }
.site-brand { min-width: 0; }
.tagline { margin: 6px 0 0; color: var(--text); font-size: 0.95rem; font-weight: 700; letter-spacing: 0.04em; }
@media (min-width: 640px) {
  .site-header { padding-top: 48px; column-gap: 16px; }
  .site-logo { width: 100px; height: 100px; }
  .site-header h1 { font-size: 2.9rem; }
  .tagline { font-size: 1.08rem; }
}
/* 404 などは中央寄せの見出しだけ */
.site-header-simple { display: block; text-align: center; padding-top: 40px; }
.site-header-simple h1 { font-size: 1.6rem; }
.site-header-simple .tagline { color: var(--muted); font-size: 0.9rem; }

/* ===== 一覧の枠 ===== */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px 24px;
}
@media (min-width: 640px) { .layout { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0 20px 32px; } }
@media (min-width: 900px) { .layout { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* ===== 検索（見せ場） ===== */
.search-panel {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 18px;
}
.search-form { position: relative; margin-top: 4px; }


.search-input {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  min-height: 60px;
  padding: 14px 52px 14px 54px;
  border: 2.5px solid #34504a;
  border-radius: 999px;
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2334504a' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5L21 21'/%3E%3C/svg%3E") no-repeat 20px center / 22px;
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  box-shadow: 0 3px 0 #34504a;
  -webkit-appearance: none;
  appearance: none;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.search-input::placeholder { color: #9a8a7e; font-weight: 500; }
.search-input::-webkit-search-cancel-button { display: none; }
.search-input:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 3px 0 var(--brand), 0 0 0 6px rgba(31, 122, 90, 0.16);
}
@media (min-width: 640px) { .search-input { min-height: 66px; font-size: 1.12rem; padding-left: 58px; background-position: 22px center; } }
.search-clear {
  position: absolute;
  top: 50%;
  right: 12px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #f1eadc;
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
}
.search-clear:hover { background: #e8dfcc; }
.search-clear:focus-visible { outline: none; box-shadow: var(--focus); }

/* 安心の案内: 検索欄のすぐ下に1行で */
.anshin {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 2px 0 0;
  padding: 0 8px;
  list-style: none;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}
.anshin li { display: flex; align-items: center; gap: 6px; }
.anshin li::before {
  content: "";
  width: 9px;
  height: 5px;
  border-left: 2.5px solid var(--brand);
  border-bottom: 2.5px solid var(--brand);
  transform: rotate(-45deg) translateY(-2px);
}
.is-filtering .anshin { display: none; }

/* ===== ジャンル・やりたいこと ===== */
.chip-area { display: flex; flex-direction: column; gap: 18px; margin-top: 12px; }
.chip-row { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.chip-label { color: var(--text); font-size: 0.9rem; font-weight: 800; letter-spacing: 0.04em; }
.label-ico { display: none; }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.chip-list li[hidden] { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 5px 14px 5px 11px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--paper);
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}
.chip:hover { border-color: var(--border-strong); background: #fffaf0; }
.chip:focus-visible { outline: none; box-shadow: var(--focus); }
.chip-ico { flex: none; width: 18px; height: 18px; color: var(--brand); }
.chip-ico svg { display: block; width: 100%; height: 100%; }
.chip[aria-pressed="true"] { border-color: var(--brand); background: var(--brand); color: #fff; }
.chip[aria-pressed="true"] .chip-ico { color: #fff; }
.chip[aria-pressed="true"]::after { content: "×"; margin-left: 2px; font-weight: 800; }

/* ジャンルは引き出しのようなタイル。スマホは横にすべらせる */
.chip-list#genre-chips {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 88px;
  gap: 8px;
  overflow-x: auto;
  margin: 0 -16px;
  padding: 2px 16px 6px;
  scroll-snap-type: x proximity;
  scroll-padding: 0 16px;
  scrollbar-width: none;
}
.chip-list#genre-chips::-webkit-scrollbar { display: none; }
.chip-list#genre-chips li { scroll-snap-align: start; }
@media (min-width: 640px) {
  .chip-list#genre-chips {
    grid-auto-flow: row;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-auto-columns: auto;
    overflow: visible;
    margin: 0;
    padding: 0;
  }
}
.chip-genre {
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  width: 100%;
  height: 100%;
  min-height: 86px;
  padding: 12px 6px 10px;
  border-radius: 18px;
  font-size: 0.78rem;
  text-align: center;
  word-break: auto-phrase;
}
.chip-genre .chip-ico { width: 32px; height: 32px; }
.chip-genre[aria-pressed="true"] { background: var(--brand-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--brand); }
.chip-genre[aria-pressed="true"]::after { content: none; }
.chip-genre[aria-pressed="true"] .chip-ico { color: inherit; }

/* やりたいことは小さめのチップ。PC は見出しと同じ行に */
@media (min-width: 640px) {
  .chip-row-action { flex-direction: row; align-items: baseline; gap: 14px; }
  .chip-row-action .chip-label { flex: none; }
}
.chip-row-action .chip-label { font-size: 0.86rem; }

/* 絞り込み中: 件数と「絞り込みを解除」を1行にまとめ、すぐ下に結果を出す */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; }
.filter-bar:has(.search-status:empty):not(:has(.tag-reset:not([hidden]))) { display: none; }
.search-status { margin: 0; color: var(--muted); font-size: 0.85rem; font-weight: 700; }
.search-status:empty { display: none; }
.tag-reset {
  margin-left: auto;
  padding: 2px 0;
  border: none;
  background: none;
  color: var(--brand);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.tag-reset:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
.no-result { grid-column: 1 / -1; margin: 0; padding: 32px 0; text-align: center; color: var(--muted); }

/* ===== ジャンルの色（見出しの印とカードのホバーにだけ使う） ===== */
.layout { --cat: var(--brand); --cat-soft: var(--brand-soft); }
#cat-pdf, #cat-pdf ~ * { --cat: #e5534b; --cat-soft: #fdeceb; }
#cat-image, #cat-image ~ * { --cat: #3a9be0; --cat-soft: #e8f3fc; }
#cat-text, #cat-text ~ * { --cat: #e0a417; --cat-soft: #fdf4dc; }
#cat-create, #cat-create ~ * { --cat: #43a047; --cat-soft: #e9f5ea; }
#cat-money, #cat-money ~ * { --cat: #7c5cd6; --cat-soft: #f0ecfb; }
#cat-number, #cat-number ~ * { --cat: #1a9aa6; --cat-soft: #e3f4f6; }
#cat-date, #cat-date ~ * { --cat: #e8697a; --cat-soft: #fdedf0; }
#cat-play, #cat-play ~ * { --cat: #f28c1b; --cat-soft: #fef1e2; }
#cat-check, #cat-check ~ * { --cat: #2e8b57; --cat-soft: #e6f3ec; }
#cat-game, #cat-game ~ * { --cat: #6a5acd; --cat-soft: #eeecfa; }

/* カテゴリの見出し: スクロール中も上に残り、今どのジャンルを見ているか分かる */
.category-title {
  position: sticky;
  top: 0;
  z-index: 2;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 30px -16px 2px;
  padding: 10px 16px 8px;
  background: var(--bg);
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}
.category-title::before { content: ""; flex: none; width: 14px; height: 14px; border-radius: 5px; background: var(--cat); }
@media (min-width: 640px) { .category-title { margin: 40px -20px 4px; padding: 10px 20px 8px; font-size: 1.2rem; } }
.is-filtering .layout > .category-title:not([hidden]) { margin-top: 8px; }

/* ===== ツールのカード: 枠だけの静かなカード。触るとジャンルの色がにじむ ===== */
.tool-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 84px;
  padding: 14px 16px;
  color: inherit;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.tool-card:hover { border-color: var(--cat); background: var(--cat-soft); }
.tool-card:focus-visible { outline: none; border-color: var(--cat); box-shadow: var(--focus); }
.tool-card:active { background: var(--cat-soft); }
.tool-icon { flex: none; width: 46px; height: 46px; }
.tool-icon svg { display: block; width: 100%; height: 100%; }
.tool-icon svg > rect:first-child { rx: 12; }
.tool-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tool-title { font-size: 0.97rem; font-weight: 800; line-height: 1.4; letter-spacing: 0.01em; }
.tool-desc {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.55;
}
/* 見出し・説明を言葉の切れ目で折り返す（対応していないブラウザは今までどおり） */
.tool-title, .tool-desc { word-break: auto-phrase; text-wrap: pretty; overflow-wrap: anywhere; }
.tool-title .nowrap { white-space: nowrap; }

.tool-card[hidden],
.chip-area[hidden],
.chip-row[hidden],
.tag-reset[hidden],
.category-title[hidden],
.no-result[hidden] { display: none; }

/* ===== 最近使ったツール（記録があるときだけ） ===== */
.otomo { grid-column: 1 / -1; margin-top: 18px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.otomo[hidden] { display: none; }
.otomo-title { margin: 0 0 12px; font-size: 1rem; font-weight: 800; letter-spacing: 0.04em; }
.otomo-title .label-ico { display: none; }
.otomo-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
@media (min-width: 640px) { .otomo-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.otomo-item { display: flex; align-items: center; gap: 8px; height: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 14px; background: var(--paper); color: var(--text); text-decoration: none; transition: border-color 0.12s ease; }
.otomo-item:hover { border-color: var(--border-strong); }
.otomo-item:focus-visible { outline: none; box-shadow: var(--focus); }
.otomo-item .tool-icon { width: 36px; height: 36px; }
.otomo-body { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.otomo-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 0.8rem; font-weight: 700; line-height: 1.35; }
.otomo-desc { overflow: hidden; color: var(--muted); font-size: 0.7rem; white-space: nowrap; text-overflow: ellipsis; }
.otomo-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin: 10px 0 0; color: var(--muted); font-size: 0.75rem; }
.otomo-clear { min-height: 24px; padding: 0; border: none; background: none; color: var(--muted); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.otomo-clear:hover, .otomo-clear:focus-visible { color: var(--text); }

/* ===== フッター ===== */
.site-footer { text-align: center; padding: 12px 16px 40px; color: var(--muted); font-size: 0.8rem; }

/* ===== 404 の「よく使われる機能」 ===== */
.popular { grid-column: 1 / -1; }
.popular-title { margin: 0 0 10px; font-size: 1.05rem; }
.popular-links { margin: 0; padding-left: 1.2em; line-height: 2; }
.popular-links a { color: var(--brand); font-weight: 700; text-underline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  .search-input, .chip, .tool-card, .otomo-item { transition: none; }
}
