/* Burn: the look of a flight-test film (SPEC §2, §12). Black glass and HUD green in flight, amber cautions,
   and mission paperwork for the cards: the flight plan before, the flight test report after. */
:root {
  color-scheme: dark;
  --glass: rgba(6, 10, 14, .6);
  --edge: rgba(214, 255, 232, .14);
  --ink: #eef4f0;
  --dim: #9fb3aa;
  --hud: #86ffae;
  --amber: #ffb547;
  --paper: #f1ece0;
  --paper-line: #d6cdbb;
  --paper-ink: #1f232a;
  --paper-dim: #6c675d;
  --stamp: #c2302a;
  --data: "B612 Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ui: "B612", "Segoe UI", system-ui, sans-serif;
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --st: env(safe-area-inset-top, 0px);
  --sr: env(safe-area-inset-right, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px);
}
html, body { margin: 0; height: 100%; overflow: hidden; background: #04060a; color: var(--ink); font-family: var(--ui); user-select: none; -webkit-user-select: none; }
[hidden] { display: none !important; }
#view, #hud { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#view { touch-action: none; }
#hud { pointer-events: none; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd { font: 700 10px var(--data); background: rgba(0, 0, 0, .08); border: 1px solid rgba(0, 0, 0, .18); border-radius: 3px; padding: 1px 5px; }
.panel { position: fixed; box-sizing: border-box; background: var(--glass); border: 1px solid var(--edge); border-radius: 6px; padding: 10px 14px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.k { font: 700 10px/1.2 var(--ui); letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }

#mission { top: calc(14px + var(--st)); left: calc(14px + var(--sl)); }
#mission .sub { font-size: 12px; color: var(--dim); margin-top: 3px; }
#mission .phase { margin-top: 8px; font: 600 22px/1 var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--hud); }
#side { position: fixed; top: calc(14px + var(--st)); right: calc(14px + var(--sr)); display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#side .panel { position: static; }
#clock { text-align: right; padding: 8px 14px; }
#clock .warp { font: 600 30px/1 var(--display); color: var(--hud); }
#clock .met { font: 400 13px var(--ui); font-variant-numeric: tabular-nums; margin-top: 3px; }
#clock .fps { font: 400 11px var(--data); color: var(--dim); margin-top: 3px; }
#map-wrap { padding: 4px; }
#map { display: block; width: 200px; height: 200px; }

#call { position: fixed; left: 50%; top: 24%; transform: translateX(-50%); font: 700 17px var(--ui); letter-spacing: .3em; padding: 5px 8px 5px 14px; color: var(--hud);
  text-shadow: 0 0 8px rgba(80, 255, 150, .6), 0 1px 3px rgba(0, 0, 0, .8); opacity: 0; transition: opacity .25s; pointer-events: none; white-space: nowrap; }
#call.on { opacity: 1; }
#call.warn { color: var(--amber); border: 2px solid var(--amber); border-radius: 3px; background: rgba(20, 10, 0, .35); text-shadow: none; }
body.carded #call, body.carded #touch, body.carded #hud, body.carded #radio { display: none; }

/* Control on the radio, bracketed by the Quindar tones' marks; static in the blackout */
#radio { left: 50%; bottom: calc(18px + var(--sb)); transform: translateX(-50%); width: max-content; max-width: min(620px, calc(100vw - 28px)); display: flex; gap: 10px;
  align-items: center; padding: 7px 14px; opacity: 0; transition: opacity .35s; pointer-events: none; }
#radio.on { opacity: 1; }
#radio .who { font: 700 10px var(--ui); letter-spacing: .16em; text-transform: uppercase; color: var(--amber); flex: none; }
#radio .say { font-size: 14px; line-height: 1.35; }
#radio .q { width: 5px; height: 5px; border-radius: 50%; background: var(--hud); box-shadow: 0 0 6px var(--hud); flex: none; opacity: .25; }
#radio.on .q { animation: quindar .25s 2 alternate; }
#radio.static .say { color: var(--dim); font-style: italic; }
#radio.static .q { background: var(--dim); box-shadow: none; animation: none; }
@keyframes quindar { to { opacity: 1; } }
body.touch #radio { bottom: calc(170px + var(--sb)); }
/* a phone on its side: low down, between the stick and the buttons */
@media (orientation: landscape) and (max-height: 520px) {
  body.touch #radio { bottom: calc(14px + var(--sb)); max-width: calc(100vw - 2 * (180px + max(var(--sl), var(--sr)))); }
  body.touch #radio .say { font-size: 12px; }
}

