/* Phase 9.1 Prompt Randomizer --------------------------------------------- */
.prompt-station {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 112;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.prompt-card {
  --prompt-preview-width: 220px;
  --prompt-card-padding: 12px;
  --prompt-header-height: 31px;
  --panel-open-width: min(calc(var(--prompt-preview-width) + 2 * var(--prompt-card-padding)), calc(100vw - 32px));
  width: var(--panel-open-width);
  max-height: min(560px, calc(100vh - 32px));
  overflow: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  padding: var(--prompt-card-padding);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: var(--panel-bg);
  box-shadow: var(--shadow-panel);
  pointer-events: auto;
  display: grid;
  gap: 8px;
}
.prompt-card[hidden] { display: none; }
.prompt-card-header { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; min-height:var(--prompt-header-height); }
.prompt-card-header > div:first-child { min-width:0; flex:1; }
.prompt-title { margin-top:2px; font-family:var(--font-title); text-transform:uppercase; font-size:var(--font-md); font-weight:400; line-height:1.2; max-width:100%; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.prompt-idle { display:grid; align-content:start; gap:9px; }
.prompt-active { display:grid; gap:6px; min-height:0; }
.prompt-mode-selector { display:grid; grid-template-columns:repeat(3,1fr); gap:4px; }
.prompt-category-selector { grid-template-columns:repeat(2,1fr); }
.prompt-category-selector #prompt-category-mixed { grid-column:1 / -1; }
.prompt-mode-button, .prompt-primary-button, .prompt-secondary-button {
  appearance:none; border:1px solid var(--panel-border); border-radius:6px;
  background:var(--surface-1); color:var(--text-color); font:inherit; cursor:pointer;
}
.prompt-mode-button { min-height:29px; font-size:var(--font-xs); font-weight:600; opacity:var(--opacity-muted); }
.prompt-mode-button[aria-pressed="true"], .prompt-mode-button:hover, .prompt-mode-button:focus-visible { opacity:1; background:var(--surface-2); }
.prompt-primary-button { min-height:34px; font-size:var(--font-sm); font-weight:600; }
.prompt-secondary-button { min-height:28px; padding:4px 11px; font-size:var(--font-xs); opacity:var(--opacity-muted); }
.prompt-primary-button:hover, .prompt-primary-button:focus-visible, .prompt-secondary-button:hover, .prompt-secondary-button:focus-visible { background:var(--surface-2); opacity:1; }
.prompt-reference-frame { position:relative; width:min(var(--prompt-preview-width), 100%); justify-self:center; margin-bottom:12px; --prompt-slide-distance: 80px; transition: opacity 1000ms var(--ease-out-quart), transform 1000ms var(--ease-out-quart); }
/* The 1000 ms here and PROMPT_COMPLETION_DELAY_MS in js/app/06-prompt-lifecycle.js (1000 ms leave + 100 ms gap) go together. */
.prompt-reference-frame.is-leaving { opacity: 0; transform: translateX(var(--prompt-slide-distance)); }
.prompt-reference-frame.is-leaving .prompt-approximation { visibility: hidden; }
.prompt-reference-frame.is-entering-start { opacity: 0; transform: translateX(calc(-1 * var(--prompt-slide-distance))); transition: none; }
.prompt-reference { display:grid; place-items:center; width:100%; aspect-ratio:11/9; border-radius:8px; background:var(--surface-1); overflow:hidden; box-sizing:border-box; }
.prompt-reference-svg { width:100%; height:100%; display:block; flex:none; }
.prompt-approximation { position:absolute; right:7px; bottom:5px; font-size:var(--font-xs); line-height:1; opacity:var(--opacity-muted); font-variant-numeric:tabular-nums; white-space:nowrap; pointer-events:none; }
.prompt-trace-toggle { justify-self:start; white-space:nowrap; }
.prompt-trace-toggle[aria-pressed="true"] { opacity:1; background:var(--surface-2); }
.prompt-category-chip { display:flex; align-items:center; justify-content:center; gap:4px; min-width:0; padding-inline:4px; }
.prompt-chip-count { font-size:var(--font-xs); font-weight:600; opacity:var(--opacity-muted); font-variant-numeric:tabular-nums; }
.prompt-completed summary { cursor:pointer; font-size:var(--font-xs); font-weight:600; opacity:var(--opacity-muted); }
.prompt-tally { display:grid; gap:3px; padding-top:4px; font-size:var(--font-xs); font-variant-numeric:tabular-nums; }
.prompt-tally-row { display:flex; justify-content:space-between; gap:8px; opacity:var(--opacity-secondary); }
.prompt-actions { display:grid; grid-template-columns:1fr auto 1fr; align-items:center; gap:6px; width:min(var(--prompt-preview-width), 100%); justify-self:center; }
#prompt-stop { justify-self:center; }
#prompt-skip { justify-self:end; }
.prompt-icon-button { display:inline-flex; align-items:center; justify-content:center; min-width:34px; padding:4px 9px; }
.prompt-icon-button svg { display:block; }
.prompt-idle[hidden], .prompt-active[hidden] { display:none; }
.prompt-secondary-button:disabled { opacity:var(--opacity-faint); cursor:default; }
@media (max-width:720px) {
  .prompt-station { top:16px; right:16px; }
  .prompt-card { --prompt-card-padding:10px; max-height:min(560px, calc(100vh - 32px)); }
}
@media (max-height:430px) {
  .prompt-station { top:12px; right:12px; }
  .prompt-card { max-height:calc(100vh - 24px); }
  .prompt-active { gap:4px; }
  .prompt-card { --prompt-preview-width:160px; --panel-open-width:min(244px, calc(100vw - 32px)); }
}
@media (prefers-reduced-motion:reduce) { .prompt-card { scroll-behavior:auto; } }

/* Receding (mouse and pen only). No prompt running: the card rests as a thin bar on its right edge, dimmed to --opacity-rest.
   Prompt running (has-active-prompt, set in renderPromptCard): the card chrome fades out and the preview glides up as the header,
   the 8px gap and the top and bottom padding collapse to 0. The preview is not dimmed. The frame, title and buttons come back when the mouse is near. The class is-expanded is set by updateRecedingPanels() in js/app/13-render-and-strokes.js.
   The bar changes its real width like the brush panel (constant radius, overflow: hidden), so the border, shadow and corners travel with the edge. */
@media (hover: hover) {
  .prompt-card {
    padding-left: 0;
    padding-right: 0;
    justify-content: end;
    transition: opacity 0.4s var(--ease-out-quart), transform 0.3s var(--ease-out-quart), width 0.4s var(--ease-out-quart), background-color 0.4s var(--ease-out-quart), border-color 0.4s var(--ease-out-quart), box-shadow 0.4s var(--ease-out-quart), padding-top 0.4s var(--ease-out-quart), padding-bottom 0.4s var(--ease-out-quart), row-gap 0.4s var(--ease-out-quart) !important;
    border-image-slice: 0 1 0 0;
    border-image-width: 0 1px 0 0;
  }
  .prompt-card > *, .prompt-actions { transition: opacity 0.4s var(--ease-out-quart), visibility 0.4s var(--ease-out-quart); }
  .prompt-card > * { flex: none; width: calc(var(--panel-open-width) - 2 * var(--prompt-card-padding) - 2px); margin-right: var(--prompt-card-padding); }
  .prompt-reference { transition: background-color 0.4s var(--ease-out-quart); }
  .prompt-card.has-active-prompt .prompt-card-header { height: var(--prompt-header-height); min-height: 0; overflow: hidden; transition: opacity 0.4s var(--ease-out-quart), visibility 0.4s var(--ease-out-quart), height 0.4s var(--ease-out-quart); }

  .prompt-card:not(.has-active-prompt):not(.is-expanded) {
    width: 12px;
    border-color: transparent;
    --edge-line: var(--text-color);
    border-image-source: linear-gradient(to bottom, transparent 0, transparent 6px, var(--edge-line) 6px, var(--edge-line) calc(100% - 6px), transparent calc(100% - 6px));
    transition: opacity 0.4s var(--ease-out-quart), transform 0.3s var(--ease-out-quart), width 0.4s var(--ease-out-quart), background-color 0.4s var(--ease-out-quart), border-color 0.4s var(--ease-out-quart), box-shadow 0.4s var(--ease-out-quart), padding-top 0.4s var(--ease-out-quart), padding-bottom 0.4s var(--ease-out-quart), row-gap 0.4s var(--ease-out-quart), --edge-line 0.2s var(--ease-out-quart) 0.2s, border-image-source 0s var(--ease-out-quart) 0.2s allow-discrete !important;
    overflow-y: hidden;
  }
  body:not(.ui-hidden) .prompt-card:not(.has-active-prompt):not(.is-expanded) { opacity: var(--opacity-rest); }
  .prompt-card:not(.has-active-prompt):not(.is-expanded) > * { opacity: 0; visibility: hidden; }

  .prompt-card.has-active-prompt:not(.is-expanded) { background-color: transparent; border-color: transparent; box-shadow: none; padding-top: 0; padding-bottom: 0; row-gap: 0; }
  .prompt-card.has-active-prompt:not(.is-expanded) .prompt-card-header,
  .prompt-card.has-active-prompt:not(.is-expanded) .prompt-actions { opacity: 0; visibility: hidden; }
  .prompt-card.has-active-prompt:not(.is-expanded) .prompt-card-header { height: 0; }
  .prompt-card.has-active-prompt:not(.is-expanded) .prompt-reference { background-color: var(--panel-bg-solid); }
}
