/* ==========================================================================
   PocketCorp Operations — product styles
   Everything the shared shell (app.css) doesn't cover: the onboarding hero,
   the five task cards, the activity feed, the review queues, the transcript.
   Monochrome, sharp, structural — status is line-work, not color.
   ========================================================================== */

/* ---------- Overflow safety ----------
   The stack-glitch effect sets `white-space: nowrap` on its slices so the
   horizontal clip bands line up. That is fine for a short wordmark, but a long
   PAGE title ("Run a company on autopilot", a task title) then can't wrap and
   pushes the whole page wider than a phone. Page titles wrap instead — the
   clip bands tile the full (taller) height either way, so the effect survives.
   The content box also refuses to scroll sideways as a last resort. */

.page-title.stack-glitch { white-space: normal; max-width: 100%; }
.page-title .stack-glitch__slice { white-space: normal; }
.content { overflow-x: hidden; }

/* ---------- Sidebar: company block ---------- */

.side-company { padding: 18px 24px 14px; display: flex; flex-direction: column; gap: 6px; }

.side-company-name {
  font-family: var(--pc-font-display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: var(--pc-track-tight);
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.side-company-mode {
  font-size: 0.55rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: var(--pc-dim-3);
}

.side-company-mode.is-auto { opacity: 1; }
.side-company-mode.is-auto::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--pc-ok);
  animation: pulse-dot 1.6s ease-in-out infinite;
}

@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- Status dots (shared) ---------- */

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  flex-shrink: 0;
}

.dot--live { background: var(--pc-ok); border-color: var(--pc-ok); animation: pulse-dot 1.2s ease-in-out infinite; }

/* ---------- Onboarding ---------- */

.onboard { display: flex; min-height: 60vh; align-items: center; }

.onboard-hero { max-width: 640px; display: flex; flex-direction: column; gap: 22px; }

.onboard-hero .page-sub { max-width: none; }

.onboard-goal { min-height: 84px; font-size: 0.8rem; }

.onboard-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* Three quiet pulsing bars while bootstrap runs. */
.onboard-pulse { display: flex; gap: 6px; }
.onboard-pulse span {
  width: 34px;
  height: 3px;
  background: var(--pc-ink);
  animation: onboard-pulse 1.2s ease-in-out infinite;
}
.onboard-pulse span:nth-child(2) { animation-delay: 0.2s; }
.onboard-pulse span:nth-child(3) { animation-delay: 0.4s; }

@keyframes onboard-pulse { 0%, 100% { opacity: 0.15; } 50% { opacity: 1; } }

.onboard-feed { display: flex; flex-direction: column; gap: 6px; min-height: 90px; }

.onboard-feed-line {
  font-size: 0.66rem;
  letter-spacing: 0.03em;
  opacity: var(--pc-dim-1);
  animation: view-enter 0.4s var(--pc-ease) both;
}

/* ---------- Proposal (approve or regenerate the name) ---------- */

.company-proposal-line {
  font-family: var(--pc-font-display);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: var(--pc-track-tight);
  margin-top: 4px;
}

.btn--lg { padding: 16px 40px; font-size: 0.72rem; }

/* ---------- Build screen (per-asset skeletons filling in) ---------- */

.onboard--build { display: block; }

.build-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--pc-gap);
  margin-top: 8px;
}

/* The logo and landing cards read as the headline assets — full width. */
.build-card:first-child, .build-card:last-of-type { grid-column: 1 / -1; }

.build-card {
  border: 1px solid var(--pc-border);
  padding: 18px 20px;
  min-height: 128px;
  transition: border-color 0.3s ease;
}

.build-card.is-done { border-color: var(--pc-border-hover); animation: content-fade 0.4s ease both; }

.build-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.build-card-label {
  font-family: var(--pc-font-display);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: var(--pc-track);
  text-transform: uppercase;
}

.build-card-status {
  font-size: 0.52rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: var(--pc-dim-3);
}

