/* The flying page: the camera's view fills the window and everything else lies over it. */
:root {
  --photo: 1.3349;                      /* the photo's width over its height; main.js sets it from the scene */
  --ratio: var(--photo);                /* the picture's width over its height as the camera is set; camera.js sets it */
  --bar: 0px;                           /* how much higher than one row the bar at the top is; main.js sets it */
  --ink: #fff;
  --dim: rgba(255, 255, 255, 0.72);
  --line: rgba(255, 255, 255, 0.28);
  --panel: rgba(16, 20, 24, 0.74);
  --ground: #181c21;                    /* the map's colour where the scene is empty */
  --warn: #ffb020;
  --good: #6fdc8c;                      /* on target, in the capture guide */
  --theirs: #1e9ad8;                    /* the flight that captured the scene (dashed on the map) */
  --yours: #d07c00;                     /* the pilot's own flight (solid on the map) */
  color-scheme: dark;
}
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  overflow: hidden;
  background: var(--ground);
  color: var(--ink);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#view { position: fixed; inset: 0; }
#view canvas { display: block; width: 100%; height: 100%; }
#photo-frame {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(100vw, 100vh * var(--photo)); height: calc(min(100vw, 100vh * var(--photo)) / var(--ratio));
  box-sizing: border-box; border: 1px solid rgba(255, 255, 255, 0.5); pointer-events: none;
}
/* Gridlines: the picture in thirds, for placing the house and the sky. */
#photo-frame.grid::before, #photo-frame.grid::after { content: ""; position: absolute; border: 0 solid rgba(255, 255, 255, 0.32); }
#photo-frame.grid::before { inset: 0 33.333%; border-width: 0 1px; }
#photo-frame.grid::after { inset: 33.333% 0; border-width: 1px 0; }
#photo-frame.flash { animation: flash 0.22s ease-out; } /* a photo was taken */
@keyframes flash { from { border-color: #fff; background: rgba(255, 255, 255, 0.14); } to { background: rgba(255, 255, 255, 0); } }
@media (prefers-reduced-motion: reduce) { #photo-frame.flash { animation: none; } }
body.no3d #view, body.no3d #photo-frame { display: none; }

button {
  font: inherit; color: var(--ink); background: var(--panel); cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px;
}
button:hover { background: rgba(60, 68, 76, 0.85); }
button:disabled { opacity: 0.5; cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
button[aria-pressed="true"] { background: var(--ink); color: #111; border-color: var(--ink); }

#top {
  position: fixed; left: 0; right: 0; top: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  padding: 8px 12px 18px; background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0));
}
#top .gap { flex: 1; }
#title { font-size: 15px; }
#state, #source { padding: 4px 10px; border-radius: 6px; background: var(--panel); }
#source.warn { color: var(--warn); }
#modes, #apps { display: inline-flex; }
#modes button, #apps button { border-radius: 0; margin-left: -1px; }
#modes button:first-child, #apps button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
#modes button:last-child, #apps button:last-child { border-radius: 0 6px 6px 0; }

#notice {
  position: fixed; left: 50%; top: calc(96px + var(--bar)); transform: translateX(-50%); text-align: center;
  max-width: min(80vw, max(320px, 100vw - 720px)); /* between the capture guide and the camera's buttons, where there is room */
  padding: 8px 16px; border-radius: 8px; background: var(--panel); font-size: 16px;
}
#loading {
  position: fixed; left: 50%; top: 45%; transform: translate(-50%, -50%); display: flex; flex-direction: column;
  align-items: center; gap: 8px; padding: 12px 18px; border-radius: 8px; background: var(--panel); text-align: center;
}
#loading progress { width: 240px; }

/* The capture guide stands above the map. */
#guide {
  position: fixed; left: 12px; top: calc(56px + var(--bar)); box-sizing: border-box; width: 330px; max-height: calc(100vh - 332px - var(--bar));
  overflow: auto; padding: 8px 12px 10px; border-radius: 8px; background: var(--panel);
}
body.bigmap #guide, body.no3d #guide { left: auto; right: 12px; max-height: calc(100vh - 286px - var(--bar)); } /* there the map has the left side */
#guide-head { display: flex; align-items: center; gap: 8px; }
#guide-head strong { flex: 1; text-align: center; font-size: 15px; }
#guide p { margin: 6px 0 8px; color: var(--dim); font-size: 13px; }
#guide-body button { display: flex; justify-content: space-between; gap: 10px; width: 100%; margin-top: 3px; text-align: left; font-size: 13px; }
#guide-body button span { color: var(--dim); white-space: nowrap; }
#guide table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
#guide th, #guide td { padding: 3px 8px 3px 0; text-align: left; white-space: nowrap; border-top: 1px solid rgba(255, 255, 255, 0.12); }
#guide tr:first-child th { border-top: 0; color: var(--dim); font-size: 12px; font-weight: normal; }
#guide th { font-weight: 600; }
#guide td.good { color: var(--good); }
#guide td.todo { color: var(--warn); }
#guide-foot { display: flex; gap: 8px; margin-top: 8px; }

/* The camera, where the aircraft's own app has it: the settings in use under the bar at the top,
   the buttons down the right side, and their menus beside them. */
#cam-bar {
  position: fixed; right: 12px; top: calc(56px + var(--bar)); max-width: calc(100vw - 366px); display: flex; flex-wrap: wrap; justify-content: flex-end;
  gap: 2px 14px; padding: 4px 12px; border-radius: 8px; background: var(--panel); font-size: 13px; font-variant-numeric: tabular-nums;
}
#cam-bar .good { color: var(--good); }
#cam-bar .todo { color: var(--warn); }
#camera {
  position: fixed; right: 12px; top: 50%; transform: translateY(-50%); width: 64px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
