/* ============================================================
   canvas.css — EduNudge GeoLab · Plate Tectonics Simulator
   Globe canvas wrapper, loading overlay, atmosphere effects,
   canvas interaction states and globe control buttons.
   Depends on: base.css (custom properties, resets)

   Phase 2 fixes:
   ✅ #loading-overlay selector matches HTML id (was #globe-loading)
   ✅ .anim-label bottom offset increased on mobile to avoid
      overlapping .quake-fab
   ✅ #anim-info-link bottom offset adjusted to match new label pos
   ============================================================ */

/* ----------------------------------------------------------
   1. MAIN LAYOUT — globe + panel split
   ---------------------------------------------------------- */
#main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
  height: 100%;
}

/* ----------------------------------------------------------
   2. GLOBE WRAPPER
   Fills the remaining space beside the side panel.
   ---------------------------------------------------------- */
#globe-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #0a1a27;
  /* matches CFG_GLOBE.bgColor */

  /* subtle inner vignette to frame the globe */
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.55),
    inset 0 -2px 0 rgba(232, 108, 47, 0.08);
}

/* ----------------------------------------------------------
   3. GLOBE CONTAINER  (Three.js mounts canvas here)
   ---------------------------------------------------------- */
#globe-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* The <canvas> Three.js injects */
#globe-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  cursor: grab;
  outline: none;

  /* smooth pixel rendering on retina */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

#globe-container canvas:active {
  cursor: grabbing;
}

/* ----------------------------------------------------------
   4. FULL-PAGE LOADING OVERLAY
   FIX: selector was #globe-loading — does not match the
   element id="loading-overlay" in index.html.
   All loading overlay styles now correctly target
   #loading-overlay.
   ---------------------------------------------------------- */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: #0a1a27;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-5);
  transition: opacity 0.5s var(--ease-out);
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ----------------------------------------------------------
   4a. LOADER LOGO
   ---------------------------------------------------------- */
.loader-logo {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  color: var(--clr-text-primary);
  letter-spacing: -0.02em;
}

.loader-logo span {
  color: var(--clr-orange);
}

/* ----------------------------------------------------------
   4b. SPINNING GLOBE ICON
   ---------------------------------------------------------- */
.globe-loader-icon {
  position: relative;
  width: 72px;
  height: 72px;
}

.globe-loader-icon__sphere {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  background: radial-gradient(circle at 35% 35%,
      var(--clr-teal-lighter) 0%,
      var(--clr-teal) 55%,
      #0a1a27 100%);
  box-shadow:
    0 0 32px rgba(79, 195, 247, 0.30),
    inset -8px -8px 20px rgba(0, 0, 0, 0.50);
  animation: spin 3s linear infinite;
}

/* orbit ring around loader sphere */
.globe-loader-icon__ring {
  position: absolute;
  inset: -10px;
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  border-top: 2px solid var(--clr-orange);
  border-bottom: 2px solid var(--clr-orange-light);
  animation: spin 1.4s linear infinite;
}

/* ----------------------------------------------------------
   4c. LOADER TEXT
   ---------------------------------------------------------- */
.globe-loader-text {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semi);
  color: var(--clr-text-primary);
  letter-spacing: -0.01em;
}

.globe-loader-text span {
  color: var(--clr-orange);
}

.globe-loader-sub {
  font-size: var(--fs-sm);
  color: var(--clr-text-muted);
  text-align: center;
  max-width: 220px;
  line-height: var(--lh-base);
}

/* ----------------------------------------------------------
   4d. ANIMATED LOADING DOTS
   ---------------------------------------------------------- */
.globe-loader-dots {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-1);
}

.globe-loader-dots span {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--clr-orange);
  animation: dotBounce 1.2s ease-in-out infinite;
}

.globe-loader-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.globe-loader-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes dotBounce {

  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.4;
  }

  40% {
    transform: scale(1.0);
    opacity: 1.0;
  }
}

/* ----------------------------------------------------------
   5. GLOBE CONTROL BUTTONS
   Floating controls overlay on the globe (zoom, spin toggle,
   reset orientation).
   ---------------------------------------------------------- */
#globe-controls {
  position: absolute;
  bottom: var(--sp-5);
  right: var(--sp-5);
  z-index: var(--z-raised);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  animation: fadeUp var(--dur-slow) var(--ease-out) both;
  animation-delay: 0.6s;
}

.globe-ctrl-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--clr-teal-alpha);
  border: 1px solid var(--clr-border-strong);
  color: var(--clr-text-secondary);
  font-size: var(--fs-base);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition:
    color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-spring);
  box-shadow: var(--shadow-sm);
}

.globe-ctrl-btn:hover {
  color: var(--clr-white);
  background: var(--clr-teal-light);
  border-color: var(--clr-orange);
  transform: scale(1.08);
}

.globe-ctrl-btn:active {
  transform: scale(0.95);
}

.globe-ctrl-btn.active {
  color: var(--clr-orange);
  border-color: var(--clr-orange);
  box-shadow: var(--shadow-glow-orange);
}

/* divider between button groups */
.globe-ctrl-divider {
  height: 1px;
  background: var(--clr-border-strong);
  margin-inline: var(--sp-1);
}

