/* Workshop operator UI (AI-395) — semantic vars from tokens.css */

/* ── Shell ─────────────────────────────────────────────────────────── */
body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-app);
  min-height: 100vh;
}

.ws-shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--page-glow), var(--surface);
}

.ws-page {
  width: 100%;
  max-width: var(--app-max);
  padding: 72px 18px 40px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Login ──────────────────────────────────────────────────────────── */
.ws-login-wrap {
  width: 100%;
  max-width: var(--app-max);
  padding: 0 24px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 24px;
}

.ws-wordmark-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.ws-wordmark {
  font: 700 28px var(--font-app);
}

.ws-tagline {
  font: 500 14px var(--font-app);
  color: var(--ink-soft);
  font-style: italic;
}

.ws-login-card {
  width: 100%;
}

.ws-login-error {
  color: var(--rest-text);
  font: 500 13px var(--font-app);
  margin: 0;
}

.ws-mono-note {
  font: 10px ui-monospace, Menlo, monospace;
  color: var(--mono-faint);
  text-align: center;
  margin: 0;
  line-height: 1.6;
}

/* ── Bench header ────────────────────────────────────────────────────── */
.ws-bench-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 4px 18px;
}

/* ── Cards ───────────────────────────────────────────────────────────── */
.ws-card {
  background: var(--card);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--card-shadow);
}

.ws-card-title {
  font: 700 17px var(--font-app);
  margin-bottom: 12px;
}

/* ── Form / Fields ──────────────────────────────────────────────────── */
.ws-run-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ws-field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ws-field-full {
  grid-column: 1 / -1;
}

.ws-field-block {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ws-field-label {
  font: 600 12px var(--font-app);
  color: var(--ink-soft);
}

.ws-field {
  height: 44px;
  border-radius: 14px;
  background: var(--field);
  box-shadow: inset 0 0 0 1.5px var(--line-12);
  border: none;
  font: 600 14px var(--font-app);
  color: var(--ink);
  padding: 0 14px;
  box-sizing: border-box;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
}

.ws-field:focus {
  outline: none;
  box-shadow: inset 0 0 0 1.5px var(--primary-outline);
}

.ws-field-select-wrap {
  position: relative;
}

.ws-field-select-wrap::after {
  content: "▾";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-soft);
  pointer-events: none;
  font-size: 12px;
}

.ws-select {
  cursor: pointer;
}

/* ── Pills ───────────────────────────────────────────────────────────── */
.ws-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  border-radius: 999px;
  font: 700 16px var(--font-app);
  color: #FFFDF7;
  border: none;
  cursor: pointer;
  padding: 0 28px;
  text-decoration: none;
  transition: transform 80ms ease;
  width: 100%;
  box-sizing: border-box;
}

.ws-pill:active {
  transform: scale(0.97);
}

.ws-pill-primary {
  background: var(--primary);
  box-shadow: 0 6px 16px var(--primary-ring);
}

.ws-pill-confirm {
  background: var(--confirm);
  box-shadow: 0 6px 16px var(--confirm-22);
}

.ws-pill-rest {
  background: var(--rest);
  box-shadow: 0 4px 12px var(--rest-16);
}

/* ── Chips (state badges) ────────────────────────────────────────────── */
.ws-chip {
  padding: 6px 14px;
  border-radius: 999px;
  font: 700 12px var(--font-app);
  flex: none;
  white-space: nowrap;
}

/* Replaces ad-hoc style="flex:none" on header chips */
.ws-chip--fixed {
  flex: none;
}

.ws-state-queued   { background: var(--accent-22);   color: var(--accent-text); }
.ws-state-running  { background: var(--accent-22);   color: var(--accent-text); }
.ws-state-staged   { background: var(--info-20);     color: var(--info-text); }
.ws-state-approved { background: var(--confirm-22);  color: var(--confirm-text); }
.ws-state-rejected { background: var(--rest-16);     color: var(--rest-text); }
.ws-state-failed   { background: var(--rest-16);     color: var(--rest-text); }

/* ── Runs list ───────────────────────────────────────────────────────── */
.ws-section-head {
  font: 700 17px var(--font-app);
  padding: 20px 4px 12px;
}

.ws-runs-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 26px;
}

.ws-run-card {
  background: var(--card);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  gap: 12px;
}

.ws-run-card--staged {
  box-shadow: var(--card-shadow), 0 0 0 1.5px var(--info-ring);
}

/* Cover thumbnail on the parent's published-stories shelf. */
.ws-story-cover {
  flex-shrink: 0;
  width: 78px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--field);
  box-shadow: 0 0 0 1.5px var(--primary-ring);
}

.ws-story-cover--ours {
  box-shadow: 0 0 0 1.5px var(--accent);
}