.build-card.is-done .build-card-status { opacity: 1; }
.build-card.is-done .build-card-status::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  background: var(--pc-ink);
}

.build-skeleton { display: flex; flex-direction: column; gap: 9px; }
.build-skeleton--square { display: block; }

.sk-line { height: 10px; }
.sk-line:last-child { width: 70%; }
.sk-box { width: 88px; height: 88px; }

.build-content { animation: content-fade 0.45s ease both; }
.build-text { font-size: 0.68rem; line-height: 1.85; opacity: var(--pc-dim-1); }
.build-tweet { font-size: 0.74rem; line-height: 1.8; }

.build-logo {
  width: 88px;
  height: 88px;
  border: 1px solid var(--pc-border);
  background: #fff;
  object-fit: cover;
}

.build-tasklist { display: flex; flex-direction: column; gap: 7px; }
.build-tasklist li {
  font-size: 0.68rem;
  line-height: 1.6;
  padding-left: 14px;
  position: relative;
}
.build-tasklist li::before { content: '›'; position: absolute; left: 0; opacity: var(--pc-dim-2); }

.build-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.build-done { margin-top: 32px; display: flex; justify-content: center; animation: view-enter 0.5s var(--pc-ease) both; }

/* ---------- Company hero (one-page dashboard) ---------- */

.company-hero { margin-bottom: 24px; }

.company-hero-row {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
}

.company-hero-text { flex: 1; min-width: 240px; }

.company-logo {
  width: 88px;
  height: 88px;
  flex-shrink: 0;
  border: 1px solid var(--pc-border);
  object-fit: cover;
  background: #fff;   /* generated logos are ink-on-white; keep them legible in dark mode */
}

.company-logo--fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--pc-font-display);
  font-size: 2.2rem;
  font-weight: 600;
  background: var(--pc-ink);
  color: var(--pc-surface);
}

.company-desc {
  margin-top: 10px;
  font-size: 0.68rem;
  line-height: 1.9;
  max-width: 560px;
  opacity: var(--pc-dim-1);
}

/* ---------- Live agent ticker (the Polsia terminal strip) ---------- */

.ticker {
  background: var(--pc-surface-inverse);
  color: var(--pc-ink-inverse);
  border: 1px solid var(--pc-border-strong);
  padding: 12px 16px;
  margin-bottom: 24px;
}

.ticker-body {
  max-height: 92px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: none;
}

.ticker-body::-webkit-scrollbar { display: none; }

.ticker-line {
  font-family: var(--pc-font-body);
  font-size: 0.64rem;
  line-height: 1.7;
  letter-spacing: 0.02em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  opacity: 0.85;
}

.ticker-line--live { opacity: 1; }
.ticker-line--live::after { content: '▋'; animation: pulse-dot 1s infinite; }

/* ---------- Metrics row ---------- */

.metrics-row { margin-bottom: 8px; }

.stat-tile .sub {
  margin-top: 4px;
  font-size: 0.55rem;
  letter-spacing: 0.06em;
  opacity: var(--pc-dim-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Two-column activity feed on the one-page layout. */
.feed--columns { max-width: 720px; }

/* ---------- Dashboard: autopilot switch ---------- */

.auto-block { display: flex; align-items: center; gap: 12px; }

.auto-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--pc-font-display);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: var(--pc-track);
  text-transform: uppercase;
  opacity: var(--pc-dim-1);
}

.switch {
  width: 46px;
  height: 24px;
  border: var(--pc-border-w) solid var(--pc-border-strong);
  padding: 2px;
  display: inline-flex;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.switch-knob {
  width: 16px;
  height: 16px;
  background: var(--pc-ink);
  transition: transform 0.25s var(--pc-ease), background 0.25s ease;
}

.switch.is-on { background: var(--pc-ink); border-color: var(--pc-ink); }
.switch.is-on .switch-knob { transform: translateX(22px); background: var(--pc-surface); }

/* ---------- Dashboard: layout ---------- */

.dash-cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--pc-gap); }
.dash-main, .dash-side { min-width: 0; }

