/* write.css — the hooks → draft → variants sheet, and its two entry points.
 *
 * Everything here leans on base.css's tokens and component classes (.btn,
 * .chip, .sheet, .section-label, .count) so the flow reads as the same app as
 * the feed and the editor. What is genuinely new: a scannable hook list, a
 * side-by-side draft comparison, and a progress block that has to stay readable
 * for a minute at a time.
 *
 * Target is a 390x844 iPhone in standalone PWA mode. Tap targets are 44px, and
 * nothing here uses hover for anything you cannot get to another way.
 */

/* ---- Entry points -------------------------------------------------------- */

/* In the Feed header, left of the draft count. A single glyph: the header is
 * already carrying a title and a count, and this is a phone. */
.write-open-head {
  position: relative;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.write-open-head:active { transform: scale(0.94); }

/* The "something is running" dot. A closed sheet with a live job has to be
 * visible from the feed, or he taps Write again and starts a second run. */
.write-open-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--bg);
  animation: pulse 1.4s ease-in-out infinite;
}
.write-open-head.busy { border-color: var(--accent); }

/* In the Feed's empty state — the moment he is most likely to want this. */
.write-empty-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.write-empty-cta .write-open { min-height: 48px; padding: 0 22px; }
.write-empty-cta .section-hint { margin: 0; max-width: 30ch; text-align: center; }

/* ---- The sheet ----------------------------------------------------------- */

.write-shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

/* openSheet() gives us .sheet; .sheet-full sizes it to the visual viewport so
 * the keyboard shrinks it instead of pushing the header off screen. */
.write-sheet .write-body { padding-bottom: calc(28px + var(--safe-bottom)); }

.write-step {
  display: flex;
  flex-direction: column;
}
/* The variants step needs to bleed past the sheet body's 16px padding for the
 * carousel, so it pads its own non-carousel children instead. */
.write-step-wide { margin: 0 -16px; }
.write-step-pad { padding: 0 16px; }

.write-step > .section-label:first-child { margin-top: 12px; }

.write-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  font-size: 0.82rem;
  color: var(--text-mid);
}

.write-go { margin-top: 18px; min-height: 52px; }
.write-resume { margin-top: 12px; }
.write-discard { margin-top: 22px; color: var(--text-dim); }

.write-blank {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 8px;
  text-align: center;
}
.write-blank h2 { font-size: 1.2rem; font-weight: 700; }
.write-blank p { color: var(--text-dim); max-width: 32ch; }

/* ---- Setup --------------------------------------------------------------- */

.write-agents { padding: 0 0 4px; }

/* Each chip carries an emoji, the agent's name and a platform badge, so two
 * agents on the same account are told apart by name and platform rather than
 * by an emoji the user has to decode. */
.write-agent { gap: 7px; padding-right: 9px; }
.write-agent .badge { font-size: 0.6rem; padding: 2px 5px; }

/* Says in words where the post lands. Shown even when there is only one agent
 * and the chip row above is hidden. */
.write-dest {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 2px 0 4px;
  font-size: 0.84rem;
  color: var(--text-mid);
}
.write-dest-arrow { color: var(--text-dim); }

.write-topic { min-height: 104px; }

/* Segmented count picker: one tap per choice, unlike a +/- stepper. */
.write-counts {
  display: flex;
  gap: 8px;
}
.write-count {
  flex: 1;
  min-height: 46px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-mid);
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.write-count[aria-checked="true"] {
  background: color-mix(in srgb, var(--accent) 22%, var(--surface-2));
  border-color: var(--accent);
  color: var(--text);
}
.write-count:active { transform: scale(0.96); }

/* ---- Progress ------------------------------------------------------------ */

