/* The workout editor's verdict marks (Components::SyntaxHighlightedTextarea
   with the live preview's Components::EditorVerdict). The colouring itself
   is the legacy syntax_highlight.css. */

/* A movement the preview could not find in the gym's library, marked where
   it is typed: a dotted caution underline under the movement's own colour,
   never a change of weight or spacing, so the text keeps its width. The
   preview's notice names the same movements (Components::UnknownMovementsNotice). */
.hl-unknown {
  text-decoration: underline dotted var(--caution);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

/* A line the parser warned about (a movement in a timed window with no rep
   count), marked whole where it is typed: a wavy caution underline, the
   warning as the title, so it reads apart from the unknown movement's dotted
   one. The preview's warnings list says the same. */
.hl-warned {
  text-decoration: underline wavy var(--caution);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

/* The autocomplete's row for a movement the preview could not find
   (description_autocomplete_controller.js): its badge in the same caution
   as the mark above. The row and badge shapes are the legacy
   description_autocomplete.css. */
.autocomplete-badge-unknown {
  color: var(--caution-ink);
  background-color: var(--caution-soft);
}

/* The unknown row wraps: badge and name on one line, the notice and offer
   on the next, where a plain row's hint is cut to one line. */
.autocomplete-item-unknown {
  flex-wrap: wrap;
}

.autocomplete-hint-unknown {
  flex-basis: 100%;
  white-space: normal;
}

/* The workout form's Scoring select and what it says about where its value
   came from (Views::WorkoutDescriptions::PreviewableForm). The select can
   shrink to fit beside Stimulus in the builder's narrow column; the
   "From description" chip wraps under it when there is no room. */
.scoring-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
}

.scoring-select {
  flex: 1 1 6rem;
  min-width: 0;
  transition: background-color 600ms;
}

/* The select just took the scoring the description states
   (workout_live_preview_controller#syncStatedScoring). */
.scoring-select[data-synced] {
  background-color: var(--accent-fill);
}

@media (prefers-reduced-motion: reduce) {
  .scoring-select {
    transition: none;
  }
}

/* The folded Program, Category, Movement prep and Benchmark: its closed
   line reads their values. */
.workout-fields-fold {
  min-width: 0;
}

/* A movement that comes round again (Planning::LineRepeats, by
   Planning::RepeatTone's gap): the editor marks the whole line typed, the
   sentence as its title (workout:repeat-marks, from Components::RepeatMarks).
   The tones differ by more than hue: danger (the same movement back to back)
   is bold on a solid underline; caution (two or three days apart, a pattern
   the day before or after, a movement like one just programmed) a dashed
   one; quiet (the same movement four to six days away) a thin dotted one.
   The syntax colours stay under all three. */
.hl-repeat-danger {
  font-weight: 700;
  text-decoration: underline solid var(--danger);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.hl-repeat-caution {
  text-decoration: underline dashed var(--caution-ink);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.hl-repeat-quiet {
  text-decoration: underline dotted var(--ink-muted);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

/* The same repeats on the live preview's lines (repeat_marks_controller.js):
   the movement's name underlined as in the editor, and beside it the mark's
   note, a UI::Popover whose trigger is a chip in the mark's tone with the
   few words that say why; it opens the full sentence on a click, a tap or
   Enter. */
.repeat-mark-danger {
  font-weight: 700;
  color: var(--danger-ink);
  text-decoration: underline solid var(--danger);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.repeat-mark-caution {
  text-decoration: underline dashed var(--caution-ink);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.repeat-mark-quiet {
  text-decoration: underline dotted var(--ink-muted);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.repeat-mark-note {
  margin-inline-start: var(--space-1);
  white-space: nowrap;
}

.repeat-mark-panel {
  max-width: 22rem;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  white-space: normal;
}

/* Inline name-ideas disclosure (under the workout name field,
   Components::NameSuggestionsDisclosure). Native details/summary; quiet
   until opened. */
.name-suggestions-disclosure {
  margin-top: var(--space-1);
}

.name-suggestions-status {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  margin: 0 0 var(--space-1);
}

/* An empty status must not reserve a row between the summary and pills. */
.name-suggestions-status:empty {
  display: none;
}

.name-suggestions-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-1);
}

.suggestion-pill {
  border: var(--line-width) solid var(--line);
  background: var(--surface);
  /* Pin text color and shadow in every state: global button hover rules
     (.btn) otherwise flip the text white on a light background. */
  color: var(--ink);
  text-shadow: none;
  border-radius: 999px;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-md);
  font-weight: 600;
  text-align: center;
  display: inline-block;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.suggestion-pill:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
  text-shadow: none;
  transform: scale(1.05);
  box-shadow: var(--shadow);
}

.suggestion-pill:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* The pill whose name the field now holds. */
.suggestion-pill-applied {
  border-color: var(--good);
  background: var(--good-soft);
  color: var(--ink);
}

.name-suggestions-more {
  border: none;
  background: none;
  color: var(--accent-ink);
  font-size: var(--text-sm);
  cursor: pointer;
  padding: 0 var(--space-1);
}

.name-suggestions-more:hover {
  text-decoration: underline;
}

.name-suggestions-more:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: no-preference) {
  .suggestion-pill[data-entering] {
    animation: name-suggestion-pill-in 0.18s ease both;
  }

  @keyframes name-suggestion-pill-in {
    from {
      opacity: 0;
      transform: translateY(var(--space-1));
    }
  }
}

/* The live preview's loading ring, shown over the pane while a refresh is
   in flight (workout_live_preview_controller.js). */
.preview-spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--surface-sunken);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: preview-spinner-turn 1s linear infinite;
}

@keyframes preview-spinner-turn {
  to {
    transform: rotate(360deg);
  }
}
