/* ============================================================
   ADD SHEET  (#add-sheet / #add-inner)
   The "Read something new" capture sheet — the frictionless way to start
   reading. Three input methods presented as DISTINCT design-system tiles:
     1. Paste a link   2. Paste text   3. Open a book (EPUB / PDF)
   js/screens/add.js reparents nothing — it RESTRUCTURES the existing input
   groups into .ds-card tiles (icon + eyebrow + title + helper) and adds the
   recent-URL chip, clipboard paste, and live word count. This stylesheet
   COMPOSES the design-system primitives (.ds-card, .ds-eyebrow, .ds-chip,
   .ds-btn-primary, .ds-cap, .ds-rise) and only styles the new content.
   Every rule scoped under #add-sheet. Brand tokens only; red = errors only.
   Mobile-first (390px).
   ============================================================ */

/* The sheet surface: a touch more padding than the shell default + a soft
   accent sheen on the rounded top edge so it reads as a lifted capture sheet. */
#add-sheet {
  padding-left: 16px;
  padding-right: 16px;
  background:
    radial-gradient(130% 70% at 50% -8%, color-mix(in srgb, var(--accent-2) 8%, transparent), transparent 60%),
    var(--panel);
}

/* Inner column: even, generous rhythm between the header, hero line and tiles. */
#add-sheet #add-inner {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---- Sheet header + hero intent ------------------------------------------ */
#add-sheet .screen-head {
  padding: 0 2px 0;
  margin-top: -2px;
}
#add-sheet .screen-head h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, var(--text), var(--muted));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
#add-sheet .add-hero-sub {
  margin: 0 2px 2px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
  max-width: 46ch;
}

/* ============================================================
   METHOD TILES — each input group is its own calm, scannable card.
   ============================================================ */
#add-sheet .add-tile {
  padding: var(--s4);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* The whole tile lights up subtly while you're working inside it. */
#add-sheet .add-tile:focus-within {
  border-color: color-mix(in srgb, var(--accent-2) 42%, var(--border-soft));
  box-shadow: var(--shadow-sm), 0 0 0 3px var(--accent-2-soft);
}

/* ---- Tile header: glyph + eyebrow + title -------------------------------- */
#add-sheet .add-tile-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
#add-sheet .add-tile-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent-2-soft);
  color: var(--accent-2-strong);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-2) 20%, transparent);
}
#add-sheet .add-tile-icon svg { width: 21px; height: 21px; }
#add-sheet .add-tile-heading {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
#add-sheet .add-tile-title {
  font-size: var(--fs-h3);
  font-weight: 650;
  color: var(--text);
  letter-spacing: -0.01em;
}
#add-sheet .add-tile-sub,
#add-sheet .add-tile .hint {
  margin: 0;
  color: var(--muted);
  font-size: 12.75px;
  line-height: 1.5;
}

/* ---- Inputs inside the tiles --------------------------------------------- */
#add-sheet input[type="text"],
#add-sheet textarea {
  background: var(--bg);
  border-color: var(--border);
  font-size: 16px;            /* 16px keeps iOS from zooming on focus */
  padding: 13px 14px;
}
#add-sheet input[type="text"]:focus,
#add-sheet textarea:focus { background: var(--panel); }

/* ---- 1. PASTE A LINK ----------------------------------------------------- */
/* URL row: input grows, "Load URL" is the confident primary action. */
#add-sheet .add-tile-url .row {
  gap: 9px;
  align-items: stretch;
}
#add-sheet #urlInput {
  min-width: 0;
  flex: 1 1 auto;
}
/* Promote the URL button to the one obvious primary CTA (compose .ds-btn-primary
   visually without changing its ID/markup). */
#add-sheet #loadUrlBtn {
  flex: 0 0 auto;
  align-self: stretch;
  min-height: 48px;
  padding: 12px 18px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--grad-accent);
  color: var(--on-accent);
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent-2) 28%, transparent);
}
#add-sheet #loadUrlBtn:hover { filter: brightness(1.06); box-shadow: 0 8px 26px color-mix(in srgb, var(--accent-2) 40%, transparent); }

