/* ——— The event form ———
   The canvas's 5, 6b and 11c (docs/planning/calendar-and-events.md, S2): the
   dialog's × in its corner, the head where there is one — from a mail, where
   the event lives — the title in the bare big voice (HANSHI, Forms C), then a
   row for each of when, repeat, where, the people and the notes, each led by
   its glyph in a column of its own. Its fields are the app's: boxed inputs,
   the to-do form's repeat (todo-form.css), the mail composer's picker
   (comboboxes.css), the house composer (lexxy.css); this file only seats
   them, at the canvas's sizes. On a phone the rows part by hairlines, each
   field as wide as its row, and Save is the foot bar (foot-bars.css). */
@layer components {
  .event-form {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--block-space-half);

    .input--boxed {
      min-block-size: 2rem;
      font-size: var(--text-small);
    }
  }

  .event-form__close {
    position: absolute;
    inset-block-start: -0.25rem;
    inset-inline-end: -0.25rem;
  }

  /* Its flow is utilities' (calendar_events/_form); clear of the ×. */
  .event-form__in {
    padding-inline-end: 2rem;
  }

  /* Who sees it follows the In (S3): each kind of home it offers has its
     line (event_audiences), and a line whose kind is not chosen stands
     down. */
  .event-form:not(:has(option[data-seen="mine"]:checked)) .event-form__seen--mine,
  .event-form:not(:has(option[data-seen="project"]:checked)) .event-form__seen--project,
  .event-form:not(:has(option[data-seen="clients"]:checked)) .event-form__seen--clients {
    display: none;
  }

  /* The written line without its line, at the dialog's display size. Two
     classes deep: this file sorts before inputs.css, whose .input would
     otherwise draw the line back (comboboxes.css says the same). Clear of
     the × in the corner. */
  .event-form .event-form__title {
    padding: 0;
    padding-inline-end: 2rem;
    font-size: var(--text-large);
    font-weight: 600;
    border: none;
  }

  .event-form__row {
    display: grid;
    grid-template-columns: 1.25rem minmax(0, 1fr);
    align-items: start;
    gap: 0.75rem;
    padding-block: 0.5625rem;

    /* Each glyph on its field's first line (owner, 2026-11-05): a box's
       2rem; the people's taller box, whose pills stand in the line the
       picker's field sets; the notes' first line of words, at the row's
       top — 0.5rem had it 4px under the caret, and 7px over the pills. */
    > .icon {
      --icon-size: 1rem;

      margin-block-start: calc((var(--event-row-line, 2rem) - var(--icon-size)) / 2);
      color: var(--color-ink-subtle);
    }

    &:has(.event-form__people) {
      --event-row-line: 2.875rem;
    }

    &:has(.composer) {
      --event-row-line: 1lh;
    }
  }

  .event-form__when,
  .event-form__hours {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--inline-space);
  }

  /* A day whole has no hours. */
  .event-form:has(input[type="checkbox"][name="calendar_event[all_day]"]:checked) .event-form__hours {
    display: none;
  }

  /* A box beside a field: All day, a Chalet call. */
  .event-form__check {
    display: inline-flex;
    align-items: center;
    gap: var(--inline-space);
    margin-inline-start: var(--inline-space-half);
    font-size: var(--text-small);
    color: var(--color-ink-subtle);
  }

  /* The select as wide as the canvas draws it, the rest of the to-do's
     block under it as it opens, in the dialog's small size. */
  .event-form .repeat-choice {
    align-items: start;
    font-size: var(--text-small);
  }

  .event-form .repeat-choice__select {
    min-inline-size: min(16.25rem, 100%);
  }

  .event-form__where {
    flex: 1 1 12rem;
  }

  /* You, then the picker's pills and its +, in one box and one flow: who is
     on it reads as one field. Its + needs no line of its own in the box. */
  .event-form__people {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem;
    border: var(--border);
    border-radius: var(--border-radius);

    > .combobox {
      display: contents;
    }

    .combobox__trigger {
      padding-inline: var(--inline-space-half);
      font-size: var(--text-small);
      border: none;
    }
  }

  /* One line at rest, as on a to-do (owner, 2026-11-03), where a dialog's
     composers otherwise stand three tall (dialog.css): the words grow it.
     A page's composer is one line already. */
  .modal .event-form .composer lexxy-editor {
    --lexxy-editor-rows: 1lh;
  }

  .event-form__actions {
    margin-block-start: 0.375rem;
  }

  /* The form's page (calendar_events/_page_head): ×, and what it is. */
  .event-page-head {
    display: grid;
    grid-template-columns: 2.75rem 1fr 2.75rem;
    align-items: center;
    margin-block-end: var(--block-space-half);

    > h1 {
      font-size: var(--text-normal);
      font-weight: 600;
      text-align: center;
    }
  }

  /* ——— A phone (the canvas's 11c) ———
     A page: the rows part by hairlines, the fields as wide as their row,
     the guests without the box, without you and without the line under
     them, and Save across the screen's foot (foot-bars.css; layout.css
     gives the page the height). */
  @container main (width < 35rem) {
    #calendar_event_form:has(> .event-form) {
      display: flex;
      flex: 1;
      flex-direction: column;
    }

    .event-form {
      flex: 1;
      gap: 0;

      .input--boxed {
        inline-size: 100%;
        min-block-size: 2.75rem;
        font-size: var(--text-normal);
      }

      .repeat-choice {
        font-size: var(--text-normal);
      }
    }

    .event-form__title {
      margin-block: var(--block-space) var(--block-space-half);
    }

    /* The In is one chip, its label inside (the canvas's 11c). */
    .event-form__in:has(.event-form__home) {
      align-self: start;
      gap: 0.375rem;
      min-block-size: 2.25rem;
      padding-inline: 0.625rem;
      border: var(--border);
      border-radius: var(--border-radius);
    }

    /* The In (S3) is a chip on a desk, its label before it (.input--chip,
       the canvas's 5); here the chip is the row's, so the select inside it
       is the bare word a select is (inputs.css), its caret at its end. */
    .event-form .event-form__home {
      padding-block: var(--block-space-half);
      padding-inline: 0 calc(0.64em + var(--inline-space));
      background-position: right 0.32em center, right center;
      border: none;
    }

    .event-form__row {
      padding-block: 0.75rem;
      border-block-start: var(--border);

      > .icon {
        margin-block-start: 0.75rem;
      }
    }

    .event-form__when {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .event-form__date {
      grid-column: 1 / -1;
    }

    .event-form__hours {
      display: contents;
    }

    .event-form__to {
      display: none;
    }

    .event-form__check {
      min-block-size: 2.25rem;
      margin-inline-start: 0;
      font-size: var(--text-normal);

      /* A box for the thumb, as 11c draws it. */
      .checkbox {
        inline-size: 1.25rem;
        block-size: 1.25rem;
      }
    }

    .event-form__people {
      padding: 0;
      border: none;
    }

    .event-form__you,
    .event-form__people-note {
      display: none;
    }
  }
}
