/* /testbuilder — public alliance build requests + suggestions */
:root {
  --navy: #071923;
  --navy2: #0d2c3d;
  --ink: #f2f6f7;
  --muted: #aabcc3;
  --line: rgba(234, 245, 246, 0.14);
  --amber: #f4b63f;
  --teal: #59c6ba;
  --hosp: #c62828;
  --pris: #6a1b9a;
  --display: "Bebas Neue", Impact, sans-serif;
  --body: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  color: var(--ink);
  background: var(--navy);
  font-family: var(--body);
  line-height: 1.5;
}

.tb-app {
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  min-height: 100svh;
}

.tb-panel {
  position: relative;
  z-index: 2;
  padding: 1.35rem 1.4rem 2rem;
  background:
    linear-gradient(165deg, rgba(13, 44, 61, 0.97) 0%, rgba(7, 25, 35, 0.98) 55%),
    radial-gradient(ellipse 80% 50% at 0% 0%, rgba(244, 182, 63, 0.12), transparent 55%);
  border-right: 1px solid var(--line);
  overflow: auto;
  animation: tb-in 0.55s ease-out both;
}

@keyframes tb-in {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: none; }
}

.tb-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  margin-bottom: 1rem;
}
.tb-brand img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px rgba(244, 182, 63, 0.35);
}
.tb-brand strong {
  display: block;
  font: 1.55rem/0.95 var(--display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tb-brand em {
  display: block;
  margin-top: 0.15rem;
  font-style: normal;
  color: var(--amber);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tb-search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
}
.tb-search-go {
  border: 0;
  border-radius: 8px;
  padding: 0 0.85rem;
  background: rgba(244, 182, 63, 0.92);
  color: var(--navy);
  font: 700 0.78rem/1 var(--body);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}
.tb-search-go:hover { filter: brightness(1.05); }
.tb-search-list .kind {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.08rem 0.35rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(244, 182, 63, 0.16);
  color: var(--amber);
}
.tb-search-list .kind.is-prison {
  background: rgba(142, 36, 170, 0.2);
  color: #ce93d8;
}
.tb-search-list .kind.is-place {
  background: rgba(89, 198, 186, 0.18);
  color: var(--teal);
}
.tb-search-list .meta {
  display: block;
  margin-top: 0.12rem;
}

.tb-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  padding: 0.3rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
}
.tb-mode {
  border: 0;
  border-radius: 7px;
  padding: 0.55rem 0.4rem;
  background: transparent;
  color: var(--muted);
  font: 700 0.72rem/1.1 var(--body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.tb-mode.is-active {
  background: var(--amber);
  color: var(--navy);
}
.tb-mode:not(.is-active):hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
}

.tb-lead {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.tb-form { display: grid; gap: 0.85rem; }
.tb-field { display: flex; flex-direction: column; gap: 0.28rem; position: relative; }
.tb-field > span,
.tb-kinds legend,
.tb-selected-kicker {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--amber);
}
.tb-field input,
.tb-field select,
.tb-field textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.22);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font: 0.95rem/1.4 var(--body);
}
.tb-field textarea { resize: vertical; min-height: 4.5rem; }
.tb-field input:focus,
.tb-field select:focus,
.tb-field textarea:focus {
  outline: none;
  border-color: rgba(244, 182, 63, 0.55);
  box-shadow: 0 0 0 2px rgba(244, 182, 63, 0.15);
}

.tb-kinds {
  margin: 0;
  padding: 0;
  border: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.1rem;
  align-items: center;
}
.tb-kinds[hidden] { display: none; }
.tb-kinds legend { width: 100%; margin-bottom: 0.15rem; }
.tb-kinds label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.92rem;
  cursor: pointer;
}
#tb-academy-wrap[hidden] { display: none; }
.tb-academy-list {
  display: grid;
  gap: 0.4rem;
}
.tb-academy-opt {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--ink);
  font: 0.92rem/1.25 var(--body);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.tb-academy-opt:hover {
  border-color: rgba(244, 182, 63, 0.45);
  background: rgba(244, 182, 63, 0.08);
}
.tb-academy-opt:has(input:checked) {
  border-color: rgba(244, 182, 63, 0.75);
  background: rgba(244, 182, 63, 0.16);
  color: #fff;
  font-weight: 600;
}
.tb-academy-opt input {
  accent-color: var(--amber);
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}
.tb-academy-empty {
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}

