/* EgyptAir 990 replay: one screen. Graphite page, Boeing-grey instrument panel, report-style serif text. */
:root {
  --page: #1c1f21;
  --page-2: #23272a;
  --panel: #464d52;
  --panel-hi: #565e63;
  --panel-lo: #31363a;
  --ink: #e8e9e5;
  --muted: #a3abaf;
  --rule: #343a3e;
  --left: #ff9147;
  --right: #58d2f6;
  --amber: #ffb43a;
  --deck-h: clamp(250px, 40vh, 400px);
  --serif: "Bitstream Charter", "Charter", "Noto Serif", Georgia, serif;
  --cond: "Open Sans Condensed", "DejaVu Sans Condensed", "Liberation Sans Narrow", "Arial Narrow", sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--page); color: var(--ink); }
body { margin: 0; font: 16px/1.5 var(--serif); }
a { color: #cfe3ec; text-underline-offset: 3px; }
a:hover { color: #fff; }
:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; margin: 0; }
.subtle { color: var(--muted); font-size: .86rem; }

/* one-screen grid */
.app {
  height: 100vh; height: 100dvh; display: grid; gap: 10px 14px; padding: 10px 16px 12px;
  grid-template-columns: minmax(0, 1fr) clamp(240px, 19vw, 310px);
  grid-template-rows: auto minmax(0, 1fr) var(--deck-h) auto;
  grid-template-areas: "head head" "stage events" "deck events" "transport events";
}

/* masthead */
.masthead { grid-area: head; display: flex; align-items: center; gap: 22px; border-bottom: 1px solid var(--rule); padding-bottom: 8px; }
.title { flex: 1; min-width: 0; }
.masthead h1 { font-size: 1.7rem; line-height: 1.1; letter-spacing: -.01em; }
.lede { margin: 2px 0 0; color: #c4cacb; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clockface { font-family: var(--cond); text-align: right; }
#clock { display: block; font: 600 2.1rem/1 var(--cond); font-variant-numeric: tabular-nums; }
.clockmeta { display: flex; justify-content: flex-end; gap: 10px; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.status { font-family: var(--cond); min-width: 230px; }
.phase { font-size: .95rem; color: #9fe3b4; }
.phase.post { color: var(--amber); }
#elapsed { font-family: var(--cond); font-variant-numeric: tabular-nums; }
.weather { font: 12.5px var(--cond); color: #a9c4d6; max-width: 360px; }

/* 3-D view */
.stage { grid-area: stage; min-height: 0; }
.viewport { position: relative; height: 100%; border-radius: 6px; overflow: hidden; background: #0b1016; }
#aircraft, #callouts { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#aircraft { cursor: grab; touch-action: none; }
#aircraft:active { cursor: grabbing; }
#callouts { pointer-events: none; }
.views { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); display: flex; gap: 2px; padding: 3px; background: rgba(10, 14, 18, .72); border-radius: 6px; }
.views button { background: transparent; color: #c9d0d3; border: 0; padding: 4px 10px; border-radius: 4px; font: 600 13px var(--cond); cursor: pointer; }
.views button[aria-pressed="true"] { background: var(--ink); color: #15191b; }

.views button:hover { color: #fff; }
.views button[aria-pressed="true"]:hover { color: #15191b; }
.subs { position: absolute; left: 50%; bottom: 30px; transform: translateX(-50%); width: min(62%, 760px); display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.sub { background: rgba(4, 6, 8, .82); border-radius: 4px; padding: 5px 12px 6px; text-align: center; font: 600 17px/1.3 var(--cond); color: #fff; }
.sub .who { display: block; font-size: 13.5px; color: #c9d6dc; font-weight: 700; letter-spacing: .01em; }
.sub .who .code { font-weight: 400; color: #7f8f97; font-size: 11.5px; }
.sub.capt { border-left: 4px solid #8fd3ff; } .sub.capt .who { color: #8fd3ff; }
.sub.relief { border-left: 4px solid #ffb38a; } .sub.relief .who { color: #ffb38a; }
.sub.fo { border-left: 4px solid #b9e59a; } .sub.fo .who { color: #b9e59a; }
.sub .ar { display: block; font: 600 19px/1.35 "Noto Naskh Arabic", "Noto Sans Arabic", "DejaVu Sans", sans-serif; color: #ffe7b0; }
.sub.sfx { font-weight: 400; font-style: italic; color: #c3ccd0; font-size: 14.5px; }
.ffnote[hidden], .prologue[hidden] { display: none; }
.prologue { position: absolute; inset: 0; display: grid; place-items: start center; padding-top: 56px; background: rgba(4, 8, 12, .72); pointer-events: none; }
.prologue-card { pointer-events: auto; max-width: 560px; padding: 14px 18px; border-radius: 6px; background: rgba(14, 20, 26, .92); border: 1px solid #39434a; }
.prologue-card h2 { font-size: 1.15rem; margin-bottom: 4px; }
.prologue-note { color: #ffd38a !important; font-weight: 600; }
.prologue-card p { margin: 0 0 10px; font-size: .92rem; color: #cdd5d8; }
body.in-prologue .deck { opacity: .45; }
.ffnote { position: absolute; left: 50%; bottom: 34px; transform: translateX(-50%); margin: 0; padding: 6px 16px; border-radius: 4px; background: rgba(20, 60, 90, .88); color: #e4f4ff; font: 700 15px var(--cond); white-space: nowrap; pointer-events: none; }
#guided[aria-pressed="false"], #evpause[aria-pressed="false"] { color: var(--muted); }
.pip { position: absolute; right: 12px; bottom: 30px; width: clamp(190px, 21%, 320px); aspect-ratio: 16 / 10; margin: 0; border-radius: 6px; overflow: hidden; border: 1px solid #4a555c; box-shadow: 0 6px 18px rgba(0, 0, 0, .5); background: #0b1016; }
.pip[hidden] { display: none; }
.pip canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pip figcaption { position: absolute; left: 8px; top: 6px; font: 600 11.5px var(--cond); color: #cfd8dc; background: rgba(0, 0, 0, .45); padding: 1px 6px; border-radius: 3px; }
.viewnote { position: absolute; left: 50%; transform: translateX(-50%); bottom: 6px; white-space: nowrap; margin: 0; color: #8e989d; font: 12px var(--cond); pointer-events: none; }
.nowebgl[hidden], .aural[hidden] { display: none; }
.aural { position: absolute; left: 50%; top: 50px; transform: translateX(-50%); margin: 0; padding: 5px 14px; border-radius: 4px; font: 700 14px var(--cond); color: #fff; background: rgba(200, 30, 30, .88); white-space: nowrap; pointer-events: none; }
.aural.caution { background: rgba(214, 140, 20, .9); color: #111; }
#sound[aria-pressed="false"] { color: var(--muted); }
.nowebgl { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 24px; text-align: center; color: var(--muted); }

/* instrument deck: alert lights above one row of instruments */
.deck {
  grid-area: deck; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 8px 10px 10px; border-radius: 8px;
  background: linear-gradient(180deg, var(--panel-hi), var(--panel) 18%, var(--panel) 82%, var(--panel-lo));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), inset 0 -2px 0 rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .35);
}
.insts { flex: 1 1 auto; min-height: 0; display: flex; gap: 10px; }
.glare { display: flex; gap: 6px; flex-wrap: nowrap; overflow: hidden; }
.annun { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3px 4px; border-radius: 3px; background: #1c2023; border: 1px solid #3a4146; font-family: var(--cond); line-height: 1.05; color: #8a949a; text-align: center; }
.annun b { font-size: 11.5px; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.annun i { font-style: normal; font-size: 10.5px; opacity: .85; white-space: nowrap; }
.annun.on.red { background: #c8231f; color: #fff; border-color: #ff6a64; box-shadow: 0 0 12px rgba(255, 60, 50, .55); }
.annun.on.amber { background: #e39a12; color: #1b1406; border-color: #ffc552; box-shadow: 0 0 12px rgba(255, 180, 40, .45); }
.annun.on.green { background: #1d6f3b; color: #dfffe9; border-color: #4fd283; }
.annun.nodata { background: repeating-linear-gradient(45deg, #1a1d1f 0 6px, #202427 6px 12px); }
.inst { margin: 0; min-width: 0; min-height: 0; display: flex; flex-direction: column; flex: 1 1 0; }
.inst canvas { display: block; width: 100%; flex: 1 1 auto; min-height: 0; }
.inst figcaption { margin-top: 4px; font: 12px/1.2 var(--cond); color: #dfe3e2; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adi { flex-grow: 1.1; } .eng { flex-grow: 1.05; } .fctl { flex-grow: 1.7; } .hsi { flex-grow: .8; } .stand { flex-grow: .9; }

/* transport and timeline strip */
.transport { grid-area: transport; min-width: 0; }
.controls { display: flex; align-items: center; gap: 6px; font-family: var(--cond); }
button, select { font: 600 14px var(--cond); color: var(--ink); background: var(--page-2); border: 1px solid #40474c; border-radius: 5px; padding: 5px 11px; cursor: pointer; }
button:hover, select:hover { border-color: #6b757a; }
button.primary { background: var(--ink); color: #15191b; border-color: var(--ink); min-width: 72px; }
button.quiet { background: transparent; }
.speed { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 6px; margin-right: 6px; }
.samplenote { flex: 1; min-width: 0; margin: 0 0 0 8px; font: 12.5px var(--cond); color: var(--muted); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip { position: relative; height: 66px; margin-top: 8px; border-radius: 5px; background: #15191b; }
.strip:focus-within { outline: 2px solid #fff; outline-offset: 2px; }
#profile { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#scrub { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; }

/* events */
.events { grid-area: events; min-height: 0; display: flex; flex-direction: column; border-left: 1px solid var(--rule); padding-left: 14px; }
.selected-event { padding: 2px 0 10px; border-bottom: 1px solid var(--rule); }
.selected-event h2 { font-size: 1.02rem; line-height: 1.3; }
.selected-event p { margin: .3rem 0; font-size: .92rem; }
.srcline { font-size: .85rem !important; }
.events ol { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; min-height: 0; }
.event { display: grid; grid-template-columns: 66px 1fr; gap: 0 8px; width: 100%; text-align: left; padding: 6px 6px 6px 9px; border: 0; border-bottom: 1px solid var(--rule); border-radius: 0; background: transparent; font: inherit; color: inherit; border-left: 3px solid transparent; }
.event:hover { background: rgba(255, 255, 255, .03); }
.event.active { border-left-color: var(--ink); background: rgba(255, 255, 255, .07); }
.event-time { grid-row: span 2; font: 600 13px var(--cond); font-variant-numeric: tabular-nums; color: #d5dad9; padding-top: 1px; }
.event-title { font-size: .88rem; line-height: 1.25; }
.event-basis { font: 11.5px var(--cond); color: var(--muted); }

/* about dialog */
dialog { max-width: min(980px, 94vw); max-height: 88vh; padding: 22px 26px; border: 1px solid #40474c; border-radius: 8px; background: var(--page-2); color: var(--ink); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { font-size: 1.35rem; margin-bottom: 12px; }
dialog h3 { font-size: 1rem; margin-bottom: .4rem; }
.aboutclose { float: right; }
.methodgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.methodgrid p { margin: 0 0 .7rem; color: #d3d7d7; max-width: 66ch; }
.livery { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 6px 0 14px; font-family: var(--cond); }
.filebtn { position: relative; overflow: hidden; display: inline-block; font: 600 14px var(--cond); background: var(--page-2); border: 1px solid #40474c; border-radius: 5px; padding: 5px 11px; cursor: pointer; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.filebtn:focus-within { outline: 2px solid #fff; outline-offset: 2px; }
.sources { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 14px 0 8px; font-family: var(--cond); }

/* small or short screens: stack and scroll */
@media (max-width: 1100px), (max-height: 660px) {
  .app { height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-template-areas: "head" "stage" "transport" "deck" "events"; }
  .viewport { height: auto; aspect-ratio: 16 / 9; }
  .masthead { flex-wrap: wrap; }
  .status { min-width: 0; }
  .insts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 230px; }
  .glare { flex-wrap: wrap; } .annun { flex-basis: 30%; }
  .subs { width: 92%; }
  .events { border-left: 0; padding-left: 0; }
  .events ol { max-height: 50vh; }
  .controls { flex-wrap: wrap; }
  .samplenote { flex-basis: 100%; text-align: left; margin: 4px 0 0; white-space: normal; }
}
@media (max-width: 640px) {
  .insts { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 210px; }
  .views { flex-wrap: wrap; justify-content: center; width: calc(100% - 20px); }
  .viewport { aspect-ratio: 4 / 3.6; }
  .viewnote { display: none; }
  .pip { width: 42%; bottom: 12px; }
  .methodgrid { grid-template-columns: 1fr; }
  .lede { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }


/* Full-stage 767 captain view; numeric indications come from the FDR. */
.pip { inset: 0; width: 100%; height: 100%; aspect-ratio: auto; border: 0; border-radius: 0; z-index: 2; }
.pip #cockpit-frame { visibility: hidden; }
.pip #cockpit-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pip figcaption { z-index: 5; left: 12px; top: 48px; color: #e0e8ea; }
.views { z-index: 8; }
.subs, .ffnote, .aural, .prologue { z-index: 6; }
.cockpit-gauge { position: absolute; z-index: 4; overflow: hidden; }
.pip .cockpit-gauge canvas { position: static; width: 100%; height: 100%; display: block; }
.cp-asi { left: 3%; top: 64%; width: 13%; height: 29%; }
.cp-adi { left: 18%; top: 63%; width: 13%; height: 15%; }
.cp-hdg { left: 18%; top: 79%; width: 13%; height: 17%; }
.cp-alt { left: 33%; top: 64%; width: 13%; height: 29%; }
.cp-eng { left: 48%; top: 63%; width: 16%; height: 31%; }
.cp-fctl { left: 66%; top: 63%; width: 19%; height: 31%; }
.cp-stand { left: 87%; top: 63%; width: 11%; height: 31%; }
.cockpit-status { position: absolute; z-index: 5; left: 50%; bottom: 2px; transform: translateX(-50%); margin: 0; padding: 1px 8px; border-radius: 3px; background: rgba(0,0,0,.7); color: #f0d58d; font: 600 11px var(--cond); text-align: center; white-space: nowrap; }

@media (max-width: 640px) {
  .pip { inset: 0; width: 100%; height: 100%; }
  .pip figcaption { top: 78px; font-size: 10px; }
  .cockpit-status { font-size: 9px; width: 95%; white-space: normal; }
}

/* Keep the cockpit in the original side inset. */
.pip {
  inset: auto; right: 12px; bottom: 30px;
  width: clamp(190px, 21%, 320px); height: auto; aspect-ratio: 16 / 10;
  border: 1px solid #4a555c; border-radius: 6px;
}
.pip figcaption { left: 8px; top: 6px; font-size: 11px; }
.cockpit-status { font-size: 8px; width: 96%; white-space: normal; }
@media (max-width: 640px) {
  .pip { inset: auto; right: 12px; bottom: 12px; width: 42%; height: auto; }
  .pip figcaption { top: 6px; font-size: 9px; }
}

/* Inset: keep only the primary flight and engine instruments readable. */
.pip { width: clamp(260px, 29%, 380px); max-width: calc(100% - 24px); }
.cp-hdg, .cp-fctl, .cp-stand { display: none; }
.cp-asi, .cp-adi, .cp-alt, .cp-eng { top: 63%; width: 21.5%; height: 31%; }
.cp-asi { left: 2.8%; }
.cp-adi { left: 26.5%; }
.cp-alt { left: 50.2%; }
.cp-eng { left: 73.9%; }
@media (max-width: 640px) { .pip { width: min(70%, 380px); } }
/* cockpit window: click to fill the 3-D view */
.pip { cursor: zoom-in; }
.pip.large { left: 0 !important; top: 0 !important; right: 0 !important; bottom: 0 !important; width: auto !important; height: auto !important; aspect-ratio: auto !important; border-radius: 6px; z-index: 6; cursor: zoom-out; }
.pip #cockpit-frame { visibility: visible; }
/* review fixes */
.events ol { position: relative; }
.piptoggle { position: absolute; right: 12px; top: 10px; z-index: 7; padding: 4px 10px; border-radius: 6px; background: rgba(10, 14, 18, .72); border: 1px solid #3a444a; color: #c9d0d3; font: 600 13px var(--cond); }
.piptoggle[aria-pressed="true"] { background: var(--ink); color: #15191b; }
.pip { top: 46px; }
.pip.nodata { display: none; }
.viewport:has(.pip.large) .views { display: none; }
dialog { overflow-y: auto; }
.findings { margin: 0 0 .7rem; color: #d3d7d7; max-width: 92ch; }
