/* Prompter — Creative Studio design system (Phase 10 V2).
   Dark graphite foundation, restrained violet/lavender accent, one
   signature background glow — see docs/phase10-v1-creative-studio-design
   -spec.md for the full rationale behind every token below. */

:root {
  --bg-0: #0b0b10;
  --surface-1: #14141c;
  --surface-2: #1b1b26;
  --surface-2-hover: #212130;
  --border: #2a2a38;
  --border-strong: #3a3a4c;
  --text-primary: #f3f1f7;
  --text-muted: #a6a3b8;
  --text-faint: #6e6b82;
  --accent: #a78bfa;
  --accent-strong: #8b5cf6;
  --accent-soft: rgba(139, 92, 246, 0.14);
  --accent-ink: #15101f;
  --danger-bg: #241318;
  --danger-border: #e5484d;
  --danger-text: #f2a6a0;

  --radius-card: 22px;
  --radius-input: 13px;
  --radius-btn: 11px;
  --radius-pill: 999px;

  --font-display: "Instrument Serif", Georgia, serif;
  --font-ui: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg-0);
  color: var(--text-primary);
  font: 400 16px/1.55 var(--font-ui);
}

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

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

/* ---------- Top bar ---------- */
.topbar { padding: 20px 24px; }
.wordmark { font: 600 15px var(--font-ui); letter-spacing: -0.01em; color: var(--text-primary); }

/* ---------- Page / glow / stage ---------- */
.page {
  position: relative;
  min-height: calc(100vh - 64px);
  padding: 24px 20px 64px;
  display: flex;
  justify-content: center;
}

.glow {
  position: fixed;
  top: 10%;
  left: 50%;
  width: 620px;
  height: 620px;
  transform: translateX(-50%);
  background: radial-gradient(circle, var(--accent-strong) 0%, transparent 70%);
  opacity: 0.1;
  filter: blur(40px);
  pointer-events: none;
  z-index: 0;
}

.stage {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 720px;
  margin-top: 24px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 40px clamp(20px, 5vw, 48px);
  box-shadow: 0 20px 50px -30px rgba(0, 0, 0, 0.6);
}

.stage:has(.phase-result:not([hidden])) { max-width: 860px; }

/* ---------- Phase transitions ---------- */
.phase[hidden] { display: none; }
.phase.entering { animation: phase-in 240ms var(--ease-out); }

@keyframes phase-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Typography ---------- */
.headline {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(32px, 4.2vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.lede { margin: 0 0 32px; color: var(--text-muted); font-size: clamp(16px, 1.6vw, 18px); line-height: 1.6; max-width: 46ch; }

.step-title { margin: 0 0 20px; font-size: 20px; font-weight: 600; }
.step-sub { font-weight: 400; color: var(--text-muted); font-size: 15px; }

.field-label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 10px; }

/* ---------- Idea input ---------- */
.idea-input {
  width: 100%;
  font: inherit;
  color: var(--text-primary);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  padding: 14px 16px;
  resize: none;
  overflow: hidden;
  min-height: 92px;
  transition: border-color 150ms var(--ease-out), background 150ms var(--ease-out);
}
.idea-input::placeholder { color: var(--text-faint); }
.idea-input:hover { border-color: var(--border-strong); }
.idea-input:focus-visible { border-color: var(--accent); background: var(--surface-2-hover); }

.idea-recap {
  margin-bottom: 24px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  color: var(--text-muted);
  font-size: 14px;
  opacity: 0.75;
}
.idea-recap[hidden] { display: none; }

.inline-hint { margin: 10px 2px 0; font-size: 14px; color: var(--text-muted); }
.inline-hint[hidden] { display: none; }
.inline-hint.warn { color: var(--danger-text); }

/* ---------- Target toggle (segmented control) ---------- */
.target { border: 0; padding: 0; margin: 20px 0 28px; }
.segmented { display: inline-flex; border: 1.5px solid var(--border); border-radius: var(--radius-pill); overflow: hidden; background: var(--surface-2); }
.segmented input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.segmented label {
  margin: 0;
  padding: 9px 20px;
  font-weight: 500;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 150ms var(--ease-out), background 150ms var(--ease-out);
}
.segmented input:checked + label { background: var(--accent); color: var(--accent-ink); }
.segmented input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: -3px; }

