
/* ===== Geography Module Styles ===== */

/* ── Module index cards ─────────────────────────────────────────────────── */
.geo-module-card {
  background: var(--surface);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 1.5rem;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  color: var(--ink);
  height: 100%;
}
.geo-module-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  border-color: var(--card-color, var(--accent));
  color: var(--ink);
}
.geo-module-icon {
  font-size: 3.5rem;
  text-align: center;
  padding: 1.5rem 1rem 0.5rem;
}
.geo-module-body {
  padding: 0.75rem 1.25rem 1.25rem;
}
.geo-module-body h2 {
  font-family: "Baloo 2", cursive;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.geo-module-body p {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}
.geo-module-badge {
  display: inline-block;
  background: var(--card-color, var(--accent));
  color: #1a2a1a;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
}

/* ── Filter bar ─────────────────────────────────────────────────────────── */
.geo-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.geo-filter-btn {
  background: var(--surface);
  border: 1.5px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.3rem 0.9rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.geo-filter-btn:hover,
.geo-filter-btn.active {
  background: var(--accent);
  color: #1a2a1a;
  border-color: var(--accent);
  transform: scale(1.05);
}

/* ── Shared grid ────────────────────────────────────────────────────────── */
.geo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.85rem;
}

/* ── Generic geo card ───────────────────────────────────────────────────── */
.geo-card {
  background: var(--surface);
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 1.25rem;
  padding: 1rem 0.75rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  transition: transform 0.18s, box-shadow 0.18s, background 0.18s, border-color 0.18s;
  text-align: center;
  color: var(--ink);
}
.geo-card:hover {
  transform: translateY(-4px) scale(1.04);
  background: var(--surface-strong);
  border-color: var(--accent);
  box-shadow: 0 12px 32px rgba(0,0,0,0.25);
}
.geo-card:active {
  transform: scale(0.96);
}

/* ── Flag card ──────────────────────────────────────────────────────────── */
.geo-flag { font-size: 2.8rem; line-height: 1; }
.geo-card-name {
  font-family: "Baloo 2", cursive;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
}
.geo-card-sub {
  font-size: 0.7rem;
  color: var(--muted);
}

/* ── State card ─────────────────────────────────────────────────────────── */
.geo-state-abbr {
  display: grid;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, rgba(255,255,255,0.22), rgba(244,162,97,0.5));
  font-family: "Baloo 2", cursive;
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink);
}

/* ── Continent card ─────────────────────────────────────────────────────── */
.geo-continent-card {
  background: var(--cont-bg, var(--surface));
  border: none;
  border-radius: 1.5rem;
  padding: 1.5rem;
  cursor: pointer;
  color: #fff;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.geo-continent-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 20px 48px rgba(0,0,0,0.3);
}
.geo-continent-card:active { transform: scale(0.97); }
.geo-continent-icon { font-size: 2.8rem; margin-bottom: 0.5rem; }
.geo-continent-name {
  font-family: "Baloo 2", cursive;
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}
.geo-continent-desc {
  font-size: 0.82rem;
  opacity: 0.9;
  margin-bottom: 0.75rem;
  line-height: 1.4;
}
.geo-continent-countries {
  font-size: 0.75rem;
  opacity: 0.75;
  font-style: italic;
}

/* ── Region card ────────────────────────────────────────────────────────── */
.geo-region-card {
  background: var(--reg-bg, var(--surface));
  border: none;
  border-radius: 1.5rem;
  padding: 1.5rem;
  cursor: pointer;
  color: #fff;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.geo-region-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 20px 48px rgba(0,0,0,0.3);
}
.geo-region-card:active { transform: scale(0.97); }
.geo-region-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.geo-region-icon { font-size: 2rem; }
.geo-region-name {
  font-family: "Baloo 2", cursive;
  font-size: 1.4rem;
  font-weight: 800;
}
.geo-region-desc {
  font-size: 0.82rem;
  opacity: 0.9;
  margin-bottom: 0.75rem;
  line-height: 1.4;
}
.geo-region-states { font-size: 0.78rem; opacity: 0.85; }
.geo-state-tag {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  margin: 0.15rem;
  font-size: 0.72rem;
}

