/* ── Scribe Task Show ─────────────────────────────────────────────
   Scoped to .st-* prefix. No global selectors used.
   Loaded only on scribe_tasks views via content_for :head.
   ─────────────────────────────────────────────────────────────── */

/* ── Page layout ─────────────────────────────────────────────── */

.st-page {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ── Breadcrumb ──────────────────────────────────────────────── */

.st-breadcrumb {
  margin-bottom: 0.25rem;
}

.st-breadcrumb .bc-sep {
  margin: 0 0.3em;
  opacity: 0.35;
}

/* ── Task header ─────────────────────────────────────────────── */

.st-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.st-header-main {
  flex: 1;
  min-width: 0;
}

.st-header-main h1 {
  margin: 0 0 0.4rem 0;
  word-break: break-word;
}

.st-header-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.st-header-actions {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
}

/* Section labels inside task page boxes need bottom spacing.
   .section-label resets margin to 0, so we restore it here with
   higher specificity rather than relying on tachyons mb3. */
.st-page .box .section-label {
  margin-bottom: 0.65rem;
}

/* ── Comment thread ──────────────────────────────────────────── */

.st-thread-box {
  /* no overflow: hidden — compose bleeds to box edge via negative margin */
}

.st-thread {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  margin-bottom: 0.75rem;
}

.st-msg {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-width: 80%;
}

.st-msg--user {
  align-self: flex-end;
  align-items: flex-end;
}

.st-msg--agent {
  align-self: flex-start;
  align-items: flex-start;
  max-width: 100%;
}

/* Bubbles */

.st-bubble {
  padding: 0.55rem 0.8rem;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.st-bubble--user {
  background: var(--color-primary);
  color: #fff;
  border: 1px solid var(--color-primary);
}

.st-bubble--agent {
  background: var(--surface-subtle);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  max-width: 640px;
}

/* Meta row under each bubble */

.st-msg-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.st-msg-meta--right {
  flex-direction: row-reverse;
}

/* ── Reply compose area ──────────────────────────────────────── */

.st-compose {
  border-top: 1px solid var(--color-border);
  /* bleed to box edges using negative margin; padding compensates */
  margin: 0 calc(var(--base-spacing) * -1) calc(var(--base-spacing) * -1);
  padding: 0.6rem var(--base-spacing) var(--base-spacing);
  background: var(--surface-subtle);
}

/* No thread above compose — remove separator line and top gap */
.st-compose--no-thread {
  border-top: none;
  margin-top: calc(var(--base-spacing) * -1);
  padding-top: var(--base-spacing);
}

.st-compose-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.st-compose-input {
  width: 100%;
  border: 1px solid var(--color-border);
  background: var(--color-box);
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  font-family: var(--font-stack-sans-serif);
  line-height: 1.5;
  resize: none;
  outline: none;
  color: var(--color-text);
  min-height: 72px;
  display: block;
  transition: border-color 0.12s;
}

.st-compose-input:focus {
  border-color: var(--color-border-hover);
  box-shadow: none;
  outline: none;
}

.st-compose-input::placeholder {
  color: var(--color-text-muted);
}

.st-compose-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.st-compose-hint {
  font-size: 0.72rem;
  opacity: 0.4;
  font-family: var(--font-stack-monospace);
  flex: 1;
}

/* ── File upload form ─────────────────────────────────────────── */

.st-upload-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.st-upload-input {
  font-size: 0.85rem;
  flex: 1;
  min-width: 0;
}

.st-upload-input::file-selector-button {
  font-family: var(--font-stack-sans-serif);
  font-size: 0.85rem;
  padding: 0.3rem 0.65rem;
  background: var(--color-box);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--color-text);
  margin-right: 0.35rem;
  transition: background-color 0.12s;
}

.st-upload-input::file-selector-button:hover {
  background: var(--surface-subtle);
}

.st-upload-caption {
  min-width: 120px;
  max-width: 200px;
  flex: 1;
}

/* ── Artifact table detail row (images, markdown, etc.) ────────── */

.st-artifact-image {
  border: 1px solid var(--color-border);
  overflow: hidden;
  line-height: 0;
}

.st-artifact-image img {
  max-width: 100%;
  display: block;
}

.st-markdown-content {
  font-size: 0.9rem;
  line-height: 1.65;
  white-space: normal;
}

.st-markdown-content p:first-child { margin-top: 0; }
.st-markdown-content p:last-child  { margin-bottom: 0; }

.st-html-content {
  all: initial;
  display: block;
  font-family: sans-serif;
  font-size: 14px;
  line-height: 1.6;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  color: #000;
}

/* ── Agent Activity section ──────────────────────────────────── */

.st-activity-details {
  /* no special box overrides needed — inherits .box styles */
}

.st-activity-details > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.st-activity-details > summary::-webkit-details-marker {
  display: none;
}

/* Single arrow from global summary::before; full-width row, no underline */
.st-activity-summary {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
  font-weight: 500;
}

.st-activity-summary:hover,
.st-activity-summary:focus {
  text-decoration: none;
  color: inherit;
}

.st-activity-summary-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
}

