/* =========================================
   Pacific Star — Premium Features
   Preloader · Dark/Light Mode · Custom Cursor
   ========================================= */

/* ---- 1. PRELOADER ---- */
.preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #0d2b5e;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.preloader.is-loaded {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  animation: preloader-pulse 1.5s ease-in-out infinite;
}

.preloader-icon {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preloader-icon img {
  width: 80px;
  height: 80px;
  display: block;
}

.preloader-text {
  font-family: var(--font-sans);
  font-size: 1.4rem;
  font-weight: 300;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: #f5a623;
}

.preloader-bar {
  width: 120px;
  height: 2px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.preloader-bar::after {
  content: '';
  position: absolute;
  left: -100%;
  top: 0;
  width: 100%;
  height: 100%;
  background: #f5a623;
  animation: preloader-bar-sweep 1.2s ease-in-out infinite;
}

@keyframes preloader-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.65; }
}

@keyframes preloader-bar-sweep {
  0%   { left: -100%; }
  100% { left: 100%; }
}

/* Respect reduced-motion for preloader animations */
@media (prefers-reduced-motion: reduce) {
  .preloader-logo { animation: none; }
  .preloader-bar::after { animation: none; left: 0; }
}

/* ---- 2. DARK / LIGHT MODE ---- */

/* Dark theme variable overrides */
html.dark-theme {
  --color-primary:   #4a90d9;
  --color-secondary: #6baae8;
  --color-accent:    #f5a623;
  --color-accent-dark: #d4891a;
  --color-text:      #dde3f0;
  --color-light:     #161c2a;
  --color-white:     #0e1219;
  --color-muted:     #8899aa;
  --color-border:    #232e42;
  --shadow-sm:       0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md:       0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg:       0 8px 32px rgba(0, 0, 0, 0.55);
  --color-surface:   #111620;
  --color-surface-alt:#161c2a;
  --color-heading:   #4a90d9;
  --color-text-light: #8899aa;
}

html.dark-theme body {
  background: #0e1219;
  color: var(--color-text);
}

html.dark-theme .site-header {
  background: rgba(10, 14, 22, 0.97);
  border-bottom-color: var(--color-border);
}

html.dark-theme .site-header.scrolled {
  background: rgba(10, 14, 22, 0.99);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
}

html.dark-theme .header-mobile-bar {
  background: #111620;
  border-top-color: var(--color-border);
}

html.dark-theme .header-mobile-link {
  color: var(--color-text);
}

html.dark-theme .nav-link,
html.dark-theme .nav-toggle {
  color: var(--color-text);
}

html.dark-theme .nav-link:hover,
html.dark-theme .nav-link.active,
html.dark-theme .nav-toggle:hover,
html.dark-theme .nav-toggle.active {
  color: var(--color-accent);
}

html.dark-theme .hero {
  background: rgba(0, 0, 0, 0.5);
}

html.dark-theme .hero-card {
  background: rgba(22, 30, 46, 0.85);
  border-color: var(--color-border);
  color: var(--color-text);
}

html.dark-theme .hero-card-desc {
  color: var(--color-muted);
}

html.dark-theme .section-alt,
html.dark-theme .bg-light {
  background: #111620;
}

html.dark-theme .card,
html.dark-theme .service-card,
html.dark-theme .premium-card,
html.dark-theme .feature-card {
  background: #161c2a;
  border-color: var(--color-border);
  color: var(--color-text);
}

html.dark-theme .btn-outline {
  border-color: var(--color-border);
  color: var(--color-text);
}

html.dark-theme .btn-outline:hover {
  background: var(--color-light);
}

html.dark-theme footer,
html.dark-theme .footer {
  background: #080c12;
}

html.dark-theme .footer-bottom {
  border-top-color: var(--color-border);
}

html.dark-theme input,
html.dark-theme textarea,
html.dark-theme select {
  background: #161c2a;
  border-color: var(--color-border);
  color: var(--color-text);
}