.stat-tile--link { text-decoration: none; display: block; }
.stat-tile--link .num { font-size: 1.2rem; padding-top: 8px; text-transform: uppercase; letter-spacing: 0.1em; }

/* ---------- Task cards (the five) ---------- */

.task-cards { display: flex; flex-direction: column; gap: 14px; }

.task-card {
  border: 1px solid var(--pc-border);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.3s ease, background 0.3s ease, transform 0.3s var(--pc-ease);
}

.task-card:hover { border-color: var(--pc-border-hover); background: var(--pc-bg-subtle); transform: translateY(-2px); }

.task-card.is-running { border-style: dashed; border-color: var(--pc-border-strong); }

.task-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.domain-chip {
  font-family: var(--pc-font-display);
  font-size: 0.52rem;
  font-weight: 600;
  letter-spacing: var(--pc-track);
  text-transform: uppercase;
  border: 1px solid var(--pc-border-strong);
  padding: 3px 8px;
}

.task-priority { font-size: 0.58rem; opacity: var(--pc-dim-3); letter-spacing: 0.1em; }

.task-title { font-size: 0.82rem; letter-spacing: var(--pc-track-tight); }

.task-desc { font-size: 0.68rem; line-height: 1.8; opacity: var(--pc-dim-1); }

.task-actions { display: flex; gap: 8px; margin-top: 4px; }

.own-task-row { margin-top: 16px; }
.own-task-input { font-size: 0.72rem; }

/* ---------- Activity feed ---------- */

.feed { display: flex; flex-direction: column; gap: 0; }

.feed-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 0 10px 14px;
  border-left: 1.5px solid var(--pc-border);
  position: relative;
  animation: view-enter 0.35s var(--pc-ease) both;
}

.feed-item::before {
  content: '';
  position: absolute;
  left: -4.5px;
  top: 14px;
  width: 8px;
  height: 8px;
  background: var(--pc-surface);
  border: 1.5px solid var(--pc-ink);
}

.feed-tweet_posted::before, .feed-task_done::before { background: var(--pc-ink); }
.feed-task_failed::before, .feed-auto_paused::before { border-color: var(--pc-danger); background: var(--pc-danger); }

.feed-time { font-size: 0.55rem; letter-spacing: 0.08em; opacity: var(--pc-dim-3); }
.feed-text { font-size: 0.66rem; line-height: 1.7; overflow-wrap: anywhere; }

/* ---------- Tasks board ---------- */

.board-rows { display: flex; flex-direction: column; }

.board-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--pc-border-muted);
  text-decoration: none;
  transition: background 0.2s ease;
}

.board-row:hover { background: var(--pc-bg-hover); }

.status-dot { width: 8px; height: 8px; flex-shrink: 0; border: 1.5px solid var(--pc-ink); }
.status-dot--pending { border-style: dotted; }
.status-dot--running { background: var(--pc-ok); border-color: var(--pc-ok); animation: pulse-dot 1.2s infinite; }
.status-dot--done { background: var(--pc-ink); }
.status-dot--failed { background: var(--pc-danger); border-color: var(--pc-danger); }
.status-dot--dismissed { opacity: 0.3; }