.tb-selected {
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(244, 182, 63, 0.35);
  background:
    linear-gradient(135deg, rgba(244, 182, 63, 0.12), transparent 55%),
    rgba(0, 0, 0, 0.22);
  animation: tb-sel-in 0.28s ease-out;
}
.tb-selected[hidden] { display: none; }
.tb-selected-kicker { display: block; margin-bottom: 0.2rem; }
.tb-selected strong {
  display: block;
  font-size: 1.05rem;
  line-height: 1.25;
}
.tb-selected .tb-hint { margin-top: 0.25rem; }
.tb-clear-sel {
  margin-top: 0.55rem;
  border: 0;
  background: none;
  color: var(--teal);
  font: 600 0.8rem/1 var(--body);
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
@keyframes tb-sel-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

#tb-suggest-fields[hidden] { display: none; }

.tb-hint { margin: 0; color: var(--muted); font-size: 0.78rem; }
.tb-suggest {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  z-index: 30;
  max-height: 12rem;
  overflow: auto;
  background: #0a2836;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}
.tb-suggest button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: var(--ink);
  padding: 0.45rem 0.7rem;
  font: 0.9rem/1.3 var(--body);
  cursor: pointer;
}
.tb-suggest button:hover,
.tb-suggest button[aria-selected="true"] {
  background: rgba(244, 182, 63, 0.16);
}
.tb-suggest .meta { color: var(--muted); font-size: 0.75rem; }

.tb-submit {
  margin-top: 0.35rem;
  border: 0;
  border-radius: 8px;
  padding: 0.8rem 1rem;
  background: var(--amber);
  color: var(--navy);
  font: 700 0.92rem/1 var(--body);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
}
.tb-submit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.tb-submit:not(:disabled):hover { filter: brightness(1.05); }
.tb-submit:not(:disabled):active { transform: translateY(1px); }

.tb-msg { margin: 0.4rem 0 0; color: var(--teal); font-size: 0.9rem; }
.tb-err { margin: 0.4rem 0 0; color: #f07178; font-size: 0.9rem; }
.hp { position: absolute; left: -9999px; opacity: 0; height: 0; width: 0; overflow: hidden; }

.tb-map-wrap {
  position: relative;
  min-height: 100svh;
  background:
    radial-gradient(ellipse 60% 40% at 70% 20%, rgba(89, 198, 186, 0.08), transparent 50%),
    var(--navy2);
}
#tb-map {
  position: absolute;
  inset: 0;
  cursor: grab;
}
.tb-app.is-suggest #tb-map { cursor: crosshair; }
.tb-app.is-suggest .tb-layer-toggles { display: none; }

.tb-map-chrome {
  position: absolute;
  z-index: 500;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  padding: 0 1rem 1rem;
  pointer-events: none;
}
.tb-layer-toggles {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  pointer-events: auto;
  max-width: min(100%, 42rem);
}
.tb-layer-hint {
  margin: 0;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: rgba(7, 25, 35, 0.72);
  color: rgba(232, 241, 245, 0.78);
  font: 600 0.68rem/1.2 var(--body);
  letter-spacing: 0.02em;
  text-align: center;
}
.tb-layer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
}
.tb-layer {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid rgba(232, 241, 245, 0.22);
  border-radius: 999px;
  padding: 0.38rem 0.45rem 0.38rem 0.55rem;
  background: rgba(7, 25, 35, 0.9);
  color: rgba(232, 241, 245, 0.72);
  font: 650 0.72rem/1 var(--body);
  letter-spacing: 0.01em;
  text-transform: none;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.tb-layer img {
  width: 16px;
  height: 20px;
  object-fit: contain;
  flex: 0 0 auto;
  opacity: 0.55;
  filter: grayscale(0.35);
}
.tb-layer .tb-layer-logo {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}
.tb-layer-label {
  white-space: nowrap;
}
.tb-layer-state {
  min-width: 2.1rem;
  padding: 0.22rem 0.42rem;
  border-radius: 999px;
  background: rgba(232, 241, 245, 0.1);
  color: rgba(232, 241, 245, 0.55);
  font: 700 0.62rem/1 var(--body);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
}
.tb-layer.is-active {
  background: rgba(7, 25, 35, 0.95);
  color: var(--ink);
  border-color: rgba(244, 182, 63, 0.75);
  box-shadow:
    0 0 0 1px rgba(244, 182, 63, 0.25),
    0 2px 12px rgba(0, 0, 0, 0.35);
}
.tb-layer.is-active img {
  opacity: 1;
  filter: none;
}
.tb-layer.is-active .tb-layer-state {
  background: var(--amber);
  color: var(--navy);
}
.tb-layer:not(.is-active):hover {
  color: var(--ink);
  border-color: rgba(244, 182, 63, 0.45);
  transform: translateY(-1px);
}
.tb-layer:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}
.tb-owned-marker {
  background: transparent !important;
  border: 0 !important;
}
.leaflet-tbOwned-pane {
  z-index: 650;
}
.tb-owned-pin {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  width: 52px;
  pointer-events: none;
}
.tb-owned-pin img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: #071923;
  border: 2px solid #f4b63f;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}
.tb-owned-pin em {
  display: inline-block;
  margin: 0;
  padding: 0.18rem 0.42rem;
  border-radius: 999px;
  background: rgba(7, 25, 35, 0.94);
  border: 1px solid rgba(244, 182, 63, 0.55);
  color: #f4b63f;
  font: 700 0.58rem/1 var(--body);
  font-style: normal;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.tb-owned-marker.is-prison .tb-owned-pin {
  /* keep logo gold ring; tint label only */
}
.tb-owned-marker.is-prison .tb-owned-pin em {
  border-color: rgba(171, 71, 188, 0.7);
  color: #e1bee7;
}
.tb-owned-marker.is-hospital .tb-owned-pin em {
  border-color: rgba(229, 57, 53, 0.7);
  color: #ffcdd2;
}
.tb-owned-pin span { display: none; }

.leaflet-marker-icon.tb-map-icon {
  background: transparent !important;
  border: 0 !important;
}
.leaflet-marker-icon.tb-map-icon.is-active {
  filter: drop-shadow(0 0 6px rgba(244, 182, 63, 0.95));
}
/* Eager decode — avoid browser lazy-img “Marker” placeholders */
.leaflet-marker-icon.tb-map-icon img,
.leaflet-marker-icon.tb-map-icon {
  image-rendering: auto;
}

.tb-map-badge {
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: rgba(7, 25, 35, 0.88);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.tb-pin {
  background: transparent !important;
  border: 0 !important;
}
.tb-pin-badge { display: none; }

@media (prefers-reduced-motion: reduce) {
  .tb-panel,
  .tb-pin-badge,
  .tb-selected,
  .tb-submit,
  .tb-mode { animation: none; transition: none; }
}

@media (max-width: 860px) {
  .tb-app {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(52svh, 1fr);
  }
  .tb-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: none;
  }
  .tb-map-wrap { min-height: 52svh; }
  .tb-layer-label { font-size: 0.68rem; }
  .tb-layer-hint { font-size: 0.62rem; }
}
