/* =========================================================================
   Vírské okruhy — styl
   Montserrat · tmavé sklo nad světlou mapou · zelená + oranžová (Horomat)
   ========================================================================= */

:root {
  --green:        #3fae64;
  --green-bright: #5db075;
  --green-deep:   #2e9e4f;
  --orange:       #f2a900;

  --rt-red:   #E23B2E;
  --rt-blue:  #1E6FD8;
  --rt-green: #2E9E4F;

  --bg:         #0e1311;
  --panel:      rgba(18, 23, 21, 0.82);
  --panel-2:    rgba(28, 34, 31, 0.92);
  --panel-solid:#141816;
  --stroke:     rgba(255, 255, 255, 0.10);
  --stroke-2:   rgba(255, 255, 255, 0.16);

  --text:    #f3f6f4;
  --text-dim:#a7b0aa;
  --text-mut:#7e877f;

  --r:    20px;
  --r-md: 16px;
  --r-sm: 12px;
  --shadow:   0 10px 34px rgba(0, 0, 0, 0.42);
  --shadow-sm:0 4px 16px rgba(0, 0, 0, 0.30);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  --topbar-h: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100%; width: 100%;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* dynamická výška kvůli mobilním lištám prohlížeče */
#app { position: fixed; inset: 0; height: 100dvh; }

#map {
  position: absolute; inset: 0;
  background: #e9efe7;
  z-index: 0;
}

button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
.no-select { user-select: none; -webkit-user-select: none; }

/* ---------------------------------------------------------------- Topbar */
.topbar {
  position: absolute; z-index: 600;
  top: 0; left: 0; right: 0;
  padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 10px) 8px calc(var(--safe-l) + 12px);
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(to bottom, rgba(10,14,12,0.78) 0%, rgba(10,14,12,0.40) 70%, transparent 100%);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand .logo {
  width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: 9px;
  box-shadow: var(--shadow-sm);
}
.brand .titles { min-width: 0; line-height: 1.05; }
.brand .t1 {
  font-weight: 800; font-size: 15px; letter-spacing: .02em;
  text-transform: uppercase; white-space: nowrap;
  text-shadow: 0 1px 6px rgba(0,0,0,.6);
}
.brand .t1 .accent { color: var(--orange); }
.brand .t2 {
  font-weight: 600; font-size: 10.5px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
}

.topbar .spacer { flex: 1 1 auto; }

.icon-btn {
  width: 40px; height: 40px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  transition: transform .12s ease, background .15s ease;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 21px; height: 21px; display: block; }

.lang-btn {
  width: auto; padding: 0 12px; height: 40px;
  display: flex; align-items: center; gap: 1px; white-space: nowrap;
  font-weight: 800; font-size: 13px; letter-spacing: .05em;
}
.lang-btn span { line-height: 1; }
.lang-btn .sep { opacity: .35; margin: 0 2px; font-weight: 600; }
.lang-btn .on { color: var(--orange); }

