/* National dishes — self-contained, no build. */
@font-face {
  font-family: "EB Garamond";
  src: url("../fonts/eb-garamond.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "EB Garamond";
  src: url("../fonts/eb-garamond-italic.woff2") format("woff2");
  font-weight: 400 800;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("../fonts/cormorant-garamond.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}
:root {
  --paper: #F4EFE6;
  --card: #F7F3EC;
  --ink: #2A221C;
  --ink-soft: #3F372F;
  --muted: #5C5349;
  --line: #C5C0B6;
  --water: #E4EAEE;
  --water-deep: #D5DEE4;
  --accent: #7A3E1D;
  --gap: #DDD6CB;
  --shadow: none;
  --radius: 16px;
  --font-serif: "EB Garamond", "Palatino Linotype", Palatino, "Times New Roman", serif;
  --font-display: "Cormorant Garamond", "EB Garamond", Palatino, serif;
  --font-sans: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 18px; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.45;
}

header, main, footer { width: min(1200px, calc(100% - 32px)); margin-inline: auto; }
header { padding: 20px 0 8px; }
h1 {
  font-family: var(--font-display);
  font-weight: 650;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.1;
  margin: 0.2rem 0 0.6rem;
  letter-spacing: -0.02em;
}
.kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}
.lead {
  font-family: var(--font-serif);
  font-size: 1.12rem;
  max-width: 42rem;
  color: var(--ink-soft);
  margin: 0 0 0.75rem;
}

#world-hero {
  margin: 0 0 0.25rem;
}
#world-wrap {
  position: relative;
  background: var(--paper);
  border: none;
  border-radius: 0;
  overflow: visible;
  box-shadow: none;
  display: flex;
  justify-content: center;
  align-items: center;
}
#world-wrap svg {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 56vh;
  aspect-ratio: 1200 / 640;
  touch-action: none;
}
#world-wrap { touch-action: none; }
#map-zoom {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#map-zoom button {
  min-width: 48px;
  min-height: 48px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font: 600 1.35rem/1 var(--font-sans);
  box-shadow: none;
  cursor: pointer;
}
#map-zoom button#zoom-reset {
  font-size: 0.85rem;
  letter-spacing: 0.01em;
}
#map-zoom button:disabled {
  opacity: 0.4;
  cursor: default;
}
@media (max-width: 720px) {
  #world-wrap {
    flex-direction: column;
    align-items: stretch;
  }
  #world-wrap svg {
    width: 100%;
    max-height: none;
  }
  #map-zoom {
    position: static;
    flex-direction: row;
    justify-content: flex-end;
    width: 100%;
    margin: 6px 0 0;
    right: auto;
    bottom: auto;
  }
}

#map-zoom button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
#world-wrap path.c {
  stroke: #F4EFE6;
  stroke-width: 0.45px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
#world-wrap path.c.other {
  fill: #E6DFD4;
  pointer-events: none;
}
#world-wrap path.c[data-staple="none"],
#world-wrap path.c.gap {
  fill: #DDD6CB;
  cursor: pointer;
}
#world-wrap path.c[data-staple="rice"] { fill: #C8A35A; cursor: pointer; }
#world-wrap path.c[data-staple="wheat"] { fill: #C47A3C; cursor: pointer; }
#world-wrap path.c[data-staple="maize"] { fill: #6E9260; cursor: pointer; }
#world-wrap path.c[data-staple="roots"] { fill: #A05C7C; cursor: pointer; }
#world-wrap path.c[data-staple="pulses"] { fill: #1A656C; cursor: pointer; }
#world-wrap path.c[data-staple="meat"] { fill: #C15A4A; cursor: pointer; }
#world-wrap path.c[data-staple="mixed"] { fill: url(#staple-hatch); cursor: pointer; }
#world-wrap path.ws {
  fill: none !important;
  stroke: #C5C0B6;
  stroke-width: 0.9px;
  stroke-dasharray: 3 2;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}
#world-wrap path.limb {
  fill: none;
  pointer-events: none;
}
#world-wrap circle.hit {
  fill: transparent;
  stroke: none;
  pointer-events: auto;
  cursor: pointer;
}
#world-wrap,
#world-wrap svg,
#world-wrap path {
  -webkit-tap-highlight-color: transparent;
  outline: none !important;
}
#world-wrap path.c.has:hover,
#world-wrap path.c.gap:hover,
#world-wrap path.c[data-iso]:hover {
  stroke: var(--ink);
  stroke-width: 1.4px;
  filter: none;
  vector-effect: non-scaling-stroke;
}
#world-wrap.has-hot path.c:not(.is-hot) { opacity: 0.45; }
#world-wrap.has-hot path.ws { opacity: 0.45; }
#world-wrap path.c.is-hot,
#world-wrap path.c.is-active {
  stroke: #1A1410;
  stroke-width: 2px;
  filter: none;
  opacity: 1;
  outline: none !important;
  vector-effect: non-scaling-stroke;
}
#world-wrap.filter-on path.c:not(.is-filtered) { opacity: 0.22; }
#world-wrap.filter-on path.c.is-filtered { opacity: 1; }
#world-wrap.filter-on path.ws { opacity: 0.35; }

