/* OpenWorldEngineer: the Aircraft artifact page (artifacts-aircraft.html, assets/art/aircraft.js). Builds on styles.css
   (tokens, .card, .seg, .select, .btn, .note) and adds only ac- classes.

   Part colours (the 3D view reads the --ac-* properties at mount and on every theme change). Three hues tell the
   moving and carried parts apart, checked with the dataviz palette validator all-pairs (any two parts can touch):
   light #2A78D6 / #F25500 / #1BAF7A on #F3F4F5 (worst CVD ΔE 10.6, normal-vision 24.0; the aqua sits under 3:1, so
   every part is also named in the legend and on hover), dark #3987E5 / #D95926 / #199E70 on #0F1012 (CVD 9.4,
   normal 20.9, all ≥ 3:1). The airframe, structure and equipment stay in neutral greys. */

.ac {
  container-type: inline-size;
  --ac-view: var(--bg);
  --ac-air: #C5C9CF;        /* wing, tails, fuselage */
  --ac-struct: #6B7078;     /* spars, longerons, joiner */
  --ac-ctl: #F25500;        /* control surfaces, bay door */
  --ac-gear: #2A78D6;       /* landing gear */
  --ac-pay: #1BAF7A;        /* cargo blocks and packages */
  --ac-power: #3A3F45;      /* motor, battery, ESC */
  --ac-sys: #8A9098;        /* servos, avionics, release */
  --ac-link: #15171A;       /* servo arms, pushrods, horns */
  --ac-prop: #5E636A;       /* propeller disc */
  --ac-ground: #E7E9EC;
  --ac-grid: #D5D8DC;
  --ac-runway: #B4B9BF;
  --ac-mark: #FFFFFF;       /* runway paint */
  --ac-pylon: #2D3136;
  --ac-fline: #D7191F;      /* the flight line */
  --ac-trail: #2D3136;
  --ac-ahead: #B4B9BF;
  --ac-vp-h: clamp(380px, calc(100svh - 300px), 680px);
  display: grid; gap: 16px; min-width: 0; color: var(--ink); font-size: var(--fs-ui);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ac {
    --ac-air: #6E737B; --ac-struct: #A3A8AF; --ac-ctl: #D95926; --ac-gear: #3987E5; --ac-pay: #199E70;
    --ac-power: #CDD0D5; --ac-sys: #959AA2; --ac-link: #F2F3F5; --ac-prop: #A3A8AF;
    --ac-ground: #17181B; --ac-grid: #26282C; --ac-runway: #3A3D42; --ac-mark: #C9CCD1; --ac-pylon: #E4E6E9;
    --ac-fline: #FF4757; --ac-trail: #E4E6E9; --ac-ahead: #4A4E54;
  }
}
:root[data-theme="dark"] .ac {
  --ac-air: #6E737B; --ac-struct: #A3A8AF; --ac-ctl: #D95926; --ac-gear: #3987E5; --ac-pay: #199E70;
  --ac-power: #CDD0D5; --ac-sys: #959AA2; --ac-link: #F2F3F5; --ac-prop: #A3A8AF;
  --ac-ground: #17181B; --ac-grid: #26282C; --ac-runway: #3A3D42; --ac-mark: #C9CCD1; --ac-pylon: #E4E6E9;
  --ac-fline: #FF4757; --ac-trail: #E4E6E9; --ac-ahead: #4A4E54;
}
.ac-head p { max-width: 78ch; }
.ac-quiet { margin: 0; padding: 18px 0; color: var(--muted); }
.ac-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* picker: model, attempt, view; then whose aircraft it is */
.ac-pick { display: grid; gap: 14px; padding: 16px 18px 18px; min-width: 0; }
.ac-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; min-width: 0; }
.ac-field { display: grid; gap: 4px; min-width: 0; }
.ac-field-k { font-size: 0.75rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.ac-seg { padding: 2px; flex-wrap: wrap; }
.ac-seg button { padding: 6px 12px; font-size: 0.8125rem; white-space: nowrap; }
.ac-seg button:focus-visible { outline-offset: -2px; }
.ac-seg button:disabled { cursor: default; opacity: 0.55; }
.ac-att button { display: inline-flex; align-items: baseline; gap: 6px; }
.ac-att b { font-weight: 640; }
.ac-att span { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ac-trial { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 20px; padding-top: 14px; border-top: 1px solid var(--rule); }
.ac-trial-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-family: var(--font-mono); font-size: 1.0625rem; font-weight: 640; letter-spacing: -0.03em; }
.ac-trial-name small { font-family: var(--font-sans); font-size: 0.8125rem; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.ac-trial a { font-size: 0.875rem; font-weight: 560; }

/* all graded flights of the attempt (hidden set): one row per mission, a chip per flight */
.ac-strip { display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--rule); min-width: 0; }
.ac-strip-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; font-size: 0.8125rem; color: var(--muted); }
.ac-strip-head b { color: var(--ink); font-weight: 620; margin-right: 4px; }
.ac-strip-head span { display: inline-flex; align-items: center; gap: 6px; }
.ac-strip-head .ac-chip { width: 14px; height: 14px; font-size: 0.6875rem; cursor: default; }
.ac-strip-row { display: grid; grid-template-columns: 13.5rem minmax(0, 1fr); align-items: center; gap: 4px 12px; min-width: 0; }
.ac-strip-k { font-size: 0.8125rem; color: var(--ink-2); white-space: nowrap; }
.ac-strip-k b { font-family: var(--font-mono); font-weight: 650; color: var(--ink); }
.ac-strip-k small { color: var(--muted); font-size: 0.75rem; }
.ac-chips { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.ac-chip {
  display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0; border-radius: 0; box-sizing: border-box;
  font: 600 0.8125rem/1 var(--font-mono); color: var(--muted); cursor: default; background: none; border: 1.5px solid var(--rule-strong);
}
.ac-chip.is-pass { background: var(--ink-2); border-color: var(--ink-2); }
.ac-chip.is-pub { outline: 2px solid var(--accent); outline-offset: 2px; cursor: pointer; }
button.ac-chip:hover { outline-width: 3px; }
.ac-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ac-differs b { color: var(--ink); }

/* the viewer card: a tool row, the viewport, the playback row */
.ac-viewer { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 12px; }
.ac-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; min-width: 0; }
.ac-tools-r { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-left: auto; }
.ac-tool {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 6px 11px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius-sm); background: var(--sheet); cursor: pointer;
  color: var(--ink-2); font-size: 0.8125rem; font-weight: 560; line-height: 1.2; white-space: nowrap;
}
.ac-tool:hover { border-color: var(--accent); color: var(--ink); }
.ac-tool[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--ink); }
.ac-tool svg { width: 14px; height: 14px; flex: none; }
.ac-vp { position: relative; height: var(--ac-vp-h); min-width: 0; overflow: hidden; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--ac-view); }
.ac-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.ac-canvas:active { cursor: grabbing; }
.ac-canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius-sm); }
.ac-loading { position: absolute; right: 10px; top: 10px; padding: 3px 10px; border-radius: 0; background: var(--sheet); border: 1px solid var(--rule); font-size: 0.75rem; color: var(--muted); }
.ac-empty { position: absolute; inset: 0; display: grid; place-content: center; gap: 4px; padding: 24px; text-align: center; color: var(--muted); font-size: var(--fs-small); }
.ac-empty b { color: var(--ink); }
.ac-readout {
  position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); padding: 4px 10px; border-radius: 0; pointer-events: none;
  font-size: 0.8125rem; color: var(--ink-2); background: color-mix(in srgb, var(--sheet) 88%, transparent); border: 1px solid var(--rule);
}
.ac-readout:empty { display: none; }
.ac-readout b { font-weight: 640; color: var(--ink); }