/* --------------------------------------------------------- FAB sloupec */
.fab-col {
  position: absolute; z-index: 600;
  right: calc(var(--safe-r) + 12px);
  bottom: calc(var(--sheet-h, 132px) + var(--safe-b) + 16px);
  display: flex; flex-direction: column; gap: 10px;
  transition: bottom .28s cubic-bezier(.22,.61,.36,1);
}
.fab {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: var(--panel-2);
  border: 1px solid var(--stroke-2);
  backdrop-filter: blur(16px) saturate(1.25);
  -webkit-backdrop-filter: blur(16px) saturate(1.25);
  box-shadow: var(--shadow);
  color: var(--text);
  transition: transform .12s ease, background .15s, color .15s;
}
.fab:active { transform: scale(0.9); }
.fab svg { width: 23px; height: 23px; }
.fab.locate.active { background: var(--green-deep); color: #fff; border-color: transparent; }
.fab.locate.searching svg { animation: spin 1s linear infinite; }
.fab[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------- Vrstvy popover */
.layers-menu {
  position: absolute; z-index: 650;
  right: calc(var(--safe-r) + 66px);
  bottom: calc(var(--sheet-h, 132px) + var(--safe-b) + 16px);
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid var(--stroke-2);
  border-radius: var(--r-md);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: var(--shadow);
  transform-origin: bottom right;
  transition: opacity .16s, transform .16s;
}
.layers-menu[hidden] { display: none; }
.layers-menu.closing { opacity: 0; transform: scale(.92); }
.layer-opt {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px 9px 10px; border-radius: 10px;
  font-weight: 600; font-size: 13.5px; white-space: nowrap;
  color: var(--text-dim);
}
.layer-opt .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text-mut); }
.layer-opt.active { background: rgba(255,255,255,.07); color: var(--text); }
.layer-opt.active .dot { background: var(--green-bright); box-shadow: 0 0 0 3px rgba(93,176,117,.25); }
.layers-menu .divider { height: 1px; background: var(--stroke-2); margin: 3px 4px; }
.poi-toggle.active .dot { background: var(--orange); box-shadow: 0 0 0 3px rgba(242,169,0,.25); }

/* ----------------------------------------------------------- Bottom sheet */
.sheet {
  position: absolute; z-index: 600;
  left: 0; right: 0; bottom: 0;
  padding: 10px calc(var(--safe-r) + 12px) calc(var(--safe-b) + 12px) calc(var(--safe-l) + 12px);
  background: linear-gradient(to top, var(--panel-solid) 62%, rgba(20,24,22,0.86) 100%);
  border-top: 1px solid var(--stroke);
  border-radius: var(--r) var(--r) 0 0;
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: 0 -10px 40px rgba(0,0,0,.45);
  transition: transform .3s cubic-bezier(.22,.61,.36,1);
}
.grab {
  width: 42px; height: 5px; border-radius: 3px;
  background: var(--stroke-2); margin: 0 auto 10px;
}

