/* Flying a drone by hand (console/fleet-pilot.js, web/DESIGN.md 26 "The pilot view"): the
   full-screen pilot view, the flight card's Fly manually, and its spotlight and speaker.
   Redwood tokens only; the drone is the drone's green, the stop the one danger button. */

/* ── The pilot view ───────────────────────────────────────────────────────── */

.ds-pilot {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: var(--rw-bg-app);
  color: var(--rw-text-primary);
}
.ds-pilot-gone { align-content: start; justify-items: start; gap: var(--rw-space-4x); padding: var(--rw-space-6x); }
.ds-pilot-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--rw-space-1x) var(--rw-space-4x);
  padding: var(--rw-space-2x) var(--rw-space-4x);
  border-block-start: 3px solid transparent;
  border-block-end: 1px solid var(--rw-divider);
  background: var(--rw-bg-content);
}
/* Holding control: the drone's green along the top, as a flight in the air has on its card. */
.ds-pilot-yours > .ds-pilot-head { border-block-start-color: var(--rw-text-success); }
.ds-pilot-title { margin: 0; font-size: var(--rw-heading-xs-size); line-height: var(--rw-heading-xs-lh); font-weight: 600; }
.ds-pilot-holder { margin: 0 0 0 auto; font-size: var(--rw-body-sm-size); line-height: var(--rw-body-sm-lh); font-weight: 600; }

.ds-pilot-body { display: grid; grid-template-columns: minmax(0, 1fr) 24rem; min-height: 0; }
.ds-pilot-sight {
  display: flex;
  flex-direction: column;
  gap: var(--rw-space-3x);
  min-height: 0;
  min-width: 0;
  padding: var(--rw-space-4x);
  overflow-y: auto;
}
.ds-pilot-instruments { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--rw-space-3x); align-items: start; }
.ds-pilot-video > .ds-video, .ds-pilot-video > .ds-video-off { margin: 0; }
.ds-pilot-video .ds-video-frame { max-height: calc(100dvh - 18rem); }

/* The heads-up display: big mono figures under the picture, never over it. */
.ds-pilot-hud { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--rw-space-2x); margin: 0; }
.ds-pilot-readout {
  display: grid;
  gap: var(--rw-space-1x);
  min-width: 0;
  padding: var(--rw-space-2x) var(--rw-space-3x);
  border: 1px solid var(--rw-divider);
  border-radius: var(--rw-radius-md);
  background: var(--rw-bg-content);
}
.ds-pilot-readout > dt { color: var(--rw-text-secondary); font-size: var(--rw-body-xs-size); line-height: var(--rw-body-xs-lh); }
.ds-pilot-readout > dd { margin: 0; overflow-wrap: anywhere; font-family: var(--font-oracle-mono); font-size: var(--rw-body-lg-size); line-height: var(--rw-body-lg-lh); }
.ds-pilot-readout-warning { border-color: var(--rw-text-warning); }
.ds-pilot-readout-warning > dd { color: var(--rw-text-warning); }
.ds-pilot-readout-danger { border-color: var(--rw-text-danger); }
.ds-pilot-readout-danger > dd { color: var(--rw-text-danger); }

/* The small map, north up, the drone in its middle. */
.ds-pilot-map { width: 10rem; margin: 0; }
.ds-pilot-map > svg { display: block; width: 100%; height: auto; }
.ds-pilot-map-none { display: grid; place-items: center; aspect-ratio: 1; border: 1px dashed var(--rw-divider); border-radius: var(--rw-radius-md); }
.ds-pilot-map-none > p { margin: 0; padding: var(--rw-space-2x); color: var(--rw-text-secondary); font-size: var(--rw-body-xs-size); line-height: var(--rw-body-xs-lh); text-align: center; }
.ds-pilot-map-ground { fill: var(--rw-bg-content); stroke: var(--rw-divider); }
.ds-pilot-map-range { fill: none; stroke: var(--rw-divider); stroke-dasharray: 2 3; }
.ds-pilot-map-keepout { fill: var(--rw-text-danger); fill-opacity: .18; stroke: var(--rw-text-danger); stroke-width: 1.2; }
.ds-pilot-map-home path { fill: none; stroke: var(--rw-text-secondary); stroke-width: 1.4; stroke-linejoin: round; }
.ds-pilot-map-drone path { fill: var(--rw-text-success); }
.ds-pilot-map-ring { fill: none; stroke: var(--rw-text-success); stroke-width: 1.5; }
.ds-pilot-map-north path { fill: var(--rw-text-secondary); }
.ds-pilot-map-north text, .ds-pilot-map-scale text { fill: var(--rw-text-secondary); font-size: 9px; font-family: var(--font-oracle-mono); }
.ds-pilot-map-scale path { fill: none; stroke: var(--rw-text-secondary); stroke-width: 1.2; }

