/* ==========================================================================
   Marine Survey, Cartography & Geomatics Portfolio - Stylesheet
   Specialist: Hamza El-Sayed Hikal (أخصائي مساحة بحرية وجيوماتكس)
   Theme: "Charting the Unseen" — Adaptive Dual Theme (Light & Dark)
   ========================================================================== */

/* --------------------------------------------------
   1. CSS Custom Properties & Design Tokens
   -------------------------------------------------- */
:root {
  /* Primary Light Theme Palette */
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.88);
  --bg-card-hover: rgba(255, 255, 255, 0.98);
  --bg-nav: rgba(255, 255, 255, 0.85);
  --bg-subtle: #f1f5f9;
  --bg-sand: #f5f3eb;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --color-sky: #0ea5e9;
  --color-sky-light: #38bdf8;
  --color-sky-subtle: #e0f2fe;
  --color-teal: #14b8a6;
  --color-teal-light: #2dd4bf;
  --color-teal-subtle: #ccfbf1;
  --color-amber: #d97706;
  --color-amber-subtle: #fef3c7;
  --color-emerald: #10b981;

  --border-subtle: rgba(226, 232, 240, 0.9);
  --border-focus: rgba(14, 165, 233, 0.4);
  --border-teal: rgba(20, 184, 166, 0.35);

  --shadow-card: 0 10px 30px -10px rgba(15, 23, 42, 0.08), 0 4px 12px -2px rgba(14, 165, 233, 0.04);
  --shadow-card-hover: 0 20px 40px -12px rgba(15, 23, 42, 0.12), 0 0 25px rgba(20, 184, 166, 0.12);
  --glow-hero: 0 0 40px rgba(14, 165, 233, 0.25), 0 0 70px rgba(20, 184, 166, 0.15);
  --hero-frame-bg: linear-gradient(145deg, #ffffff 0%, #e0f2fe 50%, #ccfbf1 100%);
  --hero-frame-border: #38bdf8;

  --3d-bg-gradient: radial-gradient(circle at 50% 50%, #f0f7fc 0%, #e2eef7 100%);

  /* Typography */
  --font-en: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
  --font-ar: 'Cairo', 'Tajawal', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* --------------------------------------------------
   Dark Mode Overrides (.dark class)
   -------------------------------------------------- */
html.dark {
  --bg-body: #050b14;
  --bg-surface: #0a1726;
  --bg-card: rgba(15, 35, 58, 0.75);
  --bg-card-hover: rgba(20, 45, 75, 0.88);
  --bg-nav: rgba(8, 21, 37, 0.85);
  --bg-subtle: #0f233a;
  --bg-sand: #162a42;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --border-subtle: rgba(56, 189, 248, 0.16);
  --border-focus: rgba(56, 189, 248, 0.45);
  --border-teal: rgba(45, 212, 191, 0.3);

  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.6), 0 0 15px rgba(14, 165, 233, 0.15);
  --shadow-card-hover: 0 20px 40px -10px rgba(0, 0, 0, 0.8), 0 0 30px rgba(45, 212, 191, 0.3);
  --glow-hero: 0 0 45px rgba(56, 189, 248, 0.35), 0 0 85px rgba(45, 212, 191, 0.25);
  --hero-frame-bg: linear-gradient(145deg, #0c233c 0%, #061527 50%, #030d1a 100%);
  --hero-frame-border: #0ea5e9;

  --3d-bg-gradient: radial-gradient(circle at 50% 50%, #0c233c 0%, #050e1b 100%);
}

/* --------------------------------------------------
   2. Base & Typography Resets
   -------------------------------------------------- */
html {
  scroll-behavior: smooth;
  font-family: var(--font-en);
  background-color: var(--bg-body);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

body[dir="rtl"] {
  font-family: var(--font-ar);
}

/* Scroll reading progress bar */
#scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3.5px;
  background: linear-gradient(90deg, #0ea5e9 0%, #14b8a6 50%, #d97706 100%);
  z-index: 100;
  width: 0%;
  transition: width 0.1s ease-out;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: var(--bg-body);
}
::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-sky);
}

/* Background animated 2D Canvas */
#bathy-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  opacity: 0.65;
}

/* --------------------------------------------------
   3. Glassmorphism Components
   -------------------------------------------------- */
.glass-nav {
  background: var(--bg-nav);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 4px 20px -4px rgba(15, 23, 42, 0.05);
}

.bathy-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.bathy-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-3px);
}

/* --------------------------------------------------
   4. Adaptive Glowing Hero Profile Frame
   -------------------------------------------------- */
.nautical-photo-frame {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  padding: 10px;
}