/* řádek s výběrem okruhů – všechny 3 se vejdou bez scrollování */
.chips { display: flex; gap: 7px; }
.chip {
  flex: 1 1 0; min-width: 0;
  display: flex; align-items: center; gap: 7px;
  padding: 8px 8px; border-radius: 14px;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid var(--stroke);
  transition: border-color .15s, background .15s, transform .1s;
}
.chip:active { transform: scale(.96); }
.chip .c-pic { width: 29px; height: 29px; flex: 0 0 auto; pointer-events: none; }
.chip .c-text { display: flex; flex-direction: column; line-height: 1.18; text-align: left; min-width: 0; }
.chip .c-name { font-weight: 700; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .c-sub  { font-weight: 600; font-size: 11px; color: var(--text-mut); white-space: nowrap; }
.chip.active { background: rgba(255,255,255,0.11); border-color: var(--rt, var(--stroke-2)); }

/* detail / nav panel */
.detail { margin-top: 12px; }
.detail[hidden] { display: none; }

.d-head { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 12px; }
.d-pic { width: 46px; height: 46px; flex: 0 0 auto; margin-top: -1px; }
.sheet.nav-mode .d-pic { width: 34px; height: 34px; }
.d-title { flex: 1 1 auto; min-width: 0; }
.d-title h2 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: .01em; }
.d-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.badge {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 4px 9px; border-radius: 999px;
  background: rgba(255,255,255,.08); color: var(--text-dim);
}
.badge.diff-hard   { background: rgba(226,59,46,.18);  color: #ff9a8f; }
.badge.diff-medium { background: rgba(242,169,0,.18);  color: #ffce6b; }
.badge.diff-easy   { background: rgba(63,174,100,.18); color: #84e0a3; }
.badge.diff-ferrata{ background: rgba(226,59,46,.18);  color: #ff9a8f; }

.d-desc { font-size: 13px; line-height: 1.5; color: var(--text-dim); margin: 0 0 12px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat {
  background: rgba(255,255,255,0.045);
  border: 1px solid var(--stroke);
  border-radius: 12px; padding: 9px 6px; text-align: center;
}
.stat .v { font-weight: 800; font-size: 15px; line-height: 1.1; }
.stat .v small { font-weight: 700; font-size: 10px; color: var(--text-dim); }
.stat .k { font-size: 9.5px; font-weight: 600; color: var(--text-mut); text-transform: uppercase; letter-spacing: .03em; margin-top: 3px; }

/* výškový profil */
.elev { margin-bottom: 14px; }
.elev .lbl { font-size: 9.5px; font-weight: 600; color: var(--text-mut); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.elev svg { width: 100%; height: 54px; display: block; }

.row-btns { display: flex; gap: 9px; }
.btn {
  flex: 1 1 auto;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 16px; border-radius: 14px;
  font-weight: 800; font-size: 14px; letter-spacing: .01em;
  background: rgba(255,255,255,0.07); border: 1px solid var(--stroke-2);
  transition: transform .1s, filter .15s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 19px; height: 19px; }
.btn.primary { background: var(--green-deep); border-color: transparent; color: #fff; }
.btn.primary:active { filter: brightness(1.08); }
.btn.danger { background: rgba(226,59,46,.16); color: #ff9a8f; border-color: rgba(226,59,46,.3); }
.btn.ghost { flex: 0 0 auto; width: 50px; padding: 13px 0; }

/* ----------------------------------------------------------- NAV panel */
/* kompaktní lišta během navigace – aby byla vidět mapa a poloha */
.sheet.nav-mode .chips,
.sheet.nav-mode .d-desc,
.sheet.nav-mode .stats,
.sheet.nav-mode .elev,
.sheet.nav-mode .d-badges { display: none; }
.sheet.nav-mode .d-head { margin-bottom: 8px; }
.sheet.nav-mode .detail { margin-top: 6px; }
.sheet.nav-mode .d-title h2 { font-size: 16px; }
.sheet.nav-mode .row-btns { margin-bottom: 10px; }

.nav-live[hidden] { display: none; }
.nav-status {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 13px; border-radius: 14px; margin-bottom: 10px;
  background: rgba(63,174,100,.14); border: 1px solid rgba(63,174,100,.32);
  transition: background .2s, border-color .2s;
}
.nav-status .pin { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; }
.nav-status .pin svg { width: 24px; height: 24px; }
.nav-status .s-text { line-height: 1.2; }
.nav-status .s1 { font-weight: 800; font-size: 14px; }
.nav-status .s2 { font-weight: 600; font-size: 11.5px; color: var(--text-dim); }
.nav-live.off .nav-status { background: rgba(242,169,0,.16); border-color: rgba(242,169,0,.4); }
.nav-live.off .nav-status .s1 { color: var(--orange); }

.progress-wrap { margin-bottom: 10px; }
.progress-bar { height: 8px; border-radius: 5px; background: rgba(255,255,255,.09); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--green-deep), var(--green-bright)); border-radius: 5px; transition: width .5s ease; }
.progress-meta { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11.5px; font-weight: 600; color: var(--text-dim); }
.progress-meta b { color: var(--text); }

/* ------------------------------------------------------------- Toast */
.toasts {
  position: absolute; z-index: 800; left: 0; right: 0;
  top: calc(var(--safe-t) + var(--topbar-h) + 6px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; padding: 0 14px;
}
.toast {
  max-width: 460px; width: max-content; max-width: 92%;
  padding: 11px 16px; border-radius: 13px;
  background: var(--panel-2); border: 1px solid var(--stroke-2);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  font-size: 13px; font-weight: 600; line-height: 1.35; text-align: center;
  animation: toastIn .25s ease;
}
.toast.warn { border-color: rgba(242,169,0,.5); }
.toast.err  { border-color: rgba(226,59,46,.5); }
.toast.leaving { animation: toastOut .3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

/* ----------------------------------------------------- Onboarding / modal */
.overlay {
  position: absolute; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--safe-t) + 18px) 18px calc(var(--safe-b) + 18px);
  background: radial-gradient(120% 80% at 50% 0%, #16201a 0%, #0b0f0d 70%);
}
.overlay[hidden] { display: none; }
.overlay.fade-out { animation: ovOut .35s ease forwards; }
@keyframes ovOut { to { opacity: 0; visibility: hidden; } }

.ob-mountains { position: absolute; left: 0; right: 0; bottom: 0; height: 42%; z-index: 0; pointer-events: none; }
.ob-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 440px;
  text-align: center;
}
.ob-logo { width: 84px; height: 84px; border-radius: 22px; box-shadow: var(--shadow); margin: 0 auto 18px; display:block; }
.ob-kicker { font-weight: 700; font-size: 12.5px; letter-spacing: .28em; text-transform: uppercase; color: var(--orange); margin-bottom: 8px; }
.ob-title { font-weight: 900; font-size: clamp(30px, 9vw, 46px); line-height: 1; text-transform: uppercase; letter-spacing: -.01em; margin: 0 0 14px; }
.ob-text { font-size: 14px; line-height: 1.55; color: var(--text-dim); margin: 0 auto 20px; max-width: 380px; }

.ob-features { display: flex; justify-content: center; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.ob-feat {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 12px; border-radius: 999px;
  background: rgba(255,255,255,.05); border: 1px solid var(--stroke);
  font-size: 11.5px; font-weight: 600;
}
.ob-feat svg { width: 15px; height: 15px; color: var(--green-bright); }

.ob-actions { display: flex; flex-direction: column; gap: 10px; max-width: 360px; margin: 0 auto; }
.ob-a2hs { font-size: 11.5px; line-height: 1.5; color: #ffffff; margin-top: 16px; max-width: 340px; margin-left: auto; margin-right: auto; }

.big-btn {
  width: 100%; padding: 16px 18px; border-radius: 16px;
  font-weight: 800; font-size: 15.5px;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  transition: transform .1s, filter .15s;
}
.big-btn:active { transform: scale(.98); }
.big-btn svg { width: 20px; height: 20px; }
.big-btn.primary { background: var(--green-deep); color: #fff; box-shadow: 0 8px 24px rgba(46,158,79,.4); }
.big-btn.primary:active { filter: brightness(1.08); }
.big-btn.ghost { background: rgba(255,255,255,.06); border: 1px solid var(--stroke-2); color: var(--text); }

/* info modal */
.modal-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 460px; max-height: 84dvh; overflow-y: auto;
  background: var(--panel-solid); border: 1px solid var(--stroke-2);
  border-radius: var(--r); box-shadow: var(--shadow);
  padding: 22px 20px;
  text-align: left;
}
.modal-card h2 { margin: 0 0 4px; font-size: 22px; font-weight: 900; }
.modal-card h3 { margin: 18px 0 6px; font-size: 14px; font-weight: 800; color: var(--green-bright); }
.modal-card p { margin: 0 0 8px; font-size: 13px; line-height: 1.55; color: var(--text-dim); }
.modal-card ol { margin: 0; padding-left: 20px; }
.modal-card li { font-size: 13px; line-height: 1.6; color: var(--text-dim); }
.modal-card a { color: var(--green-bright); }
.modal-close { position: absolute; top: 14px; right: 14px; }
.overlay.modal { background: rgba(6,9,8,.66); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }

/* ikonka v "přidat na plochu" modalu */
.a2hs-icon { display: flex; justify-content: center; margin-bottom: 4px; }
.a2hs-icon svg { width: 42px; height: 42px; color: var(--green-bright); }

/* tlačítko "Více informací" v POI popupu + foto v modalu bodu zájmu */
.p-more {
  display: inline-block; margin-top: 9px; padding: 8px 13px;
  border-radius: 10px; background: var(--green-deep); color: #fff;
  font-weight: 700; font-size: 12px;
}
.p-more:active { filter: brightness(1.1); }
.poi-photo { width: 100%; border-radius: 12px; margin: 10px 0 12px; display: block; }

/* ============================ Leaflet vrstvy ============================ */
.leaflet-container { background: #e9efe7; font-family: inherit; }
/* povinné logo + atribuce mapy.cz – vyzdvižené nad spodní lištu, aby byly vždy vidět */
.leaflet-bottom.leaflet-left {
  bottom: calc(var(--sheet-h, 132px) + var(--safe-b) + 6px);
  left: calc(var(--safe-l) + 6px);
  transition: bottom .28s cubic-bezier(.22,.61,.36,1);
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
}
.leaflet-control-attribution {
  background: rgba(20,24,22,.72) !important; color: var(--text-dim) !important;
  font-size: 10px !important; padding: 2px 7px !important; border-radius: 7px; margin: 0 !important;
  backdrop-filter: blur(6px); box-shadow: var(--shadow-sm);
}
.leaflet-control-attribution a { color: var(--green-bright) !important; }
.mapy-logo { line-height: 0; margin: 0 !important; }
.mapy-logo img { height: 20px; filter: drop-shadow(0 1px 3px rgba(0,0,0,.6)); }

/* uživatelská poloha */
.me-marker { will-change: transform; }
.me-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: #2b8aef; border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(43,138,239,.4), 0 2px 6px rgba(0,0,0,.5);
  position: relative;
}
.me-dot::before {
  content: ""; position: absolute; inset: -9px; border-radius: 50%;
  background: rgba(43,138,239,.30);
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse { 0% { transform: scale(.5); opacity: .9; } 100% { transform: scale(1.6); opacity: 0; } }
.me-heading {
  position: absolute; left: 50%; top: 50%;
  width: 0; height: 0; transform-origin: center bottom;
  border-left: 7px solid transparent; border-right: 7px solid transparent;
  border-bottom: 14px solid #2b8aef;
  margin: -22px 0 0 -7px;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.4));
}

/* POI markery */
.poi-marker {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(45deg);
  border: 2px solid #fff;
  box-shadow: var(--shadow-sm);
}
.poi-marker .glyph { transform: rotate(-45deg); width: 18px; height: 18px; color: #fff; display: grid; place-items: center; }
.poi-marker .glyph svg { width: 18px; height: 18px; }
.poi-climbing { background: #b5532a; }
.poi-ice      { background: #2aa6c9; }
.poi-ferrata  { background: var(--rt-red); }
.poi-parking  { background: #3a6f8f; }
.poi-dam      { background: #4a5a64; }
.poi-viewpoint{ background: var(--green-deep); }
.poi-info     { background: #7c6fb0; }
.poi-gate     { background: var(--orange); }

/* popup */
.leaflet-popup-content-wrapper {
  background: var(--panel-solid); color: var(--text);
  border-radius: 14px; border: 1px solid var(--stroke-2); box-shadow: var(--shadow);
}
.leaflet-popup-tip { background: var(--panel-solid); border: 1px solid var(--stroke-2); }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.45; }
.leaflet-popup-content .p-title { font-weight: 800; font-size: 14.5px; margin-bottom: 3px; }
.leaflet-popup-content .p-desc { color: var(--text-dim); }
.leaflet-popup-content .p-approx { color: var(--text-mut); font-size: 10.5px; margin-top: 5px; font-style: italic; }
.leaflet-popup-close-button { color: var(--text-dim) !important; }
.leaflet-container a.leaflet-popup-close-button { padding: 6px 8px 0 0; }

/* skrytí defaultního zoom controlu (na mobilu stačí gesta) */
.leaflet-control-zoom { display: none; }

/* desktop: užší sheet vlevo dole, ne přes celou šířku */
@media (min-width: 760px) {
  .sheet {
    left: 14px; right: auto; bottom: 14px;
    width: 380px; border-radius: var(--r);
    border: 1px solid var(--stroke);
  }
  .fab-col { bottom: calc(var(--safe-b) + 18px); }
  .layers-menu { bottom: calc(var(--safe-b) + 18px); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