/* The side: Stop now first, then the control, then the sticks. */
.ds-pilot-side {
  display: flex;
  flex-direction: column;
  gap: var(--rw-space-5x);
  min-height: 0;
  padding: var(--rw-space-4x);
  overflow-y: auto;
  border-inline-start: 1px solid var(--rw-divider);
  background: var(--rw-bg-content);
}
.ds-pilot-side h3 { margin: 0 0 var(--rw-space-2x); font-size: var(--rw-body-md-size); line-height: var(--rw-body-md-lh); font-weight: 600; }
.ds-pilot-stop { display: grid; gap: var(--rw-space-2x); }
.ds-pilot-stop > .rw-btn { width: 100%; justify-content: center; }
.ds-pilot-stopnow.rw-btn { min-height: calc(var(--rw-space-12x) + var(--rw-space-2x)); font-size: var(--rw-heading-xs-size); font-weight: 600; }
.ds-pilot-stop-note { margin: 0; font-size: var(--rw-body-xs-size); line-height: var(--rw-body-xs-lh); }
.ds-pilot-control > p { margin: 0 0 var(--rw-space-2x); }
.ds-pilot-act > .rw-btn { width: 100%; justify-content: center; }
.ds-pilot-ended {
  display: grid;
  gap: var(--rw-space-1x);
  margin: 0 0 var(--rw-space-3x);
  padding: var(--rw-space-3x);
  border: 1px solid var(--rw-text-warning);
  border-inline-start-width: 3px;
  border-radius: var(--rw-radius-md);
  background: var(--rw-bg-muted);
  animation: ds-pilot-in 240ms ease-out;
}
.ds-pilot-ended > p { margin: 0; font-size: var(--rw-body-sm-size); line-height: var(--rw-body-sm-lh); }
.ds-pilot-ended-away { font-weight: 600; }
@keyframes ds-pilot-in { from { opacity: 0; transform: translateY(-4px); } }
.ds-pilot-error { font-size: var(--rw-body-sm-size); line-height: var(--rw-body-sm-lh); }
.ds-pilot-deadman { color: var(--rw-text-secondary); font-size: var(--rw-body-xs-size); line-height: var(--rw-body-xs-lh); }
.ds-pilot-deadman-on { color: var(--rw-text-success); font-weight: 600; }
.ds-pilot-facts { display: grid; gap: var(--rw-space-1x); margin: var(--rw-space-2x) 0 0; font-size: var(--rw-body-sm-size); line-height: var(--rw-body-sm-lh); }
.ds-pilot-facts > div { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: var(--rw-space-2x); }
.ds-pilot-facts dt { color: var(--rw-text-secondary); }
.ds-pilot-facts dd { margin: 0; overflow-wrap: anywhere; }

