/**
 * File: css/meteonav_compass.css
 * Module: Compass Layer Styles
 * Version: 1.1.0
 * Date: 2026-01-05
 * Author: Alex Moustris
 * Purpose: Styles for the nautical compass rose overlay
 * Description: Isolated CSS for compass layer with overlay positioning,
 *              opacity control slider, draggable container, and responsive design.
 * Status: STABLE
 */

/* ============================================
   MAIN DRAGGABLE CONTAINER
   ============================================ */

.compass-layer-container {
  position: fixed;
  bottom: 80px;
  left: 20px;
  z-index: 800;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Safari cursor fallback chain */
  cursor: move;
  cursor: -webkit-grab;
  cursor: grab;
}

/* ============================================
   COMPASS IMAGE
   ============================================ */

.compass-layer-overlay {
  width: 200px;
  height: 200px;
  pointer-events: auto;
  transition: opacity 0.3s ease;
  /* Safari cursor fallback chain */
  cursor: move;
  cursor: -webkit-grab;
  cursor: grab;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

/* Active/dragging state cursor */
.compass-layer-overlay:active,
.compass-layer-container:active {
  cursor: move;
  cursor: -webkit-grabbing;
  cursor: grabbing;
}

.compass-layer-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.3));
  transition: filter 0.3s ease;
}

/* Dark mode - invert colors for visibility */
body.map-style-dark .compass-layer-image {
  filter: invert(0.9) hue-rotate(180deg) drop-shadow(0 2px 6px rgba(255, 255, 255, 0.2));
}

/* Satellite mode - invert like dark (ocean is dark) */
body.map-style-satellite .compass-layer-image {
  filter: invert(0.9) hue-rotate(180deg) drop-shadow(0 2px 6px rgba(255, 255, 255, 0.2));
}

/* ============================================
   OPACITY CONTROL PANEL (Below Compass)
   ============================================ */

.compass-layer-control {
  width: 160px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 51, 102, 0.25);
  border-radius: 6px;
  padding: 5px 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  font-family: 'Inter', 'Noto Sans', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  margin-top: 4px;
  pointer-events: auto;
}

/* ============================================
   BUTTON CONTROLS (Boat + Ruler)
   ============================================ */

