/* Fullscreen cockpit — canopy HUD + glare-shield instruments */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.cockpit {
  --hud: #7dffb3;
  --hud-dim: rgba(125, 255, 179, 0.55);
  --hud-warn: #ffc857;
  --cockpit-metal: #0a0d16;
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #02040a;
  color: #fff;
  overflow: hidden;
}

.cockpit-canopy {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

/* Outside world — pitches & rolls */
.cockpit-world {
  position: absolute;
  inset: -35%;
  z-index: 0;
  transform-origin: 50% 50%;
}

.cockpit-horizon {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 220%;
  height: 220%;
  transform: translate(-50%, -50%);
  /* Sky only — ground is continuous satellite imagery below the horizon */
  background:
    linear-gradient(
      180deg,
      #163560 0%,
      #2f5f96 26%,
      #6fa0c9 44%,
      #b7cfe0 49.2%,
      rgba(183, 207, 224, 0) 50.2%
    );
}

/* Soft drifting cloud bands */
.cockpit-clouds {
  position: absolute;
  left: -30%;
  right: -30%;
  top: 8%;
  height: 42%;
  opacity: 0.3;
  background:
    radial-gradient(ellipse 40% 18% at 20% 40%, rgba(255, 255, 255, 0.55), transparent 70%),
    radial-gradient(ellipse 35% 16% at 70% 55%, rgba(255, 255, 255, 0.4), transparent 70%),
    radial-gradient(ellipse 28% 14% at 45% 25%, rgba(255, 255, 255, 0.35), transparent 70%),
    radial-gradient(ellipse 32% 15% at 90% 35%, rgba(255, 255, 255, 0.3), transparent 70%);
  pointer-events: none;
  animation: cockpit-clouds-drift 48s linear infinite;
}

@keyframes cockpit-clouds-drift {
  from { transform: translateX(0); }
  to { transform: translateX(-8%); }
}

/* Ground — 2D foreshortening (trapezoid), no CSS 3D (Chrome flash) */
.cockpit-terrain {
  position: absolute;
  left: -45%;
  right: -45%;
  top: 48.5%;
  bottom: -75%;
  overflow: hidden;
  pointer-events: none;
  background: #24301c;
  /* Strong vanishing point at the horizon */
  clip-path: polygon(32% 0%, 68% 0%, 100% 100%, 0% 100%);
}

.cockpit-terrain::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 28%;
  z-index: 2;
  background: linear-gradient(
    180deg,
    rgba(183, 207, 224, 0.85) 0%,
    rgba(183, 207, 224, 0.35) 35%,
    rgba(183, 207, 224, 0) 100%
  );
  pointer-events: none;
}

.cockpit-terrain-sheet {
  position: absolute;
  left: -30%;
  width: 160%;
  top: -12%;
  height: 145%;
  overflow: hidden;
  /* Heavy vertical squash = steep look-down toward horizon */
  transform: scaleY(0.28) scaleX(1.7);
  transform-origin: 50% 0%;
}

.cockpit-terrain-strip {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 200%;
  background-image: url("../assets/hq/sat-canola.jpg");
  background-repeat: repeat;
  background-size: 28% auto;
  animation: cockpit-terrain-scroll 14s linear infinite;
}

@keyframes cockpit-terrain-scroll {
  from { transform: translateY(-50%); }
  to { transform: translateY(0); }
}

.cockpit-terrain-sheet::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(180deg, rgba(140, 175, 210, 0.25) 0%, transparent 14%),
    linear-gradient(180deg, transparent 55%, rgba(10, 14, 10, 0.4) 100%),
    linear-gradient(90deg, rgba(2, 4, 10, 0.35), transparent 18%, transparent 82%, rgba(2, 4, 10, 0.35));
  pointer-events: none;
}

.cockpit-scape {
  display: none;
}

.cockpit-haze {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(ellipse 80% 70% at 50% 42%, transparent 30%, rgba(2, 4, 10, 0.45) 100%),
    linear-gradient(180deg, rgba(2, 4, 10, 0.35) 0%, transparent 28%, transparent 55%, rgba(2, 4, 10, 0.55) 100%);
  pointer-events: none;
}