/* The optional "start at phrase" field — a quieter, secondary input. */
#add-sheet #startPhraseInput {
  margin-top: 0 !important;
  background: transparent;
  border-style: dashed;
  font-size: 14px;
}
#add-sheet #startPhraseInput:focus { border-style: solid; background: var(--panel); }

/* One-tap "recent URL" chip — refills the last link you loaded. */
#add-sheet .add-recent { display: flex; }
#add-sheet .add-recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 6px 12px 6px 10px;
  border-radius: var(--radius-pill);
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
  transition: color var(--tap), border-color var(--tap), background var(--tap);
}
#add-sheet .add-recent-chip:hover {
  filter: none;
  color: var(--accent-2-strong);
  border-color: color-mix(in srgb, var(--accent-2) 45%, var(--border));
  background: var(--accent-2-soft);
}
#add-sheet .add-recent-chip:active { transform: translateY(1px); }
#add-sheet .add-recent-icon { display: inline-flex; flex: 0 0 auto; }
#add-sheet .add-recent-icon svg { width: 14px; height: 14px; }
#add-sheet .add-recent-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- 2. PASTE TEXT ------------------------------------------------------- */
/* The textarea must read like PROSE, not a code box: override the foundation
   monospace + tiny size with the reading sans, comfortable size and leading. */
#add-sheet #textInput {
  min-height: 120px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.6;
  resize: vertical;
}
/* Action row: clipboard paste (left) + "Use This Text" commit (right). */
#add-sheet .add-tile-text .row-end {
  margin-top: 0 !important;
  gap: 9px;
  align-items: center;
  justify-content: space-between;
}
#add-sheet .add-paste-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13.5px;
}
#add-sheet .add-paste-btn .add-paste-icon { display: inline-flex; }
#add-sheet .add-paste-btn .add-paste-icon svg { width: 16px; height: 16px; }
#add-sheet .add-paste-btn.add-paste-denied {
  border-color: var(--border);
  color: var(--faint);
}
#add-sheet .add-tile-text #loadTextBtn {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 11px 18px;
  margin-left: auto;
}
/* Live word count — quiet, tabular, hides itself when the box is empty.
   DOM order (textarea -> count -> action row) already places it correctly. */
#add-sheet .add-count {
  align-self: flex-start;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  min-height: 14px;
}
#add-sheet .add-count.is-empty { min-height: 0; }

/* ---- 3. OPEN A BOOK (EPUB / PDF) ----------------------------------------- */
/* Hide the redundant inline hint that shipped inside this group — the tile head
   already carries the helper copy. */
#add-sheet .add-tile-file > .hint:not(.add-tile-sub) { display: none; }
#add-sheet .add-tile-file .row { align-items: center; }
#add-sheet #epubPickBtn {
  flex: 1 1 auto;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 15px;
}
/* Inline file glyph via the existing data-icon="file" hook. */
#add-sheet #epubPickBtn[data-icon="file"]::before {
  content: "";
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  background-color: var(--accent-2-strong);
  -webkit-mask: var(--epub-file-glyph) center / contain no-repeat;
  mask: var(--epub-file-glyph) center / contain no-repeat;
}
#add-sheet {
  --epub-file-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6'/%3E%3C/svg%3E");
}
#add-sheet #epubPickBtn:hover { border-color: var(--accent-2); }
/* Chosen filename — a quiet confirmation pill, only once a file is picked. */
#add-sheet #epubFileName.goal-hint {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
  word-break: break-word;
}
#add-sheet #epubFileName.goal-hint:not(:empty) {
  padding: 8px 12px;
  background: var(--accent-2-soft);
  border-radius: var(--radius-pill);
  color: var(--accent-2-strong);
}

/* ---- Inline errors (REAL errors only — red) ------------------------------ */
#add-sheet .err {
  font-size: 12.5px;
  margin-top: 2px;
}
#add-sheet .err:empty { margin-top: 0; display: none; }

/* ============================================================
   WIDE SCREENS — the shell docks the sheet as a 420px floating card.
   ============================================================ */
@media (min-width: 860px) {
  #add-sheet { padding-left: 18px; padding-right: 18px; }
  #add-sheet #add-inner { gap: 12px; }
  #add-sheet .add-tile { padding: var(--s4); }
}
