/* Мультяшний глобус: стилі сторінки pages/globe-v2.html */
html, body { margin: 0; height: 100%; overflow: hidden; }

body.globe-page {
  background: #03040d;
  font-family: 'Varela Round', 'Nunito', system-ui, sans-serif;
  color: var(--text-dark, #0d1b2a);
}

/* комети поверх неба (саме небо — у 3D-сцені глобуса), малює space.js */
#space {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  display: block;
  width: 100%;
  height: 100%;
}

/* хедер сайту читається на темному небі */
.globe-page .nav-transparent .nav-inner { background: rgba(255, 255, 255, 0.92) !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

#globe {
  position: fixed;
  inset: 0;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.9s ease;
  touch-action: none;
}
body.ready #globe { opacity: 1; }

/* ---------- завантаження ---------- */
#loader {
  position: fixed; inset: 0; z-index: 3;
  display: grid; place-content: center; justify-items: center; gap: 16px;
  transition: opacity 0.6s ease, visibility 0.6s;
}
body.ready #loader { opacity: 0; visibility: hidden; }
#loader p { margin: 0; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 18px; color: #dfe6ff; }
#loader .pearl { width: 30px; height: 30px; animation: bob 1.4s ease-in-out infinite; }

@keyframes bob {
  0%, 100% { transform: translateY(0) scale(0.95); }
  50% { transform: translateY(-9px) scale(1.05); }
}

#error { position: fixed; inset: 0; z-index: 4; display: none; place-content: center; text-align: center; padding: 24px; font-family: 'Fredoka', sans-serif; font-size: 20px; color: #fff; }
body.failed #error { display: grid; }
body.failed #loader { display: none; }

/* ---------- перлина: маркер країни ---------- */
.pearl {
  display: inline-block;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #fff 0%, #ffd0e4 34%, #ff4f96 100%);
  border: 1.5px solid #fff;
  box-shadow: 0 2px 5px rgba(20, 30, 90, 0.4);
}

.pin { position: absolute; width: 0; height: 0; pointer-events: none; transition: opacity 0.25s ease; }
.pin { --size: calc(11px * var(--pin-s, 1)); }
.pin .pearl {
  position: absolute; left: calc(var(--size) / -2); top: calc(var(--size) / -2); width: var(--size); height: var(--size);
  transition: transform 0.35s var(--ease-bounce, cubic-bezier(.34, 1.56, .64, 1));
}
.pin::before {
  content: ''; position: absolute; left: calc(var(--size) / -2); top: calc(var(--size) / -2); width: var(--size); height: var(--size);
  border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, 0.9);
  animation: ring 3s ease-out infinite; animation-delay: var(--delay, 0s);
}
.pin.on .pearl { transform: scale(1.5) translateY(-2px); }
.pin .name {
  position: absolute; left: 0; top: calc(var(--size) / 2 + 2px); transform: translateX(-50%);
  font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 11px; white-space: nowrap;
  color: #0d1b2a;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 5px #fff, 0 0 5px #fff;
  opacity: 0; transition: opacity 0.3s ease;
}
.pin.named .name { opacity: 1; }
.pin.on .name { opacity: 0; }

/* назви інших країн: дрібні, з'являються лише при наближенні */
.clabel {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: 'Varela Round', sans-serif;
  font-size: 10px;
  white-space: nowrap;
  color: rgba(13, 27, 42, 0.78);
  text-shadow: 0 0 2px #fff, 0 0 3px #fff, 0 0 4px rgba(255, 255, 255, 0.9);
  pointer-events: none;
  transition: opacity 0.3s ease;
}

@keyframes ring {
  0% { transform: scale(1); opacity: 0.95; }
  70%, 100% { transform: scale(2.4); opacity: 0; }
}

