/* Prompt deck — the single flight decision surface (src/ui/promptDeck.js).
   Authority: HUD_FLIGHT_ATTENTION.md (decisions are the one legitimate flight card; receipts are
   NOT cards), the Deckplate token root (--dp-*: game faces, warm bone at rest, lamp for act-on,
   phosphor for readings) and the approved resting frame (right column below the BAND row, clear
   of sector-law / contacts / radar). A timed decision's countdown is a compact arc, not a bar
   (ORRERY §3.2/§6). No backdrop-filter — flight perf floor, FIELD_HARDWARE_PROGRAM §7. Layering:
   z 20, documented in ARCHITECTURE §1.2 (above the HUD, below the modal backdrop and screens). */

#sf-prompt-deck {
  position: absolute;
  /* Upper-right HUD decision column: seated cleanly below the top status/alert band and 14px left
     of the live right-dock column (--sf-rightdock-left published by hud.js). */
  top: max(56px, calc(var(--sf-hud-edge, 20px) + 36px));
  /* Right edge keys off the live right-dock boundary (hud.js publishes --sf-rightdock-left from
     the measured plate box): a tall dock — sector law + target card + radar — used to grow up
     under this column so a decision card clipped the target's top line (D240). The deck now ends
     14px left of the dock at any dock height; the fallback keeps it clear before the first
     measurement lands. */
  right: calc(100vw - var(--sf-rightdock-left, calc(100vw - 250px)) + 14px);
  width: min(328px, calc(100vw - 32px));
  max-height: min(56vh, 540px);
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  padding: 2px;
  /* A live decision outranks the receipt lane (toasts x480–800, auto-fading) — an over-tall
     prompt may transiently cover a toast rather than clip its own choices; the deck root is
     pointer-events:none so it still costs the player nothing but the fading line. */
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  box-sizing: border-box;
  font-family: var(--dp-face-read, "Instrument Sans", system-ui, sans-serif);
  color: var(--dp-ink, #e8e2d4);
}
#sf-prompt-deck[hidden] { display: none !important; }

/* The polite announcement region — never rendered, never focused. */
.sf-prompt-deck__live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* One glass frame per rendered decision. Kind is carried by the top edge + flag word, never by
   colour alone (the countdown line and the keycaps repeat the state in text). */
.sf-prompt {
  flex: 0 0 auto;
  contain: layout paint style;
  box-sizing: border-box;
  pointer-events: auto;
  padding: 12px;
  border-radius: 4px;
  border: 1px solid rgb(236 230 216 / 0.14);
}
/* Demo-prep microinteraction: a NEW decision settles in once — promptDeck.js sets data-enter on
   first build and drops it on animationend, so re-laid-out live cards never replay the slide
   (detach+reattach restarts a bare animation). Compositor transform/opacity only, and the
   leaving beat below already owns the exit. Reduced motion cuts it. */
.sf-prompt[data-enter]:not(.sf-prompt--leaving) { animation: sf-prompt-in 150ms ease-out 1; }
@keyframes sf-prompt-in { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .sf-prompt[data-enter]:not(.sf-prompt--leaving) { animation: none; } }
html.sf-reduce-motion .sf-prompt[data-enter]:not(.sf-prompt--leaving) { animation: none; }

