/* ===== 基本設定 ===== */
:root {
  --color-bg: #fbf8f1;
  --color-bg-alt: #f1ecdf;
  --color-text: #3d3a33;
  --color-muted: #6f6a5f;
  --color-accent: #5e8c4a;
  --color-accent-dark: #466b36;
  --color-card: #ffffff;
  --color-border: #e3dccb;
  --color-land: #e4dfd2;
  --color-sea: #eef4f6;

  --header-height: 64px;
  --radius: 14px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 8px);
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.8;
}

body.no-scroll {
  overflow: hidden;
}

h1, h2, h3, h4, .logo {
  font-family: "Zen Maru Gothic", "Noto Sans JP", sans-serif;
  font-weight: 700;
}

a {
  color: var(--color-accent-dark);
}

button {
  font: inherit;
  color: inherit;
}

.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 16px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ===== ヘッダー ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(251, 248, 241, 0.95);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(6px);
}

.header-inner {
  max-width: 1160px;
  height: var(--header-height);
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.3rem;
  color: var(--color-text);
  text-decoration: none;
}

.global-nav ul {
  display: flex;
  gap: 32px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.global-nav a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 700;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: border-color 0.2s;
}

.global-nav a:hover {
  border-color: var(--color-accent);
}

/* ハンバーガー(スマホ用) */
.nav-toggle,
.nav-button {
  display: none;
}

/* ===== トップ ===== */
.hero {
  position: relative;
  overflow: hidden;
  padding: 88px 16px 120px;
  background:
    radial-gradient(circle at 85% 20%, #fff 0, transparent 40%),
    linear-gradient(180deg, #dcefd2 0%, #f3f0dc 100%);
  text-align: center;
}

.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
}

.hero-sub {
  margin: 0;
  color: var(--color-accent-dark);
  font-weight: 700;
  letter-spacing: 0.15em;
  font-size: 0.85rem;
}

.hero h1 {
  margin: 8px 0 24px;
  font-size: clamp(2.2rem, 7vw, 3.6rem);
  line-height: 1.3;
}

.hero-text {
  margin: 0 0 28px;
  color: var(--color-muted);
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 0 0 32px;
  padding: 0;
  list-style: none;
}

.hero-stats li {
  min-width: 112px;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--color-border);
}

.hero-stats strong {
  display: block;
  font-family: "Zen Maru Gothic", sans-serif;
  font-size: 1.8rem;
  line-height: 1.2;
  color: var(--color-accent-dark);
  font-variant-numeric: tabular-nums;
}

.hero-stats span {
  font-size: 0.8rem;
  color: var(--color-muted);
}

.hero-sheep {
  position: absolute;
  right: 6%;
  bottom: 10px;
  width: 180px;
  opacity: 0.9;
}

.btn {
  display: inline-block;
  padding: 12px 36px;
  border-radius: 999px;
  background: var(--color-accent);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.2s, transform 0.2s;
}

.btn:hover {
  background: var(--color-accent-dark);
  transform: translateY(-2px);
}

/* ===== セクション共通 ===== */
.section {
  padding: 80px 0;
}

.section-alt {
  background: var(--color-bg-alt);
}

.section-title {
  margin: 0;
  text-align: center;
  font-size: 2rem;
  line-height: 1.4;
}

.section-title span {
  display: block;
  color: var(--color-accent);
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.section-lead {
  margin: 12px 0 32px;
  text-align: center;
  color: var(--color-muted);
}

/* ===== 世界地図 ===== */
.map-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 32px;
}

.map-views {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}

.map-view {
  padding: 4px 16px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-card);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.map-view.is-active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.world-map {
  min-height: 200px;
}

.world-map svg,
.dlg-map svg {
  display: block;
  width: 100%;
  height: auto;
}

.map-loading {
  margin: 0;
  padding: 80px 16px;
  text-align: center;
  color: var(--color-muted);
}

.sphere {
  fill: var(--color-sea);
  stroke: var(--color-border);
}

.graticule {
  fill: none;
  stroke: #dfe8ec;
  stroke-width: 0.6;
}

.land {
  fill: var(--color-land);
  stroke: #fff;
  stroke-width: 0.5;
}

.land.has-breed {
  fill-opacity: 0.45;
  cursor: pointer;
  transition: fill-opacity 0.2s;
}

.land.has-breed:hover {
  fill-opacity: 0.75;
}

.land.has-breed.is-dim {
  fill-opacity: 0.12;
}

.pin {
  cursor: pointer;
  transition: opacity 0.2s;
}

.pin circle {
  stroke: #fff;
  stroke-width: 2;
  transition: transform 0.15s;
}

.pin:hover circle,
.pin:focus-visible circle {
  transform: scale(1.15);
}

.pin:focus {
  outline: none;
}

.pin:focus-visible circle {
  stroke: var(--color-text);
}

.pin text {
  fill: #fff;
  font-size: 12px;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
}