/* the cards: paperwork */
.card { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-.4deg); width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  overflow: auto; box-sizing: border-box; padding: 18px 22px 18px; border-radius: 2px; }
.paper { background: var(--paper); color: var(--paper-ink); box-shadow: 0 24px 60px rgba(0, 0, 0, .55), 0 2px 0 #d9d1bf; font: 13px/1.45 var(--ui); user-select: text; -webkit-user-select: text; }
.paper .head { display: flex; justify-content: space-between; font: 700 10px var(--ui); letter-spacing: .16em; text-transform: uppercase; color: var(--paper-dim);
  border-bottom: 2px solid var(--paper-ink); padding-bottom: 6px; }
.paper h1 { font: 700 54px/0.95 var(--display); letter-spacing: .06em; text-transform: uppercase; margin: 12px 0 4px; }
.paper h2 { font: 600 30px/1 var(--display); text-transform: uppercase; letter-spacing: .03em; margin: 12px 0 4px; text-wrap: balance; }
.paper .lede { font-size: 15px; margin: 0 0 10px; text-wrap: pretty; }
.paper .k { color: var(--paper-dim); }
.plan { width: 100%; border-collapse: collapse; margin: 6px 0 10px; font: 12px/1.35 var(--data); }
.plan td { padding: 4px 0; border-bottom: 1px solid var(--paper-line); vertical-align: top; }
.plan td:first-child { font: 700 10px/1.6 var(--ui); letter-spacing: .12em; text-transform: uppercase; color: var(--paper-dim); white-space: nowrap; padding-right: 12px; }
.plan small { color: var(--paper-dim); }
.how { margin: 0 0 10px; padding-left: 18px; font-size: 12.5px; }
.how li { margin: 4px 0; }
.keys { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 11.5px; color: var(--paper-dim); margin: 8px 0 12px; }
.keys kbd { color: var(--paper-ink); margin-right: 2px; }
body.touch .keys { display: none; }
.row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 6px 0 12px; }
.row .k { margin-right: 6px; }
.seg { background: transparent; border: 1px solid var(--paper-line); border-radius: 3px; padding: 4px 10px; font: 700 11px var(--ui); color: var(--paper-ink); }
.seg.on { background: var(--paper-ink); color: var(--paper); border-color: var(--paper-ink); }
.go, .alt { display: block; width: 100%; padding: 11px; border-radius: 3px; font: 600 20px/1 var(--display); letter-spacing: .14em; text-transform: uppercase; }
.go { background: var(--paper-ink); color: var(--paper); border: 0; }
.alt { background: transparent; color: var(--paper-ink); border: 2px solid var(--paper-ink); }
.buttons { display: grid; gap: 8px; }
.go:focus-visible, .alt:focus-visible, .seg:focus-visible { outline: 3px solid var(--stamp); outline-offset: 2px; }
.card.wide { width: min(620px, calc(100vw - 32px)); }
.buttons.two { grid-template-columns: 1fr 2fr; }
.buttons.three { grid-template-columns: 2fr 1.4fr 1.4fr; }
.paper .note { margin: -6px 0 10px; font-size: 12px; color: var(--paper-dim); text-wrap: pretty; }

/* the mission board: one row a mission, its medal on the right */
.board { list-style: none; margin: 4px 0 8px; padding: 0; display: grid; gap: 6px; }
.mission { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 10px;
  background: rgba(255, 255, 255, .35); border: 1px solid var(--paper-line); border-radius: 3px; color: var(--paper-ink); }