.sf-prompt__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.06em;
  color: var(--dp-ink-mute, #9ba3b0);
}
.sf-prompt--warn .sf-prompt__head { color: var(--dp-lamp, #f2b950); }
.sf-prompt--danger .sf-prompt__head { color: var(--dp-danger-hot, #ff8a70); }
.sf-prompt__sender {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sf-prompt__flag { flex: none; font-weight: 600; }
.sf-prompt__flag[hidden] { display: none !important; }

.sf-prompt__headline {
  margin: 4px 0 0;
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  font-weight: 600;
  color: var(--dp-ink-hi, #f4f1ea);
}
.sf-prompt__detail {
  margin: 3px 0 0;
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: 0.015em;
  word-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  color: var(--dp-ink-dim, #9ba3b0);
}
.sf-prompt__detail--urgent { color: var(--dp-danger-hot, #ff8a70); font-weight: 600; }

.sf-prompt__content { margin: 6px 0 0; font-size: 12px; line-height: 1.4; letter-spacing: 0.015em; word-spacing: 0.08em; color: var(--dp-ink-dim, #9ba3b0); }
.sf-prompt__content:empty { display: none; }

/* The countdown arc (fed by promptDeck.js renderCountdown; a quantity is an arc, ORRERY §3.2).
   Rides the head's right shoulder; the numeric seconds stay in the detail line. The arc's stroke
   tones are the orrery library's (.orr-phos at rest, .orr-threat in the urgent window). */
#sf-prompt-deck .sf-prompt__clock {
  flex: none;
  width: 18px;
  height: 18px;
  align-self: center;
  overflow: visible;
}
#sf-prompt-deck .sf-prompt__clock[hidden] { display: none !important; }

/* Stabilization meter (recovery adapter) — a value channel, updated in place via one custom property. */
.sf-prompt-meter {
  height: 3px;
  margin-top: 8px;
  overflow: hidden;
  background: var(--dp-metal-0, rgb(255 255 255 / 0.08));
  border-radius: 2px;
}
.sf-prompt-meter i {
  display: block;
  width: 100%;
  height: 100%;
  transform: scaleX(var(--v, 0));
  transform-origin: left center;
  background: var(--dp-phos, #dfeeff);
}

/* Choices: real buttons with printed keycaps. Digit order is the visual order; routeDigit()
   guarantees a keystroke never maps to two controls (deck owns Digit1-9 while a decision shows). */
.sf-prompt__choices {
  display: grid;
  gap: 5px;
  margin-top: 10px;
}
.sf-prompt__choices[hidden] { display: none !important; }
.sf-prompt__choice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 34px;
  padding: 6px 8px;
  color: inherit;
  font: 500 12px/1.25 var(--dp-face-read, "Instrument Sans", system-ui, sans-serif);
  letter-spacing: 0.02em;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease, translate 0.1s ease;
}
.sf-prompt__choice b {
  flex: none;
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  min-height: 20px;
  font-family: var(--dp-face-num, "Spline Sans Mono", monospace);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--dp-ink-hi, #f4f1ea);
}
/* Disabled choices claim no digit — the empty keycap box stays out of the way. */
.sf-prompt__choice b:empty { visibility: hidden; }
.sf-prompt__choice span { flex: 1; min-width: 0; white-space: normal; overflow-wrap: anywhere; }
.sf-prompt__choice:hover,
.sf-prompt__choice:focus-visible,
.sf-prompt__choice.is-highlight {
  border-color: rgb(242 185 80 / 0.55);
}
.sf-prompt__choice:active { translate: 0 1px; }
.sf-prompt__choice:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  outline: none;
  border-color: var(--dp-lamp-dim, #8a6b3a);
}
.sf-prompt__choice--danger:not(:disabled) { border-color: color-mix(in srgb, var(--dp-danger, #ff5038) 55%, transparent); }
.sf-prompt__choice--danger:not(:disabled) b { color: var(--dp-danger-hot, #ff8a70); }

/* Collapsed decisions: one honest row — keycap + left-aligned name + tabular countdown, click to raise. */
.sf-prompt-chip {
  flex: 0 0 auto;
  contain: layout style;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 34px;
  padding: 6px 12px 6px 21px;
  pointer-events: auto;
  color: var(--dp-ink, #e8e2d4);
  font: 500 12px/1.3 var(--dp-face-read, "Instrument Sans", system-ui, sans-serif);
  letter-spacing: 0.02em;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}
.sf-prompt-chip__key {
  flex: none;
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  min-height: 20px;
  font-family: var(--dp-face-num, "Spline Sans Mono", monospace);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--dp-ink-hi, #f4f1ea);
}
.sf-prompt-chip__label {
  flex: 1;
  min-width: 0;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sf-prompt-chip__time {
  flex: none;
  margin-left: auto;
  font-family: var(--dp-face-num, "Spline Sans Mono", monospace);
  font-variant-numeric: tabular-nums;
  font-style: normal;
  color: var(--dp-phos, #dfeeff);
}
.sf-prompt-chip:hover, .sf-prompt-chip:focus-visible {
  border-color: rgb(242 185 80 / 0.55);
}

/* Exit beat: the card is already detached from the entries map, so this only has to read as
   "leaving", not reserve ladder space. Slides out the same edge it entered from. */
.sf-prompt--leaving {
  opacity: 0;
  transform: translateX(14px);
  transition: opacity 150ms ease, transform 150ms ease;
}
.sf-prompt-chip--leaving {
  opacity: 0;
  transition: opacity 150ms ease;
}

/* Small viewports: one rule for the whole family — a bottom sheet above the command bar. This
   replaces the three divergent per-card breakpoints the deck retired. */
@media (max-width: 900px), (max-height: 620px) {
  #sf-prompt-deck {
    top: auto;
    /* Keep the bottom flight instruments and command rail visible. The active card and one-line
       collapsed prompts live above that reserved band; further decisions remain raisable chips. */
    bottom: max(224px, 25vh);
    left: 12px;
    right: auto;
    width: min(392px, calc(100vw - 172px));
    max-height: 44vh;
  }
}

/* In short landscape flight the instruments occupy the left side. Keep the decision on the
   right instead of stretching a sheet across the speed dial and the command rail. */
@media (min-width: 640px) and (max-height: 620px) {
  #sf-prompt-deck {
    top: 112px;
    bottom: auto;
    left: auto;
    right: 12px;
    width: min(392px, calc(100vw - 350px));
    max-height: calc(100vh - 144px);
  }
}

@media (max-width: 420px) {
  #sf-prompt-deck { width: min(352px, calc(100vw - 24px)); }
  #sf-prompt-deck .sf-prompt__choice span {
    overflow: visible;
    overflow-wrap: anywhere;
    text-overflow: clip;
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sf-prompt, .sf-prompt__choice, .sf-prompt-chip { transition: none !important; }
}

/* ══ Deckplate (FRONTEND_PROGRAM) ═══════════════════════════════════════════════════════════════
   The deck is a flight instrument, not a consumer card: each decision is a crisp 1px-bordered plate
   on the same dark glass the comms fan and power rail wear, and each verb is a distinct interactive
   row with a tabular mono keycap. The lamp means act-on (warn = amber filament, danger = lamp at
   failure), the phosphor means read (countdown, meter). Corners are machined 4px breaks — no 10px
   consumer card radius. ════════════════════════════════════════════════════════════════════════ */
#sf-prompt-deck .sf-prompt {
  border: 1px solid var(--sf-pop-seam);
  border-top: 2px solid var(--dp-phos);
  border-radius: 2px;
  background: var(--sf-pop-glass), var(--dp-glass-solid);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.07), 0 14px 32px -10px rgb(0 0 0 / 0.78);
  color: var(--dp-ink);
}
/* Attention states light the bezel itself rather than a consumer accent edge. */
#sf-prompt-deck .sf-prompt--warn {
  border-image-source: none;
  border-top-color: var(--dp-lamp);
}
#sf-prompt-deck .sf-prompt--danger {
  border-image-source: none;
  border-top-color: var(--dp-danger-hot);
}
#sf-prompt-deck .sf-prompt__head {
  gap: 7px; padding-bottom: 6px; margin-bottom: 6px; border-bottom: 1px solid var(--dp-rule-hi);
  font-family: var(--dp-face-read, "Instrument Sans", sans-serif);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dp-ink-mute);
}
#sf-prompt-deck .sf-prompt__head::before {
  content: ""; flex: none; width: 22px; height: 22px; background: var(--sf-pop-record) center / contain no-repeat;
}
#sf-prompt-deck .sf-prompt--danger .sf-prompt__head::before { background-image: var(--sf-pop-interlock); }
#sf-prompt-deck .sf-prompt__sender { flex: 1; white-space: normal; overflow-wrap: anywhere; }
#sf-prompt-deck .sf-prompt--warn .sf-prompt__head { color: var(--dp-lamp); }
#sf-prompt-deck .sf-prompt--danger .sf-prompt__head { color: var(--dp-danger-hot); }
#sf-prompt-deck .sf-prompt__headline {
  font-family: var(--dp-face-read, "Instrument Sans", sans-serif);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--dp-ink-hi, var(--dp-ink));
  text-shadow: none;
}
#sf-prompt-deck .sf-prompt__detail,
#sf-prompt-deck .sf-prompt__content {
  font-family: var(--dp-face-read, "Instrument Sans", sans-serif);
  letter-spacing: 0.015em;
  word-spacing: 0.08em;
  color: var(--dp-ink-dim);
}
#sf-prompt-deck .sf-prompt__detail--urgent { color: var(--dp-danger-hot); }
/* the meter is a recessed phosphor channel, not a painted progress bar */
#sf-prompt-deck .sf-prompt-meter {
  background: var(--dp-metal-0);
  border-radius: 2px;
  box-shadow: 0 1px 0 rgb(255 236 204 / 0.06);
}
#sf-prompt-deck .sf-prompt-meter i {
  background: var(--dp-phos);
  box-shadow: var(--dp-phos-emit-soft);
}
/* verbs are glass keys; selection is the lamp — lit edge, lit legend, printed keycap. */
#sf-prompt-deck .sf-prompt__choice {
  border: 1px solid rgb(236 230 216 / 0.11);
  border-radius: 4px;
  background: linear-gradient(180deg, rgb(255 255 255 / 0.045), rgb(255 255 255 / 0.015)), var(--dp-glass-solid);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.04);
  color: var(--dp-ink);
  font-family: var(--dp-face-read, "Instrument Sans", sans-serif);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
#sf-prompt-deck .sf-prompt__choice b {
  border: 1px solid rgb(236 230 216 / 0.20);
  border-radius: 3px;
  min-width: 20px;
  min-height: 20px;
  padding: 0 4px;
  border-image: none;
  font-family: var(--dp-face-num, "Spline Sans Mono", monospace);
  font-weight: 600;
  color: var(--dp-ink-hi, var(--dp-ink));
  background: rgb(255 255 255 / 0.05);
}
#sf-prompt-deck .sf-prompt__choice:hover,
#sf-prompt-deck .sf-prompt__choice:focus-visible,
#sf-prompt-deck .sf-prompt__choice.is-highlight {
  border-color: rgb(242 185 80 / 0.55);
  background: linear-gradient(180deg, rgb(242 185 80 / 0.14), rgb(242 185 80 / 0.05)), var(--dp-glass-solid);
  color: var(--dp-lamp-hot);
  text-shadow: none;
  outline: 0;
  box-shadow: inset 0 1px 0 rgb(242 185 80 / 0.18), 0 6px 14px -8px var(--dp-lamp-bloom);
}
#sf-prompt-deck .sf-prompt__choice:hover b,
#sf-prompt-deck .sf-prompt__choice:focus-visible b,
#sf-prompt-deck .sf-prompt__choice.is-highlight b {
  border-image-source: none;
  border-color: var(--dp-lamp);
  background: rgb(242 185 80 / 0.16);
  color: var(--dp-lamp-hot);
}
#sf-prompt-deck .sf-prompt__choice:focus-visible { outline: 1px solid var(--dp-lamp, #f2b950); outline-offset: 1px; }
#sf-prompt-deck .sf-prompt__choice:active { border-image-source: none; }
#sf-prompt-deck .sf-prompt__choice:disabled {
  opacity: 0.42;
  color: var(--dp-ink-mute);
  cursor: not-allowed;
  outline: none;
  box-shadow: none;
}
#sf-prompt-deck .sf-prompt__choice--danger:not(:disabled) {
  border-color: rgb(239 107 99 / 0.28);
  box-shadow: inset 0 1px 0 rgb(239 107 99 / 0.08);
}
#sf-prompt-deck .sf-prompt__choice--danger:not(:disabled) b {
  border-color: rgb(239 107 99 / 0.38);
  color: var(--dp-danger-hot);
}
#sf-prompt-deck .sf-prompt__choice--danger:not(:disabled):hover,
#sf-prompt-deck .sf-prompt__choice--danger:not(:disabled):focus-visible {
  border-color: rgb(239 107 99 / 0.60);
  background: linear-gradient(180deg, rgb(239 107 99 / 0.16), rgb(239 107 99 / 0.06)), var(--dp-glass-solid);
  color: var(--dp-danger-hot);
  text-shadow: none;
  box-shadow: inset 0 1px 0 rgb(239 107 99 / 0.16);
}
/* collapsed decisions: the same plate language, one row */
#sf-prompt-deck .sf-prompt-chip {
  border: 1px solid rgb(236 230 216 / 0.12);
  border-radius: 4px;
  background: linear-gradient(180deg, rgb(16 20 28 / 0.92), rgb(11 14 20 / 0.92)), var(--dp-glass-solid);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05), 0 8px 20px -6px rgb(0 0 0 / 0.65);
  color: var(--dp-ink);
  font-family: var(--dp-face-read, "Instrument Sans", sans-serif);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