/* ----------------------------------------------------------
   6. GLOBE COORDINATE DISPLAY
   Bottom-left overlay showing lat/lon on hover.
   ---------------------------------------------------------- */
#globe-coords {
  position: absolute;
  bottom: var(--sp-4);
  left: var(--sp-4);
  z-index: var(--z-raised);
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  color: var(--clr-text-muted);
  background: var(--clr-teal-alpha);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  padding: var(--sp-1) var(--sp-2);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-normal) var(--ease-out);
  white-space: nowrap;
}

#globe-coords.visible {
  opacity: 1;
}

/* ----------------------------------------------------------
   7. GLOBE LABEL OVERLAY
   Plate / boundary name labels that float above the canvas.
   ---------------------------------------------------------- */
#globe-label-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: var(--z-raised);
  overflow: hidden;
}

.globe-label {
  position: absolute;
  transform: translate(-50%, -50%);
  background: var(--clr-teal-alpha);
  border: 1px solid var(--clr-border-strong);
  border-radius: var(--radius-sm);
  padding: 2px var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--clr-text-primary);
  white-space: nowrap;
  pointer-events: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transition: opacity var(--dur-normal) var(--ease-out);
}

.globe-label.visible {
  opacity: 1;
}

.globe-label--hotspot {
  color: var(--clr-orange-light);
  border-color: var(--clr-orange);
}

.globe-label--hotspot::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--clr-orange);
  margin-right: var(--sp-1);
  vertical-align: middle;
  box-shadow: 0 0 5px var(--clr-orange);
}

/* ----------------------------------------------------------
   8. CANVAS KEYBOARD HINT
   Small legend shown on first load, auto-hides via animation.
   ---------------------------------------------------------- */
#globe-hint {
  position: absolute;
  top: var(--sp-4);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-raised);
  background: var(--clr-teal-alpha);
  border: 1px solid var(--clr-border-strong);
  border-radius: var(--radius-full);
  padding: var(--sp-1) var(--sp-4);
  font-size: var(--fs-xs);
  color: var(--clr-text-muted);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
  white-space: nowrap;
  animation: hintFade 5s var(--ease-out) forwards;
}

@keyframes hintFade {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(-4px);
  }

  10% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  75% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

.globe-hint-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--clr-surface-raised);
  border: 1px solid var(--clr-border-strong);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  font-size: var(--fs-xs);
  font-family: var(--font-display);
  color: var(--clr-text-primary);
  min-width: 20px;
}

.globe-hint-sep {
  color: var(--clr-text-muted);
  opacity: 0.5;
}

/* ----------------------------------------------------------
   9. CANVAS WATERMARK / ATTRIBUTION
   ---------------------------------------------------------- */
#globe-attribution {
  position: absolute;
  bottom: var(--sp-2);
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--fs-xs);
  color: var(--clr-text-muted);
  opacity: 0.45;
  pointer-events: none;
  white-space: nowrap;
  z-index: var(--z-raised);
}

/* ----------------------------------------------------------
   10. EARTHQUAKE FAB BUTTON
   Always-visible bottom-left shortcut to simulate earthquake.
   ---------------------------------------------------------- */
.quake-fab {
  position: absolute;
  bottom: var(--sp-5);
  left: var(--sp-5);
  z-index: var(--z-raised);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-full);
  background: rgba(244, 67, 54, 0.15);
  border: 1px solid #f44336;
  color: #f44336;
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 0 12px rgba(244, 67, 54, 0.25);
  transition: all var(--dur-fast) var(--ease-out);
  cursor: pointer;
  white-space: nowrap;
  animation: fadeUp var(--dur-slow) var(--ease-out) both;
  animation-delay: 1s;
}

.quake-fab:hover {
  background: rgba(244, 67, 54, 0.28);
  box-shadow: 0 0 20px rgba(244, 67, 54, 0.45);
  transform: translateY(-2px);
}

.quake-fab:active {
  transform: scale(0.96);
}

.quake-fab i {
  font-size: var(--fs-sm);
}

/* ----------------------------------------------------------
   11. BOUNDARY ACTION BAR BUTTONS  (.bab-btn)
   ---------------------------------------------------------- */
.bab-btn i {
  font-size: var(--fs-sm);
}

