/*
 * ViewStack presentation modes — single / stacked / sliding / tiled.
 * Sub-ticket 13. Layout is library-side (N <folia-view> elements in CSS),
 * NOT folia-view's internal split/grid. Tokens resolve through library.css.
 */

/* The explorer host fills its section; each mode lays out its panels here. */
#explorer.vs--single,
#explorer.vs--stacked {
  position: relative;
}

/* --- Header mode switcher -------------------------------------------------- */

.home-header__modes {
  display: flex;
  align-items: center;
}

.mode-switcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.mode-switcher__group {
  display: inline-flex;
  border: 1px solid var(--color-border-strong);
  border-radius: 8px;
  overflow: hidden;
  background: var(--color-bg-elevated);
}

.mode-switcher__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: none;
  border-right: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.mode-switcher__btn:last-child {
  border-right: none;
}

.mode-switcher__btn:hover {
  background: var(--color-code-bg);
  color: var(--color-fg);
}

.mode-switcher__btn--active {
  background: var(--color-accent-bg);
  color: var(--color-accent);
  font-weight: 600;
}

.mode-switcher__glyph {
  font-size: 13px;
  line-height: 1;
}

.mode-switcher__arrangements {
  display: inline-flex;
  gap: 4px;
}

.mode-switcher__arr {
  padding: 4px 8px;
  border: 1px solid var(--color-border-strong);
  border-radius: 6px;
  background: var(--color-bg-elevated);
  color: var(--color-muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.mode-switcher__arr--active {
  background: var(--color-accent-bg);
  border-color: var(--color-accent);
  color: var(--color-accent);
  font-weight: 600;
}

/* --- Multi-panel layouts -------------------------------------------------- */

/* Tiled — CSS grid per arrangement. */
.vs-grid {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 2px;
  background: var(--color-border);
}

.vs-grid[data-arrangement='1x2'] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
}

.vs-grid[data-arrangement='1x3'] {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr;
}

.vs-grid[data-arrangement='2x2'] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

/* A single panel frame. */
.vs-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--color-bg-elevated);
  overflow: hidden;
}

.vs-panel--active {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.vs-panel__map {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.vs-panel__map > folia-view {
  width: 100%;
  height: 100%;
  display: block;
}

/* Per-panel header strip: label + linkage lock toggles. */
.vs-panel__strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  background: color-mix(in srgb, var(--color-bg-elevated) 92%, transparent);
  border-bottom: 1px solid var(--color-border);
  font-size: 12px;
  z-index: 2;
}

.vs-panel__label {
  color: var(--color-fg);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vs-panel__locks {
  display: inline-flex;
  gap: 2px;
}

.vs-lock {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  background: var(--color-bg);
  color: var(--color-faint);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.vs-lock--on {
  background: var(--color-accent-bg);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* Sliding — two stacked panels; the top clipped by an x-fraction. */
.vs-sliding {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: grid; /* one cell; both panels stack via grid-area */
}

/* Both panels are normal-flow grid items that fill the single cell (overlapping
   in source order). This keeps each map at FULL size so it fires MapLibre's
   'load' — an overflow-clipped-to-0 host never does, leaving the map blank. The
   top panel is revealed by clip-path (set in JS), which clips visually without
   shrinking the layout box. */
.vs-sliding .vs-panel {
  grid-area: 1 / 1;
}

.vs-sliding__top {
  z-index: 1;
}

.vs-sliding__divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: var(--color-accent);
  cursor: ew-resize;
  z-index: 3;
  touch-action: none;
}

.vs-sliding__handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-accent);
  color: var(--color-accent);
  font-size: 13px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.18);
}

/* Pixel-pin highlight marker (best-effort overlay on linked panels). */
.vs-pixel-pin {
  position: absolute;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  margin-top: -7px;
  border: 2px solid var(--color-accent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--color-accent) 25%, transparent);
  pointer-events: none;
  z-index: 5;
}