/* ── States section headers ─────────────────────────────────────────────── */
.geo-region-title {
  font-family: "Baloo 2", cursive;
  font-size: 1.3rem;
  font-weight: 700;
  padding: 0.5rem 0;
  border-bottom: 2px solid rgba(255,255,255,0.15);
  margin-bottom: 1rem;
}

/* ── Audio feedback toast ───────────────────────────────────────────────── */
.geo-audio-feedback {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(2rem);
  background: rgba(20,48,66,0.95);
  color: var(--ink);
  border: 1.5px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  padding: 0.6rem 1.5rem;
  font-family: "Baloo 2", cursive;
  font-size: 1rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 1000;
  white-space: nowrap;
}
.geo-audio-feedback.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Bounce animation ───────────────────────────────────────────────────── */
@keyframes geo-bounce {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.18) rotate(-3deg); }
  60%  { transform: scale(0.93) rotate(2deg); }
  80%  { transform: scale(1.07); }
  100% { transform: scale(1); }
}
.geo-bounce { animation: geo-bounce 0.5s ease; }

  .geo-flag { font-size: 2.2rem; }
}

/* ===== Map Image Styles ===== */

.geo-map-wrap {
  position: relative;
  width: 100%;
  background: rgba(0,0,0,0.18);
  border-radius: 0.85rem;
  overflow: hidden;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 110px;
}
.geo-map-wrap-region { min-height: 130px; }
.geo-map-wrap-state  { min-height: 80px; margin-bottom: 0.5rem; }

.geo-map-img {
  width: 100%;
  max-height: 140px;
  object-fit: contain;
  padding: 0.5rem;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.35)) brightness(1.15);
}
.geo-ibge-img {
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4)) brightness(1.3) saturate(1.2);
}
.geo-state-map { max-height: 80px; }

.geo-map-label {
  position: absolute;
  bottom: 0.3rem;
  left: 0;
  right: 0;
  text-align: center;
  font-family: "Baloo 2", cursive;
  font-size: 0.82rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  letter-spacing: 0.03em;
  padding: 0 0.25rem;
  line-height: 1.2;
}
.geo-map-label-sm {
  font-size: 1rem;
  bottom: 0.2rem;
}

.geo-grid-states {
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
}

/* ===== Leaflet Map Styles ===== */

/* ── Map wrapper & container ──────────────────────────────────────────────── */
.geo-leaflet-wrap {
  border-radius: 1.25rem;
  /* overflow:hidden removed — clips Leaflet canvas to 0 on Android WebKit */
  overflow: visible;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  background: #a8d8ea;
  position: relative;
}
/* Apply clip via outline instead of overflow:hidden */
.geo-leaflet-map {
  border-radius: inherit;
  /* Force GPU compositing layer — prevents blank tile bug on Android 13 */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: transform;
  isolation: isolate;
}
.geo-leaflet-wrap-br {
  /* max-width removed — map fills container on all screen sizes */
  max-width: 100%;
}

/* ── Base map sizes: fill as much vertical space as possible ───────────────── */
.geo-leaflet-map {
  height: 65vh;
  min-height: 380px;
  max-height: 800px;
  width: 100%;
  background: #a8d8ea;
}
.geo-leaflet-map-br {
  height: 68vh;
  min-height: 420px;
  max-height: 860px;
}

/* ocean colour for Leaflet background */
.leaflet-container {
  background: #a8d8ea !important;
  font-family: "Nunito", sans-serif;
}

/* ── Map labels ───────────────────────────────────────────────────────────── */
.geo-map-leaflet-icon {
  background: none !important;
  border: none !important;
}

.geo-cont-label {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  font-family: "Baloo 2", cursive;
  font-size: 0.58rem;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  letter-spacing: 0.01em;
  opacity: 0.88;
}

