/* Map-first, adaptive Guide workspace. Loaded last so the interaction model can
   evolve without coupling the portable application core to a hosting runtime. */

.explore-workspace {
  position: relative;
  display: block;
  min-height: calc(100svh - 76px);
  overflow: hidden;
  background: #bed6d7;
}

.explore-workspace .atlas-map {
  min-height: calc(100svh - 76px);
}

.map-command-panel {
  position: absolute;
  z-index: 11;
  top: 18px;
  left: 18px;
  width: min(370px, calc(100% - 36px));
  max-height: calc(100% - 36px);
  overflow: auto;
  padding: 24px 26px 22px;
  border: 1px solid rgba(36,75,56,.22);
  border-radius: 5px;
  background: rgba(249,247,240,.95);
  box-shadow: 0 20px 54px rgba(24,43,30,.2);
  backdrop-filter: blur(18px);
  transform: translateX(0);
  transition: transform .24s cubic-bezier(.2,.8,.2,1), opacity .2s ease;
}

.map-command-panel.collapsed {
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(-100% - 26px));
}

.discovery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.discovery-head .eyebrow { margin-bottom: 10px; }
.discovery-head button {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255,255,255,.65);
  color: var(--forest);
  cursor: pointer;
  font-size: 20px;
}

.map-command-panel h1 { font-size: clamp(36px, 3vw, 48px); }
.map-command-panel .hero-deck { margin: 14px 0; font-size: 14px; }
.map-command-panel .search-box { height: 50px; }
.map-command-panel .map-lens-picker { margin-top: 14px; padding-top: 12px; }
.map-command-panel .map-result-summary { margin-top: 15px; padding: 12px 0; }
.map-command-panel .map-first-principle { margin-top: 13px; }
.map-command-panel .account-strip { display: none; }

.discovery-reopen {
  position: absolute;
  z-index: 10;
  top: 18px;
  left: 18px;
  min-height: 44px;
  padding: 0 15px;
  border: 1px solid rgba(36,75,56,.25);
  border-radius: 24px;
  background: rgba(249,247,240,.96);
  color: var(--forest);
  box-shadow: 0 8px 24px rgba(26,43,31,.16);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}
.discovery-reopen[hidden] { display: none; }
.discovery-reopen span { margin-right: 6px; font-size: 18px; }

.map-region-label { top: 18px; right: 70px; left: auto; }
.map-toolbar { top: 107px; right: 70px; left: auto; }
.map-weather-status { top: 158px; right: 70px; left: auto; }
.atlas-map .leaflet-top.leaflet-right { top: 205px; right: 16px; }

.guide-surface {
  --guide-width: 440px;
  --guide-height: 62vh;
  z-index: 14;
  transition: width .2s ease, height .2s ease, left .2s ease, right .2s ease;
}

.guide-surface.active {
  top: 18px;
  right: 18px;
  bottom: 18px;
  left: auto;
  width: min(var(--guide-width), calc(100% - 36px));
  max-height: none;
  transform: none;
  display: flex;
  flex-direction: column;
}

.guide-surface.active.expanded { --guide-width: 620px; }
.guide-surface.active .guide-scene {
  min-height: 0;
  max-height: none;
  flex: 1 1 auto;
  margin-bottom: 8px;
  overscroll-behavior: contain;
}
.guide-surface.active .guide-bar,
.guide-surface.active .guide-footer,
.guide-surface.active .guide-status { flex: 0 0 auto; }

.guide-resize-handle {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: -12px;
  width: 24px;
  height: 68px;
  padding: 0;
  border: 1px solid rgba(36,75,56,.25);
  border-radius: 14px;
  background: rgba(249,247,240,.98);
  box-shadow: 0 6px 20px rgba(24,43,30,.18);
  cursor: ew-resize;
  transform: translateY(-50%);
}
.guide-resize-handle span,
.guide-resize-handle span::before,
.guide-resize-handle span::after {
  display: block;
  width: 3px;
  height: 3px;
  margin: auto;
  border-radius: 50%;
  background: var(--forest);
  content: "";
}
.guide-resize-handle span::before { transform: translateY(-7px); }
.guide-resize-handle span::after { transform: translateY(4px); }

