/* ================================
   CANVAS
   ================================ */
#glCanvas {
  display: block;
  background: var(--gradient-canvas);
}

.runtime-fps {
  position: fixed;
  display: block;
  min-width: 2ch;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--ui-glass);
  color: var(--ui-ink-2);
  box-shadow: inset 0 0 0 1px rgba(15, 29, 48, 0.08), var(--ui-shadow-xs);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
  pointer-events: none;
  user-select: none;
  visibility: visible;
  opacity: 1;
}

.runtime-fps[hidden] {
  display: none;
}

.variant-swap-indicator,
.engine-first-touch-hint {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: calc(var(--z-header) + 8);
  pointer-events: none;
  opacity: 0;
  transition:
    opacity var(--t-base) var(--ease-standard),
    transform var(--t-base) var(--ease-out);
}

.variant-swap-indicator.hidden,
.engine-first-touch-hint.hidden {
  display: none;
}

.variant-swap-indicator {
  top: calc(var(--header-h) + env(safe-area-inset-top) + var(--space-6));
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 40px;
  padding: 0 var(--space-5);
  border-radius: var(--radius-round);
  background: var(--ui-glass);
  border: 1px solid var(--ui-line);
  box-shadow: var(--ui-shadow-float);
  color: var(--ui-ink);
}

.variant-swap-indicator.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.variant-swap-spinner {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid var(--ui-accent-tint);
  border-top-color: var(--ui-accent);
  animation: variant-swap-spin 0.8s linear infinite;
}

.variant-swap-label {
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: -0.005em;
}

.engine-first-touch-hint {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-round);
  background: var(--ui-glass);
  border: 1px solid var(--ui-line);
  color: var(--ui-ink);
  box-shadow: var(--ui-shadow-float);
  transform: translateX(-50%) translateY(8px);
}

.engine-first-touch-hint.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.engine-first-touch-hint span {
  position: relative;
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap;
}

.engine-first-touch-hint span + span::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-right: var(--space-3);
  border-radius: 999px;
  background: var(--ui-accent-line);
  vertical-align: middle;
}

@keyframes variant-swap-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1024px) {
  .engine-first-touch-hint {
    max-width: calc(100vw - var(--space-10));
    flex-wrap: wrap;
    justify-content: center;
  }
}

.less-engine-home {
  position: fixed;
  height: auto;
  opacity: 0.5;
  display: grid;
  place-items: center;
  cursor: pointer;
  pointer-events: auto;
}

.less-engine-home img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.less-engine-home:hover {
  opacity: 0.85;
}

/* ================================
   DRIVING, STUDIO NOTICE AND INTERIOR CONTROLS
   Cards in the dock's Controls pane (mockup Controls tab): kicker, title,
   one ink action, switch rows. One type family; digits are tabular.
   ================================ */
.driving-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  color: var(--ui-ink);
  font-family: var(--font-sans);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.driving-controls.hidden {
  display: none;
}

.driving-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--ui-line);
  border-radius: 14px;
  background: var(--ui-card);
  box-shadow: var(--ui-shadow);
}

.driving-card-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.driving-card-header > span:first-child {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.driving-card-kicker {
  display: block;
  margin: 0;
  color: var(--ui-mute);
  font-size: 11px;
  font-weight: 500;
  line-height: 18px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.driving-card-title {
  overflow: hidden;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

/* Engine state (mockup): a dot and On / Off. */
.driving-engine-status {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ui-mute);
  font-size: 13px;
  white-space: nowrap;
}

.driving-engine-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ui-switch-off);
}

.driving-controls.is-driving .driving-engine-status {
  color: var(--ui-success);
}

.driving-controls.is-driving .driving-engine-status-dot {
  background: var(--ui-success);
  box-shadow: 0 0 0 3px rgba(35, 123, 73, 0.16);
}

.driving-controls[data-engine-state="unavailable"] .driving-engine-status {
  color: var(--ui-warning);
}

.driving-drive-body {
  display: grid;
  margin-top: 12px;
}

/* Power (mockup ".big"): the card's one ink action, a machine control kept
   apart from the marine commercial action (Request a quote). */
.driving-engine-button {
  width: 100%;
  padding: 13px;
  border: 0;
  border-radius: 12px;
  background: var(--ui-ink);
  color: #ffffff;
  box-shadow: var(--ui-shadow-primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s ease;
}

.driving-engine-button:hover:not(:disabled) {
  background: var(--ui-ink-2);
}

.driving-engine-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.driving-start-label {
  font-weight: inherit;
}

/* Throttle (mockup): label and level, the bar, then the two steps. */
.driving-throttle-module {
  margin-top: 14px;
}

.driving-throttle-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
}

