/* Rescue Story — 検索サイト
   デザイントークンはアプリの src/constants/theme.ts に合わせている（warm-cream）。 */

:root {
  --surface: #FFFCF5;        /* カード・ボタン面 */
  --surface-tint: #FBF7ED;   /* パネル・ヘッダー */
  --bg: #F5F0E5;             /* ページ背景 */
  --surface-3: #EDE8DD;

  --text: #161512;
  --text-muted: rgba(22, 21, 18, 0.62);
  --text-light: rgba(22, 21, 18, 0.40);

  --border: rgba(22, 21, 18, 0.10);
  --border-medium: rgba(22, 21, 18, 0.20);

  --green: #35754D;
  --green-soft: #6FA07E;
  --green-tint: #E7F1E9;
  --accent: #F4C542;
  --accent-tint: #FCF3DA;
  --overlay: rgba(22, 21, 18, 0.45);

  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  --shadow-card: 0 2px 20px rgba(0, 0, 0, 0.05);
  --shadow-elevated: 0 4px 28px rgba(0, 0, 0, 0.10);

  --wrap: 1080px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "M PLUS Rounded 1c", -apple-system, BlinkMacSystemFont, "Hiragino Sans",
    "Noto Sans JP", sans-serif;
  font-weight: 400;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

button { font: inherit; color: inherit; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 20px;
}

/* ── ヘッダー ───────────────────────────── */

.hero {
  background: var(--surface-tint);
  border-bottom: 1px solid var(--border);
  padding: 28px 0 32px;
}

/* SP: 子猫・子犬を横並びで上段に、タイトルはその下（アプリのログイン画面と同じ構図） */
.hero-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 20px;
}

.hero-illust {
  width: 68px;
  height: auto;
  flex: none;
  filter: drop-shadow(0 6px 14px rgba(22, 21, 18, 0.10));
}

.hero-text {
  flex-basis: 100%;
  order: 3;
}

.hero-title { font-size: 24px; }

.hero-text { text-align: center; }

.hero-eyebrow {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--green);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.paw {
  width: 16px;
  height: 16px;
  display: inline-block;
  background: currentColor;
  /* 肉球シルエット */
  -webkit-mask: var(--paw) center / contain no-repeat;
  mask: var(--paw) center / contain no-repeat;
  --paw: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cellipse cx='6.2' cy='8.4' rx='2.5' ry='3.2'/%3E%3Cellipse cx='11' cy='5.6' rx='2.4' ry='3.3'/%3E%3Cellipse cx='16.2' cy='6.6' rx='2.4' ry='3.1'/%3E%3Cellipse cx='20' cy='10.6' rx='2.2' ry='2.8'/%3E%3Cpath d='M12.6 12.2c3 0 5.9 2.4 5.9 5.1 0 2.2-1.8 3.4-4 3.4-1.2 0-1.9-.4-3-.4s-1.8.4-3 .4c-2.2 0-4-1.2-4-3.4 0-2.7 3-5.1 6-5.1z'/%3E%3C/svg%3E");
}

.hero-title {
  margin: 2px 0 6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.hero-lead {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

@media (min-width: 640px) {
  .hero { padding: 40px 0 44px; }
  .hero-inner { flex-wrap: nowrap; gap: 24px; }
  .hero-illust { width: 104px; }
  .hero-text { flex-basis: auto; order: 0; }
  .hero-title { font-size: 32px; }
  .hero-lead { font-size: 15px; }
}

/* ── デモ通知 ───────────────────────────── */

.demo-notice[hidden] {
  display: none;
}

.demo-notice {
  margin: 20px 0 0;
  padding: 8px 16px;
  display: inline-block;
  background: var(--accent-tint);
  border: 1px solid rgba(244, 197, 66, 0.5);
  border-radius: var(--r-pill);
  color: #8a6410;
  font-size: 13px;
  font-weight: 500;
}

/* ── 絞り込み ───────────────────────────── */

.filters {
  margin: 20px 0 24px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
}

.chip-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1 1 auto;
}

.chip--map { flex: none; }

.chip {
  padding: 9px 18px;
  background: var(--surface-3);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.chip:hover { background: #E4DED1; }
.chip:active { transform: scale(0.97); }

.chip.is-on {
  background: var(--green);
  color: #fff;
  font-weight: 700;
}

.filter-row {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  flex: 1 1 160px;
}

.field--grow { flex: 2 1 220px; }

.field-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding-left: 4px;
}

.field select,
.field input {
  width: 100%;
  padding: 11px 14px;
  background: #fff;
  border: 1px solid var(--border-medium);
  border-radius: var(--r-sm);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  appearance: none;
  -webkit-appearance: none;
}

.field select {
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%23161512' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 11px;
}

.field select:focus-visible,
.field input:focus-visible,
.chip:focus-visible,
.card:focus-visible,
.detail-close:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.count {
  margin: 14px 0 0;
  padding-left: 4px;
  color: var(--text-muted);
  font-size: 13px;
}

.count strong {
  color: var(--green);
  font-size: 17px;
  font-weight: 700;
  margin-right: 2px;
}

/* ── 地図 ───────────────────────────────── */

.map-panel[hidden] { display: none; }

.map-panel {
  margin: 0 0 20px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
}

.map {
  height: 320px;
  background: var(--surface-3);
  border-radius: var(--r-lg);
  overflow: hidden;
}

/* leaflet.css は動的に後から読み込まれるので、勝てる詳細度で上書きする。 */
.map.leaflet-container { font-family: inherit; }

@media (min-width: 640px) {
  .map { height: 420px; }
}

.map-note:empty { display: none; }

.map-note {
  margin: 8px 0 2px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

/* 都道府県ごとの掲載頭数バッジ（Leaflet の DivIcon） */
.map .map-pin {
  display: grid;
  place-items: center;
  background: var(--green);
  border: 2px solid #fff;
  border-radius: var(--r-pill);
  box-shadow: 0 2px 8px rgba(22, 21, 18, 0.28);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}

.map .map-pin:hover { background: var(--green-soft); }

.map .map-pin:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* ── 一覧 ───────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding-bottom: 8px;
}

@media (min-width: 520px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 860px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 20px; }
}

.card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-elevated);
}