.bab-btn:hover {
  color: var(--clr-white);
  background: var(--clr-surface-raised);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.bab-btn:active {
  transform: translateY(0) scale(0.96);
}

/* convergent — orange */
.bab-btn--convergent {
  border-color: var(--clr-convergent);
}

.bab-btn--convergent:hover,
.bab-btn--convergent.active {
  background: rgba(232, 108, 47, 0.20);
  color: var(--clr-convergent);
  border-color: var(--clr-convergent);
  box-shadow: 0 0 12px rgba(232, 108, 47, 0.35);
}

/* divergent — cyan */
.bab-btn--divergent {
  border-color: var(--clr-divergent);
}

.bab-btn--divergent:hover,
.bab-btn--divergent.active {
  background: rgba(79, 195, 247, 0.15);
  color: var(--clr-divergent);
  border-color: var(--clr-divergent);
  box-shadow: 0 0 12px rgba(79, 195, 247, 0.30);
}

/* transform — green */
.bab-btn--transform {
  border-color: var(--clr-transform);
}

.bab-btn--transform:hover,
.bab-btn--transform.active {
  background: rgba(165, 214, 167, 0.15);
  color: var(--clr-transform);
  border-color: var(--clr-transform);
  box-shadow: 0 0 12px rgba(165, 214, 167, 0.25);
}

/* earthquake — red pulse */
.bab-btn--quake {
  border-color: #f44336;
}

.bab-btn--quake:hover {
  background: rgba(244, 67, 54, 0.15);
  color: #f44336;
  border-color: #f44336;
  box-shadow: 0 0 12px rgba(244, 67, 54, 0.35);
}

.bab-btn--quake.shaking {
  animation: quakeShake 0.5s var(--ease-in-out) 3;
}

@keyframes quakeShake {

  0%,
  100% {
    transform: translateX(0) translateY(0);
  }

  20% {
    transform: translateX(-4px) translateY(-2px);
  }

  40% {
    transform: translateX(4px) translateY(2px);
  }

  60% {
    transform: translateX(-3px) translateY(1px);
  }

  80% {
    transform: translateX(3px) translateY(-1px);
  }
}

/* reset */
.bab-btn--reset {
  border-color: var(--clr-border-strong);
}

.bab-btn--reset:hover {
  color: var(--clr-white);
  border-color: var(--clr-white);
}

/* ----------------------------------------------------------
   12. PHASE 2 — ANIMATION OVERLAY ELEMENTS

   .anim-label   — status text shown during boundary animations.
                   Now position:fixed and appended to <body> so
                   it always sits OUTSIDE the globe canvas and
                   never obscures the Three.js animation.

   #anim-info-link — "Explore…" CTA removed per design review.
   ---------------------------------------------------------- */
.anim-label {
  position: fixed;
  /* Horizontally centred over the globe pane (left ~65% of page) */
  bottom: 28px;
  left: 33%;
  transform: translateX(-50%);

  background: rgba(26, 53, 69, 0.95);
  color: #fff;
  font-family: var(--font-ui, 'Inter', sans-serif);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 9px 20px;
  border-radius: 24px;
  border: 1px solid rgba(232, 108, 47, 0.55);
  white-space: nowrap;
  pointer-events: none;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  animation: fadeInUp 0.4s ease;
}

/* "Explore…" link removed — keep rule so no flash if element
   ever appears from old cached code.                         */
#anim-info-link {
  display: none !important;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ----------------------------------------------------------
   13. RESPONSIVE
   ---------------------------------------------------------- */

/* Tablet — shrink controls */
@media (max-width: 1024px) {
  #globe-controls {
    bottom: var(--sp-4);
    right: var(--sp-4);
  }

  .globe-ctrl-btn {
    width: 32px;
    height: 32px;
  }
}

/* Mobile — full-width globe, panel goes below */
@media (max-width: 768px) {
  #main-layout {
    flex-direction: column;
  }

  #globe-wrapper {
    flex: none;
    height: 55vw;
    min-height: 240px;
    max-height: 380px;
    width: 100%;
  }

  #globe-controls {
    flex-direction: row;
    bottom: var(--sp-3);
    right: var(--sp-3);
  }

  .globe-ctrl-divider {
    width: 1px;
    height: auto;
    margin: var(--sp-1) 0;
  }

  #globe-hint {
    font-size: 10px;
    padding: var(--sp-1) var(--sp-3);
    gap: var(--sp-2);
  }

  #globe-coords {
    display: none;
  }

  /* quake-fab collapses to icon-only on mobile */
  .quake-fab span {
    display: none;
  }

  .quake-fab {
    padding: var(--sp-2);
    width: 36px;
    height: 36px;
    justify-content: center;
  }

  /* boundary action bar — icon only on mobile */
  #boundary-action-bar {
    bottom: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    gap: var(--sp-1);
  }

  .bab-label {
    display: none;
  }

  .bab-btn span {
    display: none;
  }

  .bab-btn {
    padding: var(--sp-2);
    width: 34px;
    height: 34px;
    justify-content: center;
  }

  /* FIX: label is now position:fixed/body — centre it on mobile */
  .anim-label {
    left: 50%;
    bottom: 20px;
  }

  #anim-info-link {
    display: none !important;
  }
}

/* Very small screens */
@media (max-width: 480px) {
  #globe-wrapper {
    height: 60vw;
    min-height: 200px;
    max-height: 300px;
  }

  #globe-controls {
    gap: var(--sp-1);
  }

  .globe-ctrl-btn {
    width: 28px;
    height: 28px;
    font-size: var(--fs-sm);
  }

  #globe-attribution {
    display: none;
  }

  .anim-label {
    left: 50%;
    bottom: 16px;
    font-size: 0.80rem;
    padding: 6px 14px;
    white-space: normal;
    text-align: center;
    max-width: 85vw;
  }

  #anim-info-link {
    display: none !important;
  }
}

/* ----------------------------------------------------------
   END canvas.css
   ---------------------------------------------------------- */