/* =============================================
   pokemon_search.css
   ============================================= */

/* --- リセット & ベース --- */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  background: #f0f4f8;
  color: #333;
  padding: 20px;
}

h1 {
  text-align: center;
  color: #e53e3e;
  margin-bottom: 24px;
  font-size: 1.8rem;
}
.overview { text-align: center; margin-bottom:30px; font-size: .9rem }

/* --- 検索ボックス --- */
.search-box {
  display: flex;
  gap: 8px;
  max-width: 480px;
  margin: 0 auto 32px;
}

.search-box input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid #cbd5e0;
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color .2s;
}
.search-box input:focus { border-color: #e53e3e; }

.search-box button {
  padding: 10px 20px;
  background: #e53e3e;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background .2s;
}
.search-box button:hover { background: #c53030; }

/* --- オートコンプリート --- */
.ac-wrap { position: relative; flex: 1; }
.ac-wrap input { width: 100%; }

.ac-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #fff;
  border: 2px solid #e53e3e;
  border-radius: 8px;
  max-height: 260px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  display: none;
}
.ac-list.open { display: block; }

.ac-item {
  padding: 9px 14px;
  cursor: pointer;
  font-size: .95rem;
  border-bottom: 1px solid #f0f0f0;
  transition: background .1s;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover,
.ac-item.active { background: #fff5f5; color: #e53e3e; }
.ac-item mark { background: none; color: #e53e3e; font-weight: bold; }

/* --- 検索対象カード --- */
.target-box, .result-box {
  max-width: 900px;
  margin: 0 auto 24px;
}
.target-box h2, .result-box h2 {
  font-size: 1.1rem;
  color: #555;
  margin-bottom: 10px;
  border-left: 4px solid #e53e3e;
  padding-left: 8px;
}

.target-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
}
.target-card .poke-name {
  font-weight: bold;
  font-size: 1.1rem;
  color: #2d3748;
}
.target-card .habitat {
  display: inline-block;
  background: #ebf8ff;
  color: #2b6cb0;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: .85rem;
  margin: 4px 4px 4px 0;
}

/* --- タグ共通 --- */
.pref-tag {
  display: inline-block;
  background: #f0fff4;
  color: #276749;
  border: 1px solid #9ae6b4;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: .8rem;
  margin: 2px;
}

/* --- 結果テーブル（PC） --- */
table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08); 
}

thead { background: #e53e3e; color: #fff; }
thead th { padding: 10px 12px; text-align: left; font-size: .9rem; }

tbody tr { background: #fff; }
tbody tr:nth-child(even) { background: #fafafa; }
tbody tr:hover           { background: #fff5f5; }

tbody td {
  padding: 9px 12px;
  font-size: .9rem;
  border-bottom: 1px solid #edf2f7;
  vertical-align: top;
}

.match-badge {
  display: inline-block;
  background: #e53e3e;
  color: #fff;
  border-radius: 12px;
  padding: 1px 10px;
  font-size: .8rem;
  font-weight: bold;
}

.no-result { text-align: center; color: #999; padding: 40px; }

.count {
  text-align: right;
  color: #666;
  font-size: .85rem;
  margin-top: 8px;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

/* =============================================
   スマートフォン対応 (max-width: 600px)
   テーブルを2段レイアウトに変換：
   　1段目：No. ／ ポケモン名 ／ 生息環境 ／ 一致数
   　2段目：好み（タグをまとめて表示）
   ============================================= */
@media screen and (max-width: 600px) {

  body { padding: 12px; }
  h1   { font-size: 1.4rem; }

  /* テーブルをブロック要素としてスタック表示 */
  table, thead, tbody, tr, th, td { display: block; }

  table {
  box-shadow: none;
  }

  /* ヘッダー行は非表示（data-label で代替） */
  thead { display: none; }

  /* 各行をカード化 */
  tbody tr {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 10px 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    /* 1段目は flexで横並び */
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    grid-template-areas:
      "num  name  habitat  badge"
      "pref pref  pref     pref";
    gap: 4px 8px;
    align-items: center;
  }
  tbody tr:nth-child(even) { background: #fff; }
  tbody tr:hover           { background: #fff5f5; }

  /* No. 列 */
  tbody td:nth-child(1) {
    grid-area: num;
    font-size: .75rem;
    color: #999;
    white-space: nowrap;
    border: none; padding: 0;
  }
  tbody td:nth-child(1)::before {
    content: attr(data-label) " ";
    font-weight: bold;
    color: #aaa;
  }

  /* ポケモン名 */
  tbody td:nth-child(2) {
    grid-area: name;
    font-weight: bold;
    font-size: 1rem;
    color: #2d3748;
    border: none; padding: 0;
  }

  /* 生息環境 */
  tbody td:nth-child(3) {
    grid-area: habitat;
    font-size: .78rem;
    color: #2b6cb0;
    background: #ebf8ff;
    border-radius: 4px;
    padding: 2px 6px;
    white-space: nowrap;
    border: none;
  }

  /* 一致数バッジ */
  tbody td:nth-child(4) {
    grid-area: badge;
    border: none; padding: 0;
    text-align: right;
  }

  /* 好み（2段目：全幅） */
  tbody td:nth-child(5) {
    grid-area: pref;
    border-top: 1px dashed #e2e8f0;
    padding: 6px 0 0;
    border-left: none; border-right: none; border-bottom: none;
  }
  tbody td:nth-child(5)::before {
    content: "好み：";
    font-size: .75rem;
    color: #999;
    display: block;
    margin-bottom: 3px;
  }

  /* カウント */
  .count { text-align: left; }
}

/* --- フッター --- */
.footer{
    font-size: .75rem;
    color: #999;
    text-align: center;
}