/* ===== 図鑑トップ（index.html の日本語版）=====
   写真と4つの探し方を中心にした構成。トークンと .hub-chip は top-page.css を使う。
   多言語版（index.template.html）は旧構成のままなので、ここはトップ専用のクラスだけを持つ。
   グリッドは常に minmax(0, 1fr)（test_css_grid_tracks.py）。 */

.home-main {
  max-width: var(--page-max-wide, 1120px);
  margin: 0 auto;
  padding: 0 var(--top-pad) 64px;
}

.home-section {
  margin-top: 36px;
}

.home-h2 {
  margin: 0 0 12px;
  font-size: 19px;
  font-weight: 900;
  line-height: 1.35;
}

/* 見出しの右に一覧へのリンクを置く（都道府県から探す） */
.home-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.home-h2 small {
  margin-left: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--top-text-faint);
}

.home-h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 800;
}

.home-text {
  margin: -4px 0 14px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--top-text-muted);
}

.home-main a:focus-visible,
.home-main summary:focus-visible {
  outline: 3px solid var(--top-purple);
  outline-offset: 2px;
}

/* ── 1. ヒーロー ── */
.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  padding-top: 20px;
}

.home-eyebrow {
  margin: 0 0 6px;
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--top-eyebrow);
  font-weight: 600;
}

.home-h1 {
  margin: 0 0 10px;
  font-size: 27px;
  font-weight: 900;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.home-lead {
  margin: 0 0 16px;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--top-text-muted);
}

.home-lead b { color: var(--top-text); }

.home-quick {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.home-quick__link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 8px 10px;
  border: 1.5px solid var(--top-purple);
  border-radius: 12px;
  background: var(--top-card-bg);
  color: var(--top-purple-dark);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

/* PC のヒーローにだけ出す導線。スマホのヒーローは3つのまま */
.home-quick__link--desktop { display: none; }

.home-quick__link--primary {
  background: var(--top-purple);
  color: #fff;
}

.home-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  background: var(--top-card-bg);
  border: 1px solid var(--top-border);
  border-radius: 13px;
  overflow: hidden;
}

.home-stat {
  display: flex;
  flex-direction: column-reverse;
  padding: 10px 4px;
  text-align: center;
  border-left: 1px solid var(--top-border-light);
}

.home-stat:first-child { border-left: 0; }

.home-stat dd {
  margin: 0;
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 18px;
  font-weight: 800;
  color: var(--top-purple-dark);
}

.home-stat dt {
  font-size: 10.5px;
  color: var(--top-text-faint);
}

/* 写真モザイク：3列で先頭だけ2×2。6枚でちょうど埋まる */
.home-mosaic { margin: 0; }

.home-mosaic__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-mosaic__item:first-child {
  grid-column: span 2;
  grid-row: span 2;
}

.home-mosaic__item a,
.home-gallery__item a {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 12px;
  background: var(--top-border-light);
}

.home-mosaic__item img,
.home-gallery__item img,
.home-poke img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
}

.home-mosaic__cap {
  position: absolute;
  inset: auto 0 0;
  padding: 18px 8px 6px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.62), transparent);
  color: #fff;
  font-size: 10.5px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-mosaic__cap b {
  display: block;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-mosaic__item:first-child .home-mosaic__cap { padding: 32px 12px 10px; font-size: 12px; }
.home-mosaic__item:first-child .home-mosaic__cap b { font-size: 16px; }

.home-mosaic__note {
  margin-top: 6px;
  font-size: 11px;
  color: var(--top-text-faint);
  text-align: right;
}

/* 小さいタイルは地名を省き、ポケモン名だけ残す */
@media (max-width: 599px) {
  .home-mosaic__item:not(:first-child) .home-mosaic__cap { font-size: 0; padding: 14px 6px 5px; }
  .home-mosaic__item:not(:first-child) .home-mosaic__cap b { font-size: 11px; }
}

.home-hero--no-photos { grid-template-columns: minmax(0, 1fr); }

/* 大地図はデスクトップだけ。スマホでは要素ごと出さない（Leaflet も読み込まれない） */
.home-map { display: none; }

/* ── 2. 探し方 ── */
.home-ways {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-way {
  display: flex;
  flex-direction: column;
  background: var(--top-card-bg);
  border: 1px solid var(--top-border);
  border-radius: var(--top-radius-card);
  overflow: hidden;
}

.home-way__main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  padding: 14px 14px 10px;
}

.home-way__icon { width: 28px; height: 28px; }

.home-way__title {
  font-size: 15px;
  font-weight: 900;
  color: var(--top-purple-dark);
}

.home-way__text {
  font-size: 12px;
  line-height: 1.6;
  color: var(--top-text-muted);
}

.home-way__links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 0;
  padding: 8px 14px 12px;
  list-style: none;
  border-top: 1px dashed var(--top-border);
  font-size: 12px;
}

