/* Ship Finder -- hosted browser build.
   Same skeleton as the Depth preview on purpose: map left, everything you can
   change on the right, so the two read as one family of tools. The palette is
   darker because the content is a radar image and a pale chrome around a
   near-black chip looks like a rendering fault. */

:root {
  --ink: #0f1417;
  --dim: #5b6b74;
  --line: #d8e0e4;
  --bg: #f6f8f9;
  --card: #fff;
  --sea: #124e6e;
  --sea-ink: #fff;
  --warn-bg: #fff4e5;
  --warn-line: #f0c48a;
  --warn-ink: #6b4310;
  --cargo: #2f7fb5;
  --military: #b4632a;
  --other: #6a7b85;
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* The map fills whatever is left after the chrome, measured rather than
   guessed -- the hosted build gets a site bar injected above everything by
   copy_web_apps, whose height this file cannot know. Hence the flex column:
   every piece of chrome takes its natural height and main takes the rest.

   `height` and not just `min-height`, above the mobile breakpoint, and that is
   the whole fix for a bug that read as "the radar overlay does not render".
   With min-height alone the body is free to GROW, so a long contact list
   stretched the grid row, `#map { height: 100% }` faithfully followed it to
   2758 px, and fitBounds then framed the AOI in the middle of a map whose top
   two thirds were the only part on screen. The imagery was drawn correctly and
   was simply below the fold. A definite height caps the row, so the panel
   scrolls inside itself instead of pushing the map out of the viewport.

   Scoped to the wide layout on purpose: below 860px the page is a normal
   scrolling document and 100vh on a mobile browser is a well-known trap. */
body { display: flex; flex-direction: column; min-height: 100vh; }
main { flex: 1 1 auto; min-height: 0; }
@media (min-width: 861px) {
  body { height: 100vh; }
}

h1, h2 { margin: 0; font-weight: 600; }
h1 { font-size: 1.15rem; letter-spacing: -0.01em; }
h2 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--dim); }
a { color: var(--sea); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 0.65rem; }
.brand p { margin: 0.15rem 0 0; color: var(--dim); font-size: 0.85rem; max-width: 58ch; }
.tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.08rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--dim);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  vertical-align: 0.22em;
}

/* Not a toast, not dismissible, not below the fold. */
.notice {
  margin: 0;
  padding: 0.55rem 1rem;
  background: var(--warn-bg);
  border-bottom: 1px solid var(--warn-line);
  color: var(--warn-ink);
  font-size: 0.85rem;
}

