/* style.css */

body {
  margin: 0;
  padding: 20px;
  font-family: 'Open Sans', sans-serif;
  background: #f7f7f7;
}

.map-header {
  text-align: center;
  margin-bottom: 16px;
}

.map-header h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  color: #065da9;
}

.map-header p {
  margin: 6px 0 0;
  font-size: 14px;
  color: #5f6b76;
}

.map-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3000;
}

.map-controls button {
  pointer-events: auto;
}

.tag {
  display: inline-block;
  background: #e8f4fb;
  color: #065da9;
  padding: 6px 12px;
  margin: 4px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

/* ============================= */
/* MAP CONTAINER                 */
/* ============================= */

.mapa {
  position: relative;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  border-radius: 24px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}

.map-viewport {
  width: 100%;
  height: min(78vh, 750px);
  overflow: hidden;
  position: relative;
  background: #f8f8f8;
  position: relative;
  touch-action: none;
  cursor: grab;
}

.map-viewport:active {
  cursor: grabbing;
}

.map-viewport::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

/* the thing that moves */
.map-content {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
  width: var(--mapW);
  height: var(--mapH);
  filter: none;
}

/* layers */
.map-layer {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  user-select: none;
  pointer-events: none;
  border-radius: 18px;
}

#mapBase {
  border-radius: 18px;
}

#mapRoads {
  opacity: 0.45;
}

/* ============================= */
/* BUTTONS                       */
/* ============================= */

.map-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.70);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 7px 11px;
  font-size: 12px;
  cursor: pointer;
}

.map-btn:hover {
  background: rgba(0, 0, 0, 0.88);
}

.map-btn-second {
  top: 50px;
}

.map-btn-third {
  top: 90px;
}

/* ============================= */
/* POINTS                        */
/* ============================= */

/* Hide points until map is loaded */
.mapa:not(.map-loaded) .point {
  opacity: 0;
  pointer-events: none;
}

.point {
  position: absolute;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  z-index: 50;

  transform: translate(-50%, -50%) scale(var(--markerScale, 1));
  transform-origin: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.2s ease;
}

.mapa.hide-points .point {
  opacity: 0 !important;
  pointer-events: none !important;
}

.location-point {
  width: 34px;
  height: 34px;
  background: #065da9;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
}

.location-point .location-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  pointer-events: none;
}

.station-point {
  width: 30px;
  height: 30px;
  background: #e67e22;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
}

.station-point .train-icon {
  width: 20px;
  height: auto;
  pointer-events: none;
}

.point:hover {
  transform: translate(-50%, -50%) scale(calc(var(--markerScale, 1) * 1.15));
}

.location-point.active {
  background: #ffffff;
  box-shadow:
    0 0 0 4px rgba(6, 93, 169, 0.55),
    0 0 0 10px rgba(31, 174, 229, 0.22);
  transform: translate(-50%, -50%) scale(calc(var(--markerScale, 1) * 1.35));
  z-index: 500;
}

.station-point.active {
  background: #ffffff;
  box-shadow:
    0 0 0 5px rgba(230, 126, 34, 0.55),
    0 0 0 14px rgba(230, 126, 34, 0.22);
  transform: translate(-50%, -50%) scale(calc(var(--markerScale, 1) * 1.35));
  z-index: 500;
}

/* ping animacija (shared) */
@keyframes mapPing {
  0% {
    transform: scale(0.9);
    opacity: 0.9;
  }
  70% {
    opacity: 0.35;
  }
  100% {
    transform: scale(1.9);
    opacity: 0;
  }
}

/* ping animacija lokacije */
.location-point.active::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid rgba(31, 174, 229, 0.5);
  animation: mapPing 2.2s ease-out infinite;
  pointer-events: none;
}

/* ping animacija stanice */

.station-point.active::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid rgba(230, 126, 34, 0.5);
  animation: mapPing 2.2s ease-out infinite;
  pointer-events: none;
}

/* ikona postane plava + pulsira */
.location-point.active .location-icon {
  /*filter: invert(18%) sepia(85%) saturate(2500%) hue-rotate(193deg) brightness(32%) contrast(92%);*/
  animation: iconPulse 1.8s ease-out infinite;
}

@keyframes iconPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.12);
  }
}

/* aktivna stanica = vlak narančast  + puls */
.station-point.active .train-icon {
  /*filter: invert(52%) sepia(79%) saturate(4561%) hue-rotate(12deg) brightness(95%) contrast(92%);*/
  animation: trainPulse 1.8s ease-out infinite;
}

