/* The UWindow-to-React shim's presentation.
 *
 * `Docs/PRD.md` decision 10 discards UWindow's Paint and its absolute
 * coordinates: "React lays the interface out and answers the pointer with a
 * semantic event". So there is not one pixel value here that came from
 * `UWindowLookAndFeel` -- no `WinLeft`, no `TabUnselectedM.H`, no bevel. What
 * this file styles is the MEANING the shim publishes: a menu bar, a pull-down, a
 * dialog, a tab strip and the ten controls.
 *
 * It shares `styles.css`'s `--tint-rgb` and `data-skin`, so the menu still obeys
 * `UMenuRootWindow.LookAndFeelClass` and `FavoriteHUDColor` as an accent rather
 * than as a texture set.
 */

.uw2-host {
  position: fixed;
  inset: 0;
  z-index: 11;
  display: flex;
  flex-direction: column;
  font: 500 14px/1.45 system-ui, "Segoe UI", sans-serif;
  color: #e8ecf2;
  /* UWindow is a viewport overlay. Entry's logo/metal BSP remains the client
     background; painting this root opaque erases the scene the menu opened on. */
  background: transparent;
  -webkit-user-select: none;
  user-select: none;
}
.uw2-host[hidden] { display: none; }

.uw2-root { display: contents; }

/* The desktop is a positioned blackout layer. Any top-level shipped window
   that has not yet earned a specialised composer must still paint above it;
   otherwise a valid live UWindow tree is interactive but visually black. */
.uw2-root > .uw2-box { position: relative; z-index: 1; }

/* `UMenuRootWindow.Paint`: MenuBlack over the viewport, then twelve square
   Bg tiles in a centred 4x3 mosaic. Its W/H calculation is exactly a 4:3
   contain fit; the original one-pixel tile overlap merely prevents seams, so
   the CSS grid has no gap. */
.uw2-desktop {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
  background-color: #000;
  background-repeat: repeat;
}
.uw2-desktop-grid {
  width: min(100vw, 133.333333vh);
  aspect-ratio: 4 / 3;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
}
.uw2-desktop-grid img { display: block; width: 100%; height: 100%; }

/* --- the menu bar ------------------------------------------------------- */