.st-activity-list {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
}

.st-activity-row {
  padding: 0.45rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.82rem;
}

.st-activity-row + .st-activity-row {
  border-top: 1px solid var(--color-border);
}

.st-activity-row--error .st-activity-tool {
  color: var(--color-danger, #c0392b);
}

.st-activity-main {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.st-activity-tool {
  font-family: var(--font-stack-monospace);
  font-weight: 600;
  color: var(--color-text);
}

.st-activity-args {
  font-family: var(--font-stack-monospace);
  opacity: 0.55;
  font-size: 0.78rem;
}

.st-activity-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.st-activity-result {
  opacity: 0.55;
  font-size: 0.78rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ── Session-grouped activity ─────────────────────────────────── */

.st-activity-session {
  border: 1px solid var(--color-border);
  border-radius: 4px;
  margin-top: 0.5rem;
}

.st-activity-session + .st-activity-session {
  margin-top: 0.5rem;
}

.st-activity-session > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.st-activity-session > summary::-webkit-details-marker {
  display: none;
}

.st-activity-session > summary::before {
  content: "\25B6";
  font-size: 0.6rem;
  transition: transform 0.15s;
}

.st-activity-session[open] > summary::before {
  transform: rotate(90deg);
}

.st-activity-session-name {
  font-family: var(--font-stack-monospace);
  font-weight: 600;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.st-activity-session-meta {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

.st-activity-session-body {
  padding: 0.25rem 0.75rem 0.75rem 1.25rem;
  margin-left: 0.5rem;
  border-left: 2px solid var(--color-border);
  display: flex;
  flex-direction: column;
}

.st-activity-message {
  padding: 0.35rem 0;
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: 0.82rem;
}

.st-activity-message + .st-activity-message,
.st-activity-message + .st-activity-row,
.st-activity-row + .st-activity-message {
  border-top: 1px solid var(--color-border);
}

.st-activity-message-content {
  margin: 0;
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 6rem;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.st-activity-expand {
  font-size: 0.78rem;
}

.st-activity-expand .st-activity-message-content {
  max-height: none;
  margin-top: 0.25rem;
}

.st-activity-output {
  margin-top: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

.st-activity-output-summary {
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
}

.st-activity-output-content {
  padding: 0.5rem;
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  max-height: 20rem;
  overflow-y: auto;
}

/* ── Empty states ─────────────────────────────────────────────── */

.st-empty {
  font-size: 0.85rem;
  opacity: 0.4;
  margin: 0;
}

/* ── Mobile ───────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .st-header {
    flex-direction: column;
    gap: 0.6rem;
  }

  .st-header-actions .button {
    width: 100%;
    justify-content: center;
  }

  .st-msg {
    max-width: 94%;
  }

  .st-msg--agent {
    max-width: 100%;
  }

  .st-compose {
    padding: 0.6rem var(--base-spacing) var(--base-spacing);
  }
}

/* ── Dark mode ────────────────────────────────────────────────── */

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .st-bubble--user {
    background: var(--color-primary);
    border-color: var(--color-primary);
  }

  html:not([data-theme="light"]) .st-bubble--agent {
    background: var(--surface-subtle);
    border-color: var(--color-border);
    color: var(--color-text);
  }

  html:not([data-theme="light"]) .st-compose {
    background: var(--surface-subtle);
  }

  html:not([data-theme="light"]) .st-compose-input {
    background: var(--input-bg);
    color: var(--color-text);
    border-color: var(--color-border);
  }

  html:not([data-theme="light"]) .st-html-content {
    color: var(--color-text);
  }
}
