/* ——— The calendar's agenda ———
   The canvas's 3 and 3b: day by day under each month's heading (the
   picker, month-picker.css), each day the event page's date block —
   today's in ink, named — and its entries: a time column, then what it
   is, who is on it and what places it. A quiet today says so. On a phone
   (11) an entry is its title and one line; under the phone's grid (11b),
   its start leads in a column of its own. */
@layer components {
  .calendar-agenda {
    flex: 1;
    min-block-size: 0;
    margin-block-start: 1.875rem;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .calendar-agenda__months {
    max-inline-size: 48.75rem;
    margin-inline: auto;
  }

  /* A month's heading stands at the top while its days pass under it, so
     the month is always said — and days loaded above, held still, slide in
     under it rather than taking its place. */
  .calendar-agenda__heading {
    position: sticky;
    inset-block-start: 0;
    z-index: var(--z-raised);
    padding-block-end: 0.625rem;
    background-color: var(--color-canvas);
  }

  .calendar-day {
    display: grid;
    grid-template-columns: 4rem minmax(0, 1fr);
    gap: var(--block-space);
    padding-block: 0.875rem;
    border-block-start: var(--border);
  }

  .calendar-day__date {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    inline-size: fit-content;
  }

  .calendar-day__entries {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
  }

  .calendar-day__quiet {
    margin-block-start: 0.875rem;
    color: var(--color-ink-subtle);
  }

  /* ——— An entry ——— */
  .calendar-entry {
    --check-size: 0.875rem;

    display: grid;
    grid-template-columns: 6.5rem minmax(0, 1fr);
    align-items: start;
    gap: 0.75rem;
  }

  .calendar-entry__time {
    padding-block-start: 1px;
    font-variant-numeric: tabular-nums;
  }

  .calendar-entry__body {
    display: flex;
    align-items: start;
    gap: 0.5rem;
    min-inline-size: 0;

    > form {
      display: contents;
    }
  }

  .calendar-entry__glyph {
    margin-block-start: 0.1875rem;
    color: var(--color-ink-subtle);
  }

  .calendar-entry__text {
    min-inline-size: 0;
  }

  .calendar-entry__title {
    font-weight: 500;
    color: var(--color-ink);
    text-decoration: none;
  }

  /* The repeat glyph leads a series' line at its 13px (the canvas's 3). */
  .calendar-entry__meta {
    --icon-size: 0.8125rem;

    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    margin-block-start: 2px;
  }

  /* The chip the line's height, as the canvas draws it: its hairline,
     clear, is all the room above and below the words. */
  :is(.calendar-entry__meta, .calendar-entry__line) > .badge {
    padding-block: 0;
  }

  /* Join, quiet, on the day of the call: the page's one filled button is
     the event page's, not a list's. */
  .calendar-entry__join {
    --btn-padding: 1px 0.625rem;
    --btn-font-size: var(--text-small);
  }

  /* On a desk the chip and Join speak a notch under the line, at the week
     cells' size (the canvas's 12.5px, calendar-weeks.css). */
  @container main (width >= 35rem) {
    .calendar-entry__meta > :is(.badge, .calendar-entry__join) {
      --text-notch: 0.125rem;
    }
  }

  .calendar-entry__line {
    display: none;
  }

  /* Done and cancelled sink to faint: done's strike drawn in (todos.css),
     a cancelled one's its time's and title's own. */
  :is(.calendar-entry--done, .calendar-entry--cancelled, .calendar-entry:has(.todo-check[aria-pressed="true"])) .calendar-entry__title {
    color: var(--color-ink-faint);
  }

  .calendar-entry--cancelled :is(.calendar-entry__time, .calendar-entry__title) {
    text-decoration: line-through;
  }

  /* ——— A phone (the canvas's 11): the title, one line under it ———
     Wherever an entry stands: the agenda's days, and the day under the
     phone's grid, where the start leads in a column between hairlines. */
  @container main (width < 35rem) {
    .calendar-agenda {
      margin-block-start: 0.625rem;
    }

    .calendar-agenda__heading {
      padding-block-end: 0.5rem;
    }

    .calendar-day {
      --event-date-width: 2.625rem;
      --event-date-padding: 0.25rem;
      --event-date-number: var(--text-medium);

      grid-template-columns: 2.75rem minmax(0, 1fr);
      gap: 0.75rem;
      padding-block: 0.75rem;
    }

    .calendar-day :is(.event-date__month, .calendar-day__date > .label) {
      display: none;
    }

    .calendar-day__entries {
      gap: 0;
    }

    .calendar-entry {
      display: block;
      padding-block: 0.25rem;
    }

    .calendar-day :is(.calendar-entry__time, .calendar-entry__meta),
    :is(.calendar-entry__body > form, .calendar-entry__glyph) {
      display: none;
    }

    .calendar-entry--near:not(:has(.todo-check[aria-pressed="true"])) .calendar-entry__title {
      color: var(--color-warning-ink);
    }

    .calendar-entry__line {
      display: block;

      > .badge {
        margin-block-start: 2px;
      }
    }

    .calendar-day-list .calendar-entry {
      display: grid;
      grid-template-columns: 3.25rem minmax(0, 1fr);
      gap: 0.625rem;
      padding-block: 0.5rem;
      border-block-start: var(--border);
    }
  }
}
