/* Simple CARE's write-up sheet, "Write up what happened" (packs/care/app/components/care/simple/write_up_component.rb). The parts that only some answers need are shown by the answer itself, with `:has()`,
   and never by a script: each rule hides a part only when the sheet says it is not needed, inside `:not(:has(...))`, so a browser that cannot read `:has()` drops the rule and shows every part (the
   server ignores an answer the choice does not need). A hidden part is `display: none`, out of the tab order and out of what a screen reader reads, and it follows the control that reveals it.

   Tokens only and logical properties only (test/styles/tokens_test.rb, test/styles/components_test.rb), in light and in dark, mirrored in a right-to-left language; nothing sets a width or a
   height, so the sheet reflows to 320 CSS px (WCAG 1.4.10). */

.care-write-up {
  min-inline-size: 0;
}

.care-write-up__form {
  min-inline-size: 0;
}

.care-write-up__what,
.care-write-up__notes,
.care-write-up__level,
.care-write-up__after,
.care-write-up__reached,
.care-write-up__with,
.care-write-up__how,
.care-write-up__booked,
.care-write-up__find,
.care-write-up__new {
  display: grid;
  gap: var(--space-3);
  min-inline-size: 0;
}

.care-write-up__meeting,
.care-write-up__booked-words,
.care-write-up__booked-kept,
.care-write-up__with-none {
  margin: 0;
  color: var(--fg2);
  overflow-wrap: anywhere;
}

.care-write-up__search {
  display: grid;
  gap: var(--space-2);
  min-inline-size: 0;
}

/* What happens next, and the level question before it, are their own parts of the sheet, set apart from the notes above them. */
.care-write-up__level,
.care-write-up__after {
  padding-block-start: var(--space-3);
  border-block-start: 1px solid var(--rule);
}

/* The meeting still to come that the step was for, and the choice to cancel it, set apart above what happened. */
.care-write-up__booked {
  padding-block-end: var(--space-3);
  border-block-end: 1px solid var(--rule);
}

/* What saving does, said once above the button, in the quiet tone. */
.care-write-up__saving {
  margin: 0;
  color: var(--fg2);
}

/* Only the sentence that applies to the choice made. Choosing the close says what saving does for it, in the hint under that choice, and the sentence above the button is left out; any other choice says the
   sentence above the button and not that hint. A person without `:has` sees both, which is true as well. */
.care-write-up:not(:has(.care-write-up__next input[value="close"]:checked)) .care-write-up__next .field-option:has(input[value="close"]) .field-option-hint,
.care-write-up:has(.care-write-up__next input[value="close"]:checked) .care-write-up__saving {
  display: none;
}

/* The new step's fields, set apart from the choice that opens them. */
.care-write-up__new {
  padding-block-start: var(--space-3);
  border-block-start: 1px solid var(--rule);
}

/* Did you reach them? Only for a call, an email or a text. */
.care-write-up:not(:has(.care-write-up__kind input:is([value="called"], [value="emailed"], [value="texted"]):checked)) .care-write-up__reached {
  display: none;
}

/* Who else it was with, and how the talk was held: only for a talk with someone else. */
.care-write-up:not(:has(.care-write-up__kind input[value="someone_else"]:checked)) :is(.care-write-up__with, .care-write-up__how) {
  display: none;
}

/* The Directory search for a talk with someone else: only for a talk, and not while something else is being made, whose own search under "With whom?" serves both (what it finds is a choice in each),
   so one search field is in view at a time. */
.care-write-up:not(:has(.care-write-up__kind input[value="someone_else"]:checked)) .care-write-up__find,
.care-write-up:has(.care-write-up__next input[value="new"]:checked) .care-write-up__find {
  display: none;
}

/* What happens next: a new step's fields only for "Something else". */
.care-write-up:not(:has(.care-write-up__next input[value="new"]:checked)) .care-write-up__new {
  display: none;
}

/* The level question and the safety box: only for a conversation, which is a call, an email or a text the student answered, a meeting they came to, or a talk with the person who sent the referral (that
   option in "Who did you talk with?" is marked `data-sender`). A sheet for a meeting that was held has no such choices, so it marks the question `--always` and the server has drawn it only when it is one. */
.care-write-up:not(:has(.care-write-up__kind input[value="met"]:checked)):not(:has(.care-write-up__kind input:is([value="called"], [value="emailed"], [value="texted"]):checked):has(.care-write-up__reached input[value="talked"]:checked)):not(:has(.care-write-up__kind input[value="someone_else"]:checked):has(.care-write-up__with option[data-sender]:checked)) .care-write-up__level:not(.care-write-up__level--always) {
  display: none;
}

/* The question says who was talked with: the student, or the person who sent the referral when that is who the talk was with. */
.care-write-up:not(:has(.care-write-up__kind input[value="someone_else"]:checked)) .care-write-up__level-sender,
.care-write-up:has(.care-write-up__kind input[value="someone_else"]:checked) .care-write-up__level-student {
  display: none;
}

/* "Not sure? Ask the assistant to read this note." and what it said, under the level question. The choice it suggests is marked "Suggested" in words, and its edge is dashed, so it reads apart
   from a choice the person made (a solid edge) in shape as well as in words; nothing is chosen for them. The answer's place is there, empty, from the start: a live region that appears with its
   words is not always announced. */
.care-write-up__ask {
  display: grid;
  gap: var(--space-2);
  min-inline-size: 0;
}

.care-write-up__ask-line,
.care-write-up__level-read {
  margin: 0;
  color: var(--fg2);
  overflow-wrap: anywhere;
}

.care-write-up__suggested:not(:empty) {
  margin-inline-start: var(--space-2);
  color: var(--fg2);
  font-weight: 600;
}

.care-write-up__level .field-option:has(.care-write-up__suggested:not(:empty)) {
  border-style: dashed;
  border-color: var(--rule-strong);
}

.care-write-up__level .field-option:has(.care-write-up__suggested:not(:empty)):has(input:checked) {
  border-color: var(--accent);
}
