/* === 📜 FONTS === */
@font-face {
  font-family: "Alegreya";
  src: url("/static/fonts/Alegreya-Regular.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: "EB Garamond";
  src: url("/static/fonts/EBGaramond.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "EB Garamond";
  src: url("/static/fonts/EBGaramond-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Piazzolla";
  src: url("/static/fonts/Piazzolla.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Piazzolla";
  src: url("/static/fonts/Piazzolla-Italic.ttf") format("truetype");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

@keyframes borderPulse {
  0%, 100% { filter: drop-shadow(0 0 3px var(--pulse-color)) brightness(1.2); }
  50% { filter: drop-shadow(0 0 12px var(--pulse-color)) brightness(1.7); }
}

@keyframes lastImpulse {
  0% { filter: drop-shadow(0 0 10px var(--pulse-color)) brightness(1.6); }
  20% { filter: drop-shadow(0 0 20px var(--pulse-color)) brightness(2.2); }
  100% { filter: drop-shadow(0 0 0px transparent) brightness(1); }
}

@property --v-stop-1 {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 45%;
}

@property --v-stop-2 {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 90%;
}

@media screen and (max-width: 800px) {
    div[id*="timeline"], div[class*="timeline"] {
        position: absolute !important;
        left: 50% !important;
        top: 5px !important;
        
        transform: translateX(-50%) scale(0.8) !important; 
        transform-origin: top center !important;
        
        width: max-content !important; 
        min-width: 60% !important;
        z-index: 1000 !important;
    }

    .splash-content {
       transform: scale(0.8) !important;
    }
}

@media screen and (max-height: 520px) {

    .sidebar-header {
      padding: 14px !important;
      gap: 8px !important;

      .sb-link-btn {
        padding: 4px 8px !important;
        font-size: 12px !important;
      }
    }

    #left-panel {
        transform-origin: left center !important;
        transform: translateY(-50%) scale(0.77) !important;
        
        gap: 0 !important; 
    }

    #left-panel > div[style*="height: 1px"] {
        display: none !important;
    }
    #tools-bar {
        margin-top: 8px !important;
    }
}

@media screen and (max-width: 520px) {
    #info-sidebar {
      max-width: 100% !important;
    }

    .splash-content {
       transform: scale(0.68) !important;
    }
}
/* === CORE THEME (GRIM DARK) === */
:root {
  --bg-color: #0a0908;
  --text-color: #a89f91;
  --text-highlight: #e6dcc8;
  --text-muted: #6b6359;
  --border-color: #4a4238;
  --ui-bg: rgba(20, 18, 16, 0.98);
  --btn-bg: #25201b;

  --anim-speed: 1.5s;
}

body,
html {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg-color);
  font-family: "Alegreya", "Georgia", serif;
  color: var(--text-color);
}

body,
#main,
html,
.leaflet-popup-content-wrapper,
.leaflet-popup-tip-container {
  cursor:
    url("https://assets.newnestgames.com/ui/mouse_ico_32.png") 6 6,
    auto;
}

a,
button,
.leaflet-interactive,
.ui-btn,
.filter-circle,
.sb-link-btn,
.tl-btn {
  cursor:
    url("https://assets.newnestgames.com/ui/mouse_pointer_ico_32.png") 6 4,
    pointer !important;
}

.leaflet-grab {
  cursor:
    url("https://assets.newnestgames.com/ui/mouse_ico_32.png") 6 4,
    grab !important;
}

.leaflet-dragging .leaflet-grab,
.leaflet-grab:active {
  cursor:
    url("https://assets.newnestgames.com/ui/mouse_grabbing_ico_32.png") 6 4,
    grabbing !important;
}

/* === 🔥 MAP WRAPPER (CLEAN & SHARP) === */
#map-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
  filter: sepia(0.3) blur(8px) brightness(0.4);
  transform: scale(0.98);
  transition:
    filter 1.5s ease-out,
    transform 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    brightness 1.5s ease;
}

/* СОСТОЯНИЕ АКТИВНОЙ КАРТЫ */
body.exploration-active #map-wrapper {
  filter: none !important;
  transform: scale(1);
}

.leaflet-tile-container,
.leaflet-tile {
  filter: none !important;
}

#map {
  width: 100%;
  height: 100%;
  z-index: 1;
  filter: brightness(0.9) contrast(1.1) saturate(0.9);
}

