/* Explorer chrome. The compact breakpoint matches app.js and Mountain.viewport(). */
body:not(.home-mode) {
  --explorer-header-height:50px;
  --map-edge:14px;
  --map-toolbar-bottom:118px;
}
body:not(.home-mode) :is(.timebar,.run-panel) { backdrop-filter:none; }
body:not(.home-mode) .map-button { box-shadow:none; }
body:not(.home-mode) :is(button,select,a):focus-visible { outline:2px solid #7a5a27; outline-offset:3px; }

/* Keep the map header to one row where space allows. The selects retain their accessible labels. */
body:not(.home-mode) .header {
  height:var(--explorer-header-height); min-height:var(--explorer-header-height);
  padding:0 18px; gap:12px; z-index:6;
}
body:not(.home-mode) .header .brand { font-size:24px; min-height:0; }
body:not(.home-mode) .brand-mark { width:26px; height:26px; }
body:not(.home-mode) .brand-mark svg { width:20px; height:20px; }
body:not(.home-mode) .header nav { height:auto; gap:20px; }
body:not(.home-mode) .header-right { gap:8px; }
body:not(.home-mode) .header-right label>span,
body:not(.home-mode) #home-search-button { display:none; }
.render-settings { display:flex; align-items:center; gap:8px; }
#render-settings-toggle { display:none; }
body:not(.home-mode) .header-right select {
  min-width:0; min-height:32px; max-width:176px; margin:0;
  padding:4px 24px 4px 9px; font-size:12px;
  background:var(--atlas-panel); border:1px solid var(--line); border-radius:5px;
}

body:not(.home-mode) #mountain-main {
  --mountain-plan-height:52px;
  --atlas-scene-height:max(580px,calc(100svh - var(--explorer-header-height) - var(--mountain-plan-height)));
}
body:not(.home-mode) .explorer { min-height:0; }
body:not(.home-mode) .map-stage { width:100%; }
body:not(.home-mode) .map-topbar {
  left:var(--map-edge); right:var(--map-edge); top:var(--map-edge);
  display:grid; grid-template-columns:minmax(0,1fr) auto;
  grid-template-areas:"layers view" "trails .";
  align-items:start; gap:10px 8px;
}
body:not(.home-mode) .map-topbar .layer-switcher {
  grid-area:layers; position:relative; inset:auto;
  justify-self:start; max-width:100%!important; overflow-x:auto;
}
.map-topbar-right { grid-area:view; justify-self:end; }
.map-topbar-left {
  grid-area:trails; justify-self:start;
  display:flex; align-items:center; min-width:0; padding:3px; gap:9px;
  background:var(--atlas-panel); border:1px solid var(--line);
  border-radius:9px; box-shadow:0 3px 12px #193e3914;
}
#mountain-title:focus { outline:none; }
body:not(.home-mode) #trail-list-toggle {
  display:flex; align-items:center; gap:6px; min-height:36px; padding:6px 8px;
  border-color:transparent; background:transparent; white-space:nowrap;
}
body:not(.home-mode) #trail-list-toggle[aria-expanded=true] { background:var(--pine); color:var(--atlas-panel); }

body:not(.home-mode) .trail-sidebar {
  position:absolute; top:var(--map-toolbar-bottom); bottom:158px; left:var(--map-edge); z-index:5;
  width:min(286px,calc(100% - 72px)); min-width:0; height:auto; max-height:none;
  padding:0; border:1px solid var(--line); border-radius:9px;
  box-shadow:var(--atlas-shadow); overflow:hidden; animation:none;
  visibility:hidden; pointer-events:none; transform:translateX(calc(-100% - var(--map-edge)));
  transition:transform .22s ease, visibility 0s .22s;
}
body:not(.home-mode) .list-open .trail-sidebar {
  visibility:visible; pointer-events:auto; transform:translateX(0);
  transition-delay:0s;
}
body:not(.home-mode) .sidebar-title { display:block; flex:none; padding:13px 14px 11px; }
body:not(.home-mode) #mountain-location { margin:4px 0 0; color:var(--muted); font-size:11px; line-height:1.45; }
body:not(.home-mode) .trail-list { overscroll-behavior:contain; }
@media(prefers-reduced-motion:reduce) {
  body:not(.home-mode) .trail-sidebar { transition:none; }
}