html.dark-theme input::placeholder,
html.dark-theme textarea::placeholder {
  color: var(--color-muted);
}

/* Theme toggle button */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  color: var(--color-text);
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.3s ease;
  flex-shrink: 0;
  padding: 0;
}

.theme-toggle:hover {
  background: var(--color-light);
  transform: rotate(20deg);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

/* Show moon in light mode, sun in dark mode */
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }

html.dark-theme .theme-toggle .icon-sun  { display: block; }
html.dark-theme .theme-toggle .icon-moon { display: none; }

/* ---- 3. CUSTOM CURSOR ---- */

/* Custom cursor dot/ring are decorative overlays only — native cursor is preserved */

.custom-cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 10px;
  height: 10px;
  background: var(--color-primary, #0d2b5e);
  border-radius: 50%;
  pointer-events: none;
  z-index: 10000;
  /* Centre the dot on the pointer — JS sets left/top to mouse coords */
  transform: translate(-50%, -50%);
  transition: width 0.2s ease, height 0.2s ease, background 0.2s ease;
  will-change: transform;
  display: none;
}

.custom-cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  width: 34px;
  height: 34px;
  border: 1.5px solid var(--color-primary, #0d2b5e);
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  /* Centre the ring on the pointer — JS sets left/top via lerp */
  transform: translate(-50%, -50%);
  transition: width 0.25s ease, height 0.25s ease, border-color 0.25s ease, opacity 0.25s ease;
  will-change: transform;
  opacity: 0.55;
  display: none;
}

@media (pointer: fine) {
  .custom-cursor,
  .custom-cursor-ring {
    display: block;
  }
}