@media (max-width: 1080px) { #camera { top: calc(50% - 50px); } } /* the readouts stand at the right, under the camera */
#camera > button {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 56px; min-height: 40px; padding: 4px 0; font-size: 12px; font-weight: 600;
}
#camera button[aria-expanded="true"] { background: var(--ink); color: #111; border-color: var(--ink); }
#camera svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
#camera > #cam-shutter { position: relative; width: 60px; height: 60px; padding: 0; border: 3px solid var(--ink); border-radius: 50%; background: rgba(0, 0, 0, 0.35); }
#cam-shutter::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--ink); transition: inset 0.12s, border-radius 0.12s; }
#cam-shutter.video::before { background: #e5484d; }
#cam-shutter.busy::before { inset: 15px; border-radius: 4px; } /* a square: pressing it now stops */
#cam-shutter-text { position: relative; color: #111; font-size: 13px; font-weight: 700; }
#cam-taken { padding: 2px 6px; border-radius: 6px; background: var(--panel); color: var(--dim); font-size: 11px; text-align: center; font-variant-numeric: tabular-nums; }
#cam-taken strong { display: block; color: var(--ink); font-size: 15px; }
#cam-menu {
  position: fixed; right: 88px; top: 50%; transform: translateY(-50%); box-sizing: border-box; width: min(340px, 100vw - 100px);
  padding: 10px 14px 6px; border: 1px solid var(--line); border-radius: 10px; background: rgba(16, 20, 24, 0.96);
  z-index: 1; /* over the readouts, where a small window leaves it no room of its own */
}
#cam-menu h2 { margin: 0 0 6px; font-size: 15px; }
#cam-menu div { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 0 8px; border-top: 1px solid rgba(255, 255, 255, 0.12); }
#cam-menu span { flex: 0 0 100%; color: var(--dim); font-size: 12px; }
#cam-menu button { padding: 3px 9px; font-size: 13px; }
/* DJI Fly has the settings in use at the bottom right, over where the sticks are shown here; a
   narrow window has the readouts there, and the strip stays at the top. */
@media (min-width: 1081px) {
  body[data-app="fly"]:not(.bigmap):not(.no3d) #cam-bar { top: auto; bottom: 96px; }
}
/* With the map large or alone, the capture guide has the right side and the camera stands beside it. */
body.bigmap #cam-bar, body.no3d #cam-bar, body.bigmap #camera, body.no3d #camera { right: 354px; }
body.bigmap #cam-menu, body.no3d #cam-menu { right: 430px; }

#map {
  position: fixed; left: 12px; bottom: 12px; width: 240px; height: 240px; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 8px; background: var(--ground);
}
/* 344px: the room the readouts need on the map's right */
body.bigmap #map { width: max(180px, min(74vh, 100vw - 344px)); height: max(180px, min(74vh, 100vw - 344px)); }
body.no3d #map { left: 0; bottom: 0; width: 100vw; height: 100vh; border: 0; border-radius: 0; }

#telemetry {
  position: fixed; left: 264px; bottom: 12px; margin: 0; padding: 8px 12px; border-radius: 8px;
  display: grid; grid-template-columns: repeat(4, auto); gap: 2px 18px;
  background: var(--panel); font-variant-numeric: tabular-nums;
}
body.bigmap #telemetry, body.no3d #telemetry { left: auto; right: 12px; bottom: 96px; grid-template-columns: repeat(2, auto); }
@media (max-width: 1080px) { /* no room between the map and the sticks in a narrow window */
  #telemetry { left: auto; right: 12px; bottom: 96px; grid-template-columns: repeat(2, auto); }
}
@media (max-width: 600px) { /* nor for the map at its usual size */
  #map { width: 180px; height: 180px; }
}
#telemetry div { display: flex; align-items: baseline; gap: 6px; }
#telemetry dt { color: var(--dim); font-size: 12px; }
#telemetry dd { margin: 0; min-width: 4.6em; font-size: 16px; }

#sticks {
  position: fixed; right: 12px; bottom: 12px; width: 168px; height: 72px;
  padding: 4px; border-radius: 8px; background: var(--panel);
}

#help {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); box-sizing: border-box;
  width: min(760px, 94vw); max-height: 88vh; overflow: auto; padding: 14px 20px 18px;
  border: 1px solid var(--line); border-radius: 10px; background: rgba(16, 20, 24, 0.95);
  z-index: 2; /* over the camera's menu too */
}
#help h2 { margin: 0 0 8px; font-size: 18px; }
#help table { width: 100%; border-collapse: collapse; }
#help th, #help td { padding: 4px 10px 4px 0; text-align: left; vertical-align: top; border-top: 1px solid rgba(255, 255, 255, 0.12); }
#help tr:first-child th { border-top: 0; color: var(--dim); font-weight: normal; }
#help th { font-weight: 600; }
#help p { color: var(--dim); }
kbd {
  display: inline-block; min-width: 1.2em; padding: 0 5px; text-align: center; font: inherit;
  border: 1px solid var(--line); border-radius: 4px; background: rgba(255, 255, 255, 0.08);
}
#reverse { margin: 12px 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; }
#reverse label { display: inline-block; margin-right: 16px; white-space: nowrap; }
#map-key span { display: inline-block; width: 30px; margin: 0 4px 0 12px; vertical-align: middle; }
#map-key span:first-child { margin-left: 0; }
#map-key .dashed { border-top: 2px dashed var(--theirs); }
#map-key .solid { border-top: 2px solid var(--yours); }