#map,
#map-wrapper,
.leaflet-container {
  background: #1a1a1a !important;
}

#map.focus-mode .leaflet-interactive:not(.border-active),
#map.focus-mode .leaflet-marker-icon {
    pointer-events: none !important;
    transition: opacity 0.5s ease;
}

.leaflet-container {
  outline: 0;
}

#vignette-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4000;
  background: radial-gradient(
    circle at center,
    transparent var(--v-stop-1),
    rgba(0, 0, 0, var(--vignette-opacity, 0.7)) var(--v-stop-2)
  );
  transition:
    --v-stop-1 0.8s ease,
    --v-stop-2 0.8s ease,
    opacity 0.8s ease;
  mix-blend-mode: multiply;
}

.layer-focused-out {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 0.5s ease-in-out !important;
}

path.border-active {
  stroke: var(--pulse-color) !important;
  stroke-opacity: 1 !important;
  animation: borderPulse 5s infinite ease-in-out;
  transition: filter 0.3s ease;
  z-index: 1000 !important;
}

path.border-deactivating {
  animation: lastImpulse 0.8s ease-out forwards !important;
}

path.border-active:hover {
  fill-opacity: var(--base-fill-opacity) !important;
}

.borders-hidden path:not(.border-active) {
    opacity: 0 !important;
    transition: opacity 0.5s ease;
}

.leaflet-zoom-anim path.border-active {
  transition: none !important;
}

.layer-faded-out {
  opacity: 0 !important;
  transition: opacity 0.6s ease-out !important;
  pointer-events: none;
}

#cursor-light {
  position: absolute;
  height: 800px;
  background: radial-gradient(
    circle closest-side,
    rgba(230, 220, 200, 0.05) 0%,
    rgba(230, 220, 200, 0.02) 40%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 3500;
  transform: translate(-50%, -50%);
  mix-blend-mode: plus-lighter; 
  opacity: 0;
  transition: opacity 1s ease;
  will-change: transform;
}

body.exploration-active #cursor-light {
  opacity: 1;
}

/* === 🔥 SPLASH SCREEN === */
#splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #1c1a17 0%, #050404 90%);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition:
    opacity var(--anim-speed) ease,
    transform var(--anim-speed) ease,
    visibility var(--anim-speed);
}
#splash-screen.faded {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(1.05);
}

.splash-content {
  text-align: center;
  position: relative;
  z-index: 2;
}
.splash-title {
  font-size: 80px;
  color: var(--text-highlight);
  text-transform: uppercase;
  letter-spacing: 4px;
  margin-bottom: 5px;
  text-shadow: 0 5px 20px rgba(0, 0, 0, 0.8);
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 10px;
  font-weight: normal;
}
.splash-subtitle {
  font-size: 18px;
  color: var(--text-muted);
  letter-spacing: 2px;
  margin-bottom: 60px;
  font-style: italic;
}
.splash-btn {
  padding: 15px 40px;
  font-size: 20px;
  color: var(--text-highlight);
  font-family: "Alegreya", serif;
  background: rgba(10, 8, 6, 0.8);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 0 15px rgba(0, 0, 0, 1);
}
.splash-btn:hover {
  background: #1c1814;
  border-color: var(--text-highlight);
  box-shadow: 0 0 25px rgba(60, 50, 40, 0.5);
}
.splash-btn-sub {
  background: transparent;
  border: none;
  color: #444;
  font-size: 14px;
  padding: 10px 20px;
  margin-top: 20px;
  cursor: not-allowed;
  font-style: italic;
}

/* === UI LAYOUT === */
#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10000;
  opacity: 0;
  transition: opacity 1s ease 1s;
}
body.exploration-active #ui-layer {
  opacity: 1;
}

#left-panel {
  position: absolute;
  top: 50%;
  left: 20px;
  transform: translateY(-50%);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 25px;
}

#filter-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ICONS */
.filter-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #554b40;
  background: var(--btn-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.8);
}
.filter-circle img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  filter: brightness(1.2) contrast(1.1) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.8));
  opacity: 1;
  transition: 0.3s;
}
.filter-circle:hover {
  transform: scale(1.15);
  border-color: var(--text-highlight);
  background: #332b24;
  box-shadow: 0 0 15px rgba(220, 208, 186, 0.2);
}
.filter-circle:hover img {
  filter: brightness(1.4) drop-shadow(0 0 5px var(--text-highlight));
}
.filter-circle.off {
  filter: grayscale(100%);
  opacity: 0.5;
  border-color: #333;
  background: #111;
  box-shadow: none;
}