.custom-cursor.is-hovered {
  width: 18px;
  height: 18px;
  background: var(--color-accent, #f5a623);
}

.custom-cursor-ring.is-hovered {
  width: 50px;
  height: 50px;
  border-color: var(--color-accent, #f5a623);
  opacity: 0.35;
}

html.dark-theme .custom-cursor {
  background: var(--color-accent, #f5a623);
}

html.dark-theme .custom-cursor-ring {
  border-color: var(--color-accent, #f5a623);
}

html.dark-theme .custom-cursor.is-hovered {
  background: #ffffff;
}

html.dark-theme .custom-cursor-ring.is-hovered {
  border-color: #ffffff;
}

/* =========================================
   SVG Route Map Styles
   ========================================= */

.svg-route-map {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---- Land polygons ---- */
.svg-map-country {
  fill: #17345f;
  fill-opacity: 0.82;
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 0.6;
  stroke-linejoin: round;
}

.svg-map-country--russia {
  fill: #5d96c3;
  fill-opacity: 0.92;
  stroke: #9fd5ff;
  stroke-width: 0.9;
}

/* ---- Animated route lines ---- */

/* Sea route: long dashes flowing forward (Новороссийск → India → China → Vladivostok) */
@keyframes svg-flow-sea {
  from { stroke-dashoffset: 26; }
  to   { stroke-dashoffset: 0; }
}

/* Land route: shorter dashes flowing forward (Trans-Siberian, Southern corridor) */
@keyframes svg-flow-land {
  from { stroke-dashoffset: 14; }
  to   { stroke-dashoffset: 0; }
}

/* NSR / Arctic route: dash-dot pattern (16+5+5+5 = 31) */
@keyframes svg-flow-nsr {
  from { stroke-dashoffset: 31; }
  to   { stroke-dashoffset: 0; }
}

/* Legacy keyframe kept for any older cached refs */
@keyframes svg-route-flow {
  from { stroke-dashoffset: 26; }
  to   { stroke-dashoffset: 0; }
}

.svg-map-route {
  fill: none;
}

.svg-map-route--sea {
  stroke-dasharray: 16 10;
  animation: svg-flow-sea 3s linear infinite;
}

.svg-map-route--land {
  stroke-dasharray: 8 6;
  animation: svg-flow-land 2.5s linear infinite;
}

/* NSR / Arctic route: dash-dot pattern for visual distinction. */
.svg-map-route--nsr {
  stroke-dasharray: 16 5 5 5;
  animation: svg-flow-nsr 3.5s linear infinite;
}

/* Invisible hit-area path for route hover (wide transparent stroke). */
.svg-map-route-hit {
  fill: none;
  cursor: pointer;
}

/* Grab-cursor for pan/zoom SVG. */
.svg-route-map {
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.svg-route-map:active {
  cursor: grabbing;
}

/* ---- City markers ---- */
.svg-map-dot {
  fill: #d4af37;
  filter: drop-shadow(0 0 4px rgba(212, 175, 55, 0.7));
}

.svg-map-marker--hub .svg-map-dot {
  fill: #ffffff;
  filter: drop-shadow(0 0 6px rgba(212, 175, 55, 0.9));
}

@keyframes svg-pulse {
  0%   { r: 7;  opacity: 0.8; }
  100% { r: 20; opacity: 0;   }
}

@keyframes svg-pulse-hub {
  0%   { r: 10; opacity: 0.8; }
  100% { r: 26; opacity: 0;   }
}

.svg-map-pulse {
  fill: none;
  stroke: #d4af37;
  stroke-width: 1.5;
  animation: svg-pulse 2.4s ease-out infinite;
}

.svg-map-marker--hub .svg-map-pulse {
  stroke: #ffffff;
  animation: svg-pulse-hub 2s ease-out infinite;
}

.svg-map-marker {
  cursor: pointer;
}

.svg-map-marker:focus {
  outline: none;
}

.svg-map-marker:focus .svg-map-dot {
  stroke: #d4af37;
  stroke-width: 2;
}

/* Route-hover: connected node highlight state.
   The inline fill/filter are set via JS; this class provides the pulse boost. */
.svg-map-marker--route-active .svg-map-pulse {
  animation: svg-pulse-hub 1.4s ease-out infinite !important;
  stroke-opacity: 0.9 !important;
}

/* Respect reduced-motion for SVG map animations */
@media (prefers-reduced-motion: reduce) {
  .svg-map-route--sea,
  .svg-map-route--land,
  .svg-map-route--nsr,
  .svg-map-pulse,
  .svg-map-marker--hub .svg-map-pulse,
  .svg-map-marker--route-active .svg-map-pulse {
    animation: none !important;
  }
}

/* ---- Minor items: hidden on small screens ---- */
/* Add class svg-map-minor to low-priority markers and routes in map-svg.js.
   To change which items are hidden: set mobile: false on the POINTS / FLOW_ROUTES entry. */
@media (max-width: 767px) {
  .svg-map-minor {
    display: none;
  }
}

/* ---- Tooltip ---- */
/* max-width must match TOOLTIP_WIDTH constant in js/map-svg.js */
.svg-map-tooltip {
  position: absolute;
  display: none;
  flex-direction: column;
  gap: 3px;
  padding: 9px 13px;
  min-width: 140px;
  max-width: 220px;
  background: rgba(13, 27, 62, 0.93);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 10;
  transform: translateY(-50%);
}

.svg-map-tt-title {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: #d4af37;
}

.svg-map-tt-desc {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.45;
}

/* =========================================
   Map Theme Picker (3-button variant chooser)
   ========================================= */

.map-theme-picker {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.map-theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 20px;
  background: transparent;
  border: 2px solid rgba(13, 43, 94, 0.22);
  border-radius: 40px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-muted, #6c757d);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s, box-shadow 0.2s;
}

.map-theme-btn:hover {
  border-color: var(--color-accent, #f5a623);
  color: var(--color-primary, #0d2b5e);
  background: rgba(245, 166, 35, 0.08);
}

.map-theme-btn--active {
  background: var(--color-primary, #0d2b5e);
  border-color: var(--color-primary, #0d2b5e);
  color: #ffffff;
  box-shadow: 0 2px 12px rgba(13, 43, 94, 0.3);
}

.map-theme-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---- City labels on SVG map ---- */
.svg-map-label {
  user-select: none;
  pointer-events: none;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.55);
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.svg-map-label--hub {
  stroke-width: 3;
}

/* Hide labels on very small screens to avoid clutter. */
@media (max-width: 480px) {
  .svg-map-label {
    display: none;
  }
}

/* ---- Map legend ---- */
.svg-map-legend {
  pointer-events: none;
}

/* =========================================
   Map Option Chooser (legacy 3-tab switcher)
   ========================================= */

.map-option-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.map-option-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  background: transparent;
  border: 2px solid var(--color-border, #dde3ee);
  border-radius: 40px;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--color-muted, #6c757d);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.map-option-tab:hover {
  border-color: var(--color-accent, #f5a623);
  color: var(--color-primary, #0d2b5e);
}

.map-option-tab--active {
  background: var(--color-accent, #f5a623);
  border-color: var(--color-accent, #f5a623);
  color: var(--color-primary, #0d2b5e);
}

.map-frame {
  width: 100%;
  height: 420px;
  border-radius: 12px;
  overflow: hidden;
  background: #0d1b3e;
  position: relative;
}

.map-panel {
  display: none;
}

.map-panel--active {
  display: block;
  min-height: 420px;
}

/* ── Full-screen route-map layout ──────────────────────────────────────────
   #routeMap breaks the map out of the .container so it spans 100% page width,
   and the section grows to fill the viewport height.                          */
#routeMap {
  padding-bottom: 0;
  display: flex;
  flex-direction: column;
}

#routeMap #map-panel-svg.map-panel--active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#routeMap .map-theme-picker {
  margin-bottom: 12px;
}

#routeMap #svg-map-container.map-frame {
  flex: 1;
  height: calc(100vh - 72px);
  min-height: 520px;
  border-radius: 0;
}

#routeMap #svg-map-container .svg-route-map {
  width: 100%;
  height: 100%;
}

@media (max-width: 767px) {
  #routeMap #svg-map-container.map-frame {
    height: 70vh;
    min-height: 360px;
  }
}

/* ---- Stats Grid (Option C) ---- */

.map-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  padding: 32px 0;
}

@media (max-width: 767px) {
  .map-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
}

.map-stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px 20px;
  background: var(--color-light, #f4f7fc);
  border-radius: 16px;
  border: 1px solid var(--color-border, #dde3ee);
  transition: box-shadow 0.2s, transform 0.2s;
}

.map-stat-card:hover {
  box-shadow: 0 8px 24px rgba(13, 43, 94, 0.12);
  transform: translateY(-2px);
}

.map-stat-icon {
  font-size: 2.2rem;
  margin-bottom: 12px;
  line-height: 1;
}

.map-stat-value {
  display: block;
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--color-primary, #0d2b5e);
  line-height: 1;
  margin-bottom: 8px;
}

.map-stat-label {
  font-size: 0.88rem;
  color: var(--color-muted, #6c757d);
  line-height: 1.4;
}

/* ── Route index (SEO / AI crawlable text near SVG map) ── */
.route-index {
  background: var(--color-light, #f4f6f9);
  border-radius: var(--radius-lg, 16px);
  padding: 28px 32px;
}

.route-index-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary, #0d2b5e);
  margin: 0 0 8px;
}

.route-index-desc {
  color: var(--color-muted, #6c757d);
  font-size: 0.92rem;
  margin: 0 0 20px;
}

.route-index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px 28px;
}

.route-index-grid h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-primary, #0d2b5e);
  margin: 0 0 8px;
}

.route-index-grid ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.88rem;
  color: var(--color-text, #333);
  line-height: 1.55;
}

/* ── Noscript navigation (crawlers / no-JS fallback) ── */
.noscript-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 12px 16px;
  background: var(--color-primary, #0d2b5e);
  font-size: 0.88rem;
}

.noscript-nav a {
  color: #fff;
  text-decoration: underline;
}