.board-title { font-size: 0.72rem; letter-spacing: 0.02em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-dismissed .board-title { opacity: 0.4; text-decoration: line-through; }

.board-meta { font-size: 0.58rem; opacity: var(--pc-dim-3); letter-spacing: 0.05em; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Task transcript ---------- */

.result-card { margin-bottom: 20px; }
.result-card p { font-size: 0.72rem; line-height: 1.8; }

.transcript {
  border: 1px solid var(--pc-border);
  background: var(--pc-bg-subtle);
  padding: 20px 22px;
  max-height: 62vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tr-line { font-size: 0.7rem; line-height: 1.8; overflow-wrap: anywhere; }

.tr-user {
  align-self: flex-end;
  max-width: 85%;
  background: var(--pc-ink);
  color: var(--pc-surface);
  padding: 8px 12px;
}

.tr-thought { opacity: var(--pc-dim-3); font-style: italic; font-size: 0.64rem; }
.tr-tool { font-size: 0.6rem; letter-spacing: 0.08em; opacity: var(--pc-dim-2); }
.tr-error { color: var(--pc-danger); }
.tr-system { opacity: var(--pc-dim-2); font-size: 0.64rem; }

.tr-result summary {
  cursor: pointer;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: var(--pc-dim-3);
}

.tr-result pre {
  margin: 6px 0 0;
  padding: 10px;
  border: 1px solid var(--pc-border);
  font-size: 0.62rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.transcript-live {
  font-size: 0.7rem;
  line-height: 1.8;
  opacity: var(--pc-dim-1);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.transcript-live::after { content: '▋'; animation: pulse-dot 1s infinite; }

/* ---------- Products (real web apps) ---------- */

.section-note {
  font-size: 0.66rem;
  line-height: 1.8;
  opacity: var(--pc-dim-2);
  margin: -8px 0 18px;
  max-width: 640px;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--pc-gap);
}

.product-card {
  border: 1px solid var(--pc-border);
  display: flex;
  flex-direction: column;
  transition: border-color 0.3s ease, transform 0.3s var(--pc-ease);
}

.product-card:hover { border-color: var(--pc-border-hover); transform: translateY(-2px); }
.product-card.status-live { border-left: 3px solid var(--pc-ink); }
.product-card.status-failed { border-left: 3px solid var(--pc-danger); }

/* A framed, live thumbnail of the actual running app. The iframe is scaled
   down so a desktop-sized app still reads as a card-sized preview. */
.product-preview {
  position: relative;
  height: 200px;
  overflow: hidden;
  border-bottom: 1px solid var(--pc-border);
  background: var(--pc-bg-subtle);
}

.product-frame {
  border: 0;
  width: 250%;
  height: 500px;
  transform: scale(0.4);
  transform-origin: top left;
  pointer-events: none;   /* the card's Open button drives interaction */
  background: #fff;
}

.product-open {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--pc-surface);
  border: 1px solid var(--pc-border-strong);
  color: var(--pc-ink);
  transition: background 0.2s ease, color 0.2s ease;
}

.product-open:hover { background: var(--pc-ink); color: var(--pc-surface); }

.product-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.product-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.product-name { font-size: 0.82rem; letter-spacing: var(--pc-track-tight); }
.product-desc { font-size: 0.66rem; line-height: 1.75; opacity: var(--pc-dim-1); }
.product-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

.status-chip--ready { border-style: dashed; }
.status-chip--live { background: var(--pc-ink); color: var(--pc-surface); border-color: var(--pc-ink); }

/* ---------- Review queues (tweets / ads / domains) ---------- */

.queue-note { padding: 14px 18px; }
.queue-note p { font-size: 0.68rem; line-height: 1.8; }
.queue-note a { text-decoration: underline; text-underline-offset: 2px; }

.composer-row { display: flex; gap: 10px; align-items: flex-start; margin-top: 18px; }
.composer-row .textarea, .composer-row .input { flex: 1; }

.queue-list { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }

.queue-row {
  border: 1px solid var(--pc-border);
  padding: 16px 20px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  transition: border-color 0.3s ease;
}

.queue-row:hover { border-color: var(--pc-border-hover); }
.queue-row.status-dismissed { opacity: 0.45; }
.queue-row.status-posted, .queue-row.status-live { border-left: 3px solid var(--pc-ink); }
.queue-row.status-failed { border-left: 3px solid var(--pc-danger); }

.queue-row-body { min-width: 0; flex: 1; }
.queue-row-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

.queue-meta { margin-top: 8px; font-size: 0.6rem; letter-spacing: 0.04em; opacity: var(--pc-dim-2); }
.queue-error { color: var(--pc-danger); opacity: 1; }

.status-chip {
  font-family: var(--pc-font-display);
  font-size: 0.5rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  padding: 2px 6px;
}

.status-chip--draft { border-style: dashed; }
.status-chip--posted, .status-chip--live, .status-chip--active { background: var(--pc-ink); color: var(--pc-surface); border-color: var(--pc-ink); }
.status-chip--failed { color: var(--pc-danger); }

.tweet-text { font-size: 0.76rem; line-height: 1.8; overflow-wrap: anywhere; }

.ad-name { font-size: 0.78rem; letter-spacing: var(--pc-track-tight); }
.ad-headline { margin-top: 6px; font-size: 0.72rem; font-weight: 500; }
.ad-copy { margin-top: 4px; font-size: 0.66rem; line-height: 1.8; opacity: var(--pc-dim-1); }

.ad-budget { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.ad-budget-num { font-family: var(--pc-font-display); font-size: 1.6rem; font-weight: 500; margin-top: 4px; }

.domain-name { font-size: 0.74rem; letter-spacing: 0.02em; overflow-wrap: anywhere; }

/* ---------- Documents ---------- */

.doc-card h3 { text-transform: none; letter-spacing: 0.02em; }
.doc-preview {
  margin-top: 12px;
  font-size: 0.62rem;
  line-height: 1.7;
  opacity: var(--pc-dim-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.doc-body { max-width: 760px; }

/* ---------- Settings ---------- */

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--pc-gap); }
.card-title { font-size: 0.78rem; letter-spacing: var(--pc-track); }

.check-row { display: flex; align-items: center; gap: 10px; font-size: 0.68rem; cursor: pointer; }
.checkbox { width: 16px; height: 16px; accent-color: var(--pc-ink); }

/* ---------- Chat page ---------- */

body.view-fixed { overflow: hidden; }
body.view-fixed .content { display: flex; flex-direction: column; height: 100vh; padding-bottom: 24px; }

.page--chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.chat-head { margin-bottom: 14px; }
.chat-title {
  font-size: 1.1rem;
  letter-spacing: var(--pc-track);
}

.chat-mount { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pco-chat-host { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .dash-cols { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .onboard { min-height: auto; }
  .onboard-actions .btn { flex: 1; }
  .queue-row { flex-direction: column; }
  .queue-row-actions { justify-content: flex-start; }
  .composer-row { flex-direction: column; }
  .composer-row .btn { align-self: flex-start; }
  .auto-block { align-self: flex-start; }
  .board-meta { display: none; }
  body.view-fixed .content { height: calc(100dvh - 65px); }

  /* Company hero stacks; the logo sits above the name, autopilot below. */
  .company-hero-row { flex-direction: column; gap: 16px; }
  .company-logo, .company-logo--fallback { width: 64px; height: 64px; }
  .company-logo--fallback { font-size: 1.6rem; }

  .build-grid { grid-template-columns: 1fr; }
  .btn--lg { width: 100%; }

  /* Task transcript: tighter padding, bubbles nearly full width, and every
     long token / pre block wraps so nothing pushes the page sideways. */
  .transcript { padding: 14px 14px; max-height: 68vh; }
  .tr-user { max-width: 100%; }
  .tr-line, .transcript-live { font-size: 0.72rem; }
  .tr-result pre { font-size: 0.6rem; }

  /* pageHead action buttons wrap under the title instead of overflowing. */
  .page-head-row { flex-direction: column; align-items: stretch; }
  .page-head-row > div:last-child { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  .onboard-pulse span, .dot--live, .status-dot--running,
  .side-company-mode.is-auto::before, .transcript-live::after,
  .ticker-line--live::after { animation: none; }
  .task-card:hover { transform: none; }
  .feed-item, .onboard-feed-line { animation: none; }
}