.geo-region-label-map {
  display: inline-block;
  padding: 0.22rem 0.7rem;
  border-radius: 999px;
  font-family: "Baloo 2", cursive;
  font-size: 0.62rem;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 1px 5px rgba(0,0,0,0.4);
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  opacity: 0.9;
}

.geo-state-label-map {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  line-height: 1.1;
}
.geo-state-abbr-map {
  display: inline-block;
  background: rgba(20,48,66,0.82);
  color: #fff;
  font-family: "Baloo 2", cursive;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  white-space: nowrap;
  text-shadow: none;
}
.geo-state-cap-map {
  display: inline-block;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.52rem;
  font-weight: 600;
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  margin-top: 1px;
  white-space: nowrap;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Map tooltip ──────────────────────────────────────────────────────────── */
.leaflet-tooltip.geo-map-tooltip {
  background: rgba(20,48,66,0.92);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 0.5rem;
  color: #fff;
  font-family: "Baloo 2", cursive;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.3rem 0.75rem;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.leaflet-tooltip.geo-map-tooltip::before {
  border-top-color: rgba(20,48,66,0.92);
}

/* ── Map error state ──────────────────────────────────────────────────────── */
.geo-map-error {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  opacity: 0.7;
  padding: 2rem;
  text-align: center;
}

/* ── Active card highlight (when map region clicked) ─────────────────────── */
.geo-card-active {
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--accent) !important;
  transform: scale(1.04) !important;
  z-index: 10;
  position: relative;
}

/* ── Compact cards (shown below map) ─────────────────────────────────────── */
.geo-card-compact {
  border: none;
  border-radius: 1rem;
  padding: 0.9rem 0.75rem;
  cursor: pointer;
  background: var(--cont-bg, var(--reg-bg, var(--surface)));
  color: #fff;
  text-align: left;
  transition: transform 0.18s, box-shadow 0.18s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.geo-card-compact:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 10px 28px rgba(0,0,0,0.3);
}
.geo-card-compact-icon { font-size: 1.6rem; line-height: 1; }
.geo-card-compact-name {
  font-family: "Baloo 2", cursive;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.2;
}
.geo-card-compact-desc {
  font-size: 0.72rem;
  opacity: 0.88;
  line-height: 1.3;
}

/* ── Region states mini tags ──────────────────────────────────────────────── */
.geo-region-states-mini { margin-top: 0.3rem; }

/* ── Leaflet zoom control style ───────────────────────────────────────────── */
.leaflet-control-zoom a {
  background: rgba(20,48,66,0.85) !important;
  color: #fff !important;
  border: 1px solid rgba(255,255,255,0.2) !important;
  font-size: 1rem !important;
}
.leaflet-control-zoom a:hover {
  background: rgba(20,48,66,1) !important;
}

/* ── Responsive – mobile first ─────────────────────────────────────────────── */

/* Touch-friendly targets on touch devices */
@media (hover: none) and (pointer: coarse) {
  .geo-card { min-height: 80px; }
  .geo-filter-btn { min-height: 44px; padding: 0.5rem 1rem; }
  .geo-card-compact { min-height: 72px; }
  .leaflet-control-zoom a {
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    font-size: 1.2rem !important;
  }
}

/* Filter bar: horizontal scroll on narrow screens */
@media (max-width: 767px) {
  .geo-filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.35rem;
    /* fade edges to hint scrollability */
    mask-image: linear-gradient(to right, transparent, black 4%, black 96%, transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 4%, black 96%, transparent);
  }
  .geo-filter-bar::-webkit-scrollbar { display: none; }
  .geo-filter-btn { flex-shrink: 0; white-space: nowrap; }
  /* Move toast above bottom nav bars (iOS safe area) */
  .geo-audio-feedback {
    bottom: calc(3.5rem + env(safe-area-inset-bottom, 0px));
    font-size: 0.88rem;
    padding: 0.45rem 1.1rem;
    max-width: calc(100vw - 2rem);
    white-space: normal;
    text-align: center;
  }
}