.help {
  padding: 0.9rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.help p { margin: 0 0 0.6rem; max-width: 76ch; font-size: 0.9rem; }
.help p:last-child { margin-bottom: 0; }
.help-links { display: flex; gap: 1rem; margin-top: 0.7rem; }
@media (min-width: 861px) {
  .help { max-height: 34vh; overflow-y: auto; }
}

main {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 0;
  min-height: 420px;
}
/* min-height:0 on both children: a grid item's default min-height is `auto`,
   which means "at least my content", and that is what let the panel's contact
   list win the argument with the row height in the first place. */
#map { height: 100%; min-height: 0; background: #dfe7ea; }

.panel {
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  background: var(--card);
  border-left: 1px solid var(--line);
}
.panel > * + * { margin-top: 0.9rem; }

.row { display: flex; gap: 0.5rem; }
.row.wrap { flex-wrap: wrap; margin-top: 0.5rem; }
/* These two were `style="margin-top:0.6rem"` in the markup, which works on a
   plain static server and is BLOCKED in production: the site serves
   `style-src 'self'`, and a CSP without 'unsafe-inline' refuses style
   attributes. The page still rendered, just fractionally wrong, with the only
   evidence two console errors nobody would see. A local http.server sends no
   CSP at all, so this class of bug can only be caught on the real origin. */
.row.spaced { margin-top: 0.6rem; }
/* Same reasoning, pre-emptively: set by app.js on the prior-flip note. CSSOM
   assignment is exempt from style-src, but keeping it in the stylesheet means
   the rule is not relying on that exemption. */
.truth.stacked { margin-top: 0.4rem; }

button {
  font: inherit;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--sea); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { flex: 1; background: var(--sea); border-color: var(--sea); color: var(--sea-ink); }
button.primary:hover:not(:disabled) { filter: brightness(1.12); }
button.ghost { white-space: nowrap; }
button.armed { background: #0b3a52; border-color: #0b3a52; color: #fff; }
button.chip {
  padding: 0.28rem 0.55rem;
  font-size: 0.8rem;
  border-radius: 999px;
}

.dim { color: var(--dim); font-size: 0.85rem; }
.hint { margin: 0.35rem 0 0; color: var(--dim); font-size: 0.78rem; line-height: 1.45; }

.opts { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.5rem 0.7rem; }
.opts summary { cursor: pointer; font-size: 0.85rem; color: var(--dim); }
.opts[open] summary { margin-bottom: 0.7rem; }

.opt { display: flex; align-items: center; justify-content: space-between; gap: 0.7rem; font-size: 0.9rem; }
.opt.check { justify-content: flex-start; gap: 0.5rem; margin-top: 0.7rem; }
.inline { display: flex; align-items: center; gap: 0.3rem; }
input[type="number"], select {
  font: inherit;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
}
select { max-width: 13rem; }
select[size] { max-width: none; width: 100%; margin-top: 0.6rem; }

.status { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.6rem 0.7rem; }
.status p { margin: 0; font-size: 0.85rem; white-space: pre-line; }
.status.err { background: #fdeeee; border-color: #e9b4b4; color: #7a1f1f; }
.bar { height: 4px; margin-top: 0.5rem; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--sea); transition: width 0.25s; }

.readout { margin: 0.2rem 0 0.6rem; font-size: 0.85rem; color: var(--dim); font-variant-numeric: tabular-nums; }
.readout strong { color: var(--ink); }

.contacts { display: flex; flex-direction: column; gap: 0.3rem; }
.contact {
  display: grid;
  grid-template-columns: 2.2rem 1fr auto;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  cursor: pointer;
  font-size: 0.85rem;
  text-align: left;
  font-variant-numeric: tabular-nums;
}
.contact:hover, .contact.on { border-color: var(--sea); background: #f2f7fa; }
.contact .n { color: var(--dim); font-size: 0.78rem; }
.contact .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact .dims { color: var(--dim); font-size: 0.78rem; white-space: nowrap; }
.contact .bucket {
  font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 700; padding: 0.05rem 0.35rem; border-radius: 999px; color: #fff;
}
.bucket.cargo { background: var(--cargo); }
.bucket.military { background: var(--military); }
.bucket.other { background: var(--other); }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #0e1a22;
  color: #dfe9ee;
}
.card canvas { display: block; width: 100%; image-rendering: pixelated; background: #060d11; }
.card .body { padding: 0.7rem 0.8rem; font-size: 0.85rem; }
.card h3 { margin: 0 0 0.15rem; font-size: 1rem; }
.card .sub { margin: 0 0 0.55rem; color: #93a8b3; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.card .why { margin: 0 0 0.5rem; line-height: 1.5; }
.card .truth { margin: 0; padding: 0.4rem 0.5rem; border-radius: 6px; font-size: 0.8rem; line-height: 1.45; }
.card .truth.amber { background: rgba(224,163,62,0.15); border: 1px solid rgba(224,163,62,0.5); color: #f0c98a; }
.card .truth.grey { background: rgba(140,160,170,0.12); border: 1px solid rgba(140,160,170,0.35); color: #b9c9d2; }
.card .ev { margin: 0.5rem 0 0; display: flex; flex-wrap: wrap; gap: 0.25rem; }
.card .ev span {
  font-size: 0.7rem; padding: 0.1rem 0.4rem; border-radius: 999px;
  background: rgba(255,255,255,0.09); color: #b9c9d2;
}

.credit { font-size: 0.72rem; color: var(--dim); line-height: 1.5; }

.leaflet-container { font: inherit; }
.aoi-hint {
  background: rgba(15,20,23,0.85); color: #fff;
  padding: 0.3rem 0.6rem; border-radius: 6px; font-size: 0.8rem;
}
/* The contact markers are drawn as hull-shaped boxes rotated to the measured
   heading, not as pins: a pin would claim a point where the tool measured an
   extent and an orientation. */
.hull { pointer-events: auto; cursor: pointer; }

@media (max-width: 860px) {
  main { grid-template-columns: 1fr; flex: 0 0 auto; }
  #map { height: 58vh; min-height: 300px; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .brand p { display: none; }
}
