/* styles.css */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--body-bg);
}

#map {
  position: fixed;
  inset: 0;
  width: 100vw !important;
  height: 100vh !important;
}

.all-controls {
  position: fixed;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
  animation: fade-in 0.4s ease both;
}

.map-controls,
.geo-control,
.search-control,
.settings-control,
.donate-control {
  gap: 1px;
  background-color: var(--bg-control);
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-medium);
  transform: translateY(-6px);
  opacity: 0;
  animation: slide-down 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) 0.1s forwards;
  border: 1px solid var(--border-control);
}

.map-controls {
  animation-delay: 0.18s;
}

.geo-control {
  animation-delay: 0.26s;
}

.map-controls button,
.geo-control button,
.search-control button,
.donate button {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--bg-button);
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s, transform 0.12s ease;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-controls button:hover,
.geo-control button:hover,
.search-control button:hover,
.donate button:hover {
  background: var(--hover-alt);
}

.map-controls button:active,
.geo-control button:active,
.search-control button:active,
.donate button:active {
  transform: scale(0.96);
}

#reset-north img.compass-icon {
  width: 18px;
  height: 18px;
  display: block;
  transition: transform 0.3s ease;
  transform-origin: center;
  filter: var(--icon-filter);
}

.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay-strong);
  backdrop-filter: blur(5px);
  display: none;
  z-index: 20;
  opacity: 0;
}

.overlay.active {
  display: block;
  animation: fade-in 0.2s ease forwards;
}

.overlay.closing {
  animation: fade-out 0.2s ease forwards;
}

.search-modal {
  position: fixed;
  top: var(--top-offset);
  left: 50%;
  transform: translateX(-50%) scale(0.98);
  width: min(720px, calc(100vw - 2 * var(--side-offset)));
  max-height: min(70vh, 640px);
  z-index: 30;
  padding: 0;
  display: none;
  opacity: 0;
}

.search-modal.active {
  display: block;
  animation: pop-in 0.22s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}

.search-modal.closing {
  animation: pop-out 0.18s ease forwards;
}

.search-card {
  width: 100%;
  height: auto;
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-strong);
}

.search-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border-strong);
  text-align: center;
}

.input-wrap {
  display: grid;
  grid-template-columns: 28px 1fr 36px;
  align-items: center;
  gap: 10px;
  background: var(--bg-input-alt);
  border: 1px solid #2a2a2e;
  border-radius: 6px;
  padding: 6px 10px;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.input-wrap:focus-within {
  border-color: var(--accent-strong);
  box-shadow: var(--focus-ring);
  background: var(--panel-4);
}

.input-wrap i {
  color: var(--text-muted-6);
}

.input-wrap input {
  width: 100%;
  background: transparent;
  color: var(--text);
  border: none;
  outline: none;
  font-size: 16px;
  font-family: "Light", Arial, sans-serif;
}

.clear-btn,
.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted-6);
  font-size: 16px;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s, transform 0.12s;
}

.clear-btn:hover,
.close-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.clear-btn:active,
.close-btn:active {
  transform: scale(0.96);
}

.search-body {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-height: calc(min(70vh, 640px) - 64px);
  background: var(--panel);
}

.results {
  display: flex;
  flex-direction: column;
}

.result-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-strong);
  transition: background 0.15s ease, transform 0.12s ease, color 0.15s ease;
  background: transparent;
}

.result-item:hover {
  background: var(--hover);
}

.result-item:active {
  transform: scale(0.99);
}

.result-item i {
  color: var(--accent);
}

.result-title {
  font-size: 15px;
  color: var(--text);
  line-height: 1.2;
  font-family: "Bold", Arial, sans-serif;
}

.result-sub {
  font-size: 12px;
  color: var(--text-muted-7);
  font-family: "Light", Arial, sans-serif;
}

.pill {
  font-size: 11px;
  color: var(--text);
  background: var(--accent);
  border: 0;
  padding: 4px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted-7);
  animation: fade-in 0.2s ease both;
}

.loading {
  padding: 20px 16px;
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--text-muted-7);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--spinner-border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes slide-down {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateX(-50%) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
}

@keyframes pop-out {
  from {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) scale(0.98);
  }
}

@keyframes slide-in-left {
  from {
    transform: translateX(-105%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slide-out-left {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-105%);
  }
}

.info-panel {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: min(420px, 92vw);
  background: var(--panel);
  backdrop-filter: blur(6px);
  border-radius: 0px 8px 8px 0px;
  overflow: hidden;
  box-shadow: var(--shadow-panel);
  color: var(--text);
  z-index: 15;
  transform: translateX(-105%);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-strong);
}

