/* MavLTE's web page: the Aircraft card in MavLTE's own dark palette (the MavGCS one), for a phone. */

:root {
  --bg: #1e1e1e;
  --surface: #252526;
  --field: #2e2e30;
  --border: #454549;
  --deep: #16171a;
  --black: #000;
  --text: #e6e6e6;
  --muted: #b0b0b4;
  --dim: #7d8ea0;
  --accent: #5ccf5c; /* MavGreen */
  --accent-press: #4cb84c;
  --on-accent: #04210f;
  --knob-on: #fff;
  --green: #5ccf5c;
  --blue: #4d9bff;
  --amber: #d8a23a;
  --amber-ground: #2f2716;
  --red: #ff5555;
  --off: #3a3b3e;
  --track: #4a4b4f;
  --shade: rgba(0, 0, 0, 0.55);
  --trail: #ffd23f; /* the track on the map: yellow shows on fields and forest alike */
  --casing: #101010;
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* the header, as MavLTE's: the badge, the aircraft's name, the relay, and the green line under it */
.head {
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 12px;
  background: var(--surface);
  border-bottom: 2px solid var(--accent);
}
.head-in { display: flex; align-items: center; gap: 14px; max-width: 528px; margin: 0 auto; } /* over the card */
.badge { flex: none; width: 48px; height: 48px; image-rendering: pixelated; }
.who { min-width: 0; }
h1 { margin: 0; font-size: 20px; line-height: 1.2; overflow-wrap: anywhere; text-wrap: balance; }
.relay { display: flex; align-items: center; gap: 8px; margin: 4px 0 0; font-size: 14px; }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px calc(28px + env(safe-area-inset-bottom, 0px));
}
.label { margin: 4px 0 6px; font-size: 15px; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }

.led { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--off); }
.led.green { background: var(--green); }
.led.blue { background: var(--blue); }
.led.amber { background: var(--amber); }
.led.red { background: var(--red); }

.top { display: flex; align-items: center; gap: 10px; padding: 12px 12px 6px; }
.headline { flex: 1; min-width: 0; font-weight: 700; }
.bars { flex: none; display: inline-flex; align-items: flex-end; gap: 2px; height: 16px; }
.bars i { width: 4px; border-radius: 1px; background: var(--off); }
.bars i:nth-child(1) { height: 25%; }
.bars i:nth-child(2) { height: 50%; }
.bars i:nth-child(3) { height: 75%; }
.bars i:nth-child(4) { height: 100%; }
.bars i.on { background: var(--accent); }

.rows {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 9px 14px;
  margin: 0;
  padding: 6px 12px 14px;
}
.rows dt { color: var(--muted); }
.rows dt.mid { align-self: center; } /* beside the switch */
.rows dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

/* the card's colours by name (aircraft_card.py) */
.c-text { color: var(--text); }
.c-muted { color: var(--muted); }
.c-dim { color: var(--dim); }
.c-green { color: var(--green); }
.c-blue { color: var(--blue); }
.c-amber { color: var(--amber); }
.c-red { color: var(--red); }
.c-off { color: var(--off); }

.actions { display: flex; gap: 8px; margin-top: 6px; }
.pill {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--field);
  color: var(--blue);
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}
.pill.off, .pill:disabled, a.pill:not([href]) { color: var(--off); pointer-events: none; }

