/* world.css — Archie spatial-percept view portal
   (plan-spatial-percept-view-portal.md). Dark overlays over a full-screen
   canvas; reuses the theme vars from style.css, same overlay conventions as
   maps.css (topbar, chat panel, minimize-able info panel). */

html, body { height: 100%; margin: 0; }
.world-body { overflow: hidden; font-family: var(--font-body); background: var(--bg); }

#world-canvas, #world-canvas-3d {
  position: absolute; inset: 0; z-index: 0; background: var(--bg);
  width: 100%; height: 100%; display: block;
  /* Movement/zoom are single- and two-finger gestures on the canvas itself
     (world.js's pointer handlers) -- without this the browser intercepts
     the pinch as a page-zoom and cancels the pointer stream mid-gesture. */
  touch-action: none;
}

#world-topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; gap: 4px; flex-wrap: nowrap;
  padding: 10px 10px; pointer-events: none;
  background: linear-gradient(to bottom, rgba(17, 17, 16, 0.92), rgba(17, 17, 16, 0));
  color: var(--text);
}
#world-topbar a, #world-topbar span, #world-topbar button, #world-topbar div { pointer-events: auto; }
#world-back { color: var(--text); text-decoration: none; font-size: 20px; padding: 2px 8px; }
#world-title { font-weight: 600; }
#world-status { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-sec); min-width: 0; }
#world-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
@media (max-width: 560px) { #world-label { display: none; } }

#world-mode-group { display: flex; gap: 2px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 2px; }
.world-mode-btn {
  background: transparent; color: var(--text-sec); border: none; border-radius: var(--radius-pill);
  padding: 3px 10px; font-size: 12px; cursor: pointer;
}
.world-mode-btn.active { background: var(--accent-dim); color: #fff; }

#btn-chat {
  background: var(--bg-surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: 3px 12px; font-size: 12px; cursor: pointer;
}

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); display: inline-block; }
.dot.ok { background: var(--green); }
.dot.busy { background: var(--amber); }
.dot.err { background: var(--red); }

/* Chat with Archie — identical shape to maps.css's #chat-panel. */
#chat-panel {
  position: absolute; z-index: 1200; right: 12px; bottom: calc(12px + var(--tb-h, 0px));
  width: min(420px, calc(100vw - 24px)); height: min(60vh, 560px);
  display: flex; flex-direction: column;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  color: var(--text); overflow: hidden;
}
#chat-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
#chat-title { font-weight: 600; }
#chat-head button {
  background: var(--bg-surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 3px 9px; font-size: 12px; cursor: pointer;
}
#btn-chat-close { margin-left: auto; }
#chat-history-list { max-height: 40%; overflow-y: auto; border-bottom: 1px solid var(--border); background: var(--bg-surface); }
.chat-hist-item { padding: 7px 10px; font-size: 12px; cursor: pointer; border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-hist-item:hover { background: var(--bg-raised); }
.chat-hist-empty { padding: 10px; font-size: 12px; color: var(--text-muted); }
#chat-messages { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { max-width: 85%; padding: 7px 11px; border-radius: var(--radius-lg); font-size: 14px; line-height: 1.4; white-space: pre-wrap; word-wrap: break-word; }
.chat-user { align-self: flex-end; background: var(--accent-dim); color: #fff; }
.chat-assistant { align-self: flex-start; background: var(--bg-surface); border: 1px solid var(--border); }
#chat-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--border); }
#chat-input { flex: 1; background: var(--bg-input); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 8px 10px; font-size: 14px; }
#chat-input:focus { outline: none; border-color: var(--border-focus); }
#chat-send { background: var(--accent-dim); color: #fff; border: 1px solid var(--accent); border-radius: var(--radius); padding: 8px 14px; cursor: pointer; font-size: 14px; }

/* World-info panel — terrain/weather/text flavor, same minimize-able shape
   as maps.css's #route-panel. */
#world-info-panel {
  position: absolute; left: 12px; bottom: calc(12px + var(--tb-h, 0px)); z-index: 1000;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 12px; width: min(360px, calc(100vw - 24px));
  color: var(--text); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}
#world-info-summary { font-size: 15px; font-weight: 600; margin-bottom: 6px; padding-right: 32px; }
#world-info-text { font-size: 13px; color: var(--text-sec); line-height: 1.4; }
#world-info-actions, .world-picker-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
#world-info-actions label, .world-picker-row label { font-size: 12px; color: var(--text-muted); }
#world-info-actions input[type="range"] { flex: 1; }
#world-radius-val { font-size: 12px; color: var(--text-sec); min-width: 2.5em; text-align: right; }
#world-picker, #world-new-id {
  flex: 1; min-width: 0; background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius); padding: 6px 8px; font-size: 13px;
}
#btn-world-go {
  background: var(--bg-surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 10px; font-size: 13px; cursor: pointer;
}
#world-info-panel.minimized #world-info-text,
#world-info-panel.minimized #world-info-actions,
#world-info-panel.minimized .world-picker-row { display: none; }
.panel-min-btn {
  position: absolute; top: 8px; right: 10px; z-index: 1;
  background: var(--bg-surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); width: 26px; height: 26px; padding: 0;
  font-size: 12px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* Gesture hint -- replaces the old D-pad. Shown once (per browser, via
   localStorage) so first-time visitors know to drag/pinch; dismissed by
   world.js on the first real gesture or after a few seconds either way, so
   it never lingers as a second obtrusive overlay. */
#world-gesture-hint {
  position: absolute; left: 50%; bottom: calc(24px + var(--tb-h, 0px)); z-index: 900;
  transform: translateX(-50%);
  background: rgba(17, 17, 16, 0.72); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: 6px 14px; font-size: 12px;
  pointer-events: none; transition: opacity 0.4s ease;
}
#world-gesture-hint.fade-out { opacity: 0; }

#world-error {
  position: absolute; top: 50px; left: 50%; transform: translateX(-50%); z-index: 1300;
  background: var(--bg-raised); border: 1px solid var(--red); color: var(--red);
  border-radius: var(--radius); padding: 6px 14px; font-size: 13px; max-width: calc(100vw - 24px);
}

body.has-rail #world-topbar { left: 60px; }
body.has-rail #world-info-panel { left: 72px; }

.hidden { display: none !important; }
