/* ready.css — the Ready view, the publish sheet and the share sheet.
 *
 * Owned by the ready/publish module (js/ready.js, js/share.js). Everything in
 * here is prefixed .ready- / .pub- / .share- so it cannot collide with base.css
 * or with the other view agents' stylesheets. Tokens (--surface, --accent,
 * --safe-bottom, --vvh …) come from base.css; none are redefined here.
 *
 * Target: iPhone standalone PWA, 390x844. Every tap target is at least 44px,
 * nothing depends on :hover, and no rule uses vh — the iOS keyboard makes vh
 * lie (see the viewport section of ui.js).
 */

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

.ready-scroll {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding-top: 4px;
}

.ready-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ready-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 2px 0;
  /* Sticky, so that with five accounts you always know whose posts you are
     looking at halfway down a long list. */
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(var(--bg) 65%, transparent);
  padding-bottom: 6px;
}

.ready-group-emoji {
  font-size: 1.05rem;
  line-height: 1;
}

.ready-group-name {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ready-group-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}

.ready-group-count {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-dim);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 2px 9px;
}

.ready-group-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---- One post ----------------------------------------------------------- */

.ready-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ready-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-dim);
  min-width: 0;
}

.ready-agent {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-mid);
}

.ready-dot {
  opacity: 0.5;
}

.ready-chars {
  margin-left: auto;
  flex: none;
}

/* A button, not a div: opening the publish checklist is the primary action of
   this view and it has to be reachable with VoiceOver and the keyboard. */
.ready-card-body {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 0;
  /* Four lines is enough to recognise a post you wrote yesterday; the full
     text is one tap away and repeated in the publish sheet. */
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ready-card-body:active {
  opacity: 0.6;
}

.ready-card-actions {
  display: flex;
  gap: 8px;
}

.ready-act {
  flex: 1;
  min-height: 44px;
  font-size: 0.9rem;
  padding: 0 8px;
}

.ready-more {
  margin-top: 4px;
}

/* The off-screen textarea used by the execCommand copy fallback. It must stay
   in the layout (display:none or visibility:hidden makes the selection fail on
   iOS) and it must be 16px or Safari zooms the page if it ever gets focus. */
.copy-shim {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  outline: 0;
  opacity: 0;
  font-size: 16px;
  pointer-events: none;
}

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

.pub-shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* Bound to the *visual* viewport so the sheet shrinks when the keyboard for
     the URL field opens instead of sliding its head off the top. */
  max-height: calc(var(--vvh) - 24px);
}

.pub {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 14px;
}

.pub-textwrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* The final text, exactly as it will be pasted. Selectable on purpose: it is
   the last-resort copy path when the clipboard API is blocked. */
.pub-text {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  /* A third of the visual viewport: enough to read a LinkedIn post's opening
     without pushing the Copy button below the fold. Not vh — see ui.js. */
  max-height: calc(var(--vvh) * 0.34);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  -webkit-user-select: text;
  user-select: text;
}

.pub-text.selectable {
  border-color: var(--accent);
  max-height: none;
}

.pub-meter {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pub-count {
  font-size: 0.8rem;
  color: var(--text-dim);
  flex: none;
}

.pub-count.over {
  color: var(--reject);
  font-weight: 700;
}

.pub-meter-track {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.pub-meter-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.2s var(--ease-out);
}

.pub-meter-fill.over {
  background: var(--reject);
}

/* ---- Brand + platform warnings ----------------------------------------- */

.pub-warnings {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
}

.pub-warning {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
}

.pub-warning-icon {
  flex: none;
  line-height: 1.4;
}

/* Hard = it will not publish cleanly. Soft = it breaks brand voice, and Artur
   is allowed to overrule his own rule. */
.pub-hard {
  background: var(--reject-dim);
  border-color: color-mix(in srgb, var(--reject) 35%, transparent);
  color: #ffd9d9;
}

.pub-soft {
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
  color: #ffe3bb;
}

/* ---- The three steps ---------------------------------------------------- */

.pub-step {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pub-step-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pub-step-n {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-mid);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.pub-step-title {
  font-weight: 700;
  font-size: 0.9rem;
}

.pub-step-hint {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.45;
  margin: -2px 0 0;
}

.pub-copy {
  min-height: 58px;
  font-size: 1.05rem;
  gap: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pub-copy-icon {
  font-size: 1.15rem;
}

.pub-copy.done {
  background: var(--like);
  color: #04160c;
}

.pub-open {
  min-height: 50px;
}

/* Once the text is on the clipboard, the next step is the one to press. */
.pub-open.next {
  border-color: var(--accent);
  color: var(--text);
}

.pub-record {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pub-url {
  width: 100%;
  min-height: 48px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0 12px;
  color: var(--text);
  /* 16px minimum: anything smaller and iOS zooms the whole sheet on focus. */
  font-size: 16px;
}

.pub-url::placeholder {
  color: var(--text-dim);
}

.pub-url:focus {
  outline: none;
  border-color: var(--accent);
}

.pub-done {
  min-height: 50px;
}

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

.share {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 18px;
}

.share-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.share-hint {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.45;
  margin-bottom: 4px;
}

.share-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.share-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 62px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  text-align: left;
}

.share-row:active {
  background: var(--surface-3);
  transform: scale(0.99);
}

.share-row[disabled] {
  opacity: 0.4;
}

.share-row.busy {
  opacity: 1;
  border-color: var(--accent);
}

.share-row-emoji {
  font-size: 1.4rem;
  line-height: 1;
  flex: none;
}

.share-row-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.share-row-name {
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-row-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-cancel {
  margin-top: 6px;
  min-height: 48px;
}

/* Someone on a desktop browser debugging over SSH gets a readable width
   instead of a 1400px line length. */
@media (min-width: 620px) {
  .ready-scroll,
  .pub,
  .share {
    max-width: 560px;
    margin: 0 auto;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pub-meter-fill {
    transition: none;
  }
  .share-row:active,
  .ready-card-body:active {
    transform: none;
  }
}