/* Canopy glass / frame */
.cockpit-frame {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(ellipse 95% 85% at 50% 45%, transparent 42%, rgba(0, 0, 0, 0.55) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(125, 255, 179, 0.08),
    inset 0 40px 80px rgba(0, 0, 0, 0.35);
}

/* HUD layer */
.cockpit-hud {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: calc(var(--header-h) + 0.75rem) clamp(0.75rem, 2.5vw, 1.5rem) 0.75rem;
  pointer-events: none;
  font-family: "Share Tech Mono", ui-monospace, monospace;
  color: var(--hud);
  text-shadow: 0 0 8px rgba(125, 255, 179, 0.35);
}

.cockpit-hud a,
.cockpit-hud button {
  pointer-events: auto;
}

.hud-top {
  display: flex;
  justify-content: center;
  align-items: start;
}

.hud-heading {
  width: min(280px, 70vw);
  text-align: center;
  border: 1px solid var(--hud-dim);
  background: rgba(2, 8, 6, 0.4);
  padding: 0.25rem 0.4rem 0.45rem;
  overflow: hidden;
}

.hud-heading-label {
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  opacity: 0.75;
}

.hud-heading-tape {
  position: relative;
  height: 1.6rem;
  margin-top: 0.15rem;
}

.hud-heading-track {
  position: absolute;
  left: 50%;
  top: 0;
  display: flex;
  gap: 0;
  transform: translateX(-50%);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.hud-heading-track span {
  display: inline-flex;
  width: 2.4rem;
  justify-content: center;
  opacity: 0.7;
}

.hud-heading-track span.is-cardinal {
  color: var(--hud-warn);
  opacity: 1;
}

.hud-heading-cue {
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 7px solid var(--hud);
  transform: translateX(-50%);
}

.hud-center {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
}

.hud-ladder-wrap {
  position: absolute;
  inset: 8% 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.hud-ladder {
  width: min(280px, 56vw);
  height: min(280px, 48vh);
  overflow: hidden;
  mask-image: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
}

.hud-ladder-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  transform-origin: 50% 50%;
}

.hud-pitch-line {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  height: 28px;
  font-size: 0.7rem;
  opacity: 0.85;
}

.hud-pitch-line i {
  display: block;
  height: 1px;
  background: var(--hud-dim);
}

.hud-pitch-line--zero i {
  background: var(--hud);
  height: 2px;
}

.hud-pitch-line--neg {
  opacity: 0.55;
}

.hud-waterline {
  position: relative;
  z-index: 2;
  width: 92px;
  height: 28px;
}

.hud-waterline svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 0 4px rgba(125, 255, 179, 0.55));
}

.hud-bank {
  position: absolute;
  top: 6%;
  left: 50%;
  width: min(220px, 50vw);
  height: 40px;
  transform: translateX(-50%);
}

.hud-bank svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.hud-bank-needle {
  transform-origin: 110px 110px;
  transition: none;
}

.hud-mission {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 3;
  max-width: min(92vw, 520px);
  pointer-events: none;
}

.hud-mission-ato {
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  color: var(--hud-dim);
  margin-bottom: 0.45rem;
}

.hud-mission-brand {
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.4vw, 1.35rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.55);
  margin: 0 0 0.35rem;
}

.hud-mission h1 {
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 4.8vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: #fff;
  margin: 0 0 0.45rem;
  text-shadow: 0 4px 28px rgba(0, 0, 0, 0.5);
}

.hud-mission p {
  font-family: var(--font-body);
  font-size: clamp(0.88rem, 1.6vw, 1.02rem);
  color: rgba(255, 255, 255, 0.82);
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.55);
  margin: 0;
  max-width: 34ch;
  margin-inline: auto;
  line-height: 1.45;
}

.hud-sides {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  bottom: auto;
  height: clamp(200px, 36vh, 300px);
  transform: translateY(-50%);
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  padding: 0 clamp(0.85rem, 3vw, 1.75rem);
  pointer-events: none;
}

.hud-tape {
  width: clamp(58px, 9vw, 78px);
  border: 1px solid var(--hud-dim);
  background: rgba(2, 10, 8, 0.72);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.45rem 0.2rem 0.35rem;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.25);
}

.hud-tape-label {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: var(--hud-dim);
}

.hud-tape-value {
  font-size: clamp(1.15rem, 2.4vw, 1.5rem);
  color: #c8ffe0;
  margin: 0.2rem 0 0.15rem;
  line-height: 1;
}

.hud-tape-unit {
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  color: var(--hud-dim);
  margin-top: 0.2rem;
}

.hud-tape-scale {
  flex: 1;
  width: 100%;
  position: relative;
  overflow: hidden;
  margin-top: 0.15rem;
  min-height: 120px;
  mask-image: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
}

.hud-tape-marks {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  text-align: center;
  line-height: 1.7;
  opacity: 0.7;
}

.hud-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.75rem;
  padding-bottom: 0.35rem;
}

.hud-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--hud-dim);
}

.hud-status b {
  color: var(--hud);
  font-weight: 400;
}

.hud-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0.45rem;
  flex: 1 1 auto;
  justify-content: flex-end;
  min-width: 0;
}