body:not(.home-mode) .map-stage>.timebar {
  left:var(--map-edge); right:auto; top:auto; bottom:var(--map-edge);
  width:min(710px,calc(100% - 84px));
}
body:not(.home-mode) .map-bottom-left { left:var(--map-edge); bottom:calc(var(--map-edge) + 86px); }

@media(max-width:980px) {
  body:not(.home-mode) .header { padding:0 12px; gap:0 8px; }
  body:not(.home-mode) .header nav { margin-left:auto; gap:12px; }
  body:not(.home-mode) .header-right { display:flex; flex:none; width:auto; height:auto; margin:0; padding:0; border:0; }
  body:not(.home-mode) .header-right select { width:100%; max-width:none; min-height:36px; }
  body:not(.home-mode) #render-settings-toggle { display:flex; }
  body:not(.home-mode) #render-settings-toggle[aria-expanded=false]+.render-settings { display:none; }
  body:not(.home-mode) .render-settings {
    position:absolute; top:calc(100% + 5px); right:12px; width:210px;
    flex-direction:column; align-items:stretch; padding:12px; gap:10px;
    border:1px solid var(--line); border-radius:8px;
    background:var(--atlas-panel); box-shadow:var(--atlas-shadow);
  }
  body:not(.home-mode) .render-settings label { flex-direction:column; align-items:stretch; gap:4px; }
  body:not(.home-mode) .render-settings label>span { display:block; font-size:10px; }
}

@media(max-width:820px) {
  body:not(.home-mode) { --explorer-header-height:94px; }
  body:not(.home-mode) .header { height:auto; flex-wrap:wrap; }
  body:not(.home-mode) .header .brand,
  body:not(.home-mode) .header nav { min-height:46px; }
  body:not(.home-mode) .header-right {
    flex:1 0 100%; width:100%; min-height:47px;
    padding:3px 0; border-top:1px solid var(--line);
  }
}