.guide-scene-head { padding-left: 20px; }
.guide-scene-head > div:first-of-type { min-width: 0; }
.guide-window-actions { display: flex; align-items: center; gap: 4px; }
.guide-window-actions button {
  min-width: 40px;
  min-height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
}
.guide-window-actions [data-guide-size] { font-size: 14px; }

.guide-bar { grid-template-columns: 92px minmax(0, 1fr) 42px 44px; }
.guide-voice { min-width: 88px; min-height: 52px; grid-template-columns: 24px 1fr; grid-template-rows: 1fr 1fr; column-gap: 5px; padding: 5px 7px; text-align: left; }
.guide-voice > span { grid-row: 1 / 3; }
.guide-voice small { align-self: end; justify-self: start; font-size: 7px; }
.guide-voice kbd { align-self: start; justify-self: start; color: rgba(255,255,255,.78); font: 500 6px/1.2 "DM Mono", monospace; letter-spacing: -.02em; white-space: nowrap; }
.guide-voice[aria-pressed="true"] { background: #9a493b; }
.guide-context-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.guide-context-row label { overflow: hidden; color: #667567; font: 7px "DM Mono"; letter-spacing: .11em; text-overflow: ellipsis; white-space: nowrap; }
.guide-context-row button { flex: 0 0 auto; min-height: 24px; padding: 3px 6px; border: 1px solid rgba(36,75,56,.2); border-radius: 12px; background: transparent; color: var(--forest); font: 500 7px "DM Mono"; letter-spacing: .05em; cursor: pointer; }
.guide-context-row button.active { border-color: var(--clay); background: #fff2e7; color: #8b4934; }
.guide-task-controls #guide-voice-output[aria-pressed="false"] { background: rgba(250,248,241,.93); color: var(--forest); }
.guide-status { min-height: 23px; }

.guide-attention {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  width: min(520px, calc(100% - 16px));
  max-width: none;
  margin: 7px 8px 0;
  padding: 10px 10px 10px 12px;
  overflow: hidden;
  border: 1px solid rgba(36,75,56,.24);
  border-left: 4px solid var(--clay);
  background: rgba(248,245,235,.97);
  color: var(--forest);
  box-shadow: 0 6px 20px rgba(24,43,30,.10);
  font-family: "Manrope", sans-serif;
  letter-spacing: 0;
}
.guide-attention::before { position: absolute; inset: 0; z-index: 0; opacity: .035; background: repeating-linear-gradient(-45deg,var(--forest) 0,var(--forest) 1px,transparent 1px,transparent 8px); content: ""; pointer-events: none; }
.guide-attention > * { position: relative; z-index: 1; }
.guide-attention-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--forest); color: white !important; }
.guide-attention div { min-width: 0; }
.guide-attention small,.guide-attention strong,.guide-attention p { display: block; margin: 0; }
.guide-attention small { color: var(--clay); font: 500 7px "DM Mono",monospace; letter-spacing: .1em; }
.guide-attention strong { margin-top: 2px; font: 600 15px/1.15 "Newsreader",serif; }
.guide-attention p { margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 8px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.guide-attention .guide-attention-action { min-height: 36px; padding: 7px 10px; border: 0; background: var(--forest); color: white; font: 700 8px "Manrope",sans-serif; white-space: nowrap; }
.guide-attention .guide-attention-dismiss { width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 18px; }

.atlas-map.guide-active .map-region-label,
.atlas-map.guide-active .map-toolbar,
.atlas-map.guide-active .map-weather-status,
.atlas-map.guide-active .leaflet-top.leaflet-right { opacity: .18; pointer-events: none; }
.atlas-map.guide-active .map-place-preview { max-width: calc(100% - var(--guide-panel-width, 440px) - 70px); }
.atlas-map.guide-active .map-key { bottom: 18px; left: calc(50% - 220px); }
.atlas-map.guide-active .map-caption { bottom: 18px; right: calc(var(--guide-panel-width, 440px) + 34px); }

@media (max-width: 1180px) {
  .guide-surface {
    position: fixed;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 12px;
    width: auto;
    transform: none;
  }
  .guide-surface.active {
    position: fixed;
    top: var(--guide-top, 38svh);
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 12px;
    width: auto;
    height: auto;
    max-height: none;
  }
  .guide-surface.active.expanded { top: max(104px, 8svh); }
  .guide-surface.active .guide-scene { flex-basis: 0; }
  .guide-resize-handle {
    top: -12px;
    left: 50%;
    width: 72px;
    height: 24px;
    cursor: ns-resize;
    transform: translateX(-50%);
  }
  .guide-resize-handle span,
  .guide-resize-handle span::before,
  .guide-resize-handle span::after { width: 4px; height: 4px; }
  .guide-resize-handle span { transform: rotate(90deg); }
  .atlas-map.guide-active .map-place-preview { top: 18px; right: 18px; bottom: auto; left: auto; max-width: 340px; }
  .atlas-map.guide-active .map-region-label,
  .atlas-map.guide-active .map-toolbar,
  .atlas-map.guide-active .map-weather-status,
  .atlas-map.guide-active .leaflet-top.leaflet-right { opacity: 1; pointer-events: auto; }
  .atlas-map.guide-active .map-key,
  .atlas-map.guide-active .map-caption { opacity: 0; }
}

@media (min-width: 641px) and (max-width: 980px) {
  .explore-workspace { min-height: calc(100svh - 98px); }
  .explore-workspace .atlas-map { min-height: calc(100svh - 98px); }
}

@media (max-width: 640px) {
  .explore-workspace { min-height: calc(100svh - 115px); }
  .explore-workspace .atlas-map { min-height: calc(100svh - 115px); }
  .map-command-panel {
    top: 10px;
    left: 10px;
    width: calc(100% - 20px);
    max-height: calc(100% - 20px);
    padding: 18px;
  }
  .map-command-panel h1 { font-size: 35px; }
  .map-command-panel .hero-deck { display: none; }
  .discovery-reopen { top: 10px; left: 10px; }
  .map-region-label { display: none; }
  .map-toolbar { top: 10px; right: 8px; left: auto; max-width: calc(100% - 112px); justify-content: flex-end; }
  .map-toolbar button { width: 44px; padding: 0; }
  .map-toolbar button span { display: none; }
  .map-weather-status { top: 61px; right: 8px; left: 8px; max-width: none; }
  .atlas-map .leaflet-top.leaflet-right { top: 59px; right: 3px; }
  .guide-surface { right: 8px; left: 8px; bottom: 8px; width: auto; transform: none; }
  .guide-surface { bottom: max(8px, env(safe-area-inset-bottom)); }
  .guide-surface.active { top: var(--guide-top, 36svh); right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); left: 8px; height: auto; }
  .guide-surface.active.expanded { top: 96px; }
  .guide-bar { grid-template-columns: 50px minmax(0, 1fr) 42px 42px; }
  .guide-voice { min-width: 50px; grid-template-columns: 1fr; grid-template-rows: 1fr auto; padding: 4px; text-align: center; }
  .guide-voice > span { grid-row: auto; justify-self: center; }
  .guide-voice small { align-self: auto; justify-self: center; }
  .guide-voice kbd { display: none; }
  .guide-context-row label { max-width: 52%; }
  .guide-attention { grid-template-columns: auto minmax(0,1fr) auto; width: calc(100% - 16px); }
  .guide-attention p { white-space: normal; }
  .guide-attention .guide-attention-action { grid-column: 2; justify-self: start; }
  .guide-attention .guide-attention-dismiss { grid-column: 3; grid-row: 1; }
  .guide-send { display: grid; place-items: center; }
  .guide-status {
    display: block;
    width: auto;
    margin: 4px 0 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .guide-footer { min-height: 34px; }
  .guide-task-controls #guide-voice-output { padding: 7px 9px; }
  .guide-scene-head h2 { font-size: 21px; }
  .guide-window-actions button { min-width: 44px; min-height: 44px; }
  .guide-route-card { min-height: 92px; }
  .guide-route-card:not(.selected) p { display: block; }
  .atlas-map.guide-active .map-place-preview { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .map-command-panel, .guide-surface { transition: none; }
}