.card:active { transform: translateY(-1px); }

.card-photo {
  aspect-ratio: 4 / 3;
  background: var(--surface-3);
  overflow: hidden;
}

.card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-photo img.is-placeholder {
  object-fit: contain;
  padding: 14%;
  background: var(--green-tint);
}

.card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.card-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-name {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gender {
  flex: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.gender--male { color: #0EA5E9; background: #E8F5FE; }
.gender--female { color: #F43F5E; background: #FEECEF; }
.gender--unknown { color: #94A3B8; background: #EFF2F5; }

.card-meta {
  color: var(--text-muted);
  font-size: 13px;
}

.card-personality {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-org {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  color: var(--text-light);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── 空状態 / エラー ───────────────────── */

.state {
  padding: 48px 20px 64px;
  text-align: center;
}

.state-illust {
  width: 148px;
  margin: 0 auto 16px;
  filter: drop-shadow(0 8px 18px rgba(22, 21, 18, 0.10));
}

.state-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
}

.state-text {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── 詳細モーダル ───────────────────────── */

.detail {
  width: min(560px, calc(100vw - 24px));
  max-height: min(88vh, 900px);
  padding: 0;
  border: none;
  border-radius: var(--r-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-elevated);
  overflow: visible;
}

.detail::backdrop { background: var(--overlay); }

.detail-body {
  max-height: min(88vh, 900px);
  overflow-y: auto;
  border-radius: var(--r-xl);
  -webkit-overflow-scrolling: touch;
}

.detail-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  background: rgba(255, 252, 245, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.detail-photo {
  aspect-ratio: 4 / 3;
  background: var(--surface-3);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  overflow: hidden;
}

.detail-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-photo img.is-placeholder {
  object-fit: contain;
  padding: 10%;
  background: var(--green-tint);
}

.detail-main { padding: 18px 20px 28px; }

.detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-name {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
}

.badge {
  padding: 4px 12px;
  border-radius: var(--r-pill);
  background: var(--green-tint);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.detail-sub {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.facts {
  margin: 18px 0 0;
  padding: 4px 16px;
  background: var(--surface-tint);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

.facts > div {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.facts > div:last-child { border-bottom: none; }

.facts dt {
  flex: none;
  width: 6.5em;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

.facts dd {
  margin: 0;
  flex: 1;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.note {
  margin: 16px 0 0;
  padding: 16px 18px;
  background: var(--accent-tint);
  border-radius: var(--r-lg);
}

.note-label {
  margin: 0 0 4px;
  color: #8a6410;
  font-size: 12px;
  font-weight: 700;
}

.note-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.org {
  margin: 20px 0 0;
  padding: 16px 18px;
  background: var(--surface-tint);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

.org-label {
  margin: 0 0 4px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.org-name {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.org-area {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.org-desc {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.org-links {
  margin: 14px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.org-link {
  padding: 8px 16px;
  background: var(--green);
  border-radius: var(--r-pill);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.org-link:hover { background: #2c5f40; }

.org-link--ghost {
  background: var(--surface);
  border: 1px solid var(--border-medium);
  color: var(--green);
}

.org-link--ghost:hover { background: var(--green-tint); }

.org-text {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

/* ── フッター ───────────────────────────── */

.footer {
  margin-top: 40px;
  padding: 28px 0 40px;
  background: var(--surface-tint);
  border-top: 1px solid var(--border);
  color: var(--text-light);
  font-size: 12px;
  text-align: center;
}

.footer p { margin: 0 0 4px; }

.footer-brand { color: var(--green); font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