.filter-circle::after,
.ui-btn::after {
  content: attr(title);
  position: absolute;
  left: 60px;
  background: #111;
  color: var(--text-highlight);
  padding: 4px 8px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: 2px;
  opacity: 0;
  transition: 0.2s;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
  z-index: 100;
}
.filter-circle:hover::after,
.ui-btn:hover::after {
  opacity: 1;
}

#fs-btn::after,
#zoom-controls .ui-btn::after {
  left: auto !important;
  right: 60px !important;
}

#tools-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.ui-btn {
  width: 44px;
  height: 44px;
  background: var(--btn-bg);
  border: 1px solid #554b40;
  color: var(--text-color);
  border-radius: 2px;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.8);
  position: relative;
  font-size: 20px; /* For text icons like + - */
  font-family: "Alegreya", serif;
}
.ui-btn:hover {
  border-color: var(--text-highlight);
  background: #332b24;
  color: var(--text-highlight);
}
.ui-btn.active {
  background: #3e3832;
  border-color: var(--text-highlight);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.8) inset;
  color: var(--text-highlight);
}
.ui-btn img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: brightness(1.2);
}

/* 🔥 TIMELINE: GHOST STYLE */
#timeline-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  justify-content: center;
  padding-top: 15px;
  pointer-events: none;
}
.timeline-controls {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 20px;
  background: rgba(10, 8, 6, 0.5);
  border: 1px solid transparent;
  border-bottom: 1px solid rgba(230, 220, 200, 0.1);
  backdrop-filter: blur(2px);
  padding: 5px 30px;
  border-radius: 30px;
  transition: 0.3s;
}
.timeline-controls:hover {
  background: rgba(10, 8, 6, 0.8);
  border-color: #4a4238;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.8);
}
.tl-year {
  font-size: 26px;
  font-weight: normal;
  color: var(--text-highlight);
  min-width: 140px;
  text-align: center;
  text-shadow: 0 2px 15px rgba(0, 0, 0, 1);
  letter-spacing: 2px;
  font-family: "Alegreya", serif;
}
.tl-btn {
  background: transparent;
  border: none;
  color: #666;
  font-size: 24px;
  cursor: pointer;
  transition: 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tl-btn:hover {
  color: var(--text-highlight);
  transform: scale(1.2);
  text-shadow: 0 0 10px var(--text-highlight);
}
.tl-btn.disabled {
  opacity: 0;
  pointer-events: none;
}

/* === POSITIONING === */
#fs-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 10001;
  pointer-events: auto;
}

#zoom-controls {
  position: absolute;
  bottom: 30px;
  right: 30px;
  z-index: 10001;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  z-index: 10999;
  pointer-events: none;
  transition: background 0.6s ease, backdrop-filter 0.6s ease;
}

#sidebar-overlay.open {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  pointer-events: auto;
}

#info-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 434px;
  height: 100%;
  background: #141210;
  border-left: 2px solid var(--border-color);
  z-index: 11000;



  transform: translateX(100%); 
  
  will-change: transform;
  backface-visibility: hidden;
  transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
  
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 50px rgba(0, 0, 0, 1);
}

#info-sidebar.open {
  transform: translateX(0);
}

@keyframes curtainFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

#sidebar-curtain {
  position: absolute;
  top: 0; 
  left: 0;
  right: 0;
  bottom: 0;
  background: #141210;
  z-index: 100;
  opacity: 1;
  pointer-events: none;
}

#sidebar-curtain.hidden {
  opacity: 0;
  visibility: hidden;
}

#sidebar-curtain.fade-out {
  animation: curtainFadeOut 0.8s ease-in-out forwards;
}

/* При закрытии просто возвращаем в исходное без анимации */
#sidebar-curtain.hidden-instant {
  opacity: 1;
  display: block;
}