.compass-control-buttons {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.compass-control-btn {
  width: 28px;
  height: 28px;
  border: 2px solid rgba(0, 51, 102, 0.2);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  outline: none;
  background-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.compass-control-btn svg {
  width: 100%;
  height: 100%;
  display: block;
}

.compass-control-btn:hover {
  border-color: rgba(0, 51, 102, 0.5);
  transform: scale(1.05);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.compass-control-btn:active {
  transform: scale(0.98);
}

/* Note: Button states (default/located/activated/measured) are now managed via inline SVG swapping in JavaScript */

/* ============================================
   MEASUREMENT POPUP
   ============================================ */

.compass-measurement-popup {
  position: absolute;
  background: rgba(10, 25, 47, 0.95);
  border: 2px solid rgba(212, 175, 55, 0.6);
  border-radius: 8px;
  padding: 10px 14px;
  color: #ffffff;
  font-size: 13px;
  font-family: 'Inter', 'Noto Sans', system-ui, sans-serif;
  pointer-events: auto; /* Changed from none to auto to allow clicking the Add Waypoint button */
  z-index: 10000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  line-height: 1.5;
}

.compass-measurement-popup div {
  margin: 2px 0;
}

.compass-measurement-value {
  font-weight: bold;
  color: rgba(212, 175, 55, 1);
  margin-left: 4px;
}

/* Intermediate popup styling (discreet) */
.compass-measurement-popup-intermediate {
  background: rgba(10, 25, 47, 0.7);
  border: 1px solid rgba(212, 175, 55, 0.4);
  padding: 6px 10px;
  font-size: 11px;
}

.compass-measurement-popup-intermediate .compass-measurement-value {
  color: rgba(212, 175, 55, 0.8);
}

/* Intermediate marker styling (smaller) */
.compass-measurement-marker-intermediate div {
  width: 10px !important;
  height: 10px !important;
  background: rgba(212, 175, 55, 0.7) !important;
  border-width: 1px !important;
}

/* Add Waypoint Button */
.compass-add-point-btn {
  width: 100%;
  margin-top: 8px;
  background: rgba(212, 175, 55, 0.2);
  border: 1px solid rgba(212, 175, 55, 0.6);
  color: #fff;
  border-radius: 4px;
  padding: 4px 0;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  display: block;
  text-align: center;
}

.compass-add-point-btn:hover {
  background: rgba(212, 175, 55, 0.5);
}

/* ============================================
   TOTALS PANEL (Independent Draggable)
   ============================================ */

.compass-totals-panel {
  position: absolute;
  /* Default starting position (bottom right) */
  right: 20px;
  bottom: 150px;
  background: rgba(10, 25, 47, 0.95);
  border: 2px solid rgba(212, 175, 55, 0.8);
  border-radius: 8px;
  padding: 14px 18px;
  color: #ffffff;
  font-size: 13px;
  font-family: 'Inter', 'Noto Sans', system-ui, sans-serif;
  z-index: 10000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  line-height: 1.6;
  pointer-events: auto;
  cursor: grab;
  /* Blur background effect */
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.compass-totals-panel:active {
  cursor: grabbing;
}

.compass-totals-panel div {
  margin: 4px 0;
}

.compass-totals-panel .compass-add-point-btn {
  margin-top: 12px;
  padding: 6px 0;
  font-size: 12px;
  font-weight: 600;
}

/* ============================================
   OPACITY CONTROL ELEMENTS
   ============================================ */

.compass-control-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.compass-control-coords {
  font-size: 10px;
  color: rgb(100, 116, 139);
  margin-bottom: 6px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compass-control-title {
  font-size: 9px;
  font-weight: 600;
  color: rgb(0, 51, 102);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.compass-control-value {
  font-size: 10px;
  font-weight: 600;
  color: rgb(0, 51, 102);
}

.compass-control-slider {
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: rgba(0, 51, 102, 0.12);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.compass-control-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgb(0, 51, 102);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease;
}

.compass-control-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.compass-control-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgb(0, 51, 102);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ============================================
   VISIBILITY STATES
   ============================================ */

/* Compass visibility is controlled by JS only (enable/disable) */
/* Visible in both Global and Local view when enabled */

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
  .compass-layer-container {
    bottom: 70px;
    left: 10px;
  }

  .compass-layer-overlay {
    width: 150px;
    height: 150px;
  }

  .compass-layer-control {
    width: 140px;
    padding: 3px 6px;
  }

  .compass-control-buttons {
    gap: 6px;
    margin-bottom: 6px;
  }

  .compass-control-btn {
    width: 25px;
    height: 25px;
  }

  .compass-control-title {
    font-size: 8px;
  }

  .compass-control-value {
    font-size: 9px;
  }

  /* Coordinates on mobile - smaller font, one line */
  .compass-control-coords {
    font-size: 8px;
  }

  /* Measurement popup - smaller on mobile */
  .compass-measurement-popup {
    font-size: 11px;
    padding: 8px 10px;
  }
}

/* Small phones */
@media (max-width: 480px) {
  .compass-layer-overlay {
    width: 120px;
    height: 120px;
  }

  .compass-layer-control {
    width: 120px;
  }

  .compass-control-btn {
    width: 22px;
    height: 22px;
  }

  .compass-measurement-popup {
    font-size: 10px;
    padding: 6px 8px;
  }
}

/* ============================================
   OFF-SCREEN INDICATOR (Snap-back arrow)
   ============================================ */

.compass-offscreen-indicator {
  position: fixed;
  z-index: 900;
  width: 36px;
  height: 36px;
  background: rgba(10, 25, 47, 0.85);
  border: 2px solid rgba(212, 175, 55, 0.8);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 0 12px rgba(212, 175, 55, 0.3);
  transition: transform 0.15s ease;
  animation: compass-indicator-pulse 2s infinite;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.compass-offscreen-indicator:hover {
  border-color: rgba(212, 175, 55, 1);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5), 0 0 20px rgba(212, 175, 55, 0.5);
}

.compass-offscreen-indicator:active {
  transform: scale(0.9) !important;
}

.compass-offscreen-indicator svg {
  pointer-events: none;
}

@keyframes compass-indicator-pulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 0 18px rgba(212, 175, 55, 0.5); }
}