.pin.is-dim {
  opacity: 0.25;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 16px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.map-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

/* ===== 絞り込み ===== */
.filters {
  position: sticky;
  top: var(--header-height);
  z-index: 50;
  margin: 0 -16px 24px;
  padding: 12px 16px;
  background: rgba(251, 248, 241, 0.96);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--color-border);
}

.region-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.region-tab {
  --c: var(--color-text);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-card);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.region-tab small {
  font-weight: 400;
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}

.region-tab:hover {
  border-color: var(--c);
}

.region-tab.is-active {
  background: var(--c);
  border-color: var(--c);
  color: #fff;
}

.region-tab.is-active small {
  color: rgba(255, 255, 255, 0.85);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 8px;
}

.use-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.chip {
  padding: 2px 12px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-card);
  font-size: 0.8rem;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--color-muted);
}

.chip.is-active {
  background: var(--color-text);
  border-color: var(--color-text);
  color: #fff;
}

.search input {
  width: 280px;
  max-width: 100%;
  padding: 6px 14px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-card);
  font: inherit;
  font-size: 0.9rem;
}

.search input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.result-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

.result-count {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.country-filter {
  padding: 0 12px;
  border: none;
  border-radius: 999px;
  background: var(--color-accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.country-filter[hidden] {
  display: none;
}

/* ===== 品種一覧 ===== */
.region-group {
  margin-bottom: 48px;
}

.region-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 3px solid var(--c);
  font-size: 1.4rem;
}

.region-heading small {
  font-family: "Noto Sans JP", sans-serif;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--color-muted);
}

.region-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c);
}

.breed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.breed-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-card);
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.breed-card:hover,
.breed-card:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(61, 58, 51, 0.12);
}

.breed-card:focus-visible {
  outline: 3px solid var(--c);
  outline-offset: 2px;
}

.breed-photo {
  aspect-ratio: 4 / 3;
  background: var(--color-bg-alt);
  overflow: hidden;
}

.breed-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s;
}

.breed-card:hover .breed-photo img {
  transform: scale(1.05);
}

.breed-body {
  flex: 1;
  padding: 12px 16px 14px;
  border-top: 4px solid var(--c);
}

.breed-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.breed-head h3 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.4;
}

.breed-en {
  margin: 0;
  font-size: 0.8rem;
  color: var(--color-muted);
}

.breed-origin {
  margin: 4px 0 0;
  font-size: 0.85rem;
}

.empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--color-muted);
}

.note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--color-muted);
}

