/*
 * The PromptSection run control and its prompt body (LIN-3975). The shared opened-task component (public/prompt-section.js)
 * is mounted on Home, Swipe and the task page, and this sheet holds the rules those mounts draw: the header and text of a
 * prompt, the warning, the streaming fade, and the .opened-task-* run control. Moved out of swipe.css so the task page
 * can style its run control without loading Swipe's card CSS. Home, Swipe and the task page each link it, after style.css.
 */
/* Prompt Section Header (fresh / generating / error) */
.prompt-section .swipe-prompt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.4rem 0;
  font-family: var(--font-content);
  font-size: 11px;
}

.prompt-section[data-phase="idle"] .swipe-prompt-header {
  border-bottom: 1px solid var(--fg-vdim);
}

.prompt-section[data-phase="fresh"] .swipe-prompt-header,
.prompt-section[data-phase="generating"] .swipe-prompt-header,
.prompt-section[data-phase="error"] .swipe-prompt-header {
  border-bottom: 1px solid var(--fg-vdim);
  margin-bottom: 0.4rem;
}

.swipe-prompt-name {
  color: var(--fg-dim);
  font-weight: 600;
}

.swipe-prompt-actions button,
.prompt-section .swipe-prompt-change {
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--fg-dim);
  font-family: var(--font-content);
  font-size: 10px;
  cursor: pointer;
  transition: background 0.15s;
}

.swipe-prompt-actions button:hover,
.prompt-section .swipe-prompt-change:hover {
  background: var(--bg-muted);
}

.swipe-prompt-text {
  padding: var(--space-2) 0 0;
  font-size: 13px;
  line-height: 1.6;
  max-height: 400px;
  overflow-y: auto;
  color: var(--fg);
}

/* Warning banner: surfaces a truncated/incomplete generation to the user */
.swipe-prompt-warning {
  margin-top: var(--space-2);
  padding: 0.4rem 0.6rem;
  font-size: 12px;
  line-height: 1.4;
  color: #8a5a00;
  background: #fff6e0;
  border: 1px solid #f0d28a;
  border-radius: 4px;
}

/* Streaming fade-in for the section */
@keyframes promptFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.prompt-section.streaming {
  animation: promptFadeIn 0.3s ease-out both;
}

/* Per-element fade-in during streaming — new blocks materialise smoothly */
@keyframes streamIn {
  from { opacity: 0; filter: blur(2px); transform: translateY(4px); }
  to   { opacity: 1; filter: blur(0);   transform: translateY(0); }
}

.swipe-prompt-text .stream-in {
  animation: streamIn 0.35s ease-out both;
}

/* Subtle indicator on the element currently being written to */
.prompt-section.streaming .swipe-prompt-text .stream-cursor {
  border-left: 2px solid rgba(0,0,0,0.12);
  padding-left: var(--space-2);
  transition: border-color 0.3s;
}

/* Bottom gradient mask during streaming — text appears to materialise */
.prompt-section.streaming .swipe-prompt-text {
  mask-image: linear-gradient(to bottom, #000 75%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 75%, transparent 100%);
}

/* ==========================================================================
   Opened-task component (LIN-2944). Swipe's Prompts accordion renders the
   shared PromptSection. These styles cover the ✦ primary, the one-line why,
   the ladder, "other prompts", the generated-age line, the visible reasoning
   block and the disabled-primary reason. Colours come ONLY from the shared
   semantic tokens plus --green-dim/--amber-dim/--blue (LIN-3123 owns contrast
   work; no new colour values here). Both light and .theme-dark inherit the
   tokens, so one block covers both themes. The face split follows CLAUDE.md:
   sans (--font-content) for human labels/prose, mono (--font-structural) for
   machine facts.
   ========================================================================== */

/* One-line ranking reason — human prose, so sans. */
.opened-task-why {
  margin: 0.15rem 0 var(--space-2);
  font-family: var(--font-content);
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

/* The ✦ primary action: the most prominent control on the surface. */
.opened-task-primary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-2) 0;
}

.opened-task-go {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 1rem;
  min-height: 40px;
  border: 1px solid var(--blue);
  border-radius: var(--radius-md);
  background: var(--blue);
  /* --bg is white in light and near-black in dark, so the label stays legible
     on the blue fill in BOTH themes without a new colour value. */
  color: var(--bg);
  font-family: var(--font-content);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s, border-color 0.15s;
}

