/* Ea Jane's World — bright daytime sibling of the bedtime site. */
@font-face {
  font-family: 'Fredoka';
  src: url('fonts/fredoka-latin.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --ocean: #cfeaf8;
  --deep: #1d3557;
  --paper: #ffffff;
  --accent: #ff8fab;
  --africa: #fdb833;
  --asia: #ef767a;
  --europe: #7bc950;
  --namerica: #f18701;
  --samerica: #b388eb;
  --oceania: #43bccd;
  --territory: #e3ecf2;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Fredoka', system-ui, sans-serif;
  background: var(--ocean);
  color: var(--deep);
  min-height: 100vh;
}

.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; }
.app-title { font-size: 1.5rem; margin: 0; flex: 1; }
.home-btn, .toggle-btn {
  font: inherit;
  color: var(--deep);
  background: var(--paper);
  border: 2px solid var(--deep);
  border-radius: 999px;
  padding: 6px 14px;
  text-decoration: none;
  cursor: pointer;
}
.toggle-btn.is-active { background: var(--accent); }

main { padding: 0 16px 24px; }

/* --- map view --- */
#map-view { position: relative; }
/* The window is twice as tall as the map itself (viewBox 1000x520), so there is
   slack above and below to pan into once zoomed — the world keeps its own size
   and sits centered. Capped to the screen, but never shorter than the map's own
   height (52% of the content width): a shorter window would scale the world down
   to fit and would also break the pan math in map.js, which assumes the map is
   sized by the window's width. */
#map-box {
  display: grid;
  place-items: center;
  width: 100%; /* keep it: with aspect-ratio alone, max-height shrinks the width */
  aspect-ratio: 1000 / 1040;
  max-height: max(84svh, calc((100vw - 32px) * 0.52));
}
#map-box svg { width: 100%; height: 100%; display: block; touch-action: none; }
.sphere { fill: #b5ddf2; }
.territory { fill: var(--territory); stroke: #fff; stroke-width: 0.4; }
.country { stroke: #fff; stroke-width: 0.5; cursor: pointer; }
.c-africa { fill: var(--africa); }
.c-asia { fill: var(--asia); }
.c-europe { fill: var(--europe); }
.c-namerica { fill: var(--namerica); }
.c-samerica { fill: var(--samerica); }
.c-oceania { fill: var(--oceania); }
.country, .territory { vector-effect: non-scaling-stroke; }
.country:hover { filter: brightness(1.15); }
.country:active { filter: brightness(1.3); }
.country.is-selected { filter: brightness(1.2); stroke: var(--deep); }
.marker { cursor: pointer; }
.marker-hit { fill: transparent; }
.marker-dot { fill: var(--deep); stroke: #fff; stroke-width: 1.5; }
.marker:hover .marker-dot, .marker.is-selected .marker-dot { fill: var(--accent); }

.zoom-controls {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.zoom-controls button {
  font-size: 1.1rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--deep);
  background: var(--paper);
  cursor: pointer;
}
@media (max-width: 600px) {
  .zoom-controls {
    position: static;
    flex-direction: row;
    justify-content: center;
    margin-top: 10px;
  }
}

/* --- A–Z view --- */
#az-letters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.az-letter {
  font: inherit;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--deep);
  background: var(--paper);
  cursor: pointer;
}
.az-letter:disabled { opacity: 0.3; cursor: default; }
.az-letter.is-active { background: var(--accent); }
#az-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.az-country {
  font: inherit;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--paper);
  border: 2px solid var(--deep);
  border-radius: 14px;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 2px 0 rgba(29, 53, 87, 0.15);
}
.az-country img { width: 34px; height: 24px; object-fit: cover; border-radius: 4px; }

/* --- country card --- */
#card-backdrop { position: fixed; inset: 0; background: rgba(29, 53, 87, 0.5); }
#card {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  background: var(--paper);
  padding: 20px;
  border: 0;
  box-shadow: 0 -12px 40px rgba(29, 53, 87, 0.3);
}
@media (prefers-reduced-motion: no-preference) {
  #card:not([hidden]) { animation: card-in 200ms ease-out; }
  @keyframes card-in { from { transform: translateY(24px); opacity: 0; } }
}
@media (min-width: 720px) {
  #card { inset: 0 0 0 auto; width: 420px; border-left: 4px solid var(--deep); }
}
.card-close {
  position: absolute;
  top: 12px;
  right: 12px;
  font: inherit;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--deep);
  background: var(--paper);
  cursor: pointer;
}
.card-head { display: flex; align-items: center; gap: 12px; margin-right: 52px; }
.card-flag { width: 84px; height: 56px; object-fit: cover; border-radius: 8px; border: 2px solid var(--deep); }
.card-head h2 { margin: 0; font-size: 1.4rem; }
.chip { display: inline-block; background: var(--ocean); border-radius: 999px; padding: 2px 10px; font-size: 0.85rem; }
.card-capital { font-size: 1.05rem; }
.card-photo { margin: 12px 0; }
.card-photo img { width: 100%; border-radius: 12px; }
.card-photo figcaption { font-size: 0.85rem; opacity: 0.8; }
.card-photo-missing { font-size: 3rem; text-align: center; margin: 12px 0; }
.langs { list-style: none; padding: 0; margin: 0 0 12px; }
.langs li { padding: 6px 0; border-bottom: 1px dashed var(--ocean); }
.lang-name { font-weight: 600; margin-right: 6px; }
.lang-hello { color: #c9184a; font-weight: 600; }
.lang-phon { opacity: 0.75; }
.say-btn {
  font-size: 1rem;
  border: 2px solid var(--deep);
  background: var(--paper);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  cursor: pointer;
}
.fun-fact { background: var(--ocean); border-radius: 12px; padding: 10px 12px; }
.wonder { background: #fff3c4; border: 2px dashed var(--africa); border-radius: 12px; padding: 10px 12px; }
.fallback, .map-loading { font-size: 1.2rem; text-align: center; padding: 40px 16px; }
.retry-btn {
  display: block;
  margin: 16px auto 0;
  font: inherit;
  font-size: 1.3rem;
  padding: 12px 28px;
  border-radius: 999px;
  border: 2px solid var(--deep);
  background: var(--accent);
  color: var(--deep);
  cursor: pointer;
}

/* --- loading placeholder --- */
.map-loading span { display: inline-block; }
@media (prefers-reduced-motion: no-preference) {
  .map-loading span { animation: globe-bounce 1.2s ease-in-out infinite; }
  @keyframes globe-bounce { 50% { transform: translateY(-6px); } }
}

/* --- tap feedback + focus --- */
:is(button, a) { transition: transform 120ms; }
:is(button, a):active { transform: scale(0.92); }
:is(button, a):focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* --- credits page --- */
body.credits { padding: 16px; background: var(--paper); }
body.credits li { margin-bottom: 4px; }