/* Добавим легкое свечение границы, как у древних артефактов */
#info-sidebar::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, transparent, var(--border-color), transparent);
  opacity: 0.5;
}
.sidebar-header {
  padding: 25px;
  background: #0c0b0a;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 15px;
  z-index: 500;
}
.sb-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sb-title {
  font-size: 1.4rem;
  font-family: "Piazolla", serif;
  color: var(--text-highlight);
}
.sb-close {
  background: none;
  border: none;
  color: #555;
  font-size: 32px;
  cursor: pointer;
  transition: 0.2s;
  line-height: 0.5;
}
.sb-close:hover {
  color: var(--ui-danger);
}
.sb-link-btn {
  align-self: flex-start;
  background: transparent;
  border: 1px solid #444;
  color: var(--text-muted);
  padding: 8px 15px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: 0.2s;
}
.sb-link-btn:hover {
  border-color: var(--text-color);
  color: var(--text-highlight);
  background: rgba(255, 255, 255, 0.03);
}
#sidebar-frame {
  flex-grow: 1;
  border: none;
  background: #141210;
  /*filter: contrast(0.9) sepia(0.2);*/
}

.safe-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}
.safe-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.8));
  transition: transform 0.2s;
}
.safe-icon:hover img {
  transform: scale(1.1);
  filter: drop-shadow(0 0 8px var(--text-highlight));
}

.ruler-tooltip {
  background: rgba(14, 12, 10, 0.95);
  border: 1px solid var(--border-color);
  color: var(--text-highlight);
  font-family: "Alegreya", serif;
  box-shadow: 0 2px 10px black;
}

.ruler-remove-btn {
  background: #4a0a0a;
  border: 1px solid #7a1a1a;
  color: #ffcccc;
  padding: 5px 10px;
  cursor: pointer;
  font-family: "Alegreya", serif;
  font-size: 14px;
  width: 100%;
}
.ruler-remove-btn:hover {
  background: #7a1a1a;
  color: white;
}

.hidden {
  display: none !important;
}

path.leaflet-interactive {
    transition: 
        stroke-width 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
        stroke 0.3s ease, 
        fill-opacity 0.3s ease,
        filter 0.3s ease,
        opacity 0.4s ease-in-out;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #141210 !important;
  color: var(--text-color) !important;
  border: 1px solid #463a25;
}

.leaflet-popup-content .popup-read-note {
  display: inline-block;
  margin-top: 10px;
  background: #1c1814 !important;
  color: #a89f91 !important;
  border: 1px solid #463a25 !important;
  padding: 6px 12px;
  cursor: pointer;
  font-family: "Alegreya", serif;
  text-transform: uppercase;
  font-size: 12px;
  transition: all 0.2s ease;
  outline: none;
}

.leaflet-popup-content .popup-read-note:hover {
  background: #2a241f !important;
  color: var(--text-highlight) !important;
  border-color: var(--text-highlight) !important;
  box-shadow: 0 0 10px rgba(230, 220, 200, 0.2);
}

/* Включаем GPU-ускорение для карты во время полета */
.leaflet-zoom-animated {
  will-change: transform;
  transition-timing-function: cubic-bezier(0.45, 0.05, 0.55, 0.95) !important;
  overflow: visible !important;
}

.leaflet-zoom-anim .leaflet-zoom-animated {
    transition: transform 1.0s cubic-bezier(0.25, 1, 0.5, 1) !important;
}

.leaflet-tile-pane {
    transition: opacity 0.5s linear;
}

.leaflet-marker-pane .leaflet-marker-icon {
    transition: transform 1.0s cubic-bezier(0.25, 1, 0.5, 1);
}

.leaflet-dragging .leaflet-interactive,
.leaflet-zoom-anim .leaflet-interactive {
  filter: none !important;
}

.leaflet-pane,
.leaflet-vml-pane,
.leaflet-overlay-pane,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer,
.leaflet-pane > svg {
    overflow: visible !important;
}

.leaflet-overlay-pane {
    pointer-events: auto;
}

.leaflet-zoom-anim .leaflet-overlay-pane,
.leaflet-zoom-anim .leaflet-marker-pane {
    opacity: 0 !important;
    will-change: opacity;
    transition: opacity 0.2s ease-out !important;
}

.leaflet-overlay-pane,
.leaflet-marker-pane {
    opacity: 1;
    will-change: opacity;
    transition: opacity 0.6s ease-in-out 0.2s !important;
}

#cloud-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 400;
    pointer-events: none;
    opacity: 0.6;
    mix-blend-mode: screen; /*OR 'NORMAL'*/
}

path.leaflet-interactive.anim-underline {
  transition: stroke-opacity 0.3s ease, stroke 0.3s ease, filter 0.3s ease !important;
  will-change: stroke-opacity, stroke, filter;
}