/* Rules the Om* components cannot carry in their scoped .razor.css. OmButton, OmLinkButton, OmTextField, OmTextArea
   and OmCheckbox render a Fluent element with no wrapper of their own, so scoped CSS cannot reach it. Linked once, from
   the host's App.razor (docs/architecture/ui-pages.md, touch targets). */

/* Rules every component shares (T-0205), kept here once instead of a copy in each component's scoped CSS. Scoped
   stylesheets load after this file: a component's own rule must not set a property these rules set, or it wins over
   their states. */

/* Text for screen readers only (OmVisuallyHidden, OmCopyField's label, OmFieldLabel Hidden, OmPageState's spinner
   name; a page may put the class on a span). */
.om-visually-hidden {
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

/* The focus ring of the library's own focusable elements: one ring, with the offset each element had before the rules
   were merged. A new focusable element joins the list, and an offset group if it needs one: 1px for most controls,
   none for items packed tightly in a bar (segments, pager pages, facets) so the next item doesn't cover the ring, 2px
   around a control with its own border-like edge, and inset (-2px) for rows of a menu or a list that fill their box. */
:is(.om-shell-brand, .om-shell-icon-button, .om-shell-avatar-button, .om-breadcrumb a, .om-chip, .om-chip-picker-toggle,
  .om-chip-picker-star, .om-copy-input, .om-copy-button, .om-date-input, .om-dialog-close, .om-facet-more,
  .om-facet-item, .om-file-input, .om-filter-tag, .om-menu-button, .om-move-button, .om-nav-link, .om-org-button,
  .om-pager-step, .om-pager-page, .om-search-input, .om-segmented-option, .om-select-input, .om-sheet-trigger,
  .om-sheet-done, .om-sheet-close, .om-sort-button, .om-table-scroll, .om-token-remove, .om-menu-item, .om-org-option,
  .om-section-header, .om-tab, .om-link-external):focus-visible {
  outline: 2px solid var(--colorStrokeFocus2);
  outline-offset: 1px;
}

:is(.om-shell-brand, .om-shell-icon-button, .om-shell-avatar-button, .om-dialog-close, .om-facet-more, .om-facet-item,
  .om-move-button, .om-pager-step, .om-pager-page, .om-segmented-option, .om-token-remove):focus-visible {
  outline-offset: 0;
}

:is(.om-file-input, .om-sort-button):focus-visible {
  outline-offset: 2px;
}

:is(.om-menu-item, .om-org-option, .om-section-header, .om-tab):focus-visible {
  outline-offset: -2px;
}

/* The field look and its states for the library's native inputs (OmSelect, OmDateField, OmSearchBox, OmCopyField),
   the same as Fluent's text field. Their scoped CSS keeps only size, padding and what is particular to them. */
:is(.om-select-input, .om-date-input, .om-search-input, .om-copy-input) {
  background: var(--colorNeutralBackground1);
  border: 1px solid var(--colorNeutralStroke1);
  border-bottom-color: var(--colorNeutralStrokeAccessible);
  border-radius: var(--borderRadiusMedium);
  box-sizing: border-box;
  color: var(--colorNeutralForeground1);
  font: inherit;
  min-width: 0;
}

  :is(.om-select-input, .om-date-input, .om-search-input, .om-copy-input):hover {
    border-color: var(--colorNeutralStroke1Hover);
    border-bottom-color: var(--colorNeutralStrokeAccessibleHover);
  }

  :is(.om-select-input, .om-date-input, .om-search-input, .om-copy-input):focus-visible {
    border-bottom-color: var(--colorCompoundBrandStroke);
  }

  :is(.om-select-input, .om-date-input, .om-search-input, .om-copy-input):disabled {
    background: var(--colorNeutralBackgroundDisabled);
    border-color: var(--colorNeutralStrokeDisabled);
    color: var(--colorNeutralForegroundDisabled);
    cursor: not-allowed;
  }

  :is(.om-select-input, .om-date-input, .om-search-input, .om-copy-input)[aria-invalid="true"] {
    border-color: var(--colorStatusDangerForeground1);
    border-bottom: 2px solid var(--colorStatusDangerForeground1);
  }

/* Fluent keeps the text padding on an icon-only button (OmButton, OmLinkButton with an icon and no text), which leaves
   a 32px button no room for its icon. */
:is(fluent-button, fluent-anchor-button)[icon-only] {
  padding: 0;
}

/* OmButton Danger: Fluent has no danger appearance, so the primary button is drawn with its brand colour tokens swapped
   for the danger ones. A class rather than a computed style attribute (docs/guides/conventions.md, CSS isolation). */
fluent-button.om-button-danger {
  --colorBrandBackground: var(--colorStatusDangerBackground3);
  --colorBrandBackgroundHover: var(--colorStatusDangerBackground3Hover, var(--colorStatusDangerBackground3));
  --colorBrandBackgroundPressed: var(--colorStatusDangerBackground3Pressed, var(--colorStatusDangerBackground3));
  --colorBrandBackgroundSelected: var(--colorStatusDangerBackground3Pressed, var(--colorStatusDangerBackground3));
}

/* Phones (app-shell spec R1-R3, docs/guides/conventions.md#responsive-layout) */
@media (max-width: 599.98px) {
  /* reboot.css sizes h1-h3 for a wide screen. */
  .om-shell-content h1 {
    font-size: 1.75rem;
  }

  .om-shell-content h2 {
    font-size: 1.35rem;
  }

  .om-shell-content h3 {
    font-size: 1.15rem;
  }
}

/* Phones, and touch screens of any width (app-shell spec R2, R27): a tablet keeps the wide layout but gets the same
   touch-sized controls. */
@media (max-width: 599.98px), (pointer: coarse) {
  /* 44px touch targets. */
  .om-shell-content fluent-text-input,
  .om-shell-content fluent-button,
  .om-shell-content fluent-anchor-button {
    min-height: 44px;
  }

  /* A checkbox's label (OmCheckbox) is its touch target. */
  .om-shell-content fluent-field[label-position="after"] > label {
    align-items: center;
    display: inline-flex;
    min-height: 44px;
  }

  /* A checkbox in a table cell (a row's select box, with no visible label) gets a hit area around its 16px box: 44px
     high, and as wide as the cell (OmTable's cell padding each side, 40px), so it never reaches the next cell; a 44px
     width would overlap a neighbouring checkbox column. A tap on the pseudo-element is a tap on the checkbox. Elsewhere
     the label is the target, and a wider box would reach into the hint or the row next to it. */
  .om-shell-content td fluent-checkbox {
    position: relative;
  }

    .om-shell-content td fluent-checkbox::after {
      content: "";
      inset: -14px calc(-1 * var(--spacingHorizontalM));
      position: absolute;
    }

  /* 16px text in Fluent's text fields and text areas (OmTextField, OmTextArea), so iOS doesn't zoom the page in when
     one gets focus. */
  fluent-text-input::part(control),
  fluent-textarea::part(control) {
    font-size: var(--fontSizeBase400);
  }
}
