/* ===== Nuzlocke overlay — fixed 1920x1080 design canvas, scaled to fit ===== */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* transparent for OBS browser source; letterbox stays transparent too */
  background: transparent;
}

#stage {
  /* font preset chosen in the admin (set on #stage via data-font) */
  font-family: var(--overlay-font, "Segoe UI", "Noto Sans", system-ui, sans-serif);
}

/* preview mode (admin iframe / normal browser): dark letterbox for visibility */
body.preview { background: #14161f; }

#stage {
  position: absolute;
  width: 1920px;
  height: 1080px;
  transform-origin: top left;
}

#bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
}

#canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 20px;
  padding: 18px 20px;
}

/* ===== player column ===== */

.column {
  display: grid;
  /* header · game (aspect-fit) · team · camera (aspect-fit, now larger) */
  grid-template-rows: 88px 1.35fr 104px 1fr;
  gap: 12px;
  min-width: 0;
}

/* game & camera windows are aspect-fit and centered inside their cell;
   their exact px size is set by fitWindows() in overlay.js. The leftover
   space around them shows the background (intended margins). */
.fit-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}

/* --- header field: shows one GLOBAL widget, chosen per column position --- */
.header-box {
  border-radius: 10px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  overflow: hidden;
}
/* 'none' slot: invisible but still reserves the row so windows stay aligned */
.header-box.empty {
  background: none;
  border: none;
  box-shadow: none;
}

/* levelcap mode: "Lvl. Cap" tag + big number + next gym leader's picture */
.cap-display {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; height: 100%;
}
.cap-display .cap-tag {
  font-size: 28px; font-weight: 800; line-height: 1; white-space: nowrap;
  color: var(--panel-muted); text-transform: uppercase; letter-spacing: 0.5px;
}
.cap-display .cap-values { font-size: 36px; font-weight: 800; letter-spacing: 1px; line-height: 1; color: var(--accent); }
.cap-display .cap-values.overridden { color: var(--accent-2); }
.cap-display .cap-note { font-size: 15px; opacity: 0.85; color: var(--panel-muted); }
.cap-display .leader-img {
  /* fill the full height of the bar (break out of the vertical padding) */
  height: calc(100% + 16px);
  margin-block: -8px;
  width: auto;
  max-width: 44%;
  object-fit: contain;
  object-position: center bottom;
  image-rendering: pixelated;
}

/* badges mode: fixed 8 per row, wraps to the next row beyond 8 */
.header-box[data-slot="badges"] { padding: 6px 10px; }
.badge-row {
  display: grid;
  gap: 6px 4px;
  justify-items: center;
  align-items: center;
  width: 100%;
}
.badge-icon {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.badge-icon img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.badge-icon.locked { filter: grayscale(1) brightness(0.45); opacity: 0.55; }
.badge-fallback {
  width: 40px; height: 40px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe27a, #c98a1b);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 800; color: #4c3000;
}
/* >8 badges → two rows, so shrink to keep both rows inside the bar */
.badge-row.compact .badge-icon { width: 34px; height: 34px; }
.badge-row.compact .badge-fallback { width: 30px; height: 30px; font-size: 13px; }

/* runinfo mode — sized like the levelcap widget (value + label) */
.run-display { display: flex; align-items: center; justify-content: center; gap: 14px; }
.run-display .run-number { font-size: 36px; font-weight: 800; line-height: 1; color: var(--accent); }
.run-display .run-best {
  font-size: 28px; font-weight: 800; line-height: 1; white-space: nowrap;
  color: var(--panel-muted);
}

/* --- windows (game / cam): frame outside, interior fully transparent --- */
.window {
  position: relative;
  min-height: 0;
}
.window .interior {
  position: absolute;
  inset: var(--frame-thickness, 12px);
  background: transparent;
}
/* .game-window / .cam-window get their px size from fitWindows() */

/* --- team bar --- */
.team-bar {
  border-radius: 10px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  padding: 8px 10px;
  align-items: center;
}
.team-slot {
  height: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.team-slot img.mon {
  /* sprites are trimmed server-side to their content, so a uniform height
     makes every generation fill the slot equally. Capped by the slot box. */
  height: 84px;
  width: auto;
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}
.team-slot .empty-ball {
  width: 30px; height: 30px; opacity: 0.35;
}
/* the placeholder ball is white; flip it to dark on light themes */
#stage[data-mode="light"] .team-slot .empty-ball { filter: invert(1); }
.team-slot .mon-label {
  position: absolute;
  bottom: -2px;
  left: 0; right: 0;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: none; /* enabled via settings later if wanted */
}

/* header/team panels use the active theme's variables (see themes.css) */
.panel {
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  color: var(--panel-text);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