/* 用途タグ */
.tag {
  display: inline-block;
  flex: 0 0 auto;
  padding: 1px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.use-wool { background: #ebe4f6; color: #5b4a85; }
.use-meat { background: #f8e1d8; color: #9a4a2e; }
.use-dual { background: #e2efd9; color: #466b36; }
.use-milk { background: #dcebf5; color: #2f6488; }
.use-hair { background: #fbefd0; color: #87631a; }
.use-pelt { background: #e9e4dd; color: #5f5446; }
.use-primitive { background: #f4dfe8; color: #8a3e5f; }

.chip.use-all { background: var(--color-card); color: var(--color-text); }
.chip.is-active { background: var(--color-text); color: #fff; }

/* ===== 詳細画面 ===== */
.breed-dialog {
  width: min(920px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  padding: 0;
  border: none;
  border-radius: 18px;
  background: var(--color-card);
  color: var(--color-text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.breed-dialog::backdrop {
  background: rgba(40, 36, 30, 0.6);
  backdrop-filter: blur(2px);
}

.breed-dialog[open] {
  animation: dlg-in 0.2s ease-out;
}

@keyframes dlg-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.dlg-inner {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "photo body"
    "nav nav";
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.dlg-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.dlg-photo {
  grid-area: photo;
  display: flex;
  flex-direction: column;
  margin: 0;
  background: var(--color-bg-alt);
}

.dlg-photo img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
}

.dlg-photo figcaption {
  padding: 6px 12px;
  font-size: 0.75rem;
  color: var(--color-muted);
}

.dlg-body {
  grid-area: body;
  padding: 28px 28px 16px;
}

.dlg-region {
  display: inline-block;
  margin: 0;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--c);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}

.dlg-body h3 {
  margin: 8px 0 0;
  font-size: 1.9rem;
  line-height: 1.3;
}

.dlg-en {
  margin: 0 0 16px;
  color: var(--color-muted);
}

.dlg-spec {
  margin: 0 0 16px;
  border-top: 1px dashed var(--color-border);
}

.dlg-spec div {
  display: grid;
  grid-template-columns: 5em 1fr;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--color-border);
}

.dlg-spec dt {
  font-weight: 700;
  color: var(--color-accent-dark);
}

.dlg-spec dd {
  margin: 0;
}

.use-note {
  display: block;
  margin-top: 2px;
  font-size: 0.8rem;
  color: var(--color-muted);
}

.dlg-desc {
  margin: 0 0 16px;
}

.dlg-body h4 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.dlg-feats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.dlg-feats li {
  padding: 2px 12px;
  border: 1px solid var(--c);
  border-radius: 999px;
  font-size: 0.85rem;
}

.dlg-map {
  margin-bottom: 8px;
}

.mini-ring {
  fill: none;
  stroke-width: 2;
}

.dlg-link {
  margin: 0;
  font-size: 0.9rem;
}

.dlg-nav {
  grid-area: nav;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}

.dlg-nav-btn {
  max-width: 48%;
  padding: 8px 16px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-card);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dlg-nav-btn:hover:not(:disabled) {
  border-color: var(--color-accent);
}

.dlg-nav-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ===== アクセス ===== */
.access-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: stretch;
}

.access-info {
  margin: 0;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px 24px;
}

.access-row {
  display: grid;
  grid-template-columns: 6em 1fr;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px dashed var(--color-border);
}

.access-row:last-child {
  border-bottom: none;
}

.access-row dt {
  font-weight: 700;
  color: var(--color-accent-dark);
}

.access-row dd {
  margin: 0;
}

.map-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  border-radius: var(--radius);
  background: repeating-linear-gradient(45deg, #e6e0d0, #e6e0d0 12px, #ece7da 12px, #ece7da 24px);
  color: var(--color-muted);
  text-align: center;
}

.map-box p {
  margin: 0;
  padding: 16px;
}

/* ===== フッター ===== */
.site-footer {
  padding: 24px 16px;
  background: var(--color-text);
  color: #fff;
  text-align: center;
  font-size: 0.85rem;
}

.site-footer p {
  margin: 0;
}

/* ===== タブレット ===== */
@media (max-width: 900px) {
  .access-wrap {
    grid-template-columns: 1fr;
  }

  .dlg-inner {
    grid-template-columns: 1fr;
    grid-template-areas:
      "photo"
      "body"
      "nav";
  }

  .dlg-photo img {
    flex: none;
    min-height: 0;
    max-height: 60vh;
    height: auto;
  }
}

/* ===== スマホ ===== */
@media (max-width: 640px) {
  :root {
    --header-height: 56px;
  }

  body {
    font-size: 15px;
  }

  /* ハンバーガーメニュー */
  .nav-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    cursor: pointer;
  }

  .nav-button span,
  .nav-button span::before,
  .nav-button span::after {
    display: block;
    position: relative;
    width: 24px;
    height: 2px;
    background: var(--color-text);
    transition: transform 0.2s, background 0.2s;
  }

  .nav-button span::before,
  .nav-button span::after {
    content: "";
    position: absolute;
  }

  .nav-button span::before { top: -8px; }
  .nav-button span::after  { top: 8px; }

  .nav-toggle:checked + .nav-button span { background: transparent; }
  .nav-toggle:checked + .nav-button span::before { top: 0; transform: rotate(45deg); }
  .nav-toggle:checked + .nav-button span::after  { top: 0; transform: rotate(-45deg); }

  .global-nav {
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s;
  }

  .nav-toggle:checked ~ .global-nav {
    max-height: 240px;
  }

  .global-nav ul {
    flex-direction: column;
    gap: 0;
  }

  .global-nav a {
    display: block;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
  }

  /* トップ */
  .hero {
    padding: 56px 16px 150px;
  }

  .hero-text br,
  .section-lead br {
    display: none;
  }

  .hero-stats li {
    min-width: 0;
    flex: 1;
    padding: 8px;
  }

  .hero-stats strong {
    font-size: 1.4rem;
  }

  .hero-sheep {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 140px;
  }

  /* セクション */
  .section {
    padding: 56px 0;
  }

  .section-title {
    font-size: 1.6rem;
  }

  .map-card {
    padding: 8px;
    margin-left: -8px;
    margin-right: -8px;
  }

  .pin text {
    font-size: 14px;
  }

  .filters {
    padding: 8px 16px;
  }

  .search,
  .search input {
    width: 100%;
  }

  .use-chips {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .chip {
    flex: 0 0 auto;
  }

  .region-heading {
    font-size: 1.2rem;
  }

  .breed-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .breed-body {
    padding: 10px 10px 12px;
  }

  .breed-head {
    flex-direction: column;
    gap: 4px;
  }

  .breed-head h3 {
    font-size: 1rem;
  }

  /* 詳細画面は全画面表示 */
  .breed-dialog {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .dlg-inner {
    height: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    grid-template-rows: auto 1fr auto;
  }

  .dlg-body {
    padding: 20px 16px 12px;
  }

  .dlg-body h3 {
    font-size: 1.6rem;
  }

  .dlg-nav {
    position: sticky;
    bottom: 0;
  }

  .access-info {
    padding: 4px 16px;
  }

  .access-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .map-box {
    min-height: 220px;
  }
}