#staple-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
}
#staple-legend button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 6px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 550;
  line-height: 1.15;
  cursor: pointer;
  text-align: left;
}
#staple-legend button .swatch {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 1px solid rgba(26, 20, 16, 0.35);
  flex: none;
}
#staple-legend button .swatch.hatch,
#map-popup .popup-staple .swatch.hatch {
  background-image: repeating-linear-gradient(
    -45deg,
    #C4B8A8 0 1.5px,
    transparent 1.5px 5px
  );
}
#staple-legend button .count {
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
#staple-legend button[aria-pressed="true"] {
  outline: 1.5px solid var(--ink);
  outline-offset: 3px;
  background: transparent;
  font-weight: 650;
}
#staple-legend button:focus-visible {
  outline: 3px solid #5A86AB;
  outline-offset: 1px;
}

#map-popup {
  position: fixed;
  z-index: 30;
  width: min(280px, calc(100vw - 16px));
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(26, 20, 16, 0.18);
  padding: 0;
}
#map-popup button.popup-card {
  appearance: none;
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 14px;
}
#map-popup button.popup-card:focus-visible {
  outline: 3px solid #5A86AB;
  outline-offset: 1px;
}
#map-popup .dish-photo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  border: 1px solid var(--line);
  background: #EEE8DC;
}
#map-popup .popup-country {
  font-weight: 700;
  margin: 0 0 2px;
  font-size: 1rem;
  line-height: 1.2;
}
#map-popup .popup-dish {
  margin: 0 0 4px;
  font-style: italic;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.25;
}
#map-popup .popup-staple {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
#map-popup .popup-staple .swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(26, 20, 16, 0.35);
  flex: none;
}

.map-note {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin: 0.45rem 0 1rem;
  background: none;
  border: none;
}

.tools { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--paper) 92%, white); padding: 10px 0 8px; margin: 0 -8px; padding-left: 8px; padding-right: 8px; }
#search {
  width: 100%;
  font: inherit;
  font-size: 1.05rem;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
}
#search:focus { outline: 3px solid #9EBFDA; border-color: #5A86AB; }
#az {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin: 8px 0 12px;
}
#az a {
  min-width: 1.7rem;
  text-align: center;
  padding: 6px 4px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: 6px;
}
#az a:hover, #az a:focus { background: #E8D3B0; outline: none; }
#az a.is-empty { color: #B0A59A; pointer-events: none; }


#grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  padding-bottom: 4rem;
}
.letter-head {
  grid-column: 1 / -1;
  font-family: var(--font-serif);
  font-size: 1.6rem;
  margin: 1.2rem 0 0.2rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--line);
  scroll-margin-top: 96px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 280px;
  width: 100%;
}
.card:hover, .card:focus {
  border-color: var(--ink);
  outline: 3px solid #9EBFDA;
  outline-offset: 2px;
}
.card .art {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: center;
  min-height: 120px;
}
.card .art .outline {
  width: 100%;
  height: 120px;
  object-fit: contain;
}
.card .art .dish-photo {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 50%;
  background: #EEE8DC;
  border: 1px solid var(--line);
}
.card h2 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  line-height: 1.2;
  margin: 0;
  font-weight: 600;
}
.card .dish {
  margin: 0;
  color: var(--accent);
  font-style: italic;
  font-size: 1.02rem;
}
.card.gap {
  background: #EFEBE4;
  opacity: 0.95;
}
.card.gap .dish { color: var(--muted); font-style: italic; }
.card .hint { margin: 0; font-size: 0.8rem; color: var(--muted); }

footer {
  border-top: 1px solid var(--line);
  padding: 1.5rem 0 3rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
footer a { color: var(--ink); }

/* Detail dialog */
#detail {
  width: min(720px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 16px 48px rgba(26, 20, 16, 0.25);
}
#detail::backdrop { background: rgba(26, 20, 16, 0.45); }
#detail .inner { padding: 24px 24px 32px; overflow: auto; max-height: calc(100vh - 24px); }
#detail h2 { font-family: var(--font-serif); font-size: 2rem; margin: 0 0 0.2rem; }
#detail .dish { font-style: italic; color: var(--accent); font-size: 1.25rem; margin: 0 0 1rem; }
#detail .hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 1.25rem;
  align-items: center;
}
#detail .hero .dish-photo {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #EEE8DC;
}
#detail .hero .outline { width: 100%; height: auto; }
#detail h3 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 1.2rem 0 0.4rem;
}
#detail ol, #detail ul { padding-left: 1.2rem; margin: 0.2rem 0 0.8rem; }
#detail li { margin: 0.25rem 0; }
#detail .source, #detail .desc {
  font-size: 0.95rem;
  color: var(--ink-soft);
}
#detail .source { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
#close-detail {
  appearance: none;
  background: var(--ink);
  color: var(--paper);
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  float: right;
}
#close-detail:hover, #close-detail:focus { background: #000; outline: 3px solid #9EBFDA; }

.hidden { display: none !important; }

@media (max-width: 640px) {
  html { font-size: 17px; }
  header, main, footer { width: calc(100% - 24px); }
  #grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { min-height: 0; padding: 10px; }
  .card .art { grid-template-columns: 1fr; }
  .card .art .outline { height: 80px; }
  .card h2 { font-size: 1.05rem; }
  #detail .hero { grid-template-columns: 1fr; }
  .tools { top: 0; }
  #az a { min-width: 1.45rem; padding: 8px 0; }
}

#map-popup.sheet {
  left: 8px !important;
  right: 8px !important;
  bottom: 8px !important;
  top: auto !important;
  width: auto;
  max-width: none;
}

#status-line { display: none; }

@media (max-width: 640px) {
  #map-popup.sheet {
    left: 8px !important;
    right: 8px !important;
    bottom: 8px !important;
    top: auto !important;
  }
}
