/* ============================================
   Component: Initiatives
   View: dashboards/summary/initiatives.html.erb
   Partials: dashboards/summary/_initiative.html.erb, dashboards/summary/_initiative_form.html.erb, and the opening's
             link to the page, dashboards/_opening.html.erb
   Stimulus: none
   ============================================ */
/* A leader's initiatives (#621, INIT-01), a page beneath the Summary, where they are added, changed and removed. Phone
   first, at every width with no width condition of its own: its lines, each initiative's lines, and each form's label
   and field read one beneath another, and a long word breaks onto the next line, so neither the page nor any part of it
   scrolls sideways. Every tap, field, choice and button is at least the tap target's height (PHONE-01). */

/* The page: its lines, the add tap, the list and the words' tap, one beneath another, as narrow as a form. */
.initiatives {
  display: grid;
  gap: var(--spacing-md);
  max-width: 40rem;
  overflow-wrap: anywhere;
}

.initiatives-source,
.initiatives-quarter,
.initiatives-read-only,
.initiatives-none {
  color: var(--color-muted);
}

/* The list, in order, each initiative on a card's surface: its lines one beneath another, then its two taps. */
.initiatives-list {
  display: grid;
  gap: var(--spacing-sm);
  list-style: none;
}

.initiative {
  display: grid;
  gap: var(--spacing-xs);
  padding: var(--spacing-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.initiative > h3 { font-size: var(--font-size-md); }

/* Its status in words; at risk in the warning colour beside them, never in their place. */
.initiative-status { font-weight: 600; }

.initiative-status.is-at-risk { color: var(--color-warning); }

.initiative-due,
.initiative-quarter,
.initiative-changed {
  color: var(--color-muted);
}

.initiative-changed { font-size: var(--font-size-sm); }

/* A closed tap: Add an initiative, Change this initiative, Remove this initiative and What the words mean. A
   <details> opens with no JavaScript and no hover, its summary at least the tap target's height, its marker drawn
   closed, then open, as the opening's panel draws its own. */
.initiatives-tap > summary {
  display: flex;
  align-items: center;
  gap: 0 var(--spacing-sm);
  min-height: var(--tap-target);
  color: var(--color-link);
  cursor: pointer;
  list-style: none;
}

.initiatives-tap > summary::-webkit-details-marker { display: none; }

.initiatives-tap > summary::before { content: "▸"; }

.initiatives-tap[open] > summary::before { content: "▾"; }

/* What a tap holds, one beneath another: a refused save's refusals, then the form; or what a remove is for, then its
   button; or the words. */
.initiatives-tap-body {
  display: grid;
  gap: var(--spacing-sm);
  padding-top: var(--spacing-xs);
}

/* A form: each field's label, its hint and its input, choice or date, one beneath another, then its button. */
.initiative-form {
  display: grid;
  gap: var(--spacing-md);
}

.initiative-form .field {
  display: grid;
  gap: var(--spacing-xs);
}

.initiative-form .field label {
  color: var(--color-text);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.initiative-form .field .initiative-form-hint {
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

.initiative-form .field input,
.initiative-form .field select,
.initiative-form .field textarea {
  width: 100%;
  min-height: var(--tap-target);
  padding: var(--spacing-xs) var(--spacing-sm);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
}

.initiative-form .field textarea { resize: vertical; }

.initiative-form .actions [type="submit"] {
  min-height: var(--tap-target);
  padding: var(--spacing-sm) var(--spacing-lg);
  border: 2px solid var(--color-accent);
  border-radius: var(--radius);
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-size: var(--font-size-md);
  cursor: pointer;
}

/* Remove in the danger colour, edged in it on the card's surface, so it never reads as a form's own button. */
.initiative-form .actions .initiative-remove {
  border-color: var(--color-danger);
  background: var(--color-surface);
  color: var(--color-danger);
}

/* A refused save's line and each refusal, on the alert's background, above the form it came from. */
.initiative-refused {
  display: grid;
  gap: var(--spacing-xs);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius);
  background: var(--color-alert-bg);
  color: var(--color-text);
}

.initiative-refused > p { font-weight: 600; }

.initiative-refused > ul { padding-left: var(--spacing-lg); }

/* The words, as the opening's panel lists its own: each word, then its definition beneath it. */
.initiatives-words { font-size: var(--font-size-sm); }

.initiatives-word-list {
  display: grid;
  gap: var(--spacing-xs);
}

.initiatives-word-list > dt {
  color: var(--color-text);
  font-weight: 600;
}

.initiatives-word-list > dd { margin-bottom: var(--spacing-xs); }

/* The opening's link to the page, alone in its paragraph beneath the initiatives, at least the tap target's height. */
.initiatives-link > a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-target);
}