/* ---------- підпис країни ---------- */
#stageLabel {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 20;
  transform: translate(-50%, 12px) scale(0.96);
  padding: 12px 30px 12px; border-radius: 28px;
  background: #fff; border: 3px solid #fff;
  box-shadow: var(--shadow-md, 0 8px 32px rgba(0, 80, 160, 0.14)), 0 0 0 4px rgba(133, 193, 233, 0.45);
  text-align: center; opacity: 0; pointer-events: none; max-width: calc(100vw - 32px);
  transition: opacity 0.18s ease, transform 0.4s var(--ease-bounce, cubic-bezier(.34, 1.56, .64, 1));
}
#stageLabel.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
#stageLabel .country {
  display: block; font-family: 'Fredoka', sans-serif; font-weight: 700;
  font-size: clamp(28px, 4.2vw, 42px); line-height: 1.1; color: #4a90e2;
}
#stageLabel .hint { display: block; margin-top: 2px; font-size: 15px; color: var(--text-muted, #5d7a8a); }
#stageLabel.open .hint { color: var(--pink-cta, #ff0066); }

/* ---------- нижня панель ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: 0 max(16px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  pointer-events: none;
}
.dock > * { pointer-events: auto; }

.legend {
  display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 20px 0 16px;
  border-radius: 999px; background: #fff; box-shadow: var(--shadow-md, 0 8px 32px rgba(0, 80, 160, 0.14));
  font-size: 15px; color: var(--text-body, #2c3e50);
}
.legend .pearl { width: 16px; height: 16px; flex: none; }

.dock-right { position: relative; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.dock-row { display: flex; gap: 10px; }

.btn {
  min-height: 46px; min-width: 46px; padding: 0 20px; border: 0; border-radius: 999px;
  background: #fff; color: var(--text-dark, #0d1b2a);
  font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 16px; cursor: pointer;
  box-shadow: var(--shadow-md, 0 8px 32px rgba(0, 80, 160, 0.14));
  transition: transform 0.25s var(--ease-bounce, cubic-bezier(.34, 1.56, .64, 1)), background 0.2s ease, color 0.2s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: scale(0.95); }
.btn.round { padding: 0; font-size: 26px; line-height: 1; }
.btn.text[aria-expanded='true'] { background: var(--pink-cta, #ff0066); color: #fff; }

:focus-visible { outline: 3px solid #4a90e2; outline-offset: 3px; }

#countryPanel {
  position: absolute; right: 0; bottom: calc(100% + 12px);
  width: min(340px, calc(100vw - 32px)); max-height: min(56vh, 460px); overflow: auto;
  padding: 10px; border-radius: 26px; background: #fff;
  box-shadow: var(--shadow-lg, 0 20px 60px rgba(0, 80, 160, 0.18)), 0 0 0 4px rgba(133, 193, 233, 0.4);
  transform-origin: bottom right;
  transition: opacity 0.2s ease, transform 0.35s var(--ease-bounce, cubic-bezier(.34, 1.56, .64, 1)), visibility 0.25s;
}
#countryPanel[hidden] { display: block; opacity: 0; visibility: hidden; transform: translateY(10px) scale(0.94); }
#countryPanel .panel-title { margin: 8px 12px 6px; font-family: 'Fredoka', sans-serif; font-size: 18px; font-weight: 600; color: #4a90e2; }
#countryPanel ul { list-style: none; margin: 0; padding: 0; }
#countryPanel a {
  display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 12px; border-radius: 16px;
  color: var(--text-dark, #0d1b2a); font-size: 17px; text-decoration: none;
}
#countryPanel a:hover, #countryPanel a:focus-visible { background: var(--surface, #d6eaf8); }
#countryPanel a .pearl { width: 12px; height: 12px; flex: none; border-width: 1.5px; }

@media (max-width: 560px) {
  .legend { font-size: 13px; padding: 0 14px 0 12px; }
  .btn.text { padding: 0 16px; }
  #stageLabel { bottom: calc(150px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .pin::before, #loader .pearl { animation: none; }
  #globe, #stageLabel, #countryPanel, .pin, .pin .pearl, .pin .name, .clabel, .btn { transition: none; }
}
