/* Units & Time (First Class): settings readout and push-buttons, band and HUD cues. */

/* Readout: the current flight in the chosen units, laid out like a cockpit data screen.
   It is a preview, not a setting row, so it is not a .topbar-settings-item (no First Class lock, not a setting). */
.units-readout-item {
  display: block;
  padding: 2px 0 6px;
}
.topbar-settings-group.collapsed .units-readout-item {
  display: none;
}
/* The readout stays pinned at the top of Settings while the rows below scroll, so every press is seen. */
.topbar-settings-group-units:not(.collapsed) .units-readout-item {
  position: sticky;
  top: -1px;
  z-index: 3;
  margin: 0 -2px;
  padding: 3px 2px 7px;
  background: #0d131e;
  box-shadow: 0 8px 10px -8px rgba(0, 0, 0, 0.75);
}
.units-readout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.10), inset 0 2px 8px rgba(0, 0, 0, 0.6);
}
.units-readout-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 7px 9px 8px;
  background: #05080e;
  transition: background-color 220ms ease;
}
.units-readout-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #63d2ff;
}
.units-readout-value {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.1;
  color: #f2f6fb;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.units-readout-value small {
  margin-left: 1px;
  font-size: 0.68em;
  font-weight: 600;
  color: rgba(242, 246, 251, 0.72);
}
.units-readout-cell.is-flash {
  animation: units-readout-flash 900ms ease-out;
}
.units-readout-cell.is-flash .units-readout-value {
  animation: units-value-flash 900ms ease-out;
}
@keyframes units-readout-flash {
  0% { background-color: #0d2a22; }
  100% { background-color: #05080e; }
}
@keyframes units-value-flash {
  0% { color: #7ff3c8; }
  100% { color: #f2f6fb; }
}

/* One row of push-buttons per quantity; the lit bar marks the chosen unit, as on a cockpit panel. */
.topbar-settings-item.units-row {
  gap: 10px;
}
.topbar-settings-item.units-row-wide {
  flex-wrap: wrap;
  row-gap: 7px;
}
.units-row-wide .topbar-settings-label {
  flex: 1 0 100%;
}
.units-keys {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 3px;
  padding: 3px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.42);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.65), inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}
.units-row-wide .units-keys {
  width: 100%;
  box-sizing: border-box;
  grid-auto-columns: auto;
}
.units-key {
  position: relative;
  min-width: 44px;
  height: 28px;
  padding: 5px 8px 0;
  border: 0;
  border-radius: 6px;
  background: linear-gradient(180deg, #2b3242 0%, #1b202b 100%);
  color: rgba(214, 224, 238, 0.66);
  font: inherit;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09), 0 1px 0 rgba(0, 0, 0, 0.55);
  transition: color 160ms ease, background-color 160ms ease;
}
.units-key::before {
  content: "";
  position: absolute;
  left: 9px;
  right: 9px;
  top: 4px;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.10);
  transition: background-color 160ms ease, box-shadow 160ms ease;
}
.units-key:hover {
  color: rgba(236, 243, 252, 0.92);
}
.units-key:active {
  transform: translateY(1px);
}
.units-key[aria-pressed="true"] {
  color: #ffffff;
  background: linear-gradient(180deg, #343d50 0%, #232a38 100%);
}
.units-key[aria-pressed="true"]::before {
  background: #3ef0b0;
  box-shadow: 0 0 6px rgba(62, 240, 176, 0.85);
}

/* Bottom band: the value whose unit just changed glows once. */
.info-item.is-unit-flash .value {
  animation: units-band-flash 1600ms ease-out;
}
@keyframes units-band-flash {
  0%, 30% { color: #8ff5d2; text-shadow: 0 0 12px rgba(62, 240, 176, 0.65); }
  100% { color: inherit; }
}

/* Cockpit HUD: unit under the tape title. */
.cockpit-hud-panel-title small {
  margin-left: 4px;
  font-size: 0.66em;
  letter-spacing: 0.08em;
  opacity: 0.82;
}

/* Phones (landscape): narrower settings panel. */
html.airshow-mobile-runtime .units-key {
  min-width: 34px;
  height: 26px;
  padding: 5px 5px 0;
  font-size: 9.5px;
  letter-spacing: 0.03em;
}
html.airshow-mobile-runtime .units-key::before {
  left: 6px;
  right: 6px;
}
html.airshow-mobile-runtime .units-readout-cell {
  padding: 5px 7px 6px;
}
html.airshow-mobile-runtime .units-readout-value {
  font-size: 12px;
}

@media (prefers-reduced-motion: reduce) {
  .units-readout-cell.is-flash,
  .units-readout-cell.is-flash .units-readout-value,
  .info-item.is-unit-flash .value {
    animation: none;
  }
  .units-key,
  .units-key::before,
  .units-readout-cell {
    transition: none;
  }
}