/* Portrait orientation: taller maps, cards below */
@media (orientation: portrait) {
  .geo-leaflet-map     { height: 58vh; min-height: 320px; max-height: 700px; }
  .geo-leaflet-map-br  { height: 65vh; min-height: 360px; max-height: 760px; }
}

/* Small phones ≤ 480px (portrait + landscape) */
@media (max-width: 480px) {
  .geo-leaflet-map     { height: 52vh; min-height: 240px; }
  .geo-leaflet-map-br  { height: 62vh; min-height: 280px; }
  .geo-grid            { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 0.55rem; }
  .geo-grid-states     { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); }
  .geo-flag            { font-size: 2rem; }
  .geo-card-name       { font-size: 0.78rem; }
  .geo-card-sub        { font-size: 0.63rem; }
  .geo-state-abbr      { width: 2.3rem; height: 2.3rem; font-size: 0.85rem; }
  .geo-cont-label      { font-size: 0.54rem; padding: 0.08rem 0.28rem; }
  .geo-region-label-map{ font-size: 0.58rem; padding: 0.09rem 0.32rem; }
  .geo-state-abbr-map  { font-size: 0.5rem;  padding: 0.07rem 0.25rem; }
  .geo-state-cap-map   { display: none; }
  .geo-card-compact-name { font-size: 0.8rem; }
  .geo-card-compact-desc { font-size: 0.64rem; }
  .geo-module-icon     { font-size: 2.5rem; }
}

/* Medium mobile 481–767px */
@media (min-width: 481px) and (max-width: 767px) {
  .geo-grid            { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .geo-flag            { font-size: 2.2rem; }
  .geo-cont-label      { font-size: 0.6rem;  padding: 0.1rem 0.35rem; }
  .geo-region-label-map{ font-size: 0.65rem; }
  .geo-state-abbr-map  { font-size: 0.53rem; }
  .geo-state-cap-map   { display: none; }
}

/* Landscape phones (short screen, device rotated) */
@media (orientation: landscape) and (max-height: 500px) {
  .geo-leaflet-map     { height: 74vh; min-height: 220px; max-height: 500px; }
  .geo-leaflet-map-br  { height: 80vh; min-height: 240px; max-height: 540px; }
}

/* Tablet portrait 768–1023px */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: portrait) {
  .geo-leaflet-map     { height: 68vh; min-height: 480px; }
  .geo-leaflet-map-br  { height: 72vh; min-height: 520px; }
}
  .geo-leaflet-map-br { height: 50vh; min-height: 300px; }
  .geo-cont-label { font-size: 0.62rem; padding: 0.15rem 0.4rem; }
  .geo-region-label-map { font-size: 0.68rem; }
  .geo-state-abbr-map { font-size: 0.56rem; }
  .geo-state-cap-map { display: none; }
}

/* ── Android-safe map overrides ───────────────────────────────────────────── */
@keyframes geo-spin {
  to { transform: rotate(360deg); }
}
/* Force GPU layer on all Leaflet panes (prevents blank-tile on old WebView) */
.leaflet-pane,
.leaflet-tile-container,
.leaflet-overlay-pane {
  -webkit-transform: translate3d(0,0,0);
  transform: translate3d(0,0,0);
}
/* Ensure map container has explicit dimensions at all times */
.geo-leaflet-map {
  min-width: 100px;
  min-height: 200px;
}

/* Tablet landscape / small desktop 768-1199px landscape */
@media (min-width: 768px) and (orientation: landscape) {
  .geo-leaflet-map     { height: 72vh; min-height: 420px; max-height: 820px; }
  .geo-leaflet-map-br  { height: 76vh; min-height: 460px; max-height: 860px; }
  .geo-cont-label      { font-size: 0.62rem; }
  .geo-region-label-map{ font-size: 0.66rem; }
}

/* Large desktop ≥ 1200px */
@media (min-width: 1200px) {
  .geo-leaflet-map     { height: 70vh; min-height: 500px; max-height: 900px; }
  .geo-leaflet-map-br  { height: 74vh; min-height: 540px; max-height: 940px; }
}