.opened-task-go:hover:not(:disabled) {
  filter: brightness(1.08);
}

.opened-task-go:disabled {
  background: var(--card);
  border-color: var(--line);
  color: var(--muted);
  cursor: not-allowed;
}

.opened-task-primary-reason {
  font-family: var(--font-content);
  font-size: 11px;
  line-height: 1.4;
  color: var(--amber-dim);
}

/* LIN-3341: Go is the primary; the ✦ next step is a secondary, and Go's
   started/refusal lines sit in the same slot. The started line reuses the task
   page's own `.task-status` / `.task-sentence` markup (styled only in
   task-page.css), so those two rules are mirrored here for Home and Swipe. */
.opened-task-next-step-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-2) 0;
}

.opened-task-next-step {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--raised);
  color: var(--text);
  font-family: var(--font-content);
  font-size: 13px;
  cursor: pointer;
}

.opened-task-next-step:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.opened-task-started {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
}

.opened-task-started .task-status {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.opened-task-started .task-status-pill { flex-shrink: 0; }

.opened-task-started .task-sentence {
  margin: 0;
  font-family: var(--font-content);
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--text);
}

.opened-task-started-link,
.opened-task-go-notice-link {
  font-family: var(--font-content);
  font-size: 12px;
  color: var(--brand);
  text-decoration: none;
}

.opened-task-go-notice {
  flex-basis: 100%;
  font-family: var(--font-content);
  font-size: 12px;
  line-height: 1.4;
  color: var(--amber-dim);
}

.opened-task-go-notice:empty { display: none; }

.opened-task-run-quota {
  font-family: var(--font-content);
  font-size: 11px;
  color: var(--muted);
}

/* The ladder: a sequence of rungs, copy -> run this step. (Go is the run-task
   move now, rendered above the ladder.) */
.opened-task-ladder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: var(--space-2) 0;
}

.opened-task-rung {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.7rem;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: var(--raised);
  color: var(--text);
  font-family: var(--font-content);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.opened-task-rung--ready {
  border-color: var(--green-dim);
  color: var(--green-dim);
}

.opened-task-rung--ready:hover {
  background: var(--card);
}

/* Not-yet-ready rungs are SHOWN, dashed and muted — available, not broken. */
.opened-task-rung--setup {
  border-style: dashed;
  border-color: var(--line);
  color: var(--muted);
}

.opened-task-setup {
  color: var(--amber-dim);
  font-size: 11px;
}

/* A rung that needs a prompt while the ✦ stream is generating one (N4):
   shown, but inert until the prompt lands. */
.opened-task-rung--pending {
  border-style: dashed;
  border-color: var(--line);
  color: var(--muted);
  cursor: default;
}

.opened-task-rung--pending .opened-task-setup {
  color: var(--muted);
}

/* Templates grouped under "other prompts" — human label, sans. */
.opened-task-other-prompts {
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--line-soft);
}

.opened-task-other-prompts-label {
  font-family: var(--font-content);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin-bottom: var(--space-1);
}

/* "generated 2h ago · regenerate" — an age fact (mono) plus an action. */
.opened-task-generated {
  font-family: var(--font-structural);
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.opened-task-regenerate {
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--raised);
  color: var(--blue);
  font-family: var(--font-content);
  font-size: 10px;
  cursor: pointer;
}

.opened-task-regenerate:hover:not(:disabled) {
  background: var(--card);
}

.opened-task-regenerate:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

/* Visible reasoning (LIN-2944 reverses LIN-70): secondary to, but readable
   beside, the prompt body. */
.opened-task-reasoning {
  margin: 0 0 var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-left: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-family: var(--font-content);
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  max-height: 300px;
  overflow-y: auto;
}

.opened-task-reasoning p { margin: 0 0 0.4rem; }

.opened-task-reasoning ul,
.opened-task-reasoning ol { margin: 0 0 0.4rem; padding-left: var(--space-4); }

/* Notice shown when a not-yet-enabled rung is pressed. */
.opened-task-setup-notice {
  margin: var(--space-1) 0;
  font-family: var(--font-content);
  font-size: 11px;
  color: var(--amber-dim);
}
