/* ── Author → Writer's Lounge chapter picker ───────────────────────────────
   Every selector is rooted at .acp-* or #authorChapterPickerModal so this file
   can be added, pinned and rolled back without touching the 21k-line
   css/style.css.

   Colours come from the app's existing tokens: the --bg tiers, --border,
   --border2, the --text tiers, and the accent tokens. Those are all redefined
   under body.light, so both themes follow the app automatically and no palette
   is duplicated here. */

.acp-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: acp-fade 160ms ease-out;
}

.acp-overlay[hidden] { display: none; }

.acp-dialog {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  max-height: min(86vh, 720px);
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg, 20px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  animation: acp-rise 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.acp-dialog:focus { outline: none; }

/* ── Header ─────────────────────────────────────────────────────────────── */

.acp-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.acp-eyebrow {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-primary);
}

.acp-title h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
}

.acp-close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-height: 44px;
  margin: -10px -8px 0 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.acp-close:hover { background: var(--bg4); color: var(--text); }
.acp-close:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }

.acp-help {
  margin: 0;
  padding: 12px 20px 0;
  font-size: 13px;
  color: var(--text3);
}

/* ── Status line ────────────────────────────────────────────────────────── */

.acp-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px 0;
}

.acp-statusbar:has(.acp-status:empty) .acp-status { display: none; }

.acp-status {
  flex: 1 1 auto;
  font-size: 13px;
  color: var(--text3);
  min-height: 0;
}

.acp-status:empty { display: none; }

.acp-status.acp-status-error { color: #f87171; }

.acp-retry {
  flex: 0 0 auto;
  padding: 0 14px;
  font-size: 13px;
}

.acp-retry[hidden] { display: none; }

/* ── Scrolling body ─────────────────────────────────────────────────────── */

.acp-manuscripts {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 12px 20px 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* With no rows the list must not keep claiming the flex space, or the empty
   state gets pushed to the bottom of a tall sheet. */
.acp-manuscripts:empty { display: none; }

/* Back control on the chapter step */
.acp-back {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 10px 0 4px;
  border: 0;
  border-radius: var(--radius-sm, 10px);
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.acp-back:hover { color: var(--text); background: var(--bg3); }
.acp-back:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }

/* Rows: manuscripts on step one, chapters on step two */
.acp-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 12px 14px;
  text-align: left;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius, 14px);
  color: var(--text);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.acp-row:hover:not(:disabled) { background: var(--bg4); border-color: var(--border2); }
.acp-row:active:not(:disabled) { transform: scale(0.995); }
.acp-row:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }

.acp-row[aria-pressed="true"],
.acp-row.acp-row-selected {
  background: var(--accent-soft);
  border-color: var(--accent-primary);
}

.acp-row:disabled,
.acp-row[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
}

.acp-row-main {
  flex: 1 1 auto;
  min-width: 0;
}

.acp-row-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

.acp-row-meta {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text3);
  overflow-wrap: anywhere;
}

.acp-row-flag {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text3);
}

.acp-row-chevron {
  flex: 0 0 auto;
  color: var(--text3);
  font-size: 16px;
  line-height: 1;
}

/* Load-more control for the keyset-paginated feeds */
.acp-more {
  align-self: center;
  min-height: 44px;
  padding: 0 18px;
  margin: 4px 0 8px;
  border: 1px solid var(--border2);
  border-radius: 999px;
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.acp-more:hover { background: var(--bg3); color: var(--text); }
.acp-more:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }

/* ── Empty state ────────────────────────────────────────────────────────── */

.acp-empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  text-align: center;
}

.acp-empty[hidden] { display: none; }

.acp-empty-text {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--text3);
}

/* ── Footer ─────────────────────────────────────────────────────────────── */

.acp-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
}

.acp-btn {
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-sm, 10px);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 140ms ease, background 140ms ease;
}

.acp-btn:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }

.acp-btn-ghost {
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
}

.acp-btn-ghost:hover { background: var(--bg3); color: var(--text); }

.acp-btn-primary {
  border: 0;
  background: var(--accent-gradient, var(--accent-primary));
  color: var(--accent-contrast, #fff);
}

.acp-btn-primary:hover:not(:disabled) { opacity: 0.92; }

.acp-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* ── Mobile: full-height sheet ──────────────────────────────────────────── */

@media (max-width: 640px) {
  .acp-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .acp-dialog {
    max-width: none;
    max-height: 100%;
    height: 100%;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    animation: acp-sheet 220ms cubic-bezier(0.16, 1, 0.3, 1);
  }

  .acp-header,
  .acp-help,
  .acp-status,
  .acp-manuscripts,
  .acp-footer { padding-left: 16px; padding-right: 16px; }

  .acp-footer > .acp-btn { flex: 1 1 0; }
}

/* ── Motion ─────────────────────────────────────────────────────────────── */

@keyframes acp-fade { from { opacity: 0; } to { opacity: 1; } }

@keyframes acp-rise {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

@keyframes acp-sheet {
  from { transform: translateY(100%); }
  to   { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .acp-overlay,
  .acp-dialog { animation: none; }

  .acp-row,
  .acp-btn,
  .acp-close { transition: none; }

  .acp-row:active:not(:disabled) { transform: none; }
}