.home-way__links a {
  color: var(--top-purple);
  font-weight: 700;
}

/* ── 新作 ── */
.home-newrel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-newrel__card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: var(--top-card-bg);
  border: 1px solid var(--top-border);
  border-radius: 12px;
  font-size: 12px;
  color: var(--top-text-muted);
}

.home-newrel__card b { font-size: 13.5px; color: var(--top-text); }

/* ── 3. 写真 ── */
/* 写真は正方形のタイルを並べ、説明（ポケモン・場所・日付）は写真の下端に重ねる。スマホ3列×3行、PC 6列×1行 */
.home-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.home-gallery__item a {
  position: relative;
  height: 100%;
  background: var(--top-card-bg);
}

.home-gallery__cap {
  position: absolute;
  inset: auto 0 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 22px 7px 6px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
  color: rgba(255, 255, 255, 0.88);
  font-size: 10.5px;
  line-height: 1.4;
}

.home-gallery__cap b {
  font-size: 11.5px;
  color: #fff;
}

.home-gallery__cap time {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.75);
}

.home-gallery__cap b,
.home-gallery__cap span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* スマホの小さいタイルでは日付を省く（ポケモンと場所だけ） */
@media (max-width: 599px) {
  .home-gallery__cap time { display: none; }
}

.home-cta,
.home-more {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--top-radius-pill);
  font-size: 13.5px;
  font-weight: 800;
}

.home-cta {
  background: var(--top-purple);
  color: #fff;
}

.home-cta::after,
.home-more::after { content: " →"; margin-left: 4px; }

.home-more {
  margin-top: 14px;
  border: 1.5px solid var(--top-purple);
  color: var(--top-purple-dark);
  background: var(--top-card-bg);
}

/* ── 4. イベント ── */
#home-events[hidden],
.home-event[hidden] { display: none; }

.home-events {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-event a {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--top-card-bg);
  border: 1px solid var(--top-border);
  border-radius: 12px;
}

.home-event__badge {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: var(--top-radius-pill);
  background: #E4574B;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.home-event__badge.is-upcoming { background: var(--top-purple-light); }

.home-event__copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.home-event__copy b { font-size: 13.5px; line-height: 1.45; }

.home-event__copy small {
  font-size: 11.5px;
  color: var(--top-text-faint);
}

/* イベント名のポケモンの写真つき：写真を左に、バッジと文面を右に縦に積む */
.home-event.has-img a {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  column-gap: 12px;
  row-gap: 4px;
  align-items: start;
}

.home-event__img {
  grid-row: 1 / span 2;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--top-border);
}

.home-event.has-img .home-event__badge { justify-self: start; }

/* 英語版トップ（generate_top_page_en.py）は今も details で畳む */
.home-events__more { margin-top: 8px; }

.home-events__more summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  color: var(--top-purple);
}

.home-events__more[open] summary { margin-bottom: 4px; }

/* 日本語版：スマホ・タブレットは先頭3件だけ。「すべて見る」で残りを開く（PC は全件で、ボタンも出さない） */
.home-events__toggle {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  color: var(--top-purple);
}

@media (max-width: 959px) {
  #home-events:not(.is-open) .home-event.is-extra { display: none; }
}
#home-events.is-open .home-events__toggle { display: none; }

/* ── 5. 都道府県 ── */
.home-regions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.home-region {
  padding: 12px 14px 10px;
  background: var(--top-card-bg);
  border: 1px solid var(--top-border);
  border-radius: var(--top-radius-card);
}

.home-region__title {
  margin: 0 0 6px;
  font-size: 13.5px;
  font-weight: 800;
}

.home-region__title small {
  margin-left: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--top-text-faint);
}

.home-pref {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-pref a {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  min-height: 40px;
  align-items: center;
  border-bottom: 1px solid var(--top-border-light);
  font-size: 13.5px;
  font-weight: 700;
}

.home-pref__count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--top-purple);
}

/* スマホは地方ごとのカードをやめて1枚にまとめ、県を3列・低めの行で詰める（縦に長くなりすぎるため） */
@media (max-width: 599px) {
  .home-regions {
    gap: 10px;
    padding: 12px 12px 6px;
    background: var(--top-card-bg);
    border: 1px solid var(--top-border);
    border-radius: var(--top-radius-card);
  }
  .home-region {
    padding: 0;
    background: none;
    border: 0;
    border-radius: 0;
  }
  .home-region__title { margin-bottom: 2px; font-size: 12.5px; color: var(--top-text-muted); }
  .home-pref { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 10px; }
  .home-pref a { min-height: 34px; font-size: 13px; }
  .home-pref__count { font-size: 11px; }
}

.home-pref-note {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.75;
  color: var(--top-text-muted);
}