.info-panel.active {
  animation: slide-in-left 0.28s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}

.info-panel.closing {
  animation: slide-out-left 0.2s ease forwards;
}

.info-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 12px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border-strong);
}

.city-row {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: center;
  justify-items: start;
}

.city-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-width: 0;
}

.flag {
  width: 37px;
  height: 28px;
  border-radius: 3px;
  object-fit: cover;
  box-shadow: var(--shadow-flag);
  border: 1px solid var(--flag-border);
  background: var(--bg-hero);
}

.city-title {
  font-size: 2em;
  line-height: 1.2;
  font-family: "Bold", sans-serif;
  text-align: left;
  width: 100%;
}

.city-sub {
  color: var(--text-muted-7);
  font-size: 1em;
  margin-top: 2px;
  font-family: "Light", Arial, sans-serif;
  text-align: left;
  width: 100%;
}

.info-close {
  background: transparent;
  border: none;
  color: var(--text-muted-6);
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.12s;
  justify-self: end;
}

.info-close:hover {
  background: var(--hover);
  color: var(--text);
}

.info-close:active {
  transform: scale(0.96);
}

.info-body {
  padding: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  display: block;
  background: var(--panel);
}

.city-photo-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-input-alt);
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border-strong);
}

.city-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.city-photo.loaded {
  opacity: 1;
}

.photo-skeleton {
  position: absolute;
  inset: 0;
  background: var(--gradient-photo-skeleton);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.photo-caption {
  position: absolute;
  left: 8px;
  bottom: 8px;
  background: var(--bg-photo-caption);
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--text-muted-14);
  font-size: 11px;
  backdrop-filter: blur(4px);
}

.photo-caption a {
  color: var(--text-muted-15);
  text-decoration: none;
}

.photo-caption a:hover {
  color: var(--accent);
  text-decoration: underline;
}

#wiki-text {
  font-family: "Light";
}

.info-section {
  padding: 14px;
  display: grid;
  gap: 14px;
  background: var(--panel);
}

.info-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  font-size: 1em;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-strong);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  letter-spacing: 0.02em;
  white-space: nowrap;
  font-family: "Bold", Arial, sans-serif;
}

.info-label i {
  color: var(--text);
}

.info-value {
  color: var(--text);
  justify-self: end;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: "Light", Arial, sans-serif;
}

.muted {
  color: var(--text-muted-6);
}

.wiki {
  font-size: 1em;
  line-height: 1.6;
  color: var(--text-muted-16);
}

.panel-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted-7);
  padding: 14px;
}

.pin {
  width: 24px;
  height: 24px;
  position: relative;
  transform: translateY(-6px);
  animation: pin-pop 0.28s ease both;
}

@keyframes pin-pop {
  0% {
    transform: translateY(-6px) scale(0.6);
    opacity: 0;
  }
  60% {
    transform: translateY(-6px) scale(1.08);
    opacity: 1;
  }
  100% {
    transform: translateY(-6px) scale(1);
  }
}

.pin:before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-bottom: 22px solid var(--pin-color);
  transform: translateX(-50%);
  filter: drop-shadow(var(--shadow-pin));
}

.pin:after {
  content: "";
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text);
}

.pin-shadow {
  position: absolute;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  width: 18px;
  height: 6px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  filter: blur(4px);
}

.all-controls-left {
  position: fixed;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10000;
  animation: fade-in 0.4s ease both;
}

.settings-control {
  gap: 1px;
  background-color: var(--bg-control);
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-medium);
  transform: translateY(-6px);
  opacity: 0;
  animation: slide-down 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) 0.14s forwards;
}

.settings-control button {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--bg-button);
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s, transform 0.12s ease;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-control button:hover {
  background: var(--hover-alt);
}

.settings-control button:active {
  transform: scale(0.96);
}

.donate-control {
  gap: 1px;
  background-color: var(--bg-control);
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-medium);
  transform: translateY(-6px);
  opacity: 0;
  animation: slide-down 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) 0.14s forwards;
}

.donate-control button {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--bg-button);
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s, transform 0.12s ease;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}

.donate-control button:hover {
  background: var(--hover-alt);
}

.donate-control button:active {
  transform: scale(0.96);
}
