/* Three panes wide, two panes on a tablet, one pane with tabs on a phone. */

.app-header {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 2);
  height: var(--header-h);
  padding: 0 calc(var(--u) * 2);
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}

.tab-bar { display: none; }

.app-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 340px;
  height: calc(100dvh - var(--header-h) - var(--tabs-h));
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-panel);
}
/* The middle pane is a desktop: the grid field repeats here as wallpaper
   (the global #field-grid sits below the panes, so it cannot show through). */
.pane-terminal {
  position: relative;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
}
.pane-map { border-right: 0; }

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--u);
  padding: calc(var(--u) * 1.5) calc(var(--u) * 2);
  border-bottom: 1px solid var(--border);
}

.pane-note {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.pane-foot {
  margin-top: auto;
  padding: calc(var(--u) * 1.5) calc(var(--u) * 2);
  border-top: 1px solid var(--border);
}

/* The map collapses to a rail on narrower desktops before it disappears. */
body.map-collapsed .app-grid { grid-template-columns: 320px minmax(0, 1fr) 0; }
body.map-collapsed .pane-map { display: none; }

@media (max-width: 1199px) {
  .app-grid { grid-template-columns: 300px minmax(0, 1fr); }

  /* The map becomes a drawer, so the header carries the current path instead. */
  .pane-map {
    position: fixed;
    top: var(--header-h);
    right: 0;
    bottom: 0;
    z-index: 5;
    width: min(360px, 86vw);
    border-left: 1px solid var(--border-bright);
    box-shadow: -18px 0 40px rgba(0, 0, 0, .45);
    transform: translateX(100%);
    transition: transform .22s cubic-bezier(.22, .61, .36, 1);
  }
  body.map-open .pane-map { transform: translateX(0); }
  body.map-collapsed .pane-map { display: flex; }
  .header-path { display: flex !important; }
  /* The path badge carries margin-left: auto here, so the buttons give up theirs. */
  .header-actions { margin-left: var(--u); }
}

@media (max-width: 859px) {
  :root { --tabs-h: 44px; }

  .header-kicker, .header-path { display: none !important; }
  .app-header { gap: var(--u); padding: 0 var(--u); }
  .brand img { width: 150px; height: auto; }

  .tab-bar {
    position: relative;
    z-index: 3;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    height: var(--tabs-h);
    border-bottom: 1px solid var(--border);
    background: var(--bg-panel);
  }
  .tab-bar button {
    border: 0;
    border-right: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 2px;
    cursor: pointer;
  }
  .tab-bar button:last-child { border-right: 0; }
  .tab-bar button[aria-selected='true'] {
    color: var(--accent-1);
    box-shadow: inset 0 -2px 0 var(--accent-1);
  }

  .app-grid { grid-template-columns: minmax(0, 1fr); }
  .pane { display: none; border-right: 0; }
  .pane.is-active { display: flex; }

  .pane-map {
    position: static;
    width: auto;
    transform: none;
    box-shadow: none;
    border-left: 0;
  }
  body.map-collapsed .pane-map { display: none; }
  body.map-collapsed .pane-map.is-active { display: flex; }

  #btn-map { display: none; }
}