.hud-btn {
  pointer-events: auto;
  font-family: "Share Tech Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 0.65rem 1rem;
  border: 1px solid var(--hud);
  color: var(--hud);
  background: rgba(2, 12, 8, 0.45);
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  white-space: nowrap;
  flex: 0 0 auto;
  box-sizing: border-box;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hud-btn:hover {
  background: var(--hud);
  color: #04140c;
  box-shadow: 0 0 18px rgba(125, 255, 179, 0.35);
  text-decoration: none;
}

.hud-btn--solid {
  background: var(--hud);
  color: #04140c;
}

.hud-btn--solid:hover {
  filter: brightness(1.06);
  color: #04140c;
}

.hud-tilt-btn {
  border-style: dashed;
  /* Reserve width for the longer idle label so toggle doesn't reflow the row */
  min-width: 11.5ch;
}

.hud-tilt-btn.is-on {
  background: rgba(125, 255, 179, 0.18);
  border-style: solid;
  color: #c8ffe0;
  box-shadow: 0 0 14px rgba(125, 255, 179, 0.25);
}

.hud-tilt-btn.is-calibrating {
  box-shadow: 0 0 18px rgba(125, 255, 179, 0.55);
  background: rgba(125, 255, 179, 0.28);
}

.hud-tilt-btn[hidden] {
  display: none !important;
}

/* Mouse/desktop: never show tilt (touch laptops still get pointer:fine) */
@media (hover: hover) and (pointer: fine) {
  .hud-tilt-btn {
    display: none !important;
  }
}

/* Glare-shield instrument panel (same fullscreen experience) */
.cockpit-panel.panel {
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
  overflow: visible;
  background:
    linear-gradient(180deg, #161b28 0%, #0c101a 45%, #080a12 100%);
  border-top: 2px solid rgba(201, 162, 39, 0.4);
  border-bottom: 1px solid rgba(0, 0, 0, 0.55);
  box-shadow:
    0 -2px 0 rgba(255, 255, 255, 0.06),
    0 -14px 36px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  padding: 0.85rem 0 1.35rem;
  color: rgba(255, 255, 255, 0.9);
}

.cockpit-panel .panel-media,
.cockpit-panel .panel-scrub {
  display: none;
}

.cockpit-panel .wrap {
  position: relative;
  z-index: 2;
  padding-bottom: 0.35rem;
}

.cockpit-panel::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 6px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent);
  pointer-events: none;
}

.cockpit-panel .wing-edge {
  display: none;
}

.cockpit-rail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
  padding: 0 0.25rem;
}

.cockpit-rail-title {
  font-family: "Share Tech Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(125, 255, 179, 0.7);
}

.cockpit-rail-title span {
  color: rgba(255, 255, 255, 0.45);
}

.cockpit-panel .dial-grid {
  gap: 0.55rem 0.45rem;
}

.cockpit-panel .dial-label {
  font-size: 0.72rem;
}

.cockpit-panel .dial-sub {
  font-size: 0.68rem;
  max-width: 12ch;
}

.cockpit-panel .dial-card {
  gap: 0.45rem;
}

.cockpit-panel .gauge {
  width: min(100%, 110px);
}

@media (min-width: 900px) {
  .cockpit-panel .gauge {
    width: min(100%, 118px);
  }
}

@media (max-width: 760px) {
  .cockpit-canopy {
    min-height: min(42vh, 420px);
  }

  .hud-mission {
    top: 14%;
  }

  .hud-mission p {
    display: none;
  }

  .hud-sides {
    top: 50%;
    bottom: auto;
    height: clamp(170px, 32vh, 240px);
    transform: translateY(-50%);
    padding: 0 0.55rem;
  }

  .hud-tape {
    width: 52px;
    font-size: 0.6rem;
  }

  .cockpit-panel .dial-grid {
    grid-template-columns: repeat(4, 1fr);
    overflow-x: auto;
    padding-bottom: 0.35rem;
  }
}

@media (max-width: 560px) {
  .hud-heading {
    width: min(240px, 78vw);
  }

  .hud-bottom {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
  }

  .hud-actions {
    width: 100%;
    justify-content: stretch;
  }

  .hud-btn {
    flex: 1 1 0;
    padding: 0.55rem 0.45rem;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    min-height: 2.6rem;
  }

  .hud-tilt-btn {
    min-width: 0;
  }

  .cockpit-panel .dial-grid {
    grid-template-columns: repeat(4, minmax(72px, 1fr));
  }

  .cockpit-panel .dial-sub {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cockpit-clouds,
  .cockpit-terrain-strip {
    animation: none !important;
  }

  .cockpit-world,
  .cockpit-terrain,
  .hud-ladder-inner,
  .hud-heading-track,
  .hud-tape-marks {
    transition: none !important;
  }
}
