/* =============== BASE STYLES (APPLY TO ALL) =============== */
html, body {
  height: 100%;
  margin: 0;
  font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  overflow: hidden;
  background: #0f2027;
  background: linear-gradient(to right, #2c5364, #203a43, #0f2027);
  color: #fff;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#map {
  height: 100%;
  width: 100%;
  position: absolute;
  z-index: 0;
}

.glassy {
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

/* Animation keyframes */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-5px); }
  100% { transform: translateY(0px); }
}

.floating {
  animation: float 3s ease-in-out infinite;
}

/* =============== DESKTOP VERSION (768px and up) =============== */
@media (min-width: 768px) {
  .navbar {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    z-index: 1000;
    padding: 6px 12px;
    background: rgba(255,255,255,0.08);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.1);
    height: auto;
    width: auto;
    right: auto;
  }
  .nav-item {
    padding: 12px 18px;
    cursor: pointer;
    color: #ccc;
    transition: all 0.3s ease;
    border-radius: 20px;
    margin: 0 6px;
    font-weight: 600;
    background: rgba(255,255,255,0.05);
    font-size: 16px;
    min-width: 90px;
    height: auto;
    text-align: center;
    padding-left: 22px;
    padding-right: 22px;
  }

  .nav-item.active {
    background: linear-gradient(to right, #ff416c, #ff4b2b);
    color: #fff;
    box-shadow: 0 0 15px rgba(255, 65, 108, 0.7);
  }

  /* Year Controls */
  .year-controls {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    z-index: 1000;
    padding: 18px 32px;
    gap: 18px;
    background: rgba(255,255,255,0.13);
    border-radius: 32px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25), 0 2px 8px rgba(0,0,0,0.10);
    border: 1.5px solid rgba(255,255,255,0.18);
    backdrop-filter: blur(18px);
    transition: box-shadow 0.2s, background 0.2s;
  }
  .year-controls:hover {
    box-shadow: 0 12px 40px rgba(0,0,0,0.32), 0 4px 16px rgba(0,0,0,0.13);
    background: rgba(255,255,255,0.18);
  }
  .control-btn {
    width: 48px;
    height: 48px;
    font-size: 22px;
    border-radius: 50%;
    margin: 0 4px;
  }
  .year-input input, .year-input-row input {
    padding: 12px 18px;
    border-radius: 28px;
    width: 130px;
    font-size: 18px;
    margin: 0 8px;
    background: linear-gradient(120deg, rgba(255,255,255,0.18) 0%, rgba(44,83,100,0.13) 100%);
    color: #fff;
    border: 1.5px solid rgba(255,255,255,0.22);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08) inset, 0 1px 4px rgba(44,83,100,0.10);
    transition: border 0.18s, box-shadow 0.18s, background 0.18s;
    outline: none;
  }
  .year-input input:focus, .year-input-row input:focus {
    border: 2px solid #ff6a00;
    background: linear-gradient(120deg, rgba(255,255,255,0.28) 0%, rgba(44,83,100,0.18) 100%);
    box-shadow: 0 0 0 3px rgba(255,106,0,0.18), 0 2px 8px rgba(0,0,0,0.10) inset;
  }
  .load-btn {
    padding: 12px 26px;
    border-radius: 28px;
    font-size: 1.08rem;
    margin-left: 8px;
    margin-right: 0;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  }

  .load-btn.neon {
    background: linear-gradient(90deg, #ff6a00, #ee0979);
    color: #fff;
  }

  /* Timeline */
  .timeline-container {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    height: 90vh;
    width: auto;
    overflow-y: auto;
    z-index: 1000;
    scrollbar-width: none; /* Hide scrollbar Firefox */
  }

  .timeline-container::-webkit-scrollbar {
    display: none; /* Hide scrollbar Chrome/Safari */
  }

  .timeline-line {
    position: absolute;
    left: 12px;
    top: 50px;
    height: 900px;
    width: 4px;
    background: linear-gradient(to bottom, #00f260, #0575e6);
    z-index: -1;
  }

  .timeline-years {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding-left: 30px;
  }

  /* Legend */
  .legend-toggle {
    position: fixed;
    bottom: 30px;
    right: 20px;
    z-index: 1000;
  }

  /* Language Switcher - Updated Position */
   .language-switcher {
    position: fixed;
    right: 30px;
    bottom: 30px;
    left: auto;
    top: auto;
    width: auto;
    min-width: 120px;
    max-width: 160px;
    border-radius: 20px;
    padding: 5px 14px;
    background: rgba(255,255,255,0.75);
    box-shadow: 0 4px 24px rgba(58,134,255,0.13);
    border: 1.5px solid rgba(58,134,255,0.10);
    align-items: center;
    z-index: 3000;
    justify-content: center;
    transition: box-shadow 0.2s, background 0.2s;
    display: flex;
    gap: 8px;
  }

  .control-btn {
    background: linear-gradient(135deg, #232526 0%, #414345 100%);
    color: #fff;
    border: 1.5px solid rgba(255,255,255,0.18);
    box-shadow: 0 2px 8px rgba(31,64,55,0.18), 0 0 8px 0 rgba(255,255,255,0.08);
    transition: transform 0.18s, box-shadow 0.18s, background 0.18s;
  }
  .control-btn:hover, .control-btn:focus {
    background: linear-gradient(135deg, #485563 0%, #29323c 100%);
    transform: scale(1.13);
    box-shadow: 0 4px 18px 2px rgba(255,65,108,0.18), 0 0 16px 2px rgba(255,255,255,0.13);
    outline: none;
  }
  .load-btn {
    background: linear-gradient(90deg, #ff6a00 0%, #ee0979 100%);
    color: #fff;
    border: 1.5px solid rgba(255,255,255,0.18);
    box-shadow: 0 2px 8px rgba(255,106,0,0.10), 0 0 8px 0 rgba(255,255,255,0.08);
    transition: transform 0.18s, box-shadow 0.18s, background 0.18s;
  }
  .load-btn:hover, .load-btn:focus {
    background: linear-gradient(90deg, #ee0979 0%, #ff6a00 100%);
    transform: scale(1.08);
    box-shadow: 0 4px 18px 2px rgba(255,106,0,0.18), 0 0 16px 2px rgba(255,255,255,0.13);
    outline: none;
  }
}

/* =============== MOBILE VERSION (767px and below) =============== */
@media (max-width: 767px) {
  /* Map adjustment */
  #map {
    position: fixed;
    top: 0;
    bottom: 180px;
    left: 0;
    right: 0;
    z-index: 0;
  }

  .timeline-container {
    display: flex !important;
    position: fixed;
    top: 50px;
    left: 0;
    right: 0;
    height: 50px;
    z-index: 1000;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 5px;
    background: rgba(15, 23, 42, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    align-items: center;
    scrollbar-width: none;
  }

  .timeline-container::-webkit-scrollbar {
    display: none;
  }

  .timeline-line {
    display: none;
  }

  .timeline-years {
    display: flex;
    gap: 10px;
    padding: 0 10px;
    height: 100%;
    align-items: center;
  }

  /* Year Marker - Mobile Version */
  .year-marker {
    padding: 6px 12px;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 60px;
    text-align: center;
  }

  /* Navbar */
  .navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    background: rgba(15, 23, 42, 0.95);
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000;
    height: 50px;
    box-sizing: border-box;
  }

  .nav-item {
    padding: 8px 10px;
    font-size: 12px;
    min-width: 60px;
    height: 30px;
    text-align: center;
  }

  /* Year Controls */
  .year-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 12px 15px;
    background: rgba(9, 18, 30, 0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.3);
  }

  .year-input {
    display: flex;
    align-items: center;
    flex-grow: 1;
    max-width: 300px;
    gap: 8px;
  }

  .year-input input {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: white;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  }

  .year-input input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    border-color: #3a86ff;
    box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.3);
  }

  .control-btn {
    width: 44px;
    height: 44px;
    font-size: 16px;
    background: linear-gradient(145deg, #3a86ff, #2667cc);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        0 4px 6px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }

  .load-btn {
    padding: 11px 16px;
    font-size: 13px;
    font-weight: 600;
    background: linear-gradient(145deg, #8338ec, #6a2bc4);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    min-width: 70px;
    text-align: center;
  }

  .load-btn.neon {
    padding: 11px 14px;
    font-size: 12px;
    background: linear-gradient(145deg, #ff006e, #d4005b);
    animation: pulse 2s infinite;
    min-width: 90px;
  }

  /* Language Switcher - Updated Position */
  .language-switcher {
    display: flex;
    position: static;
    width: auto;
    height: 32px;
    margin-left: 6px;
    margin-top: -12px;
    align-self: flex-start;
    background: transparent;
    box-shadow: none;
    border: none;
    padding: 0;
    align-items: center;
    gap: 2px;
  }
  .lang-btn {
    font-size: 13px;
    padding: 4px 6px;
    border-radius: 6px;
    min-width: 0;
    font-weight: 600;
    letter-spacing: 0.1px;
  }

  @keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 0, 110, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(255, 0, 110, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 0, 110, 0); }
  }
}

/* =============== COMMON COMPONENT STYLES =============== */
.year-marker {
  background: linear-gradient(145deg, #0f2027, #203a43, #2c5364);
  color: #fff;
  padding: 10px 20px;
  border-radius: 30px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease-in-out;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  animation: fadeInUp 0.4s ease both;
}

.year-marker:hover {
  transform: scale(1.1);
  background: linear-gradient(145deg, #ff416c, #ff4b2b);
  box-shadow: 0 6px 20px rgba(255, 65, 108, 0.6);
}

.year-marker.active-marker {
  background: #ff6a00;
  color: #fff;
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(255, 106, 0, 0.6);
}

.legend-panel {
  position: fixed;
  display: none;
  backdrop-filter: blur(12px);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.legend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(to right, #ff416c, #ff4b2b);
  color: white;
  font-weight: 600;
}

.legend-content {
  padding: 15px;
  max-height: 300px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.08);
}

.lang-btn {
  background: transparent;
  color: #ccc;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 15px;
  font-weight: 600;
  font-size: 14px;
  min-width: 40px;
  text-align: center;
  position: relative;
  z-index: 1002;
}

.lang-btn.active {
  background: linear-gradient(to right, #ff416c, #ff4b2b);
  color: #fff;
  box-shadow: 0 2px 10px rgba(255, 65, 108, 0.5);
}

.lang-btn:hover:not(.active) {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.image-modal {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}

.image-modal.active {
  display: flex;
}

.modal-content {
  position: relative;
  max-width: 100%;
  max-height: 90%;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
  animation: modalFadeIn 0.3s ease-out;
}

.close-modal {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  background: rgba(0, 0, 0, 0.75);
  border: 2px solid rgba(255, 255, 255, 0.85);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  z-index: 2100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.close-modal:hover,
.close-modal:focus {
  background: linear-gradient(135deg, #ff416c, #ff4b2b);
  border-color: #fff;
  transform: scale(1.1) rotate(90deg);
  outline: none;
}

@media (max-width: 767px) {
  .close-modal {
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    font-size: 22px;
  }
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

#originalMapImage {
  display: block;
  max-width: none;
  max-height: none;
  border: 4px solid white;
  border-radius: 10px;
  box-shadow: 0 0 30px rgba(255, 255, 255, 0.2);
  cursor: grab;
  transition: transform 0.05s ease-out;
}

/* Enhanced Language Switcher Styles for Main Page */
.language-switcher {
  display: flex;
  gap: 8px;
  box-shadow: 0 4px 24px rgba(58,134,255,0.13);
  border-radius: 24px;
  padding: 5px 14px;
  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(8px);
  border: 1.5px solid rgba(58,134,255,0.10);
  align-items: center;
  z-index: 1001;
  min-width: 140px;
  width: 140px;
  max-width: 140px;
  justify-content: space-between;
  transition: box-shadow 0.2s, background 0.2s;
}
.lang-btn {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  text-align: center;
  border: none;
  outline: none;
  border-radius: 16px;
  padding: 8px 0;
  font-weight: 700;
  font-size: 16px;
  background: transparent;
  color: #2c3e50;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s, transform 0.18s;
  box-shadow: none;
  position: relative;
  letter-spacing: 0.5px;
}
.lang-btn.active {
  background: linear-gradient(90deg, #3a86ff, #8338ec);
  color: #fff;
  box-shadow: 0 2px 12px rgba(58,134,255,0.18);
  transform: scale(1.08);
  z-index: 1;
}
.lang-btn:not(.active):hover {
  background: rgba(58,134,255,0.10);
  color: #3a86ff;
  transform: scale(1.04);
}

@media (max-width: 767px) {
  .year-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 8px 4px;
    width: 100vw;
    box-sizing: border-box;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 0;
  }
  .year-input-row, .year-btn-row {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    width: 100%;
    gap: 6px;
  }
  .year-input-row input[type="number"] {
    flex: 1 1 60px;
    min-width: 0;
    max-width: 90px;
    font-size: 1rem;
    padding: 4px 6px;
    height: 32px;
    text-align: center;
  }
  .control-btn, .load-btn {
    font-size: 1rem;
    padding: 4px 10px;
    min-width: 0;
    height: 32px;
    border-radius: 6px;
  }
  .year-btn-row .load-btn {
    flex: 1 1 50%;
    margin: 0 2px;
    font-size: 0.95rem;
    padding: 4px 0;
    min-width: 0;
    height: 32px;
  }
  .language-switcher {
    position: fixed;
    right: 12px;
    left: auto;
    bottom: 70px;
    transform: none;
    width: auto;
    min-width: 60px;
    max-width: 90px;
    border-radius: 12px;
    padding: 2px 6px;
    margin: 0;
    background: rgba(255,255,255,0.95);
    box-shadow: 0 2px 10px rgba(44,83,100,0.13);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1001;
    gap: 2px;
  }
  .lang-btn {
    font-size: 11px;
    padding: 3px 0;
    border-radius: 6px;
    min-width: 0;
    font-weight: 600;
    letter-spacing: 0.1px;
  }
}
.leaflet-interactive {
    transition: stroke-opacity 0.5s ease, fill-opacity 0.5s ease;
}

.leaflet-interactive:focus {
    outline: none;
}
.mapAuthor{
  position: absolute;
  z-index:  2000;
  bottom: 0;
  left: 10px;
  display: block;
}

@media (max-width: 767px) {
  .leaflet-control-zoom,
  .leaflet-control-layers {
    display: none !important;
  }
}

#totalarea {
    position: absolute;
    bottom: 0;
    right: 0;
    z-index: 1001;
    margin: 0;
    padding: 2px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border-radius: 8px 0 0 0;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
}
#totalarea p {
    margin: 0;
    padding: 0;
}

@media (max-width: 767px) {
  #totalarea {
    position: fixed;
    bottom: 90px;
    left: 5px;
    top: auto;
    right: auto;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.75em;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
  }
  
  #totalarea p {
    margin: 0;
    padding: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  /* Smaller font for Georgian text to prevent overlap */
  html[lang="ka"] #totalarea,
  html[lang="ka"] #totalarea p {
    font-size: 0.75em;
  }
}

/* block interaction with popup content */
.leaflet-popup-content {
    -webkit-user-select: none;
    -moz-user-select: none;   
    -ms-user-select: none;    
    user-select: none;       
}

.leaflet-popup-close-button {
    pointer-events: auto !important;
}