/*
 * NO @import of a webfont host here, deliberately. Loading the fonts is the
 * consuming app's job — see "Fonts" in the README.
 *
 * This file used to open with a Google Fonts @import, and it was broken for
 * every consumer using a bundler. CSS requires @import to precede all other
 * rules; a bundler that concatenates stylesheets puts other rules ahead of it,
 * and the browser then drops it silently. Confirmed in a Next.js 16 /
 * Turbopack app: the built bundle contained no @import and no
 * `fonts.googleapis` string at all, so no font ever loaded.
 *
 * It failed quietly rather than loudly. The font tokens named bare families
 * with no generic fallback, so the unresolved families fell through to the
 * browser default and the whole system rendered in a default serif — which
 * reads as a token bug, not a font-loading one. The fallbacks added to
 * token-overrides.json are what makes that failure mode legible.
 *
 * Reaching a third-party host at CSS parse time was also the wrong default
 * regardless: it is a render-blocking request the consumer did not opt into,
 * it bypasses next/font and friends, and it hands visitor IPs to Google.
 */
@import url('./tokens/index.css');

/*
 * Before the components, deliberately. `.ion-icon` is a primitive that every
 * slot below sizes with its own `... svg` rule, and those rules have to be free
 * to win on ordering as well as specificity.
 */
@import url('./icon.css');
@import url('./button.css');
@import url('./tabs.css');
@import url('./alert.css');
@import url('./badge.css');
@import url('./input.css');
@import url('./textarea.css');
@import url('./phone-input.css');
@import url('./select.css');
@import url('./checkbox.css');
@import url('./radio.css');
@import url('./fieldset.css');
@import url('./toggle.css');
@import url('./slider.css');
@import url('./tree-view.css');
@import url('./menu.css');
@import url('./avatar.css');
@import url('./avatar-gradient.css');
@import url('./header.css');
@import url('./logo.css');
@import url('./table.css');
@import url('./table-batch.css');
@import url('./tree-grid.css');
@import url('./pagination.css');
@import url('./divider.css');
@import url('./toolbar.css');
@import url('./link.css');
@import url('./modal.css');
@import url('./popover.css');
@import url('./coachmark.css');
@import url('./app-switcher.css');
@import url('./split-pane.css');
@import url('./tooltip.css');
@import url('./toggletip.css');
@import url('./ai-label.css');
@import url('./chat-message.css');
@import url('./stack.css');
@import url('./grid.css');
@import url('./theme-zone.css');
@import url('./skip-link.css');
@import url('./toast.css');
@import url('./nav-item.css');
@import url('./scroll-progress.css');
@import url('./full-card.css');

/*
 * The agentic tier. No Figma counterpart yet, so these borrow their
 * measurements from Button and Alert rather than inventing any — see the
 * header of each file.
 */
@import url('./agent-stop.css');
@import url('./approval-gate.css');
@import url('./agent-activity.css');
@import url('./streaming-text.css');
@import url('./citation.css');
@import url('./confidence-indicator.css');
@import url('./empty-state.css');
@import url('./spinner.css');
@import url('./progress-bar.css');
@import url('./progress-ring.css');
@import url('./skeleton.css');
@import url('./breadcrumb.css');
@import url('./accordion.css');
@import url('./drawer.css');
@import url('./side-panel.css');
@import url('./description-list.css');
@import url('./list.css');
@import url('./button-group.css');
@import url('./split-button.css');
@import url('./copy-button.css');
@import url('./code-snippet.css');
@import url('./stepper.css');
@import url('./prompt-input.css');
@import url('./tool-call.css');
@import url('./number-input.css');
@import url('./search-field.css');
@import url('./password-input.css');
@import url('./status-indicator.css');
@import url('./inline-loading.css');
@import url('./notifications-panel.css');
@import url('./inline-edit.css');
@import url('./selectable-tile.css');
@import url('./truncated-text.css');
@import url('./timeline.css');
@import url('./segmented-control.css');
@import url('./sidebar.css');
@import url('./file-upload.css');
@import url('./combobox.css');
@import url('./multi-select.css');
@import url('./dual-listbox.css');

/*
 * date-range-picker AFTER date-picker, and the order is load-bearing rather
 * than alphabetical. The range band overrides `.ion-calendar__day`'s
 * border-radius at equal specificity — square sides so consecutive days join
 * into one bar — and at equal specificity the later rule is the one that wins.
 */
@import url('./date-picker.css');
@import url('./date-range-picker.css');
@import url('./date-time-picker.css');
@import url('./time-field.css');
@import url('./color-picker.css');
@import url('./stat-tile.css');
@import url('./setting-row.css');
@import url('./chart.css');
@import url('./card.css');
@import url('./page-header.css');
@import url('./tag-group.css');
@import url('./kbd.css');
@import url('./command-palette.css');

/*
 * Visually hidden, but not hidden from assistive tech.
 *
 * Written once here rather than per component: two components already needed
 * it for their live regions, and a second copy of a rule this fiddly is how the
 * two quietly diverge. `display: none` and `visibility: hidden` both remove the
 * node from the accessibility tree, so an announcement placed in one would
 * never be made — the clip-path is what keeps it readable while occupying no
 * space. No `margin: -1px`: that belongs to the older `clip: rect()` variant
 * and is not needed here, which is convenient, because it is also not a token.
 */
.ion-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/*
 * Every IonBase element is border-box.
 *
 * Not cosmetic: `<button>` inherits border-box from the UA stylesheet but
 * `<div>` does not, so a component built on a div sized its min-height against
 * the CONTENT box and came out 16px taller than the design. Button looked
 * correct only by accident of its tag name.
 *
 * Scoped to `ion-` classes so the design system never restyles a host app.
 */
[class^='ion-'],
[class*=' ion-'] {
  box-sizing: border-box;
}

