/* GPX Lab Route: full-bleed map, sticker panel, sticker elevation strip. Tokens from /lab.css. */

html, body { height: 100%; }
body { display: flex; flex-direction: column; }

.mapWrap { flex: 1; position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: #e8e6e0; }
.leaflet-container { font-family: var(--fb); }

/* ---------- loading ---------- */
.progressBar { position: relative; height: 3px; z-index: 1090; overflow: hidden; display: none; }
.progressBar.active { display: block; }
.progressBar__fill { position: absolute; top: 0; bottom: 0; width: 38%; background: var(--signal); animation: slide 1.1s var(--ease) infinite; }
@keyframes slide { from { left: -40%; } to { left: 100%; } }

.mapToast {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 1050;
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 16px; border-radius: 6px;
  background: var(--stem); color: var(--on); box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .6);
  font: 800 16px/1 var(--fd); text-transform: uppercase; letter-spacing: .05em;
}
.spinner {
  width: 14px; height: 14px; flex: none; border-radius: 50%; display: inline-block;
  border: 2px solid var(--hair-2); border-top-color: var(--signal); animation: spin .8s linear infinite;
}
.spinner--lg { width: 30px; height: 30px; border-width: 3px; }
.overlay { position: fixed; inset: 0; z-index: 2000; background: rgba(13, 13, 11, .88); display: flex; align-items: center; justify-content: center; }
.overlay__box { display: flex; flex-direction: column; align-items: center; gap: 16px; color: var(--on); font: 800 26px/1 var(--fd); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- first-run prompt on the map ---------- */
.mapHint {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 1040;
  display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 18px 0 12px; border-radius: 6px;
  background: var(--signal); color: var(--ink); white-space: nowrap; pointer-events: none;
  box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .5);
  font: 800 18px/1 var(--fd); text-transform: uppercase; letter-spacing: .04em;
  animation: hintIn .5s var(--ease) both;
}
.mapHint svg { width: 20px; height: 20px; }
@keyframes hintIn { from { opacity: 0; transform: translate(-50%, -8px); } }
.mapWrap.placing .leaflet-container { cursor: crosshair; }
@media (max-width: 600px) { .mapHint { top: 10px; font-size: 15px; height: 36px; } }

/* ---------- block tools: rail on the right, instruction bar on top ---------- */
.banRail {
  position: absolute; top: 108px; right: 14px; z-index: 990; display: grid; overflow: hidden;
  background: var(--sticker); border-radius: 8px; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4);
}
.banRail__h { padding: 7px 0 5px; text-align: center; font: 800 12px/1 var(--fd); text-transform: uppercase; letter-spacing: .08em; color: #c4270a; border-bottom: 1px solid var(--rule); }
.banRail button {
  display: grid; place-items: center; align-content: center; gap: 3px; width: 54px; height: 54px;
  border: 0; background: none; color: var(--ink); font: 800 12px/1 var(--fd); text-transform: uppercase; letter-spacing: .04em;
}
.banRail button + button { border-top: 1px solid var(--rule); }
.banRail svg { width: 20px; height: 20px; }
.banRail button:hover { background: #fff; }
.banRail button[aria-pressed="true"] { background: var(--ink); color: var(--sticker); }
.mapWrap.drawing .leaflet-container { cursor: crosshair; }
.mapWrap.drawing .mapToast { top: 70px; }

.drawBar {
  position: absolute; top: 14px; left: 398px; right: 78px; z-index: 1060; margin: 0 auto; width: max-content; max-width: calc(100% - 476px);
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; padding: 6px 6px 6px 16px; border-radius: 6px;
  background: var(--signal); color: var(--ink); box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .5);
  font: 800 16px/1.15 var(--fd); text-transform: uppercase; letter-spacing: .04em;
}
.drawBar__btns { display: flex; gap: 6px; margin-left: auto; }
.drawBar button {
  height: 32px; padding: 0 12px; border-radius: 4px; border: 1px solid rgba(13, 13, 11, .35); background: none; color: var(--ink);
  font: 800 14px/1 var(--fd); text-transform: uppercase; letter-spacing: .05em;
}
.drawBar button:hover:not(:disabled) { border-color: var(--ink); }
.drawBar button.go { background: var(--ink); border-color: var(--ink); color: var(--sticker); }
.drawBar button:disabled { opacity: .4; cursor: not-allowed; }
@media (max-width: 900px) { .drawBar { left: 14px; right: 78px; max-width: none; width: auto; } }
@media (max-width: 600px) {
  .banRail { top: 104px; right: 10px; }
  .drawBar { top: 10px; left: 10px; right: 70px; font-size: 14px; padding-left: 12px; }
}

/* ---------- control panel: floating controls over the map (strips are the elevation + results) ---------- */
.panel {
  position: absolute; top: 14px; left: 14px; z-index: 1000;
  width: min(370px, calc(100vw - 28px)); max-height: calc(100% - 28px); overflow-y: auto;
  background: var(--sticker); color: var(--ink); border-radius: 12px; padding: 16px;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .12);
}
.mapWrap.hasElev:not(.elevCollapsed) .panel { max-height: calc(100% - 28px - 164px); }
.mapWrap.hasElev.elevCollapsed .panel { max-height: calc(100% - 28px - 48px); }
.panel ::selection { background: var(--ink); color: var(--sticker); }