@media(max-width:1100px) {
  body:not(.home-mode) { --map-edge:12px; --map-toolbar-bottom:136px; }
  body:not(.home-mode) .explorer {
    flex-direction:column; height:auto; max-height:none; overflow:visible;
  }
  body:not(.home-mode) .map-stage {
    order:0; flex:none;
    height:max(430px,calc(100svh - var(--explorer-header-height) - var(--mountain-plan-height) - 100px));
    min-height:0; max-height:none;
  }
  body:not(.home-mode) #trail-list-toggle { min-height:44px; }
  body:not(.home-mode) .map-topbar { row-gap:6px; }
  body:not(.home-mode) .map-topbar-right { margin-left:auto; gap:4px; }
  body:not(.home-mode) .map-topbar-right .map-button { min-height:44px; padding:8px; font-size:11px; flex-shrink:0; }
  body:not(.home-mode) .map-topbar-right #village-view { width:44px; }
  body:not(.home-mode) .map-topbar-right #village-view>span { display:none; }
  body:not(.home-mode) .map-topbar-right .map-button svg { width:17px; height:17px; }
  body:not(.home-mode) .layer-switcher,
  body:not(.home-mode) .map-stage.panel-open .layer-switcher {
    width:max-content;
  }
  body:not(.home-mode) .layer-switcher button,
  body:not(.home-mode) .map-stage.panel-open .layer-switcher button {
    min-width:44px; min-height:44px; padding:10px 12px; font-size:0;
  }
  body:not(.home-mode) .layer-switcher button span { display:block; }
  body:not(.home-mode) .map-topbar .active-layer-label { top:0; left:0; }
  /* Let the controls scroll with the results when the drawer is short or text wraps. */
  body:not(.home-mode) .trail-sidebar {
    bottom:var(--map-edge); overflow:auto;
    max-height:max(8rem,calc(100svh - var(--explorer-header-height) - var(--map-toolbar-bottom) - var(--map-edge)));
    overscroll-behavior-y:contain; scrollbar-width:thin; scrollbar-color:var(--line) transparent;
    overflow-wrap:anywhere;
  }
  body:not(.home-mode) .map-stage:fullscreen .trail-sidebar { max-height:none; }
  body:not(.home-mode) .trail-sidebar > * { flex-shrink:0; }
  body:not(.home-mode) .trail-list { flex-basis:auto; overflow:visible; }
  body:not(.home-mode) .trail-sidebar .search-wrap { height:auto; }
  body:not(.home-mode) .trail-sidebar :is(.list-tabs,.difficulty-filters) { flex-wrap:wrap; }
  body:not(.home-mode) .map-controls { top:155px; bottom:auto; right:var(--map-edge); }
  body:not(.home-mode) .map-controls .square { width:44px; height:44px; min-height:44px; }
  body:not(.home-mode) .map-stage.panel-open .map-controls {
    top:var(--map-toolbar-bottom); right:var(--map-edge); bottom:auto; flex-direction:row; gap:5px;
  }
  body:not(.home-mode) .map-stage.panel-open .map-controls .zoom-buttons { display:flex; flex-direction:row; gap:5px; }
  body:not(.home-mode) .compass { width:44px; min-height:50px; }
  body:not(.home-mode) .run-panel {
    left:var(--map-edge); right:var(--map-edge); top:auto; bottom:20px; width:auto;
    height:42%; max-height:42%; border-radius:12px;
  }
  body:not(.home-mode) .map-bottom-left { bottom:var(--map-edge); }
  body:not(.home-mode) .map-stage:is(.list-open,.panel-open) .map-bottom-left { display:none; }
  body:not(.home-mode) .explorer>.timebar {
    position:static; order:1; width:100%; height:auto; min-height:0;
    padding:10px 14px 12px; gap:10px;
    border:0; border-top:1px solid var(--line); border-radius:0; box-shadow:none;
  }
}

@media(max-width:700px) {
  body:not(.home-mode) .header .brand { font-size:22px; }
  body:not(.home-mode) .map-topbar { grid-template-areas:"layers layers" "trails view"; }
  body.ski-day-mode:not(.home-mode) .map-topbar { grid-template-areas:"layers view" "trails ."; }
  body:not(.home-mode) .map-topbar-right { gap:2px; }
  body:not(.home-mode) .map-topbar-right .map-button { width:44px; justify-content:center; }
  body:not(.home-mode) .map-topbar-right :is(#snow-toggle,#view-toggle)>span:last-child { display:none; }
  body:not(.home-mode) .list-open .trail-sidebar {
    width:min(322px,calc(100% - 2 * var(--map-edge)));
  }
  body:not(.home-mode) .list-open :is(.active-layer-label,.map-controls) { visibility:hidden; }
  body:not(.home-mode) .trail-sidebar .sidebar-title { min-height:0; padding-block:8px 6px; margin-bottom:4px; }
  body:not(.home-mode) .trail-sidebar .search-wrap { margin-bottom:4px; }
  body:not(.home-mode) .trail-sidebar .difficulty-filters { padding:3px 6px; gap:3px; }
  body:not(.home-mode) .trail-sidebar .difficulty-filters button {
    flex:1 1 36px; max-width:44px; height:auto; min-height:44px;
  }
  body:not(.home-mode) .trail-sidebar .list-caption { padding-block:3px; }
  body:not(.home-mode) .explorer>.timebar { flex-wrap:wrap; }
}
@media(max-width:359px) {
  body:not(.home-mode) .header .brand { font-size:20px; }
  body:not(.home-mode) .header nav { gap:8px; }
  body:not(.home-mode) .header-right { gap:4px; }
  #trail-list-toggle .toggle-lifts { display:none; }
}

body:not(.home-mode) .map-stage:fullscreen { height:100svh; min-height:100svh; max-height:none; }