.ds-pilot-sticks { display: grid; grid-template-columns: 1fr 1fr; gap: var(--rw-space-3x); }
.ds-pilot-stick { display: grid; justify-items: center; gap: var(--rw-space-1x); margin: 0; }
.ds-pilot-stick > svg { width: 6rem; height: 6rem; }
.ds-pilot-stick > figcaption { color: var(--rw-text-secondary); font-size: var(--rw-body-xs-size); line-height: var(--rw-body-xs-lh); text-align: center; }
.ds-pilot-stick-ground { fill: var(--rw-bg-muted); stroke: var(--rw-divider); }
.ds-pilot-stick-cross { fill: none; stroke: var(--rw-divider); }
.ds-pilot-stick-dot { fill: var(--rw-text-success); transition: cx 90ms linear, cy 90ms linear; }
.ds-pilot-zone { display: flex; align-items: center; justify-content: space-between; gap: var(--rw-space-3x); margin: var(--rw-space-3x) 0; font-size: var(--rw-body-sm-size); }
.ds-pilot-zone > select { width: auto; min-width: 8rem; }
.ds-pilot-map-keys > summary { cursor: pointer; font-size: var(--rw-body-sm-size); line-height: var(--rw-body-sm-lh); font-weight: 600; }
.ds-pilot-map-keys > p { margin: var(--rw-space-2x) 0 0; font-size: var(--rw-body-xs-size); line-height: var(--rw-body-xs-lh); }
.ds-pilot-keys { width: 100%; margin-top: var(--rw-space-2x); border-collapse: collapse; font-size: var(--rw-body-xs-size); line-height: var(--rw-body-xs-lh); }
.ds-pilot-keys th, .ds-pilot-keys td { padding: var(--rw-space-1x) var(--rw-space-2x) var(--rw-space-1x) 0; border-block-end: 1px solid var(--rw-divider); text-align: start; vertical-align: top; }
.ds-pilot-keys thead th { color: var(--rw-text-secondary); font-weight: 400; }
.ds-pilot-keys tbody th { font-weight: 600; }
.ds-pilot-keys kbd { display: inline-block; min-width: 1.5em; padding: 0 var(--rw-space-1x); border: 1px solid var(--rw-border-enabled); border-radius: var(--rw-radius-sm); text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .ds-pilot-ended { animation: none; }
  .ds-pilot-stick-dot { transition: none; }
}
.ds-pilot-still .ds-pilot-ended { animation: none; }
.ds-pilot-still .ds-pilot-stick-dot { transition: none; }

/* A phone, or a narrow window: one column, the side under the picture. */
@media (max-width: 59.99rem) {
  .ds-pilot { display: block; overflow-y: auto; }
  .ds-pilot-head { padding: var(--rw-space-2x) var(--rw-space-3x); }
  .ds-pilot-holder { flex-basis: 100%; margin: 0; }
  .ds-pilot-body { display: block; }
  .ds-pilot-sight { padding: var(--rw-space-3x); overflow: visible; }
  .ds-pilot-video .ds-video-frame { max-height: none; }
  .ds-pilot-instruments { grid-template-columns: minmax(0, 1fr); }
  .ds-pilot-hud { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ds-pilot-readout > dd { font-size: var(--rw-body-md-size); line-height: var(--rw-body-md-lh); overflow-wrap: normal; }
  .ds-pilot-map { width: 10rem; }
  .ds-pilot-side { padding: var(--rw-space-3x); overflow: visible; border-inline-start: 0; border-block-start: 1px solid var(--rw-divider); }
}

/* ── On the flight card ──────────────────────────────────────────────────── */

.ds-flight-manual { display: flex; flex-wrap: wrap; align-items: center; gap: var(--rw-space-1x) var(--rw-space-3x); margin: var(--rw-space-3x) 0 0; }
.ds-flight-manual > .ds-fleet-reason { flex-basis: 100%; margin: 0; }
.ds-flight-manual-hint { font-size: var(--rw-body-xs-size); line-height: var(--rw-body-xs-lh); }
.ds-flight-payloads { display: grid; gap: var(--rw-space-3x); margin: var(--rw-space-3x) 0 0; }
.ds-payload { display: grid; gap: var(--rw-space-2x); }
.ds-payload > .ds-fleet-reason { margin: 0; }
.ds-payload-name { font-size: var(--rw-body-sm-size); line-height: var(--rw-body-sm-lh); font-weight: 600; }
.ds-payload .ds-fleet-buttons { align-items: center; }
.ds-payload-num.rw-input { width: 5.5rem; min-width: 0; }
.ds-payload-unit { margin-inline-start: calc(-1 * var(--rw-space-1x)); font-size: var(--rw-body-sm-size); }
.ds-payload-say { display: flex; gap: var(--rw-space-2x); }
.ds-payload-say > .rw-input { flex: 1 1 auto; min-width: 0; }