/* ---------- Buttons ---------- */
.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.actions-secondary { margin-top: 20px; }

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  border-radius: var(--radius-btn);
  border: 1.5px solid transparent;
  padding: 11px 22px;
  transition: transform 120ms var(--ease-out), background 150ms var(--ease-out), border-color 150ms var(--ease-out);
}
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0) scale(0.98); }

.btn-primary { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%); color: var(--accent-ink); }
.btn-quiet { background: transparent; color: var(--text-primary); border-color: var(--border); }
.btn-quiet:hover:not(:disabled) { border-color: var(--border-strong); }
.btn-outline { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-outline:hover:not(:disabled) { background: var(--accent-soft); }
.btn-outline.copied { background: var(--accent-soft); }

/* ---------- Questions ---------- */
.questions-list { margin-bottom: 8px; }
.question-row { margin-bottom: 18px; }
.question-row label { display: block; font-weight: 500; font-size: 15px; margin-bottom: 8px; }
.question-row textarea {
  width: 100%;
  font: inherit;
  color: var(--text-primary);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  padding: 10px 14px;
  resize: vertical;
}
.question-row textarea:hover { border-color: var(--border-strong); }
.question-row textarea:focus-visible { border-color: var(--accent); }

/* ---------- Generating ---------- */
.generating { display: flex; align-items: center; gap: 14px; padding: 40px 0; min-height: 120px; }
.pulse-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}
.generating-label { color: var(--text-muted); font-size: 16px; }

/* ---------- Result ---------- */
.result-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.result-meta { color: var(--text-muted); font-size: 14px; }

.result-panel { position: relative; }
.result-panel.materialize { animation: materialize 260ms var(--ease-out); }
@keyframes materialize {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.prompt-text {
  margin: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  padding: 20px 22px;
  font: 400 14px/1.75 var(--font-mono);
  color: var(--text-primary);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 58vh;
  overflow: auto;
  user-select: text;
}
.prompt-text mark.tag { background: var(--accent-soft); color: var(--text-primary); padding: 1px 4px; border-radius: 4px; }
.prompt-text mark.fill { background: transparent; color: var(--text-primary); outline: 1.5px dashed var(--accent); outline-offset: 1px; border-radius: 3px; }
.fill-sample { background: transparent; color: var(--text-primary); outline: 1.5px dashed var(--accent); outline-offset: 1px; border-radius: 3px; padding: 0 2px; }

.result-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(11, 11, 16, 0.45);
  border-radius: var(--radius-input);
  color: var(--text-muted);
  font-size: 14px;
  backdrop-filter: blur(1px);
}
.result-overlay[hidden] { display: none; }
.prompt-text.dimmed { opacity: 0.5; }

/* ---------- Refine ---------- */
.refine { margin-top: 24px; }
.refine-row { display: flex; gap: 10px; }
.refine-row input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--text-primary);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  padding: 11px 14px;
}
.refine-row input::placeholder { color: var(--text-faint); }
.refine-row input:focus-visible { border-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  background: transparent;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  cursor: pointer;
  transition: background 150ms var(--ease-out);
}
.chip:hover:not(:disabled) { background: var(--accent-soft); }
.chip:disabled { opacity: 0.45; cursor: progress; }

/* ---------- Error banner ---------- */
.banner.error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 24px;
  padding: 14px 16px;
  border-left: 4px solid var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-text);
  border-radius: 0 10px 10px 0;
  font-size: 15px;
}
.banner.error[hidden] { display: none; }
.retry-btn {
  flex-shrink: 0;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  color: var(--danger-text);
  background: transparent;
  border: 1.5px solid var(--danger-border);
  border-radius: var(--radius-btn);
  padding: 7px 14px;
  cursor: pointer;
}
.retry-btn:hover { background: rgba(229, 72, 77, 0.12); }
.retry-btn[hidden] { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .stage { padding: 28px 18px; margin-top: 12px; }
  .result-bar { flex-wrap: wrap; }
  .prompt-text { max-height: none; }
  .phase-idea .actions,
  .phase-questions .actions {
    position: sticky;
    bottom: 12px;
    margin-top: 24px;
    padding: 10px;
    background: linear-gradient(180deg, transparent, var(--surface-1) 30%);
    border-radius: var(--radius-btn);
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