.ws-run-card-link {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.ws-run-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ws-run-title {
  font: 700 15px var(--font-app);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ws-run-meta {
  font: 500 12px var(--font-app);
  color: var(--ink-soft);
}

/* ── Delete button (armed two-tap) ──────────────────────────────────── */
.ws-delete-btn {
  height: 40px;
  min-width: 40px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--ghost);
  color: var(--ink-soft);
  border: none;
  font: 700 13px var(--font-app);
  cursor: pointer;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms, color 150ms, transform 80ms;
}

.ws-delete-btn:active { transform: scale(0.94); }

.ws-delete-btn[data-armed] {
  background: var(--rest);
  color: #FFFDF7;
}

.ws-delete-btn--wide { width: auto; padding: 0 16px; }

.ws-delete-story-row {
  display: flex;
  justify-content: center;
  padding: 0 0 24px;
}

/* ── Empty state ─────────────────────────────────────────────────────── */
.ws-empty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  padding: 26px 20px;
}

.ws-empty-title {
  font: 700 15px var(--font-app);
  color: var(--ink-soft);
}

.ws-empty-sub {
  font: 500 13px var(--font-app);
  color: var(--ink-faint);
}

/* ── Run page header ─────────────────────────────────────────────────── */
.ws-run-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 4px 20px;
}

.ws-back-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--btn-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 20px var(--font-app);
  color: var(--ink-soft);
  text-decoration: none;
  flex: none;
  transition: transform 80ms;
}

.ws-back-btn:active { transform: scale(0.94); }

.ws-run-head-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ws-run-head-title {
  font: 700 19px var(--font-app);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ws-run-head-meta {
  font: 500 13px var(--font-app);
  color: var(--ink-soft);
}

/* ── Start card ──────────────────────────────────────────────────────── */
.ws-start-card {
  margin-bottom: 0;
}

/* ── Progress card ───────────────────────────────────────────────────── */
.ws-progress-card {
  border-radius: 22px;
  padding: 26px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

/* ── Beads ───────────────────────────────────────────────────────────── */
.ws-beads {
  display: flex;
  align-items: center;
  gap: 14px;
}

.ws-bead {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex: none;
  transition: all 300ms ease;
}

.ws-bead--done    { background: var(--confirm); }
.ws-bead--current { width: 24px; height: 24px; background: var(--accent); box-shadow: 0 0 0 5px var(--accent-22), 0 0 22px 2px var(--accent-22); transition: none; }
.ws-bead--rest    { background: var(--card); box-shadow: inset 0 0 0 3px var(--rest); }
.ws-bead--future  { background: var(--line-10); }

.ws-bead-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

.ws-bead-label {
  font: 600 10px var(--font-app);
  color: var(--ink-faint);
}

.ws-bead-label--done    { color: var(--ink-soft); }
.ws-bead-label--current { font-weight: 700; color: var(--accent-text); }
.ws-bead-label--rest    { color: var(--rest-text); }

.ws-progress-headline {
  font: 700 19px var(--font-app);
  text-align: center;
}

.ws-progress-headline--staged   { color: var(--info-text); }
.ws-progress-headline--approved { color: var(--confirm-text); }
.ws-progress-headline--rested   { color: var(--rest-text); }

.ws-progress-card--staged {
  box-shadow: var(--card-shadow), 0 0 0 1.5px var(--info-ring);
}

.ws-progress-sub {
  font: 500 13px var(--font-app);
  color: var(--ink-soft);
  text-align: center;
  max-width: 280px;
}

/* ── Review pills ────────────────────────────────────────────────────── */
.ws-review-pills {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

/* ── Error box ───────────────────────────────────────────────────────── */
.ws-error-box {
  background: var(--rest-16);
  color: var(--rest-text);
  border-radius: 12px;
  padding: 12px 14px;
  font: 11px ui-monospace, Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
  width: 100%;
  box-sizing: border-box;
}

/* ── Ghost anticipatory card ─────────────────────────────────────────── */
.ws-ghost-card {
  margin-top: 4px;
  background: var(--card);
  border-radius: 22px;
  padding: 18px 20px;
  box-shadow: var(--card-shadow), 0 0 0 1.5px var(--info-ring);
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0.55;
  width: 100%;
  box-sizing: border-box;
}

.ws-ghost-title { font: 700 16px var(--font-app); }
.ws-ghost-sub   { font: 500 12px var(--font-app); color: var(--ink-soft); }

/* ── Progress actions ───────────────────────────────────────────────── */
.ws-progress-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
}

/* ── Story review pages ─────────────────────────────────────────────── */
.ws-story-pages {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 120px; /* room for sticky footer */
}

.ws-page-card {
  padding: 0;
  overflow: hidden;
  border-radius: 22px;
}

.ws-page-art {
  width: 100%;
  display: block;
  border-radius: 22px 22px 0 0;
  aspect-ratio: 16/9;
  object-fit: cover;
}

.ws-page-art-fallback {
  width: 100%;
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, var(--info-20) 0%, var(--accent-22) 50%, var(--primary-16) 100%);
}

.ws-page-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ws-page-art-wrap {
  position: relative;
}

.ws-page-num {
  position: absolute;
  bottom: 14px;
  right: 16px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 253, 247, 0.9);
  color: var(--ink-soft);
  font: 700 12px var(--font-app);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ws-page-text {
  font: 500 16px/1.65 var(--font-story);
  color: var(--ink);
  margin: 0;
}

/* ── Audio pill ─────────────────────────────────────────────────────── */
.ws-audio-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  background: var(--field);
  border-radius: 999px;
  padding: 0 14px 0 6px;
  box-shadow: inset 0 0 0 1.5px var(--line-12);
}