.topRow { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel .status { font: 700 14px/1 var(--fd); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--ink-3); }
.dot.ok { background: var(--signal); }
.dot.warn { background: var(--signal); }
.dot.busy { background: var(--signal); animation: pulse 1s infinite; }
.dot.err { background: #c4270a; }
@keyframes pulse { 50% { opacity: .3; } }
.linkBtn {
  background: none; border: 0; padding: 4px 2px; color: var(--ink-3);
  font: 700 14px/1 var(--fd); text-transform: uppercase; letter-spacing: .06em;
}
.linkBtn:hover { color: var(--ink); }

.points { margin-top: 12px; display: grid; gap: 6px; position: relative; }
.point { display: flex; align-items: center; gap: 8px; }
.coords {
  flex: 1; min-width: 0; height: 38px; padding: 0 10px; outline: none;
  background: #fff; color: var(--ink); border: 1px solid var(--rule); border-radius: 6px; font-size: 15px;
}
.coords:hover { border-color: var(--ink-3); }
.coords:focus { border-color: var(--ink); }
.coords::placeholder { color: var(--ink-3); }
.pointLabel { flex: 1; font: 700 16px/1 var(--fd); text-transform: uppercase; letter-spacing: .04em; }

.pdot { width: 12px; height: 12px; flex: none; border-radius: 50%; }
.pdot-start, .k--start { background: var(--signal); }
.pdot-end, .k--end { background: conic-gradient(var(--ink) 25%, #fff 0 50%, var(--ink) 0 75%, #fff 0) 0 0 / 6px 6px; box-shadow: inset 0 0 0 1.5px var(--ink); }
.pdot-via, .k--via { background: var(--signal); }
.pdot-nogo, .k--nogo { background: #fff; box-shadow: inset 0 0 0 3px #c4270a; }

.mini {
  flex: none; display: grid; place-items: center; width: 38px; height: 38px;
  background: #fff; color: var(--ink); border: 1px solid var(--rule); border-radius: 6px;
}
.mini svg { width: 16px; height: 16px; }
.mini:hover { border-color: var(--ink); }
.mini.danger:hover { border-color: #c4270a; color: #c4270a; }

.searchDrop {
  position: absolute; left: 0; right: 0; z-index: 20; overflow: hidden;
  background: #fff; border: 1px solid var(--rule); border-radius: 8px; box-shadow: 0 16px 36px -12px rgba(0, 0, 0, .35);
}
.searchDrop button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; color: var(--ink); font: 600 14px/1.35 var(--fb); }
.searchDrop button small { display: block; color: var(--ink-3); font-weight: 400; }
.searchDrop button:hover, .searchDrop button.sel { background: var(--ink); color: var(--sticker); }
.searchDrop button:hover small, .searchDrop button.sel small { color: rgba(244, 246, 247, .7); }

.hint { margin-top: 12px; font-size: 14px; color: var(--ink-2); }
.hint b { color: #c13c0b; }

.stats { margin-top: 14px; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.stat { padding: 10px 4px 9px; min-width: 0; }
.stat + .stat { border-left: 1px solid var(--rule); padding-left: 10px; }
.stat b { display: block; font: 800 26px/1 var(--fd); }
.stat span { display: block; margin-top: 4px; font: 700 12px/1 var(--fd); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat--warn b, .stat--warn span { color: #c13c0b; }

.legend { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font: 700 13px/1 var(--fd); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; }
.legend i, .mapInfo i.line { display: inline-block; width: 24px; height: 0; border-top: 4px solid var(--signal); margin-right: 6px; vertical-align: middle; }
.legend .legend__dash, .mapInfo i.line.dash { border-top-style: dashed; border-top-color: var(--signal); }
.legend .legend__unknown, .mapInfo i.line.dot { border-top-style: dotted; border-top-color: #8a8a84; }

.error { margin-top: 10px; font-size: 14px; color: #a3290a; border: 1px solid rgba(193, 60, 11, .4); border-radius: 6px; padding: 8px 10px; overflow-wrap: anywhere; }

.actions { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .btn { height: 44px; padding: 0 10px; font-size: 17px; }
.actions .btn--wide { grid-column: 1 / -1; }
.panel .btn--line { border-color: var(--rule); color: var(--ink); }
.panel .btn--line:hover:not(:disabled) { border-color: var(--ink); }

.importRow { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: 14px; color: var(--ink-3); }
.importRow a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--rule); }
.importRow a:hover { text-decoration-color: var(--signal); }
.importLabel { font: 700 13px/1 var(--fd); text-transform: uppercase; letter-spacing: .06em; }
.importNote { flex-basis: 100%; font-size: 13px; }

.panel footer { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--rule); font-size: 12.5px; color: var(--ink-3); line-height: 1.55; }
.panel footer a { color: var(--ink-2); }

/* ---------- elevation: the sticker along the bottom ---------- */
.elev {
  position: absolute; left: 14px; right: 14px; bottom: 14px; height: 150px; z-index: 900;
  background: var(--sticker); padding: 6px 8px 4px;
  border-radius: 18px; box-shadow: inset 0 1px 0 #fff, inset 0 -1px 0 rgba(13, 13, 11, .08);
  /* label-roll cut: rounded ends with a punched notch left and right */
  -webkit-mask: radial-gradient(circle 7px at left 50%, #0000 97%, #000) left / 51% 100% no-repeat, radial-gradient(circle 7px at right 50%, #0000 97%, #000) right / 51% 100% no-repeat;
  mask: radial-gradient(circle 7px at left 50%, #0000 97%, #000) left / 51% 100% no-repeat, radial-gradient(circle 7px at right 50%, #0000 97%, #000) right / 51% 100% no-repeat;
}
.elev canvas { width: 100%; height: 100%; cursor: crosshair; }
.elev__toggle {
  position: absolute; top: 5px; right: 8px; z-index: 2; width: 28px; height: 24px; display: grid; place-items: center;
  background: none; border: 0; color: var(--ink-2); border-radius: 4px;
}
.elev__toggle svg { width: 12px; height: 8px; transition: transform .25s var(--ease); }
.elev__toggle:hover { background: rgba(13, 13, 11, .06); color: var(--ink); }
.elev.collapsed { height: 34px; }
.elev.collapsed canvas { display: none; }
.elev.collapsed .elev__toggle svg { transform: rotate(180deg); }
.mapWrap.hasElev .leaflet-bottom { bottom: 164px; }
.mapWrap.hasElev.elevCollapsed .leaflet-bottom { bottom: 48px; }

/* ---------- pins ---------- */
.mapPin { display: block; width: 22px; height: 22px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .45); }
.mapPin-start { background: var(--signal); }
.mapPin-end { background: conic-gradient(var(--ink) 25%, #fff 0 50%, var(--ink) 0 75%, #fff 0) 0 0 / 8px 8px; }
.viaPin {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--signal); color: var(--ink); border: 2px solid #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .45);
  font: 800 13px/1 var(--fd);
}
.nogoPin { position: relative; display: block; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 3px solid #c4270a; box-shadow: 0 3px 8px rgba(0, 0, 0, .45); }
.nogoPin::after { content: ""; position: absolute; left: 1px; right: 1px; top: 50%; height: 3px; margin-top: -1.5px; background: #c4270a; transform: rotate(-45deg); }
.k { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; }

/* ---------- leaflet chrome ---------- */
.leaflet-popup-content-wrapper { border-radius: 8px; background: var(--sticker); color: var(--ink); box-shadow: 0 16px 36px -12px rgba(0, 0, 0, .4); }
.leaflet-popup-tip { background: var(--sticker); }
.leaflet-popup-content { margin: 6px; }
.popupMenu { display: grid; gap: 2px; }
.popupRemove, .popupMenu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 4px;
  background: none; color: var(--ink); text-align: left; white-space: nowrap;
  font: 700 15px/1.2 var(--fd); text-transform: uppercase; letter-spacing: .04em;
}
.popupRemove:hover, .popupMenu button:hover { background: var(--ink); color: var(--sticker); }
.leaflet-bar { border: 0 !important; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4) !important; }
.leaflet-bar a { width: 36px !important; height: 36px !important; line-height: 36px !important; background: var(--sticker); color: var(--ink); border-bottom-color: var(--rule) !important; }
.leaflet-bar a:hover { background: #fff; color: var(--ink); }
.leaflet-control-layers { border: 0 !important; border-radius: 8px !important; background: var(--sticker); color: var(--ink); box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4) !important; }
.leaflet-control-layers-expanded { padding: 8px 14px 8px 10px; font: 700 15px/1.7 var(--fd); text-transform: uppercase; letter-spacing: .04em; }
.leaflet-control-layers input { accent-color: var(--ink); }
.leaflet-control-attribution { background: rgba(244, 246, 247, .88) !important; color: var(--ink-2); font-size: 11px; }
.leaflet-control-attribution a { color: var(--ink); }

.mapInfoBtn {
  position: absolute; top: 14px; right: 14px; z-index: 1200; width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: var(--sticker); color: var(--ink); box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4);
}
.mapInfoBtn svg { width: 18px; height: 18px; }
.mapInfoBtn:hover { background: #fff; }
.mapInfoBtn[aria-expanded="true"] { background: var(--ink); color: var(--sticker); }
.leaflet-top.leaflet-right { margin-top: 50px; }
.mapInfo {
  position: absolute; top: 14px; right: 58px; z-index: 1201; width: min(310px, calc(100vw - 72px));
  background: var(--sticker); color: var(--ink-2); border-radius: 12px; padding: 14px 16px;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .55); font-size: 14px; line-height: 1.5;
}
.mapInfo__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.mapInfo__head b { font: 800 22px/1 var(--fd); text-transform: uppercase; color: var(--ink); }
.mapInfo__close { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 4px; background: none; color: var(--ink-2); }
.mapInfo__close svg { width: 12px; height: 12px; }
.mapInfo__close:hover { background: rgba(13, 13, 11, .06); color: var(--ink); }
.mapInfo ul { list-style: none; padding: 0; display: grid; gap: 10px; }
.mapInfo b { color: var(--ink); }
.mapInfo .k { vertical-align: -1px; margin-right: 4px; }

@media (max-width: 600px) {
  .panel { top: auto; bottom: 10px; left: 10px; right: 10px; width: auto; max-height: 52vh; padding: 14px; }
  .mapWrap.hasElev:not(.elevCollapsed) .panel { bottom: 124px; max-height: calc(100% - 144px); }
  .mapWrap.hasElev.elevCollapsed .panel { bottom: 54px; }
  .elev { left: 10px; right: 10px; bottom: 10px; height: 104px; }
  .mapWrap.hasElev .leaflet-bottom { bottom: 118px; }
  .mapInfoBtn { top: 10px; right: 10px; }
  .mapInfo { top: 10px; right: 54px; }
}