.mission:hover:not(:disabled) { background: rgba(255, 255, 255, .7); }
.mission:focus-visible { outline: 3px solid var(--stamp); outline-offset: 2px; }
.mission:disabled { opacity: .55; cursor: default; }
.mission .n { font: 700 26px/1 var(--display); text-align: center; color: var(--paper-dim); }
.mission .nm { display: flex; flex-direction: column; min-width: 0; }
.mission b { font: 600 19px/1.1 var(--display); letter-spacing: .05em; text-transform: uppercase; }
.mission small { font-size: 11.5px; color: var(--paper-dim); }
.mission .medal { display: flex; align-items: center; gap: 8px; font: 700 12px var(--data); color: var(--paper-dim); white-space: nowrap; }
.mission.free { margin-bottom: 4px; }
.badge { width: 22px; height: 22px; border-radius: 50%; border: 2px dashed var(--paper-line); box-sizing: border-box; }
.badge.bronze { background: #b06a3b; border: 2px solid #7d4626; }
.badge.silver { background: #b8bcc2; border: 2px solid #80858c; }
.badge.gold { background: #d9b13b; border: 2px solid #9c7a17; }

/* the report: the grade stamped in the corner, the score by part, and the profile */
#end { position: fixed; }
#end .why { margin: 4px 0 8px; font-size: 14px; text-wrap: pretty; padding-right: 120px; }
#end .best { margin: -4px 0 8px; font: 700 11px var(--ui); letter-spacing: .14em; text-transform: uppercase; color: #1f8a4a; }
#end .stamp { position: absolute; right: 22px; top: 40px; display: flex; flex-direction: column; align-items: center; min-width: 62px; padding: 6px 10px 4px; border: 3px solid #1f8a4a;
  color: #1f8a4a; border-radius: 4px; font: 700 15px/1 var(--display); letter-spacing: .1em; transform: rotate(-9deg); opacity: .88; mix-blend-mode: multiply; }
#end .stamp .g { font-size: 48px; line-height: .9; }
#end.lost .stamp { color: var(--stamp); border-color: var(--stamp); }
.plan.score td:nth-child(2) { color: var(--paper-dim); font-size: 11.5px; }
.plan.score td:last-child { text-align: right; white-space: nowrap; padding-left: 10px; }
.plan.score tr.total td { border-bottom: 0; font: 700 13px var(--data); color: var(--paper-ink); padding-top: 6px; }
.profile { margin: 4px 0 12px; }
.profile canvas { display: block; width: 100%; height: 170px; }
.profile figcaption { display: flex; gap: 6px 14px; align-items: center; font-size: 11px; color: var(--paper-dim); margin-top: 3px; }
.profile i { display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--stamp); margin-right: -8px; vertical-align: middle; }
.profile i.guided { border-top: 2px dashed var(--paper-dim); }
@media (max-width: 520px) {
  /* the score's detail under its name, the points on the right */
  .plan.score tr { display: grid; grid-template-columns: 1fr auto; border-bottom: 1px solid var(--paper-line); }
  .plan.score td { border-bottom: 0; padding: 2px 0; }
  .plan.score td:nth-child(2) { grid-column: 1; grid-row: 2; padding-bottom: 5px; }
  .plan.score td:last-child { grid-column: 2; grid-row: 1; }
  .buttons.three { grid-template-columns: 1fr 1fr; }
  .buttons.three .go { grid-column: span 2; }
  .paper h1 { font-size: 44px; }
  #end .why { padding-right: 90px; }
  #end .stamp .g { font-size: 38px; }
}

/* touch: a stick under the left thumb, coming to wherever it lands in its zone; buttons and the speed brake's
   slider under the right; or tilt, with a dot showing it */
#touch { display: none; }
body.touch:not(.carded) #touch { display: block; }
#t-zone { position: fixed; left: 0; bottom: 0; width: 48vw; height: 58vh; touch-action: none; }
#t-stick { position: fixed; left: calc(24px + var(--sl)); bottom: calc(24px + var(--sb)); width: 130px; height: 130px; border-radius: 50%; border: 2px solid var(--edge);
  background: rgba(6, 10, 14, .35); pointer-events: none; transition: opacity .2s; opacity: .7; }
#t-stick.on { opacity: 1; }
body.tilt #t-zone, body.tilt #t-stick { display: none; }
#t-tilt { display: none; position: fixed; left: calc(24px + var(--sl)); bottom: calc(24px + var(--sb)); width: 84px; height: 84px; border-radius: 50%; border: 2px dashed var(--edge); pointer-events: none; }
body.tilt #t-tilt { display: block; }
#t-tilt span { position: absolute; left: 0; right: 0; bottom: -18px; text-align: center; font: 700 10px var(--ui); letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
#t-dot { position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: var(--hud); }
#t-sb { position: fixed; right: calc(20px + 138px + 12px + var(--sr)); bottom: calc(24px + var(--sb)); width: 44px; height: 114px; border-radius: 8px; border: 1px solid var(--edge);
  background: var(--glass); overflow: hidden; touch-action: none; }
