/* The game window: title bar (map + region), four resizable panes around the viewport, and
   panels the player can drag between them. Sizes and placement live in ui/layout.js. */
#app { height: 100%; }
#app-grid {
  --size-top: 0px;
  --size-left: 260px;
  --size-right: 260px;
  --size-bottom: 220px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  height: 100%;
  padding: var(--gap);
}

/* ------------------------------------------------------------------ title bar */
#titlebar {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 0 2px 3px;
  border-bottom: 1px solid var(--ink);
  flex: 0 0 auto;
}
#titlebar .brand { letter-spacing: .04em; }
#titlebar .sep { opacity: .5; }
#titlebar .where { font-weight: 700; }
#titlebar .spacer { flex: 1; }
#titlebar .menu-button { padding: 0 6px; font-size: 11px; }

/* ------------------------------------------------------------------ workspace */
#workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  gap: var(--gap);
  grid-template-columns: var(--size-left) 1fr var(--size-right);
  grid-template-rows: var(--size-top) 1fr var(--size-bottom);
  grid-template-areas:
    "top top top"
    "left view right"
    "bottom bottom bottom";
}
#viewport { grid-area: view; }
.pane { position: relative; display: flex; min-width: 0; min-height: 0; }
.pane-top { grid-area: top; }
.pane-bottom { grid-area: bottom; }
.pane-left { grid-area: left; }
.pane-right { grid-area: right; }

/* Panels stack down the sides and top, and run left-to-right along the bottom. */
.pane-inner {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
  min-height: 0;
  overflow: auto;
}
.pane-top > .pane-inner, .pane-bottom > .pane-inner { flex-direction: row; }
.pane-inner > .panel { flex: 1 1 0; min-width: 0; min-height: 0; overflow: auto; }
/* The hotbar is a fixed-width strip; the dialogue and quest list share the rest. */
.pane-inner > .panel[data-panel="hotbar"] { flex: 0 0 auto; }
.pane-bottom > .pane-inner > .panel[data-panel="dialogue"] { flex: 1.6 1 0; }
.pane-bottom > .pane-inner > .panel[data-panel="quests"] { flex: 1 1 0; }

/* ------------------------------------------------------------------ panel frame */
.panel {
  position: relative;
  border: 1px solid var(--ink);
  padding: var(--gap);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel-body { flex: 1 1 auto; min-height: 0; min-width: 0; overflow: auto; }

/* The title is the drag handle: grab it to move the panel to another side. */
.panel h2, .panel-head {
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.panel h2::before { content: '≡'; opacity: .4; font-weight: 400; }
.panel h2, .panel-head { justify-content: flex-start; padding-right: 18px; }
.panel h2 > span, .panel-head .grip { margin-left: auto; }
.panel-head {
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 2px;
  margin-bottom: var(--gap);
  font-weight: 700;
}
.panel-head .grip { opacity: .4; margin-left: auto; }
.panel h2 { align-items: center; gap: 6px; }
.panel h2 > span { margin-left: auto; }
.panel-hide {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 2;
  border: 0;
  background: none;
  padding: 0 2px;
  line-height: 1;
  font-size: 13px;
  opacity: .45;
  cursor: pointer;
}
.panel-hide:hover { opacity: 1; background: none; color: inherit; }
body.dragging-panel, body.dragging-panel * { user-select: none; cursor: grabbing !important; }

/* Highlight of the pane a dragged panel would land in. */
.pane.drop-target > .pane-inner { outline: 1px dashed var(--ink); outline-offset: -1px; }
.drop-hint {
  position: fixed;
  z-index: 25;
  border: 1px dashed var(--ink);
  background: rgba(255, 255, 255, .55);
  display: grid;
  place-items: center;
  font-size: 11px;
  pointer-events: none;
}
.drop-hint[hidden] { display: none; }

/* ------------------------------------------------------------------ resizers */
.resizer { position: absolute; z-index: 6; touch-action: none; }
.resizer:hover, .resizer.dragging { background: var(--ink); }
.resizer-left { right: -4px; top: 0; bottom: 0; width: 8px; cursor: ew-resize; }
.resizer-right { left: -4px; top: 0; bottom: 0; width: 8px; cursor: ew-resize; }
.resizer-top { bottom: -4px; left: 0; right: 0; height: 8px; cursor: ns-resize; }
.resizer-bottom { top: -4px; left: 0; right: 0; height: 8px; cursor: ns-resize; }
body.resizing { user-select: none; }

/* ------------------------------------------------------------------ Esc menu */
#menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, .35);
  display: grid;
  place-items: center;
}
#menu-overlay[hidden] { display: none; }
.menu-card {
  background: var(--paper);
  border: 1px solid var(--ink);
  padding: 12px;
  width: min(420px, 92vw);
  max-height: 86vh;
  overflow: auto;
}
.menu-card h2 { align-items: center; }
.menu-card h3 { margin: 10px 0 4px; font-weight: 700; }
.menu-close { padding: 0 6px; }
.menu-list { display: flex; flex-direction: column; gap: 2px; }
.menu-row { display: flex; align-items: center; gap: 6px; padding: 1px 0; }
.menu-row b { flex: 1; }
.menu-actions { display: flex; gap: 6px; flex-wrap: wrap; }