.ws-audio-play {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #FFFDF7;
  border: none;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: transform 80ms;
}

.ws-audio-play:active { transform: scale(0.93); }

.ws-audio-track {
  flex: 1;
  height: 4px;
  background: var(--line-10);
  border-radius: 2px;
  overflow: hidden;
}

.ws-audio-progress {
  height: 100%;
  background: var(--primary);
  width: 0%;
  border-radius: 2px;
  transition: width 200ms linear;
}

.ws-audio-time {
  font: 600 11px ui-monospace, Menlo, monospace;
  color: var(--ink-soft);
  flex: none;
}

/* ── Sticky review footer ────────────────────────────────────────────── */
.ws-review-footer {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max);
  padding: 12px 18px 28px;
  box-sizing: border-box;
  background: linear-gradient(to top, var(--surface) 60%, transparent);
  display: flex;
  gap: 10px;
}

.ws-review-footer .ws-pill {
  flex: 1;
}

/* ── Delete story link ───────────────────────────────────────────────── */
.ws-delete-story-link {
  background: none;
  border: none;
  color: var(--rest-text);
  font: 500 13px var(--font-app);
  cursor: pointer;
  padding: 8px 0;
  text-decoration: underline;
}

.ws-delete-story-btn {
  background: var(--ghost);
  border: none;
  color: var(--ink-soft);
  font: 500 12px var(--font-app);
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 999px;
}

/* ── Start card spacing ──────────────────────────────────────────────── */
.ws-start-card + .ws-section-head {
  padding-top: 20px;
}

/* ── Library link (below start card, above runs) ─────────────────────── */
.ws-pill--library-link {
  margin-top: 12px;
}

/* ── Parent tab shell ────────────────────────────────────────────────── */
.ws-tabs {
  display: flex;
  gap: 8px;
  padding: 0 4px 16px;
}

.ws-tab {
  flex: 1;
  text-align: center;
  height: 44px;
  border-radius: 999px;
  background: var(--ghost);
  color: var(--ink-soft);
  font: 700 13px var(--font-app);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms, color 120ms;
}

.ws-tab--active {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--card-shadow), inset 0 0 0 1.5px var(--line-12);
}

/* ── Rest card (cap state) ───────────────────────────────────────────── */
.ws-card--rest {
  background: var(--rest-16);
  color: var(--rest-text);
  margin-bottom: 12px;
}

.ws-card--rest .ws-card-title {
  color: var(--rest-text);
}

/* ── Capped form (dim + inert) ───────────────────────────────────────── */
.ws-form--capped {
  opacity: 0.45;
  pointer-events: none;
}

/* ── Four-minute note ────────────────────────────────────────────────── */
.ws-form-note {
  font: 500 13px var(--font-app);
  color: var(--ink-soft);
  margin: 0;
  text-align: center;
}

/* ── Parent header: title stack + child's-shelf exit ──────────────────── */
.ws-parent-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 16px;
}

.ws-parent-title-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ws-parent-title {
  font: 700 25px var(--font-app);
}

.ws-parent-sub {
  font: 500 12.5px var(--font-app);
  color: var(--ink-soft);
}

.ws-pill-shelf {
  flex: none;
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 15px;
  border-radius: 999px;
  background: var(--confirm-22);
  box-shadow: inset 0 0 0 1.5px var(--confirm);
  color: var(--confirm-text);
  font: 700 12.5px var(--font-app);
  text-decoration: none;
}

/* ── Filter / sort bar ───────────────────────────────────────────────── */
.ws-filter-bar {
  display: flex;
  gap: 8px;
  height: 36px;
  align-items: center;
  padding: 0 2px 0;
  margin-bottom: 4px;
}