/* Global baseline resets using token variables only */
body {
  font-family: var(--font-family-sans);
  font-size: var(--type-body);
  line-height: var(--type-body-line-height);
  background-color: var(--surface-page);
  color: var(--text-default);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/*
 * Reduced motion — WCAG 2.3.3.
 *
 * One global block covers every `ion-*` element, its descendants and their
 * `::before` / `::after`, rather than a media query per stylesheet. The
 * pseudo-elements were missing until 0.135.0: `*` does not match them, so
 * Slider's thumb and Table's resize handle kept animating. `0.01ms` rather
 * than `0` so the browser still fires `transitionend` / `animationend` for
 * anything that listens.
 *
 * The only rules that out-rank it are loops that must keep moving to mean
 * anything — Spinner and the indeterminate ProgressBar, slowed rather than
 * stopped. Anything else that needs its own reduced-motion rule sets
 * `animation: none` or a static end state, which this block does not fight.
 */
@media (prefers-reduced-motion: reduce) {
  [class^='ion-'],
  [class*=' ion-'],
  [class^='ion-'] *,
  [class*=' ion-'] *,
  [class^='ion-']::before,
  [class^='ion-']::after,
  [class*=' ion-']::before,
  [class*=' ion-']::after,
  [class^='ion-'] *::before,
  [class^='ion-'] *::after,
  [class*=' ion-'] *::before,
  [class*=' ion-'] *::after {
    /* stylelint-disable declaration-property-unit-disallowed-list --
       the one place a raw duration belongs: the "no motion" value itself. */
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    /* stylelint-enable declaration-property-unit-disallowed-list */
    scroll-behavior: auto !important;
  }
}

/*
 * Forced colours — Windows High Contrast / WCAG 1.4.11.
 *
 * Components that convey state with background or border tokens flatten to
 * unreadable blocks when the OS remaps colour. Re-express those states with
 * system colour keywords so selected, checked, focused and disabled remain
 * distinguishable. `forced-color-adjust: none` only where the system would
 * otherwise erase a fill the mark depends on (checked boxes, selected pills).
 */
@media (forced-colors: active) {
  .ion-button:focus-visible,
  .ion-button[data-focused='true'],
  .ion-nav-item:focus-visible,
  .ion-nav-item[data-focused='true'],
  .ion-tabs__item:focus-visible,
  .ion-tabs__item[data-focused='true'],
  .ion-tabs__panel:focus-visible,
  .ion-menu__item:focus-visible,
  .ion-input:focus-within,
  .ion-select:focus-within,
  .ion-scroll-progress__trigger:focus-visible,
  .ion-scroll-progress__heading:focus-visible,
  .ion-table-container:focus-visible {
    outline: var(--border-width-thick) solid Highlight;
    outline-offset: 2px;
  }

  .ion-checkbox__input:focus-visible + .ion-checkbox__indicator,
  .ion-checkbox[data-focused='true'] .ion-checkbox__indicator,
  .ion-radio__input:focus-visible + .ion-radio__indicator,
  .ion-radio[data-focused='true'] .ion-radio__indicator,
  .ion-toggle__input:focus-visible + .ion-toggle__track,
  .ion-toggle[data-focused='true'] .ion-toggle__track {
    outline: var(--border-width-thick) solid Highlight;
    outline-offset: 2px;
  }

  /* Checked / selected before disabled so specificity reads non-decreasing. */
  .ion-checkbox__input:checked + .ion-checkbox__indicator,
  .ion-checkbox__input:indeterminate + .ion-checkbox__indicator,
  .ion-radio__input:checked + .ion-radio__indicator,
  .ion-toggle__input:checked + .ion-toggle__track {
    forced-color-adjust: none;
    background-color: Highlight;
    border-color: Highlight;
  }

  .ion-checkbox__input:checked + .ion-checkbox__indicator .ion-checkbox__mark,
  .ion-checkbox__input:indeterminate
    + .ion-checkbox__indicator
    .ion-checkbox__mark {
    forced-color-adjust: none;
    color: HighlightText;
  }

  .ion-radio__input:checked + .ion-radio__indicator .ion-radio__dot {
    forced-color-adjust: none;
    background-color: HighlightText;
  }

  .ion-toggle__input:checked + .ion-toggle__track .ion-toggle__thumb {
    forced-color-adjust: none;
    background-color: HighlightText;
  }

  /* Named as table.css names it, so it outweighs the selected tint there. */
  .ion-table tbody tr.ion-table__row[data-selected='true'] {
    forced-color-adjust: none;
    background-color: Highlight;
    color: HighlightText;
  }

  .ion-tabs__item--underline[data-selected='true'] {
    border-bottom-color: Highlight;
  }

  .ion-tabs__item--pill[data-selected='true'] {
    forced-color-adjust: none;
    background-color: Highlight;
    color: HighlightText;
  }

  .ion-button:disabled,
  .ion-button[data-disabled='true'],
  .ion-nav-item--disabled,
  .ion-nav-item[data-disabled='true'],
  .ion-tabs__item[data-disabled='true'],
  .ion-menu__item:disabled,
  .ion-menu__item[data-disabled='true'],
  .ion-input[data-disabled='true'],
  .ion-select[data-disabled='true'],
  .ion-checkbox--disabled,
  .ion-checkbox[data-disabled='true'],
  .ion-radio--disabled,
  .ion-radio[data-disabled='true'],
  .ion-toggle--disabled,
  .ion-toggle[data-disabled='true'] {
    color: GrayText;
    border-color: GrayText;
  }

  .ion-checkbox__input:disabled + .ion-checkbox__indicator,
  .ion-radio__input:disabled + .ion-radio__indicator,
  .ion-toggle__input:disabled + .ion-toggle__track {
    border-color: GrayText;
    background-color: Canvas;
  }

  /*
   * Disabled AND on is still on. These were in the group above, painted as
   * the page, so a checked disabled box looked exactly like an unchecked one.
   * Filled in GrayText instead: on, and not available.
   */
  .ion-checkbox__input:checked:disabled + .ion-checkbox__indicator,
  .ion-checkbox__input:indeterminate:disabled + .ion-checkbox__indicator,
  .ion-toggle__input:checked:disabled + .ion-toggle__track {
    forced-color-adjust: none;
    border-color: GrayText;
    background-color: GrayText;
  }

  .ion-checkbox__input:checked:disabled
    + .ion-checkbox__indicator
    .ion-checkbox__mark,
  .ion-checkbox__input:indeterminate:disabled
    + .ion-checkbox__indicator
    .ion-checkbox__mark {
    color: Canvas;
  }

  .ion-toggle__input:checked:disabled + .ion-toggle__track .ion-toggle__thumb {
    background-color: Canvas;
  }

  /*
   * A selected table row is Highlight (above), and so is its checked box:
   * edged in the row's text colour, or it is a Highlight square on a
   * Highlight row. After the disabled boxes, which it outweighs.
   */
  .ion-table
    tbody
    tr.ion-table__row[data-selected='true']
    .ion-checkbox__input:checked
    + .ion-checkbox__indicator {
    border-color: HighlightText;
  }

  .ion-radio__input:checked:disabled + .ion-radio__indicator {
    border-color: GrayText;
    background-color: Canvas;
  }

  .ion-radio__input:checked:disabled + .ion-radio__indicator .ion-radio__dot {
    forced-color-adjust: none;
    background-color: GrayText;
  }
}