.driving-throttle-readout strong {
  font-weight: 700;
}

.driving-throttle {
  grid-column: 1 / -1;
  margin: 10px 0;
}

.driving-throttle-track {
  display: block;
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--ui-track);
}

/* toolbar.js scales the fill with transform: scaleX(throttle). */
.driving-throttle-marker {
  display: block;
  height: 100%;
  background: var(--ui-accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.2s ease;
}

.driving-throttle-actions {
  display: flex;
  gap: 8px;
}

.driving-touch-button {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px;
  border: 1px solid var(--ui-line-strong);
  border-radius: 12px;
  background: var(--ui-card);
  color: var(--ui-ink);
  box-shadow: var(--ui-shadow-xs);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  touch-action: none;
}

.driving-touch-button strong {
  font-weight: inherit;
}

.driving-touch-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.driving-touch-button.is-active {
  border-color: var(--ui-accent);
  background: var(--ui-accent-soft);
  color: var(--ui-accent-text);
}

.driving-control-help {
  margin: 12px 0 0;
  color: var(--ui-mute);
  font-size: 12px;
  line-height: 1.45;
}

.driving-help-on,
.driving-help-touch,
.driving-controls.is-driving .driving-help-off,
.ipad-steering .driving-controls.is-driving .driving-help-on {
  display: none;
}

/* While driving: the keyboard hint, or the touch hint on an iPad. */
.driving-controls.is-driving .driving-help-on,
.ipad-steering .driving-controls.is-driving .driving-help-touch {
  display: inline;
}

/* Telemetry: roll, speed and pitch rings. toolbar.js sets the sweep through
   --driving-gauge-angle and the attitude sign through data-direction. */
@property --driving-gauge-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

.driving-gauge-cluster {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.driving-round-gauge {
  --driving-gauge-color: var(--ui-accent);
  min-width: 0;
  display: grid;
  justify-items: center;
  row-gap: 8px;
}

.driving-attitude-gauge {
  --driving-gauge-color: var(--ui-success);
}

.driving-attitude-gauge[data-direction="negative"] {
  --driving-gauge-color: var(--ui-warning);
}

.driving-gauge-title,
.driving-gauge-subtitle {
  color: var(--ui-mute);
  font-size: 11px;
  letter-spacing: 0.14em;
}

.driving-gauge-ring,
.driving-gauge-center {
  grid-area: 2 / 1;
}

.driving-gauge-ring {
  width: min(100%, 92px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(
    from 235deg,
    var(--driving-gauge-color) 0deg var(--driving-gauge-angle),
    var(--ui-track) var(--driving-gauge-angle) 250deg,
    transparent 250deg
  );
  -webkit-mask: radial-gradient(circle closest-side, transparent 86%, #000 87%);
  mask: radial-gradient(circle closest-side, transparent 86%, #000 87%);
  transition: --driving-gauge-angle 120ms linear;
}

.driving-gauge-center {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
}

.driving-speed {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.driving-speed-unit {
  color: var(--ui-mute);
  font-size: 12px;
}

.driving-attitude-number {
  font-weight: 700;
}

/* Touch steering (tablets): a horizontal drag well. toolbar.js moves the knob
   through --driving-joystick-x and sizes its travel for a 38px knob. */
.driving-steering-card {
  display: none;
}

.ipad-steering .driving-steering-card {
  display: block;
}

/* iPad landscape: the dock pane is short, so steering follows the throttle
   and telemetry comes last (toolbar.js scrolls the well into view when the
   engine starts). */
@media (orientation: landscape) {
  .ipad-steering .driving-instruments-card {
    order: 1;
  }
}

.driving-steering-body {
  margin-top: 12px;
}

.driving-joystick {
  position: relative;
  height: 96px;
  overflow: hidden;
  border: 1px solid var(--ui-line-strong);
  border-radius: 12px;
  background: var(--ui-well);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  scroll-margin: 10px;
}

.driving-joystick[aria-disabled="true"] {
  opacity: 0.42;
  cursor: not-allowed;
}

.driving-joystick.is-active {
  border-color: var(--ui-accent);
}

.driving-joystick-label,
.driving-steering-direction {
  position: absolute;
  color: var(--ui-mute);
  font-size: 11px;
  letter-spacing: 0.14em;
  white-space: nowrap;
  pointer-events: none;
}

.driving-joystick-label {
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
}

.driving-steering-direction {
  bottom: 10px;
}

.driving-steering-left {
  left: 12px;
}

.driving-steering-right {
  right: 12px;
}

.driving-joystick-track {
  position: absolute;
  top: 50%;
  left: 14px;
  right: 14px;
  height: 1px;
  background: var(--ui-line-strong);
}

.driving-joystick-center {
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: 50%;
  width: 1px;
  background: var(--ui-line);
}

.driving-joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--ui-accent);
  box-shadow: var(--ui-shadow-primary);
  pointer-events: none;
  transform: translate(-50%, -50%) translate(calc(var(--driving-joystick-x, 0) * 1px), 0);
  transition: transform 0.08s linear;
}

/* Studio mode: driving needs the environment. */
.studio-driving-notice-copy {
  display: grid;
  gap: 4px;
}

.studio-driving-notice-copy strong {
  font-weight: 700;
}

.studio-driving-notice-copy > span:last-child {
  color: var(--ui-mute);
  font-size: 13px;
  line-height: 1.45;
}

/* Interior lights and cameras (mockup ".tog" rows); the "All on" row leads
   the lights without a rule above it. */
.interior-hud-list {
  display: grid;
}

.interior-master-toggle,
.interior-hud-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border: 0;
  border-top: 1px solid var(--ui-line);
  background: none;
  color: var(--ui-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.interior-master-toggle,
.interior-camera-list > :first-child {
  border-top: 0;
}

.interior-master-toggle:disabled {
  opacity: 0.42;
  cursor: default;
}

.interior-hud-item-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.interior-hud-item small {
  color: var(--ui-mute);
  font-size: 12px;
}

.interior-master-toggle::after,
.interior-hud-light::after {
  content: "";
  flex: none;
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--ui-switch-off-fill);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}

.interior-master-toggle[aria-pressed="true"]::after,
.interior-hud-light[aria-pressed="true"]::after {
  background: var(--ui-switch-on-fill);
}

.interior-hud-camera[aria-pressed="true"] .interior-hud-item-name {
  color: var(--ui-accent-text);
  font-weight: 700;
}

.interior-hud-empty {
  margin: 12px 0 0;
  color: var(--ui-mute);
  font-size: 13px;
}

/* Tablet portrait: the cards stand side by side, so power, throttle, steering
   and telemetry (or lights and cameras) fit the sheet without scrolling. */
@media (orientation: portrait) and (min-width: 600px) {
  .driving-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .driving-controls > .driving-card {
    flex: 1 1 200px;
  }

  .driving-controls > .driving-drive-card {
    flex: 1.3 1 250px;
  }

  .driving-touch-button {
    padding-inline: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .driving-throttle-marker,
  .driving-gauge-ring,
  .driving-joystick-knob {
    transition: none;
  }
}

/* ================================
   DIMENSION LABELS
   ================================ */
#lengthLabel,
#labels .label {
  position: absolute;
  color: var(--ui-ink);
  font-size: var(--text-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
  pointer-events: none;
  transform: translate(-50%, -100%) scale(0.96);
  background: var(--ui-card);
  box-shadow: var(--ui-shadow-sm);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid var(--ui-line);
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
}

#lengthLabel.visible,
#labels .label.visible {
  opacity: 1;
  transform: translate(-50%, -110%) scale(1);
  display: block;
}

#labels {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
}

#lengthLabel {
  z-index: 60;
}

.ruler-anchor {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--hud-marker-bg-soft);
  border: 1px solid var(--hud-marker-border-strong);
  transform: translate(-50%, -50%) scale(0.9);
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.ruler-anchor::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--hud-marker-dot);
}

.ruler-anchor.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Interior camera nodes (styles injected by js/engine/camera/camera-nodes.js):
   light Marine plates with the marine hover. Colours only; body + id beats the
   injected rules; their other effects stay in that JS untouched. */
body #cameraNodeLabelLayer .cam-node-label {
  border-color: rgba(15, 29, 48, 0.14);
  background: var(--ui-glass);
  color: var(--ui-ink);
  box-shadow: var(--ui-shadow-float);
}

body #cameraNodeLabelLayer .cam-node-label .cam-node-cap {
  border-color: rgba(15, 29, 48, 0.12);
  background: var(--ui-glass);
  color: var(--ui-ink);
  font: 500 11px/1.3 var(--font-sans);
}

body #cameraNodeLabelLayer .cam-node-label:hover,
body #cameraNodeLabelLayer .cam-node-label:hover .cam-node-cap {
  border-color: var(--ui-accent);
  background: var(--ui-accent);
  color: var(--ui-on-accent);
}