/* the flight HUD over the viewport */
.ac-hud {
  position: absolute; left: 8px; top: 8px; display: grid; grid-template-columns: auto auto; gap: 1px 12px; padding: 7px 10px 8px;
  border-radius: 0; pointer-events: none; font-size: 0.75rem; line-height: 1.45; color: var(--muted);
  background: color-mix(in srgb, var(--sheet) 86%, transparent); border: 1px solid var(--rule);
}
.ac-hud b { font-family: var(--font-mono); font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ac-hud .ac-hud-ph { grid-column: 1 / -1; color: var(--ink-2); font-weight: 600; }
.ac-tags { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.ac-tag {
  position: absolute; pointer-events: none; transform: translate(-50%, -100%); padding: 1px 6px; border-radius: 0; white-space: nowrap;
  font-size: 0.6875rem; font-weight: 560; color: var(--ink-2); background: color-mix(in srgb, var(--ac-view) 80%, transparent);
}

/* playback */
.ac-play { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 8px 12px; min-width: 0; }
.ac-play[hidden] { display: none; }
.ac-pbtn { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border-radius: 0; border: 1px solid var(--rule-strong); background: var(--sheet); color: var(--ink); cursor: pointer; }
.ac-pbtn:hover { border-color: var(--accent); }
.ac-pbtn svg { width: 14px; height: 14px; }
.ac-track { position: relative; min-width: 0; padding: 8px 0 12px; }
.ac-range { display: block; width: 100%; margin: 0; accent-color: var(--accent); }
.ac-ticks { position: absolute; left: 0; right: 0; bottom: 0; height: 9px; pointer-events: none; }
.ac-tick { position: absolute; bottom: 0; width: 2px; height: 7px; margin-left: -1px; border-radius: 0; background: var(--ink-2); }
.ac-tick.is-drop { background: var(--ac-pay); height: 9px; }
.ac-tick.is-bad { background: var(--accent-2); height: 9px; }
.ac-time { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* under the viewer: the flight's source and officiated result, the legend */
.ac-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 24px; font-size: var(--fs-small); color: var(--muted); }
.ac-foot b { color: var(--ink); font-weight: 600; }
.ac-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.ac-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.ac-sw { display: inline-block; width: 10px; height: 10px; border-radius: 0; flex: none; }
.ac-sw-line { height: 2px; width: 14px; border-radius: 0; }

/* specs */
.ac-specs { padding: 16px 18px; }
.ac-specs h2 { font-size: 0.9375rem; font-weight: 650; letter-spacing: -0.02em; }
.ac-specs dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px 20px; margin: 12px 0 0; }
.ac-specs dt { font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.ac-specs dd { margin: 2px 0 0; font-family: var(--font-mono); font-size: 0.9375rem; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.ac-specs dd small { display: block; margin-top: 1px; font-family: var(--font-sans); font-size: 0.75rem; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.ac-specs .note { margin-top: 12px; }

@container (max-width: 640px) {
  .ac-pick { padding: 14px; }
  .ac-row > .ac-field { flex: 1 1 100%; }
  .ac-row .select { width: 100%; }
  .ac-row .ac-seg { display: flex; }
  .ac-row .ac-seg button { flex: 1 1 auto; }
  .ac-viewer { padding: 10px; }
  .ac-vp { height: clamp(330px, 58svh, 460px); }
  .ac-tools-r { margin-left: 0; }
  .ac-play { grid-template-columns: auto minmax(0, 1fr) auto; }
  .ac-play .ac-speed { grid-column: 1 / -1; justify-self: start; }
  .ac-hud { font-size: 0.6875rem; gap: 0 10px; padding: 5px 8px 6px; }
  .ac-strip-row { grid-template-columns: minmax(0, 1fr); }
  .ac-specs { padding: 14px; }
  .ac-specs dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* a task page's frame (styles.css pins the viewport height there, since svh follows the frame): a fixed height on a
   phone too, lower, as the aircraft is wider than tall */
@container (max-width: 640px) {
  .embed .ac-vp { height: 380px; }
}