/* Two equal-width pills (handoff §4 "Filter and sort"). */
.ws-filter-bar > * {
  flex: 1 1 0;
  min-width: 0;
}

.ws-filter-wrap {
  position: relative;
}

.ws-filter-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  border-radius: 999px;
  font: 600 13px var(--font-app);
  color: var(--ink-soft);
  background: var(--ghost);
  border: none;
  cursor: pointer;
  padding: 0 14px;
  white-space: nowrap;
  text-decoration: none;
  transition: background 120ms, color 120ms;
  width: 100%;
  box-sizing: border-box;
}

.ws-filter-pill--active {
  background: var(--accent-22);
  color: var(--accent-text);
}

.ws-filter-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 180px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--card-shadow), 0 0 0 1.5px var(--line-12);
  z-index: 100;
  overflow: hidden;
}

.ws-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--ink);
  font: 500 13px var(--font-app);
  gap: 12px;
  transition: background 80ms;
}

.ws-filter-row:hover { background: var(--ghost); }

.ws-filter-row--selected { color: var(--accent-text); font-weight: 700; }

.ws-filter-name { flex: 1; }

.ws-filter-count {
  font: 600 12px var(--font-app);
  color: var(--ink-faint);
}

/* ── Result count ────────────────────────────────────────────────────── */
.ws-stories-count {
  font: 500 12px var(--font-app);
  color: var(--ink-faint);
  padding: 0 4px 10px;
}

/* ── Armed-delete wrap ───────────────────────────────────────────────── */
.ws-delete-armed-wrap {
  display: flex;
  align-items: center;
  flex: none;
}

.ws-arm-confirm {
  margin: 0;
}

.ws-delete-btn--armed {
  background: var(--rest);
  color: #FFFDF7;
  font-size: 12px;
  white-space: nowrap;
}

/* ── Accent pill (orchid CTA) ────────────────────────────────────────── */
.ws-pill-accent {
  background: var(--accent);
  box-shadow: 0 6px 16px var(--accent-22);
  color: var(--on-accent);
  gap: 9px;
}

.ws-pill-plus {
  font-size: 20px;
  line-height: 1;
}

/* ── Make-a-story CTA spacing ────────────────────────────────────────── */
.ws-pill--make-cta {
  margin-bottom: 14px;
}

/* ── Make screen note card ───────────────────────────────────────────── */
.ws-make-note-card {
  margin-top: 12px;
  border: 1.5px solid var(--line-12);
  background: var(--ghost);
  box-shadow: none;
}

.ws-make-note-body {
  font: 500 14px/1.6 var(--font-app);
  color: var(--ink-soft);
  margin: 0;
}

/* ── Textarea field (make screen premise) ────────────────────────────── */
.ws-textarea {
  height: auto;
  padding: 10px 14px;
  resize: vertical;
  min-height: 80px;
}

/* ── Shared badge ────────────────────────────────────────────────────── */
.ws-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font: 700 11px var(--font-app);
  flex: none;
  white-space: nowrap;
}

.ws-badge--ours {
  background: var(--accent-22);
  color: var(--accent-text);
}

.ws-badge--shared {
  background: var(--info-20);
  color: var(--info-text);
}

/* ── Being-made run row (parent) ─────────────────────────────────────── */
.ws-run-row {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.ws-run-row-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ws-run-row-beads {
  display: flex;
  align-items: center;
  gap: 7px;
}

.ws-run-row-beads .ws-bead {
  width: 10px;
  height: 10px;
}

.ws-run-row-beads .ws-bead--current {
  width: 14px;
  height: 14px;
  box-shadow: 0 0 0 3px var(--accent-22);
}

.ws-run-row-beads .ws-bead--rest {
  box-shadow: inset 0 0 0 2px var(--rest);
}

.ws-run-row-step {
  font: 600 11px var(--font-app);
  color: var(--ink-soft);
  padding-left: 4px;
}

.ws-run-row-action {
  height: 42px;
}

/* ── Sign out: quiet, top-right, only once Clerk confirms a user ─────── */
.ws-signout {
  position: absolute;
  top: 16px;
  right: max(16px, calc(50% - var(--app-max) / 2 + 16px));
  width: auto;
  height: 34px;
  padding: 0 14px;
  background: var(--ghost);
  box-shadow: inset 0 0 0 1.5px var(--line-12);
  color: var(--ink-soft);
  font: 600 12.5px var(--font-app);
}

/* `hidden` must win over component display rules (.ws-pill is inline-flex). */
[hidden] {
  display: none !important;
}

/* ── Empty state muted line ──────────────────────────────────────────── */
.ws-empty-muted {
  font: 500 12px var(--font-app);
  color: var(--ink-faint);
  margin-top: 4px;
}
