/* The v2 map page (resources/views/Map/mapview.htm). Colours only from the tokens; the map's
   own data colours live in public/js/v2/map/hikingmap.js. */

.mapx-page .site-main { display: flex; }
.mapx {
  --panel-w: 400px;
  position: relative; flex-grow: 1; display: grid; grid-template-columns: var(--panel-w) 1fr; grid-template-rows: auto 1fr;
  height: calc(100dvh - var(--header-h)); min-height: 420px; border-top: 1px solid var(--c-outline);
}
.mapx.is-embed { grid-template-columns: 1fr; grid-template-rows: 1fr; height: 100dvh; border: 0; }
.mapx.is-fullscreen { height: 100dvh; background: var(--c-surface); }

/* ---- the panel: search, kinds, list ---- */
.mapx-top { grid-column: 1; grid-row: 1; padding: 18px 18px 12px; background: var(--c-surface); display: flex; flex-direction: column; gap: 14px; z-index: 2; }
.mapx-search { height: 50px; background: var(--c-surface-2); border-color: transparent; }
.mapx-back { display: none; }
.mapx-kinds .chip .dot { background: var(--kind); }
.mapx-kinds .chip.is-off { background: var(--c-surface); border-color: var(--c-outline-strong); color: var(--c-text-2); }
.mapx-kinds .chip.is-off .dot { opacity: .35; }
.mapx-kinds .chip:not(.is-off) { background: var(--c-primary-container); border-color: transparent; color: var(--c-primary-dark); }
.mapx-kinds .chip.more { background: var(--c-surface); border-color: var(--c-outline-strong); color: var(--c-text); }
.mapx-panel { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; min-height: 0; background: var(--c-surface); border-right: 1px solid var(--c-outline); z-index: 2; }
.mapx-handle { display: none; }
.mapx-tabs { padding: 0 18px; flex-shrink: 0; }
.mapx-list { overflow-y: auto; padding: 10px 10px 18px; flex-grow: 1; overscroll-behavior: contain; }
.mapx-empty { padding: 24px 12px; text-align: center; }
.mapx-item { display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: center; width: 100%; padding: 10px; border-radius: var(--r-m); text-align: left; color: var(--c-text); background: none; border: 0; cursor: pointer; }
.mapx-item:hover, .mapx-item.is-active { background: var(--c-primary-container); }
.mapx-item.is-active { box-shadow: inset 3px 0 0 var(--c-primary); }
.mapx-thumb { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; background: var(--c-surface-2); display: flex; align-items: center; justify-content: center; }
.mapx-thumb .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--kind); border: 3px solid #fff; box-shadow: 0 0 0 1px var(--c-outline); }
.mapx-item b { display: block; font-size: 15px; line-height: 1.3; }
.mapx-item .meta { font-size: 13px; margin-top: 3px; }
.mapx-item .lvl { margin-top: 6px; }

