/* Precision Runway P2: optional detailed avionics. This sheet intentionally
   loads after the shared responsive UI so it cannot regress the hangar or
   compact-flight layouts. */

#hud-strip .hud-metric-advanced {
  display: none;
}

#hud-strip .hud-metric[data-system="vertical-speed"] strong.engaged,
#hud-strip .hud-metric[data-system="engine"] strong.engaged {
  color: var(--hfs-flight);
}

#hud-strip .hud-metric[data-system="brake"] strong.engaged,
#hud-strip .hud-metric[data-system="spoiler"] strong.engaged {
  color: var(--hfs-warning);
}

#hud-strip .hud-metric strong.disabled {
  color: var(--hfs-text-muted);
  opacity: 0.72;
}

#game-screen:not(.mobile-controls-enabled).hud-mode-full #hud {
  width: min(568px, calc(100vw - 48px));
  height: 244px;
}

#game-screen:not(.mobile-controls-enabled).hud-mode-full #hud #attitude-card {
  flex-basis: 208px;
  height: 244px;
}

#game-screen:not(.mobile-controls-enabled).hud-mode-full #hud #hud-strip {
  height: 244px;
}

#game-screen:not(.mobile-controls-enabled).hud-mode-full #hud-strip .hud-data-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 4px 8px;
}

#game-screen:not(.mobile-controls-enabled).hud-mode-full #hud-strip .hud-metric,
#game-screen:not(.mobile-controls-enabled).hud-mode-full #hud-strip .hud-metric-primary,
#game-screen:not(.mobile-controls-enabled).hud-mode-full #hud-strip .hud-metric-advanced {
  min-height: 30px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 3px 5px;
}

#game-screen:not(.mobile-controls-enabled).hud-mode-full #hud-strip .hud-metric strong {
  font-size: 0.76rem;
}

#game-screen:not(.mobile-controls-enabled).hud-mode-full #hud-strip .hud-metric span {
  font-size: 0.56rem;
}

#game-screen:not(.mobile-controls-enabled).hud-mode-full #hud-strip .hud-lever-bank {
  display: none;
}

#game-screen.mobile-controls-enabled #hud-strip .hud-metric-advanced {
  display: none;
}

#game-screen.mobile-controls-enabled.hud-mode-full #hud-strip .hud-metric-advanced {
  display: grid;
}

#game-screen.mobile-controls-enabled.hud-mode-full #hud-strip .hud-metric-primary,
#game-screen.mobile-controls-enabled.hud-mode-full #hud-strip .hud-metric-network {
  display: none !important;
}

#game-screen.mobile-controls-enabled.hud-mode-full #hud-strip .hud-data-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
}

/* Annunciators are short, stateful cues rather than modal error surfaces. */
#annunciator .annunciator-stack {
  width: 100%;
  display: grid;
  gap: 4px;
}

#annunciator .annunciator-item {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 7px;
}

#annunciator .annunciator-item strong {
  flex: 0 0 auto;
  color: var(--hfs-success);
}

#annunciator .annunciator-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#annunciator .annunciator-item-warning strong {
  color: var(--hfs-warning);
}

#annunciator .annunciator-item-danger strong {
  color: var(--hfs-danger);
}

#annunciator[data-alert-count="2"],
#annunciator[data-alert-count="3"] {
  min-width: 238px;
}

#game-screen.mobile-controls-enabled #annunciator .annunciator-stack {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  overflow: hidden;
}

#game-screen.mobile-controls-enabled #annunciator .annunciator-item {
  min-width: 0;
  gap: 0;
}

#game-screen.mobile-controls-enabled #annunciator .annunciator-item-warning strong {
  color: var(--hfs-warning);
}

#game-screen.mobile-controls-enabled #annunciator .annunciator-item-danger strong {
  color: var(--hfs-danger);
}

#game-screen.mobile-controls-enabled #annunciator .annunciator-item span,
#game-screen.mobile-controls-enabled #annunciator .annunciator-item:nth-child(n + 3) {
  display: none;
}

#game-screen.mobile-controls-enabled #annunciator[data-alert-count="2"],
#game-screen.mobile-controls-enabled #annunciator[data-alert-count="3"] {
  min-width: 0;
}

/* P2 HUD preferences ------------------------------------------------------ */

:root {
  --hfs-hud-scale: 1;
  --hfs-hud-safe-inset: 0px;
}

.hud-preferences-section {
  gap: 8px;
}

.hud-preferences-note {
  margin: 0;
  color: var(--hfs-text-muted, rgba(232, 236, 238, 0.68));
  font-size: 0.74rem;
  line-height: 1.35;
}

/* These variables deliberately apply only to the desktop HUD. The mobile
   compact and expanded layouts have their own carefully bounded geometry. */
#game-screen:not(.mobile-controls-enabled) {
  --hfs-desktop-hud-scale: var(--hfs-hud-scale);
  --hfs-desktop-hud-inset: var(--hfs-hud-safe-inset);
}

#game-screen:not(.mobile-controls-enabled) #hud {
  top: max(
    calc(14px + var(--hfs-desktop-hud-inset)),
    calc(var(--safe-top) + 10px + var(--hfs-desktop-hud-inset))
  );
  transform: translateX(-50%) scale(var(--hfs-desktop-hud-scale));
  transform-origin: top center;
}

