/* Board styling — owned by agent:ui-board (roadmap 3.1) */

.board-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  background: var(--bg);
}

.board-global-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  filter: brightness(0.35) saturate(0.85);
  z-index: 0;
}

.board-global-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, rgb(13 21 28 / 0.2) 0%, rgb(13 21 28 / 0.8) 100%);
  z-index: 0;
}

.board-stage {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  border-radius: var(--radius);
  box-shadow: 0 8px 36px rgb(0 0 0 / 0.65);
  overflow: hidden;
  background: color-mix(in srgb, var(--surface) 40%, transparent);
  border: 1px solid color-mix(in srgb, var(--ink) 10%, transparent);
  z-index: 1;
}

.board-stage.is-animating {
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.board-viewport.is-zoomed {
  cursor: grab;
}

.board-viewport.is-panning {
  cursor: grabbing;
}

/* Tile content is class-driven only: the lead's drag-and-drop highlights tiles with an
   injected <style> rule targeting [data-space], so tiles must not carry inline
   opacity/box-shadow/outline/filter styles and must keep pointer events enabled. */

/* Region headers: always a single fully-visible line. */
.board-region-header {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
  font-family: var(--font-display);
  font-size: max(7.5px, calc(var(--sw, 844) * 0.0105px));
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.92;
  text-shadow: 0 1px 3px rgb(0 0 0 / 0.9);
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 10%, transparent);
  white-space: nowrap;
}

.board-region-header > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.board-region-header.is-divider {
  font-size: max(7px, calc(var(--sw, 844) * 0.009px));
  border-bottom: 0;
  opacity: 0.85;
}

/* Space tiles ---------------------------------------------------------- */
.space-tile {
  position: absolute;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  border: 1.5px solid color-mix(in srgb, var(--ink) 18%, transparent);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.45);
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  z-index: 3;
  transition: transform 0.15s var(--ease), opacity 0.2s var(--ease);
  container-type: size;
}

.space-tile .space-art {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
}

.space-tile .space-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.space-tile.is-legal {
  border-color: var(--accent);
  box-shadow: 0 0 0 1.5px var(--accent), 0 4px 14px color-mix(in srgb, var(--accent) 45%, transparent);
  z-index: 5;
}

.space-tile.is-dimmed {
  opacity: 0.35;
}

.space-tile.is-selected {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--ink), 0 6px 20px rgb(0 0 0 / 0.7);
  z-index: 6;
}

.space-tile.is-choice-target {
  border-color: var(--ok);
  animation: pulse-space 1.5s infinite;
  z-index: 5;
}

.space-tile.is-recommended {
  box-shadow: 0 0 0 2px var(--ok), 0 0 16px color-mix(in srgb, var(--ok) 65%, transparent);
}

@keyframes pulse-space {
  50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 40%, transparent); }
}

/* Name row: grows/shrinks, always keeps at least one line. */
.space-header {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 3px;
  width: 100%;
  flex: 1 1 auto;
  min-height: 1.15em;
  overflow: hidden;
  z-index: 2;
}

.space-name {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-display);
  font-size: max(7.5px, calc(var(--sw, 844) * 0.0115px));
  font-weight: 600;
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: auto;
  text-shadow: 0 1px 2px rgb(0 0 0 / 0.95);
}

.space-combat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--danger);
  flex: none;
  margin-top: 1px;
}

/* Icon + costs + rewards: fixed single row, never wraps. */
.space-mid {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  flex: none;
  height: 12px;
  overflow: hidden;
  white-space: nowrap;
  z-index: 2;
  font-size: 10px;
}

.space-mid .space-icon {
  flex: none;
}

.space-costs {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: none;
}

.space-mid .space-rewards {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
}

.maker-bonus {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: none;
  padding: 0 4px;
  height: 12px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--accent) 30%, rgb(0 0 0 / 0.7));
  border: 1px solid var(--accent);
  font-size: 9px;
  font-weight: 700;
  color: var(--ink);
}

/* Occupants + control: fixed row, always fully visible. */
.space-foot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  width: 100%;
  flex: none;
  height: 12px;
  z-index: 2;
}

.space-agents {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  overflow: visible;
}

.space-agents .agent-token + .agent-token {
  margin-left: -5px;
}