#t-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(134, 255, 174, .55); }
#t-sb.auto #t-fill { background: rgba(134, 255, 174, .22); }
#t-sb.on { border-color: var(--hud); }
#t-sb span { position: absolute; left: 0; right: 0; top: 6px; text-align: center; font: 700 11px var(--ui); letter-spacing: .08em; text-transform: uppercase; }
#t-sb .gnd, body.ground #t-sb .air { display: none; }
body.ground #t-sb .gnd { display: block; }
body.orbit #t-sb { display: none; }
#t-knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: rgba(134, 255, 174, .35); border: 2px solid var(--hud); }
#t-buttons { position: fixed; right: calc(20px + var(--sr)); bottom: calc(24px + var(--sb)); display: grid; grid-template-columns: repeat(2, 64px); gap: 10px; }
#t-buttons button { height: 52px; border-radius: 8px; border: 1px solid var(--edge); background: var(--glass); font: 700 12px var(--ui); letter-spacing: .08em; text-transform: uppercase; touch-action: none; }
#t-buttons button.on { background: var(--hud); color: #08140d; }
#t-burn { display: none; grid-column: span 2; }
body.orbit #t-burn { display: block; }
body.orbit #t-gear { display: none; }   /* nothing to lower in orbit */
#t-chute { display: none; }
body.ground #t-chute { display: block; }   /* the chute in place of the gear, once it's down */
body.ground #t-gear { display: none; }

@media (prefers-reduced-motion: reduce) { #call, #radio { transition: none; } #radio.on .q { animation: none; } }
@media (max-width: 700px), (max-height: 520px) {
  #map { width: 130px; height: 130px; }
  #mission .sub { display: none; }
  #mission .phase { font-size: 17px; }
  #clock .warp { font-size: 22px; }
}

/* settings that only mean something on a phone */
.touch-only { display: none; }
body.touch .touch-only { display: flex; }
body.touch p.touch-only { display: block; }
.buttons.one { grid-template-columns: 1fr; }

/* the beach cut: a caption low on the left, as a film's, with the flight's panels put away */
#cut { position: fixed; left: calc(24px + var(--sl)); bottom: calc(28px + var(--sb)); display: none; flex-direction: column; gap: 4px; pointer-events: none; text-shadow: 0 1px 3px rgba(0, 0, 0, .75); }
body.cut #cut { display: flex; animation: cut-in .5s ease-out; }
#cut .k { color: var(--amber); }
#cut-where { font: 600 24px/1.1 var(--display); letter-spacing: .06em; text-transform: uppercase; }
#cut .skip { font-size: 11px; color: var(--dim); }
body.cut #hud, body.cut #mission, body.cut #side, body.cut #radio, body.cut #call, body.touch.cut #touch { display: none; }
@keyframes cut-in { from { opacity: 0; transform: translateY(6px); } }

/* the replay: play and pause, where in the run, the moments to jump to, the speed and the view */
#replay { display: none; left: 50%; bottom: calc(14px + var(--sb)); transform: translateX(-50%); width: min(780px, calc(100vw - 28px)); padding: 8px 10px; flex-direction: column; gap: 8px; }
body.replay:not(.carded) #replay { display: flex; }
body.touch.replay #touch { display: none; }
body.replay #radio { bottom: calc(112px + var(--sb)); }
.rp-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#rp-seek { flex: 1; min-width: 120px; accent-color: var(--hud); }
#rp-time { font: 400 12px var(--data); color: var(--dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.rp-b { background: transparent; border: 1px solid var(--edge); border-radius: 4px; padding: 6px 10px; font: 700 11px var(--ui); letter-spacing: .1em; text-transform: uppercase; color: var(--ink); }
#rp-play { min-width: 70px; color: var(--hud); border-color: rgba(134, 255, 174, .45); }
.rp-marks { display: flex; gap: 4px; flex-wrap: wrap; flex: 1 1 260px; }
.rp-tools { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.rp-speed { display: flex; gap: 2px; }
#replay .seg { color: var(--ink); border-color: var(--edge); }
#replay .seg.on { background: var(--hud); color: #08140d; border-color: var(--hud); }
.rp-b:focus-visible, #replay .seg:focus-visible, #rp-seek:focus-visible { outline: 2px solid var(--hud); outline-offset: 2px; }

/* the report's four buttons: Try again widest; two to a row on a phone */
.buttons.four { display: flex; gap: 8px; }
.buttons.four > * { flex: 1.3 1 0; min-width: 0; }
.buttons.four .go { flex-grow: 2; }
@media (max-width: 520px) {
  .buttons.four { flex-wrap: wrap; }
  .buttons.four > * { flex: 1 1 40%; }
  .buttons.four .go { flex-basis: 100%; }
}