.home-pref-note a {
  color: var(--top-purple);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── 6. 目的から探す ── */
.home-purpose__block + .home-purpose__block { margin-top: 18px; }

.home-purpose__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.home-purpose__more {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--top-purple);
}

.home-purpose__more::after { content: " →"; }

.home-chips .hub-chip {
  min-height: 40px;
  padding: 8px 13px;
  font-size: 13px;
}

/* ポケふた旅のカード（/trip/ のヒーローと同じ中身） */
.home-trips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.home-trip {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  background: var(--top-card-bg);
  border: 1px solid var(--top-border);
  border-radius: 12px;
}

.home-trip__pref { font-size: 11.5px; font-weight: 800; color: var(--top-text-faint); }
.home-trip__name { font-size: 14px; color: var(--top-text); }
.home-trip__time { font-size: 13px; color: var(--top-purple); }
.home-trip__mode { font-size: 11.5px; color: var(--top-text-muted); }

.home-trip .stop-thumbs {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 3px;
  margin: 4px 0 2px;
}

.home-trip .stop-thumbs img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--top-border-light);
}

.home-trip .stop-thumb-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--top-purple-pale);
  font-size: 12px;
  font-weight: 800;
  color: var(--top-purple);
}

.home-pokes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-poke a {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--top-card-bg);
  border: 1px solid var(--top-border);
  border-radius: 12px;
}

.home-poke__name {
  padding: 7px 9px 0;
  font-size: 13px;
  font-weight: 800;
}

.home-poke__count {
  padding: 0 9px 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  color: var(--top-purple);
}

.home-poke img { aspect-ratio: 4 / 3; }

.home-poke__placeholder {
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--top-border-light);
}

.home-poke--all a {
  justify-content: center;
  align-items: center;
  text-align: center;
  background: var(--top-purple-pale);
  border-color: transparent;
}

@media (hover: hover) {
  .home-way:hover,
  .home-gallery__item a:hover,
  .home-poke a:hover,
  .home-event a:hover,
  .home-region:hover { border-color: var(--top-purple-light); }
  .home-mosaic__item a:hover img,
  .home-gallery__item a:hover img { opacity: 0.9; }
  .home-quick__link:hover { filter: brightness(1.05); }
}

/* ── タブレット ── */
@media (min-width: 600px) {
  .home-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .home-regions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-newrel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .home-events { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── デスクトップ ── */
@media (min-width: 960px) {
  .home-main { padding-left: 24px; padding-right: 24px; }
  .home-section { margin-top: 48px; }
  .home-h2 { font-size: 22px; }

  /* ヒーロー：旧トップと同じく大きな日本地図の上に説明パネルを重ねる */
  .home-hero {
    position: relative;
    display: block;
    min-height: 660px;
    margin-top: 20px;
    padding: 0;
    border: 1px solid var(--top-border);
    border-radius: 20px;
    overflow: hidden;
    background: #E4ECEF;
  }
  .home-mosaic { display: none; }
  .home-map { display: block; position: absolute; inset: 0; }
  /* z-index で重ね合わせの文脈を作り、Leaflet のペイン（z-index 400〜）を中に閉じ込める */
  .home-map__canvas { position: absolute; inset: 0; z-index: 0; background: #E4ECEF; }
  .home-hero__copy {
    position: relative;
    z-index: 1;
    width: 420px;
    margin: 24px;
    padding: 24px 24px 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 18px;
    box-shadow: 0 8px 28px rgba(43, 43, 48, 0.12);
  }
  .home-quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-quick__link--map { display: none; }
  .home-quick__link--desktop { display: flex; }
  .home-quick__link--wide { grid-column: 1 / -1; }
  .home-map__cta {
    position: absolute;
    right: 20px;
    bottom: 26px;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    min-height: 48px;
    padding: 12px 20px;
    border-radius: var(--top-radius-pill);
    background: var(--top-purple);
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    box-shadow: 0 6px 18px rgba(108, 92, 166, 0.45);
  }
  .home-map__attr {
    position: absolute;
    right: 8px;
    bottom: 4px;
    z-index: 1;
    font-size: 10px;
    color: var(--top-text-muted);
  }
  .home-map .leaflet-marker-icon { cursor: pointer; }
  .home-h1 { font-size: 28px; }
  .home-lead { font-size: 14.5px; }

  .home-ways { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
  /* 写真は横6列1行（生成した9枚のうち先頭6枚） */
  .home-gallery { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
  .home-gallery__item:nth-child(n+7) { display: none; }
  .home-gallery__cap { padding: 28px 9px 8px; font-size: 11px; }
  .home-gallery__cap b { font-size: 12.5px; }
  .home-gallery__cap time { font-size: 11px; }
  .home-trips { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .home-events__toggle { display: none; }
  .home-regions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .home-events { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .home-pokes { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
  .home-newrel { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