#game-screen:not(.mobile-controls-enabled).hud-mode-full #hud {
  left: max(
    calc(16px + var(--hfs-desktop-hud-inset)),
    calc(var(--safe-left) + 12px + var(--hfs-desktop-hud-inset))
  );
  top: auto;
  bottom: max(
    calc(16px + var(--hfs-desktop-hud-inset)),
    calc(var(--safe-bottom) + 12px + var(--hfs-desktop-hud-inset))
  );
  transform: scale(var(--hfs-desktop-hud-scale));
  transform-origin: left bottom;
}

#game-screen:not(.mobile-controls-enabled) #minimap {
  right: max(
    calc(16px + var(--hfs-desktop-hud-inset)),
    calc(var(--safe-right) + 12px + var(--hfs-desktop-hud-inset))
  );
  top: max(
    calc(14px + var(--hfs-desktop-hud-inset)),
    calc(var(--safe-top) + 10px + var(--hfs-desktop-hud-inset))
  );
  transform: scale(var(--hfs-desktop-hud-scale));
  transform-origin: top right;
}

#game-screen:not(.mobile-controls-enabled) #flight-network-chip {
  right: max(
    calc(16px + var(--hfs-desktop-hud-inset)),
    calc(var(--safe-right) + 12px + var(--hfs-desktop-hud-inset))
  );
  top: max(
    calc(140px + var(--hfs-desktop-hud-inset)),
    calc(var(--safe-top) + 136px + var(--hfs-desktop-hud-inset))
  );
  transform: scale(var(--hfs-desktop-hud-scale));
  transform-origin: top right;
}

#game-screen:not(.mobile-controls-enabled) #annunciator {
  top: max(
    calc(70px + var(--hfs-desktop-hud-inset)),
    calc(var(--safe-top) + 66px + var(--hfs-desktop-hud-inset))
  );
  transform: translateX(-50%) scale(var(--hfs-desktop-hud-scale));
  transform-origin: top center;
}

/* Avoid edge clipping when a narrow desktop viewport has not opted into the
   touch controls. The saved preference remains intact for wider displays. */
@media (max-width: 760px), (max-height: 520px) {
  #game-screen:not(.mobile-controls-enabled) {
    --hfs-desktop-hud-scale: min(1, var(--hfs-hud-scale));
    --hfs-desktop-hud-inset: min(12px, var(--hfs-hud-safe-inset));
  }
}

html.hfs-reduced-motion *,
html.hfs-reduced-motion *::before,
html.hfs-reduced-motion *::after {
  scroll-behavior: auto !important;
  animation-duration: 0.001ms !important;
  animation-delay: 0ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

/* P3 local lesson -------------------------------------------------------- */

.training-objective {
  position: absolute;
  left: max(16px, calc(var(--safe-left) + 12px));
  top: max(72px, calc(var(--safe-top) + 68px));
  z-index: 6;
  width: min(260px, calc(100vw - 40px));
  display: grid;
  gap: 3px;
  padding: 9px 11px;
  border: 1px solid var(--hfs-border-soft, rgba(150, 176, 194, 0.22));
  border-radius: var(--hfs-radius-control, 10px);
  color: var(--hfs-text-1, #f4f8fb);
  background: rgba(8, 24, 36, 0.76);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
  pointer-events: none;
}

.training-objective > span {
  color: var(--hfs-flight, #2db8d0);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.56rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.training-objective strong {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.training-objective p,
.training-objective small {
  margin: 0;
  overflow: hidden;
  color: var(--hfs-text-2, #b5c1ca);
  font-size: 0.66rem;
  line-height: 1.3;
  text-overflow: ellipsis;
}

.training-objective small {
  color: var(--hfs-text-muted, #b5c1ca);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#game-screen.hud-mode-hidden .training-objective {
  opacity: 0;
}

.training-settings-section {
  gap: 9px;
}

.training-checklist {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 5px;
  list-style: none;
}

.training-checklist li {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 7px;
  border: 1px solid var(--hfs-border-soft, rgba(150, 176, 194, 0.2));
  border-radius: 7px;
  color: var(--hfs-text-2, #b5c1ca);
  background: rgba(255, 255, 255, 0.025);
  font-size: 0.74rem;
}

.training-checklist li > span:first-child {
  width: 14px;
  flex: 0 0 14px;
  color: var(--hfs-text-muted, #b5c1ca);
  font-weight: 900;
  text-align: center;
}

.training-checklist li[data-done="true"] {
  color: var(--hfs-text-1, #f4f8fb);
  border-color: rgba(83, 214, 170, 0.3);
}

.training-checklist li[data-done="true"] > span:first-child {
  color: var(--hfs-success, #53d6aa);
}

.training-debrief {
  display: grid;
  gap: 7px;
  color: var(--hfs-text-2, #b5c1ca);
  font-size: 0.72rem;
}

.training-debrief-result {
  margin: 0;
  line-height: 1.35;
}

.training-debrief-metrics {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 9px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

.training-debrief-metrics dt {
  color: var(--hfs-text-muted, #b5c1ca);
}

.training-debrief-metrics dd {
  margin: 0;
  color: var(--hfs-text-1, #f4f8fb);
  text-align: right;
}

#mobile-flap-button {
  right: calc(var(--mobile-edge) + var(--mobile-throttle-width) + 12px);
  bottom: calc(var(--mobile-control-bottom) + (var(--mobile-button-size) + var(--mobile-button-gap)) * 3);
}

#game-screen.mobile-controls-enabled .training-objective {
  display: none;
}

@media (max-width: 900px), (max-height: 550px) {
  #game-screen:not(.mobile-controls-enabled) .training-objective {
    display: none;
  }
}

@media (max-height: 350px) and (orientation: landscape) {
  #mobile-flap-button {
    display: none;
  }
}