.nautical-photo-frame::before {
  content: '';
  position: absolute;
  inset: -14px;
  border-radius: 9999px;
  border: 1.5px dashed var(--hero-frame-border);
  opacity: 0.7;
  animation: rotateCompass 40s linear infinite;
  pointer-events: none;
}

.nautical-photo-frame::after {
  content: '';
  position: absolute;
  inset: -28px;
  border-radius: 9999px;
  border: 1px solid var(--color-teal);
  box-shadow: var(--glow-hero);
  animation: pulseGlow 5s ease-in-out infinite alternate;
  pointer-events: none;
}

.hero-avatar-wrapper {
  background: var(--hero-frame-bg);
  border-color: var(--hero-frame-border);
}

@keyframes rotateCompass {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulseGlow {
  0% {
    transform: scale(0.99);
    opacity: 0.75;
  }
  100% {
    transform: scale(1.02);
    opacity: 1;
  }
}

.logo-monogram-ring {
  box-shadow: 0 8px 25px -4px rgba(14, 165, 233, 0.3);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.logo-monogram-ring:hover {
  transform: scale(1.08) rotate(4deg);
  box-shadow: 0 12px 30px -4px rgba(20, 184, 166, 0.45);
}

/* --------------------------------------------------
   5. Button Styling & Hydrographic Themes
   -------------------------------------------------- */
.btn-hydro-primary {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 50%, #0f766e 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.3);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-hydro-primary:hover {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 50%, #115e59 100%);
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.45);
  transform: translateY(-2px);
}

.btn-hydro-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1.5px solid var(--border-subtle);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-hydro-secondary:hover {
  border-color: var(--color-sky);
  color: var(--color-sky);
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.15);
  transform: translateY(-2px);
}

.btn-hydro-mint {
  background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(20, 184, 166, 0.3);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-hydro-mint:hover {
  background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
  box-shadow: 0 8px 24px rgba(20, 184, 166, 0.45);
  transform: translateY(-2px);
}

.btn-call-emerald {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-call-emerald:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.5);
  transform: translateY(-2px);
}

/* --------------------------------------------------
   6. 3D Canvas Viewport
   -------------------------------------------------- */
#three-canvas-container {
  position: relative;
  width: 100%;
  height: 500px;
  background: var(--3d-bg-gradient);
  border-radius: 1.5rem;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.06), 0 12px 32px -8px rgba(14, 165, 233, 0.12);
}

#three-canvas-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  outline: none;
  cursor: grab;
}

#three-canvas-container canvas:active {
  cursor: grabbing;
}

/* --------------------------------------------------
   7. Before / After Map Comparison Slider
   -------------------------------------------------- */
.comparison-container {
  position: relative;
  width: 100%;
  height: 420px;
  border-radius: 1.5rem;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-subtle);
}

.comparison-image-before,
.comparison-image-after {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
}

.comparison-image-after {
  width: 50%;
  overflow: hidden;
  border-right: 3px solid #14b8a6;
  box-shadow: 4px 0 15px rgba(20, 184, 166, 0.4);
}

.comparison-slider-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 4px;
  background: #14b8a6;
  cursor: ew-resize;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
}

.comparison-slider-btn {
  width: 42px;
  height: 42px;
  border-radius: 9999px;
  background: #ffffff;
  color: #0f172a;
  border: 3px solid #14b8a6;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: ew-resize;
  transition: transform 0.2s ease;
}

.comparison-slider-btn:hover {
  transform: scale(1.15);
}

/* --------------------------------------------------
   8. Modals & Badges
   -------------------------------------------------- */
.modal-backdrop {
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.badge-soft-sky {
  background-color: var(--color-sky-subtle);
  color: #0369a1;
  border: 1px solid rgba(14, 165, 233, 0.3);
}

html.dark .badge-soft-sky {
  background-color: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.3);
}

.badge-soft-mint {
  background-color: var(--color-teal-subtle);
  color: #0f766e;
  border: 1px solid rgba(20, 184, 166, 0.3);
}

html.dark .badge-soft-mint {
  background-color: rgba(20, 184, 166, 0.15);
  color: #2dd4bf;
  border-color: rgba(45, 212, 191, 0.3);
}

/* --------------------------------------------------
   9. Print Optimization
   -------------------------------------------------- */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  #bathy-canvas,
  #scroll-progress,
  header,
  footer,
  #sound-toggle-btn,
  #mobile-nav,
  .no-print {
    display: none !important;
  }
  .bathy-card {
    border: 1px solid #cccccc !important;
    box-shadow: none !important;
    break-inside: avoid;
  }
}