/* ---- the map and its tools ---- */
.mapx-map { grid-column: 2; grid-row: 1 / span 2; position: relative; min-width: 0; }
.mapx.is-embed .mapx-map { grid-column: 1; grid-row: 1; }
.mapx-canvas { position: absolute; inset: 0; background: var(--c-surface-2); }
.mapx-loading {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: color-mix(in srgb, var(--c-surface-2) 82%, transparent); color: var(--c-text-2); font-weight: 600; font-size: 15px;
  transition: opacity .3s;
}
.mapx-loading.is-done { opacity: 0; pointer-events: none; }
.mapx-spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--c-primary-container); border-top-color: var(--c-primary); animation: mapx-spin .8s linear infinite; }
@keyframes mapx-spin { to { transform: rotate(360deg); } }
.mapx-skel { cursor: default; }
.mapx-skel:hover { background: none; }
.mapx-tools-left { position: absolute; left: 16px; top: 16px; z-index: 3; }
.mapx-addbtn { box-shadow: var(--shadow-1); }
.mapx-tools-right { position: absolute; right: 16px; top: 16px; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; z-index: 3; }
.mapx-tools-br { position: absolute; right: 16px; bottom: 40px; display: flex; flex-direction: column; gap: 10px; z-index: 3; }
.mapx-zoom { display: flex; flex-direction: column; border-radius: 12px; box-shadow: var(--shadow-1); overflow: hidden; }
.mapx-zoom .icon-btn { border-radius: 0; box-shadow: none; }
.mapx-zoom .icon-btn + .icon-btn { border-top: 1px solid var(--c-outline); }
.mapx-3d { font-weight: 800; font-size: 14px; }
.mapx-3d[aria-pressed="true"] { background: var(--c-primary); color: var(--c-on-primary); }
.mapx-tools-bl { position: absolute; left: 16px; bottom: 16px; display: flex; align-items: center; gap: 8px; z-index: 3; }
.mapx-tools-bl .btn { box-shadow: var(--shadow-1); }
#mapx-scale .maplibregl-ctrl-scale { margin: 0; border-color: var(--c-text); background: rgb(255 255 255 / .85); border-radius: 6px; padding: 3px 8px; font: 500 12px var(--font-ui); height: auto; }
.mapx-layers { position: relative; }
.mapx-layers-panel {
  position: absolute; right: 56px; top: 0; width: 290px; padding: 12px; background: var(--c-surface); border-radius: var(--r-l);
  box-shadow: var(--shadow-2); display: flex; flex-direction: column; gap: 4px;
}
.mapx-layers-panel .menu-label { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--c-text-2); padding: 4px 8px; }
.mapx-layers-panel hr { border: 0; border-top: 1px solid var(--c-outline); margin: 6px 0; }
.mapx-layers-panel .check { padding: 8px; justify-content: space-between; flex-direction: row-reverse; }
.mapx-base { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 8px; border-radius: 12px; border: 0; background: none; text-align: left; color: var(--c-text); cursor: pointer; }
.mapx-base small { display: block; font-size: 12px; color: var(--c-text-2); }
.mapx-base .icon { visibility: hidden; color: var(--c-primary); }
.mapx-base.is-on { background: var(--c-primary-container); }
.mapx-base.is-on .icon { visibility: visible; }
.mapx-swatch { width: 44px; height: 36px; border-radius: 8px; }
.mapx-swatch.relief { background: linear-gradient(135deg, #dfe9d8, #c7d8bf 50%, #eef2e8); }
.mapx-swatch.topo { background: linear-gradient(135deg, #efe2c3, #e7d6ad 50%, #f5ecd6); }
.mapx-bar {
  position: absolute; left: 50%; top: 16px; transform: translateX(-50%); z-index: 4; display: flex; align-items: center; gap: 10px;
  width: min(560px, calc(100% - 32px)); padding: 10px 10px 10px 18px; background: var(--c-surface); border-radius: var(--r-m); box-shadow: var(--shadow-2);
}
.mapx-bar .grow { flex-grow: 1; }
.mapx-toast { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 5; background: var(--c-text); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow-2); max-width: calc(100% - 32px); }
.hm-here { width: 18px; height: 18px; border-radius: 50%; background: var(--c-info); border: 3px solid #fff; box-shadow: 0 0 0 6px color-mix(in srgb, var(--c-info) 25%, transparent); }
.maplibregl-ctrl-attrib { font: 11px var(--font-ui); }

/* ---- the card of what was picked ---- */
.mapx-card { width: 330px; max-width: 100%; color: var(--c-text); }
.mapx-card-media { position: relative; aspect-ratio: 16 / 8; background: var(--c-surface-2); }
.mapx-card-media img { width: 100%; height: 100%; object-fit: cover; }
.mapx-card-close { position: absolute; right: 10px; top: 10px; }
.mapx-card-close.icon-btn { width: 36px; height: 36px; border-radius: 50%; }
.mapx-card-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.mapx-card-title { font-weight: 700; font-size: 18px; line-height: 1.3; }
.mapx-card-sub { font-size: 13px; color: var(--c-text-2); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mapx-card-text { font-size: 14px; line-height: 1.5; color: var(--c-text-2); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.mapx-card .stat-tiles b { font-size: 18px; }
.mapx-profile { width: 100%; height: 56px; display: block; }
.mapx-profile .area { fill: var(--c-primary-container); }
.mapx-profile .line { fill: none; stroke: var(--c-primary); stroke-width: 2; }
.mapx-card-actions { display: flex; gap: 8px; }
.mapx-card-actions .btn-primary { flex-grow: 1; justify-content: center; }
.mapx-sheet-card .mapx-card { width: auto; }
.mapx-card-sub span { display: inline-flex; align-items: center; gap: 4px; }
.mapx-card-float {
  position: absolute; left: 16px; top: 16px; z-index: 4; max-height: calc(100% - 32px); overflow-y: auto;
  background: var(--c-surface); border-radius: var(--r-l); box-shadow: var(--shadow-2); overscroll-behavior: contain;
}
.mapx.is-embed .mapx-card-float { width: min(330px, calc(100% - 32px)); }

/* ---- add a place ---- */
.mapx-kindgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 10px 0 18px; }
.mapx-kindbtn { display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 12px; border: 1px solid var(--c-outline); border-radius: var(--r-m); background: var(--c-surface); color: var(--c-text); cursor: pointer; }
.mapx-kindbtn:hover { border-color: var(--c-primary); }
.mapx-kindbtn .dot { width: 14px; height: 14px; margin-top: 3px; border-radius: 50%; flex-shrink: 0; background: var(--kind); }
.mapx-kindbtn small { display: block; font-size: 12px; color: var(--c-text-2); line-height: 1.35; margin-top: 2px; }

/* ---- phone: the map fills the screen, the list is a sheet ---- */
@media (max-width: 860px) {
  .mapx-page .site-header { display: none; }
  .mapx { display: block; height: 100dvh; border: 0; }
  .mapx-map { position: absolute; inset: 0; }
  .mapx-top { position: absolute; left: 0; right: 0; top: 0; padding: 12px 12px 0; background: none; gap: 10px; pointer-events: none; }
  .mapx-top > * { pointer-events: auto; }
  .mapx-search { height: 48px; background: var(--c-surface); box-shadow: var(--shadow-1); padding-left: 6px; }
  .mapx-back { display: inline-flex; border: 0; width: 38px; height: 38px; }
  .mapx-kinds { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px 4px; }
  .mapx-kinds::-webkit-scrollbar { display: none; }
  .mapx-kinds .chip { box-shadow: var(--shadow-1); }
  .mapx-kinds .chip:not(.is-off):not(.more) { background: var(--c-primary); color: var(--c-on-primary); }
  .mapx-kinds .chip:not(.is-off):not(.more) .dot { box-shadow: 0 0 0 2px #fff; }
  .mapx-tools-left { top: auto; bottom: calc(var(--sheet-h, 120px) + 16px); left: 12px; }
  .mapx-tools-right { top: 124px; right: 12px; }
  .mapx-tools-br { bottom: calc(var(--sheet-h, 120px) + 16px); right: 12px; }
  .mapx:not(.is-embed) .mapx-tools-br .mapx-zoom { display: none; }
  .mapx-tools-bl { display: none; }
  .mapx-layers-panel { right: 56px; width: min(290px, calc(100vw - 90px)); }
  .mapx-bar { top: auto; bottom: calc(var(--sheet-h, 120px) + 16px); }
  .mapx:not(.is-embed) .maplibregl-ctrl-bottom-right { bottom: var(--sheet-h, 120px); }
  .mapx-panel {
    position: absolute; left: 0; right: 0; bottom: 0; height: var(--sheet-h, 120px); border: 0; border-radius: 22px 22px 0 0;
    box-shadow: 0 -8px 30px rgb(20 29 25 / .18); transition: height .25s ease;
  }
  .mapx-handle { display: flex; justify-content: center; padding: 10px 0 6px; border: 0; background: none; width: 100%; cursor: grab; }
  .mapx-handle span { width: 44px; height: 5px; border-radius: 3px; background: var(--c-outline-strong); }
  .mapx-panel.has-card .mapx-tabs, .mapx-panel.has-card .mapx-list { display: none; }
  .mapx-sheet-card { overflow-y: auto; padding: 0 16px 16px; }
  .mapx-sheet-card .mapx-card-media { border-radius: var(--r-m); overflow: hidden; }
  .mapx-sheet-card .mapx-card-body { padding: 14px 0 0; }
}