.voice { display: flex; align-items: center; gap: 10px; }
.switch {
  position: relative;
  flex: none;
  width: 52px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 15px;
  background: var(--track);
  cursor: pointer;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s;
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { background: var(--knob-on); transform: translateX(22px); }
.switch:disabled { opacity: 0.45; cursor: default; }

/* Snapshot, at the bottom of the card */
.camera { padding: 12px; border-top: 1px solid var(--border); }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.controls > .accent { flex: 1 1 8em; } /* on a phone: each its own line, the whole width */
.accent {
  padding: 10px 20px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  cursor: pointer;
}
.accent:active { background: var(--accent-press); }
.accent:disabled { background: var(--field); color: var(--dim); cursor: default; }
.sizes { flex: 1 1 15em; display: flex; overflow: hidden; border: 1px solid var(--border); border-radius: 6px; }
.sizes button {
  flex: 1;
  padding: 9px 12px;
  border: 0;
  background: var(--field);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.sizes button + button { border-left: 1px solid var(--border); }
.sizes button[aria-checked="true"] { background: var(--accent); color: var(--on-accent); }
.sizes button:disabled { color: var(--dim); cursor: default; }
.sizes button[aria-checked="true"]:disabled { background: var(--border); color: var(--muted); }
.status { margin: 10px 0 0; font-size: 14px; }
.progress { height: 4px; margin-top: 6px; overflow: hidden; border-radius: 2px; background: var(--field); }
#progress-bar { width: 0; height: 100%; background: var(--accent); transition: width 0.3s; }
.last { margin: 6px 0 0; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.photo {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--deep);
  cursor: zoom-in;
}
.photo img { display: block; width: 100%; max-width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; }

.foot { margin-top: 18px; color: var(--dim); font-size: 13px; text-align: center; }
.link {
  padding: 6px 4px;
  border: 0;
  background: none;
  color: var(--dim);
  text-decoration: underline;
  cursor: pointer;
}

/* no news from the server: the card fades until there is */
.net {
  margin: 0 0 10px;
  padding: 8px 12px;
  border: 1px solid var(--amber);
  border-radius: 6px;
  background: var(--amber-ground);
  color: var(--amber);
  font-size: 14px;
}
body.stale .card, body.stale .relay { opacity: 0.55; }

.signin { display: grid; gap: 10px; margin-top: 16px; padding: 18px; }
.signin h2 { margin: 0; font-size: 18px; }
.hint { margin: 0; color: var(--muted); font-size: 14px; }
.signin label { margin-top: 6px; color: var(--muted); font-size: 14px; }
.signin input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--field);
  color: var(--text);
  font-size: 16px; /* smaller makes iOS zoom in */
}
.signin input:focus { border-color: var(--accent); outline: none; }
.signin .accent { margin-top: 4px; }
.error { min-height: 1.45em; margin: 0; color: var(--red); font-size: 14px; }
.unseen { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* a photo, the whole screen */
body.viewing { overflow: hidden; }
.viewer { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; background: var(--black); }
.viewer img { flex: 1; width: 100%; min-height: 0; object-fit: contain; }
.viewer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
}
.viewer-bar p { flex: 1; min-width: 0; margin: 0; color: var(--muted); font-size: 13px; text-align: center; overflow-wrap: anywhere; }
.viewer-bar button, .close {
  flex: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--field);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.viewer-bar button:disabled { opacity: 0.35; cursor: default; }
.close { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: 12px; background: var(--shade); }

/* the moving map, the whole screen: the aircraft on Esri World Imagery, and its track */
.mapview { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; background: var(--black); }
.map { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--deep); touch-action: none; cursor: grab; }
#tiles img { /* a pixel wider than their place: no seams on screens that scale (125 %, say) */
  position: absolute; top: 0; left: 0; width: 257px; height: 257px; user-select: none; -webkit-user-drag: none;
}
.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.casing, .trail { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.casing { stroke: var(--casing); stroke-width: 5px; }
.trail { stroke: var(--trail); stroke-width: 3px; }
#plane { fill: var(--amber); stroke: var(--casing); stroke-width: 2px; stroke-linejoin: round; }
#plane.live { fill: var(--green); }
.credit {
  position: absolute;
  right: 0;
  bottom: 0;
  max-width: 100%;
  margin: 0;
  padding: 2px 6px;
  background: var(--shade);
  color: var(--muted);
  font-size: 11px;
}
.map-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
}
.map-bar p { flex: 1 1 14em; min-width: 0; margin: 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.map-buttons { display: flex; align-items: center; gap: 8px; }
.map-buttons button {
  min-width: 44px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--field);
  font-size: 20px;
  cursor: pointer;
}
#follow { font-size: 14px; }
#follow[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