.agent-token {
  display: inline-block;
  flex: none;
  width: 11px;
  height: 11px;
  border-radius: 50% 50% 35% 35%;
  background: var(--player-color, var(--accent));
  box-shadow: 0 0 0 1.5px var(--bg), 0 2px 5px rgb(0 0 0 / 0.5);
  animation: agent-appear 0.25s var(--ease);
}

@keyframes agent-appear {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Diamond pennant in the occupying... controlling player's color. */
.control-flag {
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  margin-right: 2px;
  transform: rotate(45deg);
  border-radius: 2px;
  background: var(--player-color, var(--accent));
  box-shadow: 0 0 0 1.5px var(--bg), 0 1px 4px rgb(0 0 0 / 0.5);
}

/* Compact chrome on the shortest tiles (small landscape phones): shrink the
   name so two lines always clear the fixed icon and occupant rows. */
@container (max-height: 47px) {
  .space-name { font-size: 7px; line-height: 1.1; }
  .space-mid { height: 11px; }
  .space-foot { height: 11px; }
}

/* Hide rewards first on narrow/short tiles, then art — never name or occupants. */
@container (max-width: 132px) {
  .space-mid .space-rewards { display: none; }
}

@container (max-height: 48px) {
  .space-mid .space-rewards { display: none; }
}

@container (max-height: 40px) {
  .space-tile .space-art { display: none; }
}

/* Faction tracks -------------------------------------------------------- */
.faction-track {
  position: absolute;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.4);
  overflow: hidden;
  z-index: 3;
}

.track-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  height: 11px;
  padding: 0 3px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.track-head .track-icon {
  width: 11px;
  height: 11px;
}

.alliance-token {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  opacity: 0.35;
}

.alliance-token.held {
  opacity: 1;
  background: var(--player-color, var(--accent));
  box-shadow: 0 0 0 1px var(--bg);
}

.track-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.track-rung {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  padding: 0 3px 0 4px;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 8%, transparent);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  overflow: hidden;
}

.track-rung:last-child {
  border-bottom: 0;
}

.track-rung.is-alliance {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}

.track-rung.is-vp {
  background: color-mix(in srgb, var(--ok) 12%, transparent);
}

.rung-label {
  font-size: max(5px, calc(var(--sw, 844) * 0.0062px));
  line-height: 1;
  opacity: 0.85;
  flex: none;
}

.rung-markers {
  display: flex;
  align-items: center;
  gap: 1px;
  min-width: 0;
  overflow: hidden;
}

.rung-markers .player-dot {
  box-shadow: 0 0 0 1px var(--bg);
}

/* Camera controls: desktop only (see the fine-pointer block below). Anchored to the
   bottom-right of the board, above the hand dock. */
.board-cam {
  position: absolute;
  right: calc(10px + var(--safe-r));
  bottom: calc(var(--dock-h, 112px) + 10px);
  display: none;
  gap: 8px;
  z-index: 10;
}

.board-cam .cam-btn {
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.5);
}

.board-cam .cam-fit {
  width: auto;
  padding: 0 14px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
}

/* Hover tooltip (fine pointers only; rendered by Board.js after a short delay).
   Never blocks clicks. */
.board-tip {
  position: absolute;
  z-index: 20;
  max-width: 250px;
  min-width: 150px;
  transform: translate(-50%, calc(-100% - 10px));
  pointer-events: none;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 28px rgb(0 0 0 / 0.6);
  padding: 8px 10px 9px;
  font-size: 12px;
  line-height: 1.3;
}

.board-tip.is-below {
  transform: translate(-50%, 12px);
}

.board-tip .tip-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
}

.board-tip .tip-sub {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 1px 0 5px;
}

.board-tip .tip-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.board-tip .tip-combat,
.board-tip .tip-maker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.board-tip .tip-agents {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.board-tip .tip-agent,
.board-tip .tip-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

.board-tip .tip-control .control-flag {
  margin-right: 0;
}

/* Fine pointers: hover states, camera controls. Hover never carries information
   on its own — the tooltip duplicates what long-press → inspect already shows. */
@media (hover: hover) and (pointer: fine) {
  .space-tile:hover {
    border-color: var(--ink);
    filter: brightness(1.18);
    transform: translateY(-1px);
  }

  .space-tile.is-dimmed:hover {
    filter: brightness(1.18);
  }

  .board-cam {
    display: flex;
  }

  .board-cam .cam-btn:hover {
    border-color: var(--accent);
  }
}