.uw2-menubar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 0 8px;
  background: #0d1119;
  border-bottom: 1px solid color-mix(in srgb, #ffffff 12%, transparent);
}
.uw2-menu { position: relative; }
.uw2-menubar > .uw2-menu > button {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 10px 14px;
  cursor: pointer;
}
.uw2-menubar > .uw2-menu > button:hover,
.uw2-menubar > .uw2-menu > button[aria-expanded="true"] {
  background: color-mix(in srgb, rgb(var(--tint-rgb, 0 0 254)) 40%, #0d1119);
}
.uw2-menubar u { text-decoration-thickness: 1px; text-underline-offset: 2px; }

.uw2-pulldown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 260px;
  padding: 4px 0;
  background: #131924;
  border: 1px solid color-mix(in srgb, #ffffff 14%, transparent);
  box-shadow: 0 18px 40px rgb(0 0 0 / 55%);
  z-index: 2;
}
.uw2-pulldown button {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 16px;
  cursor: pointer;
}
.uw2-pulldown button:hover { background: color-mix(in srgb, rgb(var(--tint-rgb, 0 0 254)) 45%, #131924); }
.uw2-pulldown button[disabled] { opacity: .45; cursor: default; }
.uw2-pulldown button[aria-checked="true"]::before { content: "\2713\a0"; }
.uw2-pulldown hr { border: 0; border-top: 1px solid color-mix(in srgb, #ffffff 12%, transparent); margin: 4px 0; }

/* --- a framed window ---------------------------------------------------- */

.uw2-window {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(760px, calc(100% - 48px));
  max-height: calc(100% - 48px);
  padding: 0;
  overflow: auto;
  -webkit-user-select: none;
  user-select: none;
  background: #101620;
  color: inherit;
  border: 1px solid color-mix(in srgb, #ffffff 14%, transparent);
  box-shadow: 0 24px 60px rgb(0 0 0 / 55%);
}
.uw2-window::backdrop {
  background: rgb(0 0 0 / 42%);
}
.uw2-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: color-mix(in srgb, rgb(var(--tint-rgb, 0 0 254)) 30%, #101620);
  font-weight: 700;
  letter-spacing: .04em;
  cursor: grab;
  touch-action: none;
}
.uw2-window[data-dragging="true"] .uw2-titlebar { cursor: grabbing; }
.uw2-close {
  appearance: none; border: 0; background: transparent; color: inherit;
  font-size: 18px; line-height: 1; cursor: pointer; padding: 2px 6px;
}
.uw2-client { padding: 14px 16px 18px; }

/* UMenuBotmatchClientWindow's native splitter is a 280px left page plus a map
   preview on the right. UTMenu's CreatePages override leaves both as siblings
   in the live window graph; these selectors express that authored ownership
   without reading the old absolute WinLeft/WinWidth paint coordinates. */
.uw2-box.uw2-utmenubotmatchcw {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(230px, 2fr);
  gap: 14px 18px;
  align-items: start;
}
.uw2-utmenubotmatchcw > .uw2-pages { grid-column: 1; grid-row: 1; }
.uw2-utmenubotmatchcw > .uw2-uwindowhsplitter { grid-column: 2; grid-row: 1; }
.uw2-utmenubotmatchcw > .uw2-button { grid-row: 2; justify-self: end; }
.uw2-utmenubotmatchcw > .uw2-button + .uw2-button { justify-self: start; }

.uw2-map-preview { margin: 0; min-width: 0; }
.uw2-map-preview img, .uw2-map-preview-empty {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: #000;
}
.uw2-map-preview figcaption {
  display: grid;
  gap: 2px;
  padding-top: 9px;
  color: #b9c4d4;
  line-height: 1.3;
}
.uw2-map-preview figcaption strong { color: #e8ecf2; }
.uw2-map-preview figcaption span:last-child { color: #93a2b8; }

/* UTMenu.NewCharacterWindow. The script publishes the five field/value pairs,
   player DrawClippedActor window, description and arrow controls; React groups
   those semantics into a full-viewport campaign surface without reading the
   original absolute WinLeft/WinTop paint coordinates. */
.uw2-campaign {
  position: fixed;
  z-index: 2;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  width: min(920px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 34%);
  gap: 18px 28px;
  padding: 26px;
  box-sizing: border-box;
  background:
    linear-gradient(145deg, rgb(20 29 43 / 97%), rgb(7 11 18 / 98%));
  border: 1px solid color-mix(in srgb, rgb(var(--tint-rgb, 0 0 254)) 52%, #fff 12%);
  box-shadow: 0 30px 90px rgb(0 0 0 / 72%), inset 0 1px 0 rgb(255 255 255 / 8%);
}
.uw2-campaign > header {
  grid-column: 1 / -1;
  padding-bottom: 14px;
  border-bottom: 1px solid rgb(255 255 255 / 10%);
}
.uw2-campaign > header span {
  color: rgb(var(--tint-rgb, 0 0 254));
  font-size: .76em;
  font-weight: 800;
  letter-spacing: .2em;
  text-transform: uppercase;
}
.uw2-campaign > header h1 { margin: 4px 0 0; font-size: clamp(24px, 4vw, 42px); line-height: 1; }
.uw2-campaign-form { display: grid; align-content: start; gap: 10px; }
.uw2-campaign-field {
  display: grid;
  grid-template-columns: minmax(90px, 30%) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}
.uw2-campaign-field > span { color: #9baac0; }
.uw2-campaign-field > .uw2-field { display: contents; }
.uw2-campaign-field > .uw2-field > span { display: none; }
.uw2-campaign-field > .uw2-field > input { grid-column: 2; width: 100%; box-sizing: border-box; }
.uw2-campaign-field > .uw2-button { width: 100%; text-align: left; }
.uw2-campaign-form > .uw2-textarea {
  margin-top: 8px;
  padding: 12px;
  min-height: 82px;
  max-height: 150px;
  overflow: auto;
  background: rgb(0 0 0 / 24%);
  border: 1px solid rgb(255 255 255 / 8%);
}
.uw2-campaign-preview { min-width: 0; }
.uw2-campaign-preview .uw2-viewport {
  width: 100%;
  max-height: 470px;
  border: 1px solid rgb(255 255 255 / 12%);
  box-shadow: inset 0 0 36px rgb(0 0 0 / 75%);
}
.uw2-campaign > footer {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
}
.uw2-campaign-next {
  background: color-mix(in srgb, rgb(var(--tint-rgb, 0 0 254)) 48%, #1c2537);
  font-weight: 700;
}

.uw2-campaign-slots { grid-template-columns: minmax(0, 1fr); }
.uw2-campaign-slots > header p { margin: 8px 0 0; color: #93a2b8; }
.uw2-save-slots {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}
.uw2-save-slot {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  padding: 12px 14px;
  background: linear-gradient(145deg, #1a263a, #0d1420);
  border: 1px solid rgb(255 255 255 / 11%);
}
.uw2-save-slot.empty { opacity: .62; background: #0d131d; }
.uw2-save-number {
  display: grid;
  place-items: center;
  width: 40px;
  aspect-ratio: 1;
  border-radius: 50%;
  color: #dce5f3;
  background: rgb(var(--tint-rgb, 0 0 254) / 28%);
  font-weight: 800;
}
.uw2-save-copy { min-width: 0; }
.uw2-save-copy h2 {
  margin: 0;
  overflow: hidden;
  font-size: 1.16em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.uw2-save-copy p { margin: 5px 0 0; color: #8795aa; }
.uw2-save-copy dl { display: flex; flex-wrap: wrap; gap: 5px 18px; margin: 7px 0 0; }
.uw2-save-copy dl > div { display: flex; gap: 5px; }
.uw2-save-copy dt { color: #8f9db2; }
.uw2-save-copy dd { margin: 0; color: #d7e0ed; }
.uw2-save-actions { display: flex; gap: 8px; }
.uw2-save-actions .uw2-button:disabled { opacity: .32; cursor: default; }
.uw2-save-delete { color: #d5a7a7; }

.uw2-campaign-manager { grid-template-columns: minmax(0, 1fr); }
.uw2-campaign-manager > header p,
.uw2-campaign-ladder > header p { margin: 8px 0 0; color: #93a2b8; }
.uw2-campaign-doors {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.uw2-campaign-doors > .uw2-button {
  display: grid;
  align-content: center;
  gap: 7px;
  min-height: 86px;
  padding: 18px;
  font-size: 1.12em;
  font-weight: 750;
  text-align: left;
  background: linear-gradient(145deg, #26334a, #121a28);
  border-color: rgb(var(--tint-rgb, 0 0 254) / 45%);
}
.uw2-campaign-door small {
  color: #91a0b7;
  font-size: .68em;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.uw2-campaign-doors > .uw2-campaign-door.selected {
  background: linear-gradient(145deg,
    color-mix(in srgb, rgb(var(--tint-rgb, 0 0 254)) 58%, #26334a), #182238);
  border-color: rgb(var(--tint-rgb, 0 0 254));
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 11%);
}
.uw2-campaign-doors > .uw2-campaign-door.locked,
.uw2-campaign-doors > .uw2-campaign-door.locked:hover {
  opacity: .35;
  color: #8a93a1;
  background: linear-gradient(145deg, #1b2230, #0d121b);
  border-color: rgb(255 255 255 / 12%);
  cursor: not-allowed;
}
.uw2-campaign-doors > .uw2-button:hover:not(:disabled) {
  background: linear-gradient(145deg,
    color-mix(in srgb, rgb(var(--tint-rgb, 0 0 254)) 52%, #26334a), #182238);
}
.uw2-campaign-manager-info,
.uw2-campaign-ladder-info { grid-column: 1 / -1; min-height: 72px; }

.uw2-campaign-ladder {
  width: min(1160px, calc(100vw - 40px));
  grid-template-columns: minmax(0, 1fr);
}
.uw2-campaign-ladder-body {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(360px, 44%) minmax(0, 1fr);
  gap: 18px;
  min-height: 0;
}

.uw2-campaign-roster-body {
  display: grid;
  grid-template-columns: minmax(12rem, 0.7fr) minmax(20rem, 1.5fr);
  gap: 1.25rem;
  min-height: 0;
}

.uw2-campaign-roster-names {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.uw2-campaign-roster-names .selected {
  border-color: #d9b64c;
  color: #fff2a8;
}

.uw2-campaign-roster-profile {
  display: grid;
  grid-template-columns: minmax(13rem, 0.8fr) minmax(16rem, 1.2fr);
  gap: 1rem;
  min-height: 18rem;
}

@media (max-width: 760px) {
  .uw2-campaign-roster-body,
  .uw2-campaign-roster-profile {
    grid-template-columns: 1fr;
  }
}
.uw2-campaign-rungs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 9px;
  max-height: 58vh;
  padding-right: 4px;
  overflow: auto;
}
.uw2-rung {
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 9px;
  color: #dce5f3;
  background: #182235;
  border: 1px solid rgb(255 255 255 / 12%);
  text-align: left;
  cursor: pointer;
}
.uw2-rung > span:first-child {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgb(var(--tint-rgb, 0 0 254) / 28%);
}
.uw2-rung-copy { min-width: 0; }
.uw2-rung-copy strong,
.uw2-rung-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.uw2-rung-copy small { margin-top: 3px; color: #91a0b7; font-size: .78em; }
.uw2-rung.selected { border-color: rgb(var(--tint-rgb, 0 0 254)); }
.uw2-rung:disabled { opacity: .34; cursor: default; }

.uw2-campaign-match {
  display: grid;
  grid-template-columns: minmax(150px, 34%) minmax(0, 1fr);
  align-content: start;
  gap: 16px 18px;
  min-width: 0;
  max-height: 58vh;
  padding: 16px;
  overflow: auto;
  background: rgb(0 0 0 / 26%);
  border: 1px solid rgb(255 255 255 / 9%);
}
.uw2-campaign-match-shot img,
.uw2-campaign-match-no-shot {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #000;
  border: 1px solid rgb(255 255 255 / 10%);
  box-sizing: border-box;
}
.uw2-campaign-match-heading { align-self: center; min-width: 0; }
.uw2-campaign-match-heading > span {
  color: rgb(var(--tint-rgb, 0 0 254));
  font-size: .76em;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.uw2-campaign-match-heading h2 { margin: 6px 0; font-size: clamp(22px, 3vw, 34px); line-height: 1; }
.uw2-campaign-match-heading code { color: #91a0b7; font-family: inherit; }
.uw2-campaign-match-facts {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  background: rgb(255 255 255 / 8%);
}
.uw2-campaign-match-facts > div { padding: 9px 11px; background: #0d1420; }
.uw2-campaign-match-facts dt {
  margin-bottom: 3px;
  color: #8190a7;
  font-size: .72em;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.uw2-campaign-match-facts dd { margin: 0; }
.uw2-campaign-team-bio,
.uw2-campaign-opponents,
.uw2-campaign-briefing { grid-column: 1 / -1; }
.uw2-campaign-team-bio { margin: 0; color: #c1cad7; line-height: 1.45; }
.uw2-campaign-opponents { display: grid; gap: 8px; }
.uw2-campaign-opponents section,
.uw2-campaign-briefing { padding: 11px 12px; background: rgb(255 255 255 / 4%); }
.uw2-campaign-opponents h3,
.uw2-campaign-briefing h3 { margin: 0 0 5px; font-size: .9em; }
.uw2-campaign-opponents p,
.uw2-campaign-briefing p { margin: 0; color: #aeb9c9; line-height: 1.45; }

@media (max-width: 700px) {
  .uw2-campaign { grid-template-columns: 1fr; }
  .uw2-save-slot { grid-template-columns: 42px minmax(0, 1fr); }
  .uw2-save-actions { grid-column: 2; justify-content: flex-end; }
  .uw2-campaign-doors { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .uw2-campaign-ladder-body { grid-template-columns: 1fr; }
  .uw2-campaign-rungs,
  .uw2-campaign-match { max-height: none; }
  .uw2-campaign-preview { grid-row: 3; }
  .uw2-campaign-preview .uw2-viewport { max-height: 36vh; }
}

@media (max-width: 480px) {
  .uw2-save-slot { grid-template-columns: 1fr; }
  .uw2-save-number { display: none; }
  .uw2-save-actions { grid-column: 1; justify-content: stretch; }
  .uw2-save-actions .uw2-button { flex: 1; }
  .uw2-campaign-rungs,
  .uw2-campaign-match-facts { grid-template-columns: 1fr; }
  .uw2-campaign-match { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .uw2-box.uw2-utmenubotmatchcw { grid-template-columns: 1fr; }
  .uw2-utmenubotmatchcw > .uw2-pages,
  .uw2-utmenubotmatchcw > .uw2-uwindowhsplitter { grid-column: 1; grid-row: auto; }
}

/* --- tabs --------------------------------------------------------------- */

.uw2-tabs { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: 12px; }
.uw2-tabs button {
  appearance: none; border: 0; font: inherit; color: inherit; cursor: pointer;
  padding: 8px 14px;
  background: #182031;
  border-bottom: 2px solid transparent;
}
.uw2-tabs button[aria-selected="true"] {
  background: #202a3e;
  border-bottom-color: rgb(var(--tint-rgb, 0 0 254));
}

/* --- the ten controls --------------------------------------------------- */

.uw2-field {
  display: grid;
  grid-template-columns: minmax(160px, 40%) 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.uw2-checkbox { grid-template-columns: auto 1fr; }
.uw2-field > span:first-child { color: #b9c4d4; }
.uw2-field input[type="text"], .uw2-field input[type="number"], .uw2-field select {
  background: #0b1017;
  color: inherit;
  border: 1px solid color-mix(in srgb, #ffffff 18%, transparent);
  padding: 5px 8px;
  font: inherit;
  min-width: 0;
}
.uw2-field input[type="text"], .uw2-field input[type="number"], .uw2-field textarea {
  -webkit-user-select: text;
  user-select: text;
}
.uw2-field input[type="range"] { accent-color: rgb(var(--tint-rgb, 0 0 254)); }
.uw2-field output { font-variant-numeric: tabular-nums; color: #93a2b8; min-width: 3ch; }
.uw2-label { color: #b9c4d4; }
.uw2-button {
  appearance: none; font: inherit; color: inherit; cursor: pointer;
  background: #1c2537;
  border: 1px solid color-mix(in srgb, #ffffff 16%, transparent);
  padding: 6px 14px;
}
.uw2-button:hover { background: color-mix(in srgb, rgb(var(--tint-rgb, 0 0 254)) 35%, #1c2537); }
.uw2-list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow: auto; }
.uw2-row { padding: 5px 10px; cursor: pointer; }
.uw2-row.selected { background: color-mix(in srgb, rgb(var(--tint-rgb, 0 0 254)) 45%, #101620); }
.uw2-textarea p { margin: 0 0 6px; color: #b9c4d4; }

.uw2-bindings {
  max-height: min(62vh, 620px);
  overflow: auto;
  outline: none;
}
.uw2-bindings-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.uw2-bindings-table th,
.uw2-bindings-table td {
  padding: 5px 9px;
  text-align: left;
  border-bottom: 1px solid color-mix(in srgb, #ffffff 8%, transparent);
}
.uw2-bindings-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #151d2a;
  color: #e8ecf2;
}
.uw2-bindings-table tbody th { width: 55%; color: #b9c4d4; font-weight: 500; }
.uw2-binding-section th {
  padding-top: 13px;
  background: #101722;
  color: #e8ecf2;
  font-weight: 700;
}
.uw2-binding-button {
  width: 100%;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, #ffffff 14%, transparent);
  background: #0b1017;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.uw2-bindings-table tr.selected .uw2-binding-button,
.uw2-bindings[data-polling="true"] .uw2-bindings-table tr.selected .uw2-binding-button {
  border-color: rgb(var(--tint-rgb, 0 0 254));
  background: color-mix(in srgb, rgb(var(--tint-rgb, 0 0 254)) 28%, #0b1017);
}
.uw2-bindings-reset { float: right; margin-top: 12px; }
.uw2-bindings-joystick { clear: both; margin: 14px 0 0; border: 1px solid #313b4d; }

/* `Canvas.DrawClippedActor`, native 471. The live presenter appends its own
   canvas; this element supplies the clipped black viewport the native caller
   paints before drawing the actor. */
.uw2-viewport {
  aspect-ratio: 4 / 5;
  background: #05070b;
  overflow: hidden;
}
.uw2-viewport canvas { display: block; width: 100%; height: 100%; }

/* --- the generic container that serves the other 210 window classes ------ */

.uw2-box { display: flow-root; }
.uw2-box > .uw2-box { padding-left: 0; }
