@layer cinder.tokens, cinder.foundation, cinder.components, cinder.utilities;
@import '/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/components/chip/chip.css';
@import '/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/components/combobox/combobox.css';
@import '/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/components/form-field/form-field.css';
@import '/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/components/input/input.css';
@import '/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/components/number-input/number-input.css';
@import '/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/components/select/select.css';

@layer cinder.components {
  /* ========================================
   * SCHEDULE-BUILDER
   * Recurrence-definition control: Repeats, At and Time zone fields, with an
   * always-visible read-back sentence and next-runs preview, and optional
   * overlap and catch-up policy selects.
   * ======================================== */

  .cinder-schedule-builder {
    display: flex;
    flex-direction: column;
    gap: var(--cinder-space-4);
  }

  /* ----------------------------------------
   * Fields
   * ---------------------------------------- */

  .cinder-schedule-builder__field-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--cinder-space-3);
  }

  /* A Select here shares its row with a number or a time field, so it keeps their height on a
     coarse pointer instead of the smaller painted height a Select has on its own. */
  .cinder-schedule-builder__field-row {
    --_cinder-painted-height-md: var(--cinder-control-height-md);
  }

  /* Repeats takes the room its longest choice needs and At the width of a time, so they sit side
     by side at a form's reading width and the weekday group, Time zone or Unit wrap beneath. */
  .cinder-schedule-builder__repeats {
    flex: 0 1 17.5rem;
    min-inline-size: 10rem;
  }

  /* With no At beside it (an interval, a cron), Repeats takes the whole row. */
  .cinder-schedule-builder:not([data-cinder-variant='compact'])
    .cinder-schedule-builder__field-row:not([data-cinder-time-of-day])
    > .cinder-schedule-builder__repeats {
    flex: 1 1 100%;
  }

  .cinder-schedule-builder__time {
    flex: 0 0 8rem;
  }

  .cinder-schedule-builder__count {
    flex: 0 1 8rem;
  }

  .cinder-schedule-builder__unit {
    flex: 0 1 12.5rem;
  }

  .cinder-schedule-builder__day-of-month {
    inline-size: 8rem;
    max-inline-size: 100%;
  }

  .cinder-schedule-builder__zone {
    min-inline-size: 0;
  }

  .cinder-schedule-builder[data-cinder-variant='compact'] .cinder-schedule-builder__zone {
    flex: 1 1 10rem;
  }

  .cinder-schedule-builder[data-cinder-variant='compact'] .cinder-schedule-builder__repeats {
    flex: 1 1 12rem;
  }

  .cinder-schedule-builder__help {
    margin: 0;
    font-size: var(--cinder-text-xs);
    line-height: var(--cinder-leading-normal);
    color: var(--cinder-text-muted);
  }

  /* The offset on a Time zone row sits at the trailing edge, in figures that line up. */
  .cinder-schedule-builder__offset,
  .cinder-schedule-builder__time-zone-footer {
    font-size: var(--cinder-text-xs);
    color: var(--cinder-text-muted);
    font-variant-numeric: tabular-nums;
  }

  /* ----------------------------------------
   * Custom days: seven toggles joined into one group
   * ---------------------------------------- */

  /* The seven toggles share the group's width, so on a narrow screen they shrink together
     instead of pushing Sun past the edge; given room, each is 3rem wide. The width (not the flex
     basis) is what the group's own size is measured from. */
  .cinder-schedule-builder__weekday-group {
    display: inline-flex;
    flex-wrap: nowrap;
    max-inline-size: 100%;
    min-inline-size: 0;
  }

  /* Each day is the height of the At field beside the group (the medium control step, 32px), not
     the chip's small toolbar step, so the group's top and bottom line up with the field's. */
  .cinder-schedule-builder__weekday-group > .cinder-chip {
    box-sizing: border-box;
    min-block-size: var(--cinder-control-height-md);
    inline-size: 3rem;
    flex: 0 1 auto;
    border-radius: 0;
    justify-content: center;
    min-inline-size: 0;
    padding-inline: var(--cinder-space-1);
    font-size: var(--cinder-text-sm);
  }

  .cinder-schedule-builder__weekday-group > .cinder-chip + .cinder-chip {
    margin-inline-start: -1px;
  }

  .cinder-schedule-builder__weekday-group
    > .cinder-chip:first-child:where(
      :not([dir='rtl'], [dir='rtl'] *),
      [dir='rtl'] [dir='ltr'],
      [dir='rtl'] [dir='ltr'] *
    ) {
    border-top-left-radius: var(--cinder-radius-md);
    border-bottom-left-radius: var(--cinder-radius-md);
  }

  .cinder-schedule-builder__weekday-group
    > .cinder-chip:first-child:where(
      :is([dir='rtl'], [dir='rtl'] *):not([dir='rtl'] [dir='ltr'], [dir='rtl'] [dir='ltr'] *)
    ) {
    border-top-right-radius: var(--cinder-radius-md);
    border-bottom-right-radius: var(--cinder-radius-md);
  }

  .cinder-schedule-builder__weekday-group
    > .cinder-chip:last-child:where(
      :not([dir='rtl'], [dir='rtl'] *),
      [dir='rtl'] [dir='ltr'],
      [dir='rtl'] [dir='ltr'] *
    ) {
    border-top-right-radius: var(--cinder-radius-md);
    border-bottom-right-radius: var(--cinder-radius-md);
  }

  .cinder-schedule-builder__weekday-group
    > .cinder-chip:last-child:where(
      :is([dir='rtl'], [dir='rtl'] *):not([dir='rtl'] [dir='ltr'], [dir='rtl'] [dir='ltr'] *)
    ) {
    border-top-left-radius: var(--cinder-radius-md);
    border-bottom-left-radius: var(--cinder-radius-md);
  }

  /* A day that is not chosen sits on the field surface with the field's own edge, in the medium
     weight of the field text: the grey chip fill belongs to a standalone chip, not to a joined
     group of fields. `background-color` (not the shorthand) leaves the chip's hover film alone. */
  .cinder-schedule-builder__weekday-group
    > .cinder-chip[aria-pressed='false'][data-cinder-variant]:not(:disabled) {
    background-color: var(--cinder-control-background);
    border-color: var(--cinder-control-border);
    color: var(--cinder-text-muted);
    font-weight: var(--cinder-font-medium);
  }

  /* A chosen day is filled in the accent tint, and paints over its neighbours' shared edge so
     its accent edge is whole. */
  .cinder-schedule-builder__weekday-group > .cinder-chip[aria-pressed='true'][data-cinder-variant] {
    background: var(--cinder-accent-background);
    color: var(--cinder-accent-text);
    border-color: var(--cinder-accent-solid);
    font-weight: var(--cinder-font-semibold);
    position: relative;
    z-index: 1;
  }

  .cinder-schedule-builder__weekday-group > .cinder-chip:focus-visible {
    position: relative;
    z-index: 2;
  }

  /* ----------------------------------------
   * Custom cron: five labelled fields in one row, each with its range beneath
   * ---------------------------------------- */

  .cinder-schedule-builder__cron {
    display: flex;
    flex-direction: column;
    gap: var(--cinder-space-2);
  }

  .cinder-schedule-builder__cron-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(4.5rem, 1fr));
    gap: var(--cinder-space-3);
    min-inline-size: 0;
  }

  /* The error is the form field's own error line, so it reads the same as any other. With no
     message the shared rule takes it out of the layout but keeps it mounted, so the live region
     announces the message when it arrives. */

  /* ----------------------------------------
   * Runs panel and the plain Next runs list
   * ---------------------------------------- */

  /* The Runs panel is a flat group of the sentence and the next runs: it sits in the form's own
     surface, with no inset fill and no border, so it is never a box inside a box. */

  .cinder-schedule-builder__panel {
    display: flex;
    flex-direction: column;
    gap: var(--cinder-space-2);
    margin: 0;
    padding: 0;
  }

  .cinder-schedule-builder__preview {
    display: flex;
    flex-direction: column;
    gap: var(--cinder-space-1);
    margin: 0;
  }

  .cinder-schedule-builder__section-label {
    display: block;
    margin: 0;
    font-size: var(--cinder-text-xs);
    font-weight: var(--cinder-font-semibold);
    color: var(--cinder-text-muted);
  }

  .cinder-schedule-builder__summary-text {
    margin: 0;
    font-size: var(--cinder-text-sm);
    color: var(--cinder-text-default);
  }

  .cinder-schedule-builder__preview-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--cinder-space-1);
  }

  .cinder-schedule-builder__preview-item {
    font-size: var(--cinder-text-sm);
    color: var(--cinder-text-default);
    font-variant-numeric: tabular-nums;
  }

  .cinder-schedule-builder__empty {
    margin: 0;
    font-size: var(--cinder-text-sm);
    color: var(--cinder-text-muted);
  }

  /* The compact block has no panel, so its Next runs list reads as quiet text. */
  .cinder-schedule-builder[data-cinder-variant='compact'] .cinder-schedule-builder__section-label {
    font-weight: var(--cinder-font-normal);
  }

  /* ----------------------------------------
   * Policy selects: two plain selects sharing a row
   * ---------------------------------------- */

  .cinder-schedule-builder__policies {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: var(--cinder-space-3);
  }
}