.write-progress {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.write-progress.running { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.write-progress.failed { border-color: color-mix(in srgb, var(--reject) 55%, var(--line)); }

.write-progress-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.write-progress-head .spinner { width: 18px; height: 18px; flex: none; }
.write-progress-title { font-weight: 600; font-size: 0.95rem; }
.write-progress-time { margin-left: auto; color: var(--text-dim); font-size: 0.85rem; }
.write-progress-note {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.4;
}
.write-progress .btn { margin-top: 12px; }

/* Placeholder rows so the list has shape before the first file lands. */
.write-skeleton { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.write-skeleton-row, .write-skeleton-card {
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%);
  background-size: 300% 100%;
  animation: write-shimmer 1.4s linear infinite;
}
.write-skeleton-row { height: 62px; }
.write-skeleton-card { height: 260px; }
@keyframes write-shimmer { to { background-position: -300% 0; } }

/* ---- The hook list ------------------------------------------------------- */

.write-hooks { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.write-hooks .section-hint { margin: 8px 0 2px; }

/* A dozen hooks on a 390px screen is the scannability problem of this whole
 * flow. The number rail on the left gives the eye a fixed place to land, and
 * the hook line itself is the only thing at full contrast — angle and note sit
 * back so the list reads as twelve sentences, not thirty-six lines. */
.write-hook {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 13px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
  text-align: left;
  transition: transform 0.12s var(--ease-out), border-color 0.12s ease;
}
.write-hook:active {
  transform: scale(0.985);
  border-color: var(--accent);
}

.write-hook-n {
  flex: none;
  width: 24px;
  padding-top: 1px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-dim);
  text-align: right;
}

.write-hook-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.write-hook-line {
  font-size: 0.97rem;
  line-height: 1.4;
  color: var(--text);
  /* No clamp: the hook is the one line he is choosing between, and a truncated
   * hook is not a hook. They are short by construction. */
}
.write-hook-angle {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
  opacity: 0.85;
}
.write-hook-note {
  font-size: 0.76rem;
  color: var(--text-dim);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Hook editor --------------------------------------------------------- */

.write-hook-edit {
  min-height: 108px;
  font-size: 17px;
  line-height: 1.45;
}

.write-warnings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.8rem;
}
.write-warnings .count { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.write-warnings .count.over { color: var(--reject); font-weight: 700; }
.write-warning {
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--warn);
  line-height: 1.3;
}
.write-warning.hard { background: var(--reject-dim); color: var(--reject); }

.write-step .agent-note {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border-left: 3px solid var(--edit);
}
.write-step .agent-note p { font-size: 0.86rem; color: var(--text-mid); white-space: pre-wrap; }
.write-step .agent-note-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--edit);
  margin-bottom: 4px;
}

/* ---- Variant carousel ---------------------------------------------------- */

/* Native scroll-snap, not a custom gesture. Comparing four 500-character posts
 * is a side-by-side job; a hand-rolled drag would have to re-solve the
 * horizontal/vertical conflict the deck already solves, and get it wrong. */
.write-track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 4px 16px 6px;
}
.write-track::-webkit-scrollbar { display: none; }

.write-variant {
  flex: 0 0 calc(100% - 44px);
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.write-variant-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.write-variant-n { font-weight: 700; color: var(--text-mid); }
.write-variant-head .count { margin-left: auto; }
.write-variant-head .count.over { color: var(--reject); font-weight: 700; }
.write-variant-warn { color: var(--warn); font-weight: 700; }

/* Each card scrolls its own body: a long LinkedIn draft must not make the card
 * taller than the sheet. */
.write-variant-body {
  flex: 1;
  min-height: 180px;
  max-height: calc(var(--vvh) - 380px);
  overflow-y: auto;
  overscroll-behavior: contain;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
}

.write-variant-note {
  align-self: flex-start;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--text-mid);
  font-size: 0.8rem;
}

.write-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 6px 0 2px;
}
.write-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
  transition: background 0.15s ease, transform 0.15s ease;
}
.write-dot.on { background: var(--accent); transform: scale(1.3); }

/* ---- Final edit ---------------------------------------------------------- */

.write-final-edit {
  min-height: 240px;
  font-size: 17px;
  line-height: 1.5;
}

.write-saves { display: flex; flex-direction: column; gap: 4px; }
.write-saves .btn { min-height: 50px; }
.write-saves .section-hint { margin: 0 0 10px; padding: 0 2px; }