#sf-prompt-deck .sf-prompt-chip__key {
  border: 1px solid rgb(236 230 216 / 0.20);
  border-radius: 3px;
  min-width: 20px;
  min-height: 20px;
  padding: 0 4px;
  border-image: none;
  font-family: var(--dp-face-num, "Spline Sans Mono", monospace);
  font-weight: 600;
  color: var(--dp-ink-hi, var(--dp-ink));
  background: rgb(255 255 255 / 0.05);
}
#sf-prompt-deck .sf-prompt-chip__time { color: var(--dp-phos); text-shadow: none; }
#sf-prompt-deck .sf-prompt-chip:hover, #sf-prompt-deck .sf-prompt-chip:focus-visible {
  border-color: rgb(242 185 80 / 0.55);
  background: linear-gradient(180deg, rgb(242 185 80 / 0.12), rgb(14 18 24 / 0.94)), var(--dp-glass-solid);
  color: var(--dp-lamp-hot);
  outline: none;
  box-shadow: inset 0 1px 0 rgb(242 185 80 / 0.16), 0 8px 20px -6px rgb(0 0 0 / 0.65);
}
#sf-prompt-deck .sf-prompt-chip:focus-visible {
  outline: 2px solid var(--dp-lamp, #f2b950);
  outline-offset: 2px;
}
#sf-prompt-deck .sf-prompt-chip:hover .sf-prompt-chip__key,
#sf-prompt-deck .sf-prompt-chip:focus-visible .sf-prompt-chip__key {
  border-color: var(--dp-lamp);
  background: rgb(242 185 80 / 0.16);
  color: var(--dp-lamp-hot);
}

@media (forced-colors: active) {
  #sf-prompt-deck .sf-prompt,
  #sf-prompt-deck .sf-prompt__choice,
  #sf-prompt-deck .sf-prompt-chip,
  #sf-prompt-deck .sf-prompt__choice b,
  #sf-prompt-deck .sf-prompt-chip__key {
    border-image:none; border:1px solid CanvasText;
    background:Canvas; color:CanvasText; box-shadow:none;
  }
  #sf-prompt-deck .sf-prompt__choice:hover,
  #sf-prompt-deck .sf-prompt__choice:focus-visible,
  #sf-prompt-deck .sf-prompt-chip:hover,
  #sf-prompt-deck .sf-prompt-chip:focus-visible { outline:2px solid Highlight; }
}
