/* "Custom" feed: the "+" add panel, the add_verse_modal form
   (add-modal.js, built on modals.css's .about-modal shell), the toast and
   the row highlight (custom-feed.js). */

.custom-add-panel {
  margin-top: 20px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
}

.custom-add-icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
}

/* Topbar copy of the panel's "+" (top-right, beside the tag bubble) --
   same look, scaled down to fit the header. */
.topbar-add-btn {
  width: 32px;
  height: 32px;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

/* Favourite/unfavourite heart inside the add_verse_modal, top-left --
   shown only in edit mode (see openEditModal in add-modal.js). Same underlying offlineStore
   favouriting mechanism as play_modal's heart, just toggled from here
   instead (play_modal's options menu shows only the edit pencil for a
   custom track, no heart). */
.custom-edit-heart {
  position: absolute;
  top: 0.75rem;
  left: 0.8rem;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.custom-edit-heart svg {
  width: 20px;
  height: 20px;
}

.custom-edit-heart:hover {
  color: var(--text);
}

.custom-edit-heart.active {
  color: var(--danger);
}

.custom-edit-heart:disabled {
  opacity: 0.5;
  cursor: default;
}

/* AI passage picker sparkle (accent-coloured, like the Add button),
   inside the right-hand end of the Passages input -- plain "add" mode
   only. Greyed out while the box is empty or already AI-filled. */
.custom-ai-input {
  position: relative;
}

.custom-field .custom-ai-input input {
  padding-right: 2.8rem;
}

/* Passages' rotating example text (startPlaceholderRotation) -- sits
   where the input's own placeholder would, fading between examples. */
.custom-placeholder {
  position: absolute;
  top: 50%;
  left: calc(0.7rem + 1px);
  right: 2.8rem;
  transform: translateY(-50%);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  transition: opacity 0.8s ease;
}

.custom-placeholder.fading {
  opacity: 0;
}

.custom-field input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

.custom-ai-sparkle {
  position: absolute;
  top: 50%;
  right: 0.3rem;
  transform: translateY(calc(-50% + 1px));
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--accent);
  cursor: pointer;
  padding: 0.2rem;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.custom-ai-sparkle svg {
  width: 26px;
  height: 26px;
}

.custom-ai-sparkle:disabled {
  color: rgba(var(--fg-rgb), 0.25);
  cursor: default;
}

.custom-ai-input:has(.custom-ai-sparkle.hidden) input {
  padding-right: 0.7rem;
}

/* Spinner shown over the whole add_verse_modal while /api/passages runs --
   also swallows clicks so the form can't be edited or closed mid-request. */
.custom-ai-busy {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
}

.custom-ai-busy-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid rgba(var(--fg-rgb), 0.12);
  border-radius: var(--radius);
  padding: 1.6rem 2rem 1.2rem;
  box-shadow: var(--shadow-modal);
}

.custom-ai-busy-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.custom-ai-spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent);
  animation: custom-ai-spin 0.9s linear infinite;
}

@keyframes custom-ai-spin {
  to { transform: rotate(360deg); }
}

/* add_verse_modal */
.custom-add-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 0.5rem;
  text-align: left;
}

/* Paired fields (Verse/Passage Pause, Times played/Repeat Pause) sit side
   by side, each half width -- the first stays half width even when its
   partner is hidden. */
.custom-field-pair {
  display: flex;
  gap: 0.75rem;
}

.custom-field-pair .custom-field {
  flex: 0 0 calc(50% - 0.375rem);
  min-width: 0;
}

.custom-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.custom-field-subtext {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.custom-field-subtext-icon svg {
  width: 1.5em;
  height: 1.5em;
  vertical-align: -0.4em;
}

.custom-field input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid rgba(var(--fg-rgb), 0.14);
  color: var(--text);
  font: inherit;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
}

.custom-field input:focus {
  outline: none;
  border-color: var(--accent);
}

.custom-stepper {
  display: flex;
  align-items: stretch;
  border: 1px solid rgba(var(--fg-rgb), 0.14);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
}

.custom-stepper-btn {
  flex: 0 0 2.6rem;
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.45rem 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.custom-stepper-btn:active:not(:disabled) {
  background: rgba(var(--fg-rgb), 0.08);
}

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

.custom-stepper-btn:disabled {
  color: rgba(var(--fg-rgb), 0.25);
  cursor: default;
}

.custom-stepper-value {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  border-left: 1px solid rgba(var(--fg-rgb), 0.14);
  border-right: 1px solid rgba(var(--fg-rgb), 0.14);
  user-select: none;
}

.custom-field-error {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--danger);
}

.custom-add-submit {
  width: 8.5rem;
  align-self: center;
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 700;
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  cursor: pointer;
}

.custom-add-submit:disabled {
  background: rgba(var(--fg-rgb), 0.14);
  color: var(--text-muted);
  cursor: default;
}

.custom-add-delete {
  border: none;
  background: none;
  color: var(--danger);
  font: inherit;
  font-weight: 600;
  padding: 0.5rem;
  cursor: pointer;
  text-align: center;
}

.custom-add-delete:hover {
  text-decoration: underline;
}

.custom-add-delete:disabled {
  opacity: 0.6;
  cursor: default;
  text-decoration: none;
}

.custom-add-status {
  margin: 0.8rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.custom-add-status.error {
  color: var(--danger);
}

/* Toast */
.custom-toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 0);
  max-width: calc(100vw - 2rem);
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid rgba(var(--fg-rgb), 0.14);
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  font-size: 0.9rem;
  text-align: center;
  z-index: var(--z-toast);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.custom-toast.visible {
  opacity: 1;
  transform: translate(-50%, -0.4rem);
}

/* Highlight on the list row a successful edit just rebuilt */
@keyframes custom-updated-flash {
  0%, 60% {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent), var(--shadow-card);
  }
  100% {
    border-color: rgba(var(--fg-rgb), 0.12);
    box-shadow: 0 0 0 0 transparent, var(--shadow-card);
  }
}

.track.custom-updated-flash {
  animation: custom-updated-flash 3s ease-out;
}

/* Sit the modal at the top of the visible area, near full width, keyboard
   or not -- so it doesn't jump around as the soft keyboard comes and goes
   (see the visualViewport handling in add-modal.js's buildModal). */
.custom-add-modal {
  align-items: flex-start;
  padding: 0;
}

.custom-add-modal .about-modal-content {
  margin: 0.5rem;
  padding: 1.2rem 1.2rem 1rem;
}

/* Soft keyboard up: tighten spacing so as much of the form fits as
   possible. */
.custom-add-modal.keyboard-open .custom-add-form {
  gap: 0.6rem;
}