@keyframes trainPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.12);
  }
}

/* ============================= */
/* POPUP                         */
/* ============================= */

.popup {
  position: absolute;
  width: 240px;
  max-width: min(280px, calc(100vw - 40px));

  /* PC should not scroll */
  max-height: none;
  overflow: visible;

  background: #ffffff;
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  z-index: 9999;

  color: #1f1f1f;
  font-size: 14px;
  line-height: 1.45;
}

.hidden {
  display: none;
}

.popup-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.popup h3 {
  text-align: center;
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #065da9;
  text-align: center;
  flex: 1;
}

.popup h4 {
  margin: 0 32px 12px 0;
  font-size: 15px;
  font-weight: 700;
  color: #1faee5;
}

.popup p {
  margin: 0 0 10px 0;
  font-size: 14px;
  color: #2c2c2c;
}

.popup-text-align p {
  text-align: center;
}

.popup ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.popup li {
  position: relative;
  padding-left: 16px;
  margin-bottom: 8px;
  font-size: 14px;
  color: #2c2c2c;
}

.popup li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 6px;
  height: 6px;
  background: #1faee5;
  border-radius: 50%;
}

.popup .list {
  margin: 0;
  padding: 0;
}

.popup .list-item {
  position: relative;
  padding-left: 16px;
  margin-bottom: 8px;
  font-size: 14px;
  color: #2c2c2c;
}

.popup .list-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 6px;
  height: 6px;
  background: #1faee5;
  border-radius: 50%;
}

/* CLOSE BUTTON ALWAYS VISIBLE */
.popup-close {
  position: absolute;
  top: 0px;
  right: 0px;

  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);

  font-size: 20px;
  cursor: pointer;
  color: #666;

  display: flex;
  align-items: center;
  justify-content: center;

  z-index: 999;
}

.popup-close:hover {
  background: #f1f1f1;
}

.popup::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  background: #ffffff;
}

/* ============================= */
/* TIMETABLE                     */
/* ============================= */

.timetable {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tt-head {
  display: grid;
  grid-template-columns: 1fr 1fr;
  font-weight: 700;
  font-size: 13px;
  color: #1faee5;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  padding-bottom: 6px;
}

.tt-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  font-size: 14px;
  padding: 4px 0;
}

.tt-note {
  margin-top: 8px;
  font-size: 11px;
  color: #666;
}

.train-box {
  margin-top: 10px;
}

/* ============================= */
/* FOOTER                        */
/* ============================= */

.footer {
  margin-top: 18px;
  padding: 16px 12px;
  text-align: center;
  font-size: 12px;
  color: #777;
}

.footer-logos {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.footer-logo {
  height: 48px;
  width: auto;
  object-fit: contain;
}

.footer-logo-event {
  height: 55px;
}

.footer-text {
  line-height: 1.5;
}

/* ============================= */
/* MOBILE                        */
/* ============================= */

@media (max-width: 700px) {

    .popup {
    position: fixed !important;
    left: 50% !important;
    bottom: 14px !important;
    top: auto !important;

    transform: translateX(-50%);
    width: min(340px, calc(100vw - 20px)) !important;

    max-height: 30vh !important; /* malo više prostora */
    overflow-y: auto !important;
    overflow-x: hidden !important;

    -webkit-overflow-scrolling: touch;

    padding-top: 0; /* bitno */
    z-index: 99999 !important;
  }

  .popup::after {
    display: none !important;
  }

  .popup-header {
    position: sticky;
    top: 0;
    z-index: 10;

    background: #fff;
    padding: 14px 16px 10px;
    margin: 0;

    backdrop-filter: blur(8px);
    background: rgba(255,255,255,0.9);
  }

  .popup-close {
    position: absolute; 
    top: 10px;
    right: 10px;
    left: auto;
    margin-left: 0;
  }

  .popup h3 {
    margin-top: 0;
  }

  .location-point { width: 24px; height: 24px; }
  .location-point .location-icon { width: 16px; height: 16px; }

  .station-point { width: 20px; height: 20px; }
  .station-point .train-icon { width: 14px; }

  .footer-text {
    line-height: 1.6;
  }

  .footer-text p {
    margin-top: 10px;
  }

  .footer-text p br {
    display: block;
  }

  .footer-line {
    white-space: nowrap;
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
  }

  .footer-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
  }

  .sep {
    display: none;
  }
}

.span {
  display: none;
}

/* ============================= */
/* PC                            */
/* ============================= */

@media (min-width: 701px) {
  .footer-text p br {
    display: none;
  }
}
