/*! Perspective Fluent kit: fonts and additions to the generated fluent.css.
 *
 * Selawik, Copyright (c) Microsoft Corporation, SIL Open Font License 1.1
 * (fonts/OFL.txt). Segoe UI is used when installed and never bundled.
 */

/* Selawik: the open substitute for Segoe UI, second in the font stack (ADR 0002).
 * Paths are relative to this file; ship the fonts/ directory next to it. Selawik 1.01
 * draws the horizontal ellipsis (U+2026) as a single dot, so that character is left to the
 * next font of the stack (`unicode-range`); text-overflow ellipses and "Syncing…" use it. */
@font-face {
  font-family: "Selawik";
  src: url("fonts/selawik-light.woff2") format("woff2");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0-2025, U+2027-10FFFF;
}
@font-face {
  font-family: "Selawik";
  src: url("fonts/selawik-semilight.woff2") format("woff2");
  font-weight: 350;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0-2025, U+2027-10FFFF;
}
@font-face {
  font-family: "Selawik";
  src: url("fonts/selawik-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0-2025, U+2027-10FFFF;
}
@font-face {
  font-family: "Selawik";
  src: url("fonts/selawik-semibold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0-2025, U+2027-10FFFF;
}
@font-face {
  font-family: "Selawik";
  src: url("fonts/selawik-bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0-2025, U+2027-10FFFF;
}

/* Wrappers the kit puts around portalled popups (they carry the popup's `dir`): no box of
 * their own. */
.perspective-PopupHost,
.perspective-TooltipHost {
  display: contents;
}

/* Navigation selection in trees (the folder pane). Fluent's tree has no such state:
 * neutral selected background and a brand bar at the inline start. */
.fui-TreeItem[aria-selected="true"] > .fui-TreeItemLayout {
  position: relative;
  background-color: var(--colorNeutralBackground1Selected);
  color: var(--colorNeutralForeground1Selected);
}
.fui-TreeItem[aria-selected="true"] > .fui-TreeItemLayout::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 50%;
  width: var(--strokeWidthThicker);
  height: 16px;
  margin-top: -8px;
  border-radius: var(--borderRadiusCircular);
  background-color: var(--colorCompoundBrandStroke);
}
/* Unread counts keep 4.5:1 on the selected background: brand foreground 1 falls to
 * 3.7–4.3:1 there with several presets, brand foreground 2 (a shade darker in light mode,
 * lighter in dark mode) stays above 4.6:1 (pinned by tests/stylesheet.rs). */
.fui-TreeItem[aria-selected="true"] > .fui-TreeItemLayout .fui-CounterBadge[data-appearance="ghost"][data-color="brand"] {
  color: var(--colorBrandForeground2);
}
/* High contrast: the selected row takes the highlight colour, on which brand foreground 2
 * (the canvas text, white) falls to 1.5:1 (#55): the count takes the highlight's text. Not
 * under forced colours, where the theme is on too and the rule below gives the system's. */
@media (forced-colors: none) {
  :root[data-theme="high-contrast"] .fui-TreeItem[aria-selected="true"] > .fui-TreeItemLayout .fui-CounterBadge[data-appearance="ghost"][data-color="brand"] {
    color: var(--colorNeutralForeground2BrandSelected);
  }
}
@media (forced-colors: active) {
  .fui-TreeItem[aria-selected="true"] > .fui-TreeItemLayout {
    forced-color-adjust: none;
    background-color: Highlight;
    color: HighlightText;
  }
  .fui-TreeItem[aria-selected="true"] > .fui-TreeItemLayout::before {
    background-color: HighlightText;
  }
  .fui-TreeItem[aria-selected="true"] > .fui-TreeItemLayout .fui-CounterBadge[data-appearance="ghost"][data-color="brand"] {
    color: HighlightText;
  }
}

/* Filled danger badges: Fluent writes them in on-brand text, which the tokens' on-brand
 * safeguard turns dark when the brand background is light (mono in dark mode: 4.0:1 on
 * the red). The red does not follow the brand; white keeps 4.9:1 on it in light and dark
 * (pinned by tests/stylesheet.rs). High contrast keeps Fluent's colours. */
:root:not([data-theme="high-contrast"]) .fui-Badge[data-appearance="filled"][data-color="danger"] {
  color: var(--colorNeutralForegroundStaticInverted);
}

/* Inactive avatars: Fluent dims them to 80 % opacity, which takes their initials below
 * 4.5:1 with every preset (2.8:1 for duck in light mode). Perspective keeps the smaller
 * size only. */
.fui-Avatar[data-active="inactive"] {
  opacity: 1;
}

/* The tree chevron turns with an inline transition (as in Fluent); honour reduced motion.
 * Fluent only shortens the button's colour transition to 0.01 ms there, and a transition,
 * however short, starts at the next frame: until then a button just enabled keeps its
 * disabled colours without being disabled (#346). Without one, its colours change with
 * its state. */
@media (prefers-reduced-motion: reduce) {
  .fui-TreeItemLayout__expandIcon > svg {
    transition: none !important;
  }
  .fui-Button {
    transition: none;
  }
}

/* The Perspective glyph (brand.rs): one colour, the theme's brand foreground, so that it
 * follows the presets and the light, dark and high-contrast modes. */
.perspective-BrandGlyph {
  flex: none;
  color: var(--colorBrandForeground1);
}

/* Overflow toolbar (toolbar.rs): an item that no longer fits leaves the flow and the view
 * for the "more" menu, keeping its size so that the toolbar knows when it fits again (so
 * does a group's hidden part). Items never shrink: their width is what the toolbar
 * measures. Labels are regular, but primary and pressed ones (#341). */
.perspective-OverflowToolbar {
  position: relative;
  flex-wrap: nowrap;
  min-width: 0;
  overflow: hidden;
}
.perspective-OverflowToolbar > .perspective-OverflowItem,
.perspective-OverflowToolbar > .perspective-OverflowMore,
.perspective-OverflowCommand,
.perspective-RibbonGroup__collapse {
  display: flex;
  flex: none;
  align-items: center;
}
.perspective-OverflowToolbar > .fui-ToolbarDivider {
  flex: none;
  align-self: stretch;
}
.perspective-OverflowToolbar [data-overflowing] {
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  visibility: hidden;
  pointer-events: none;
}
.perspective-OverflowToolbar [hidden] {
  display: none;
}
.perspective-OverflowToolbar .fui-Button:not([data-appearance="primary"], [aria-pressed="true"]) {
  font-weight: var(--fontWeightRegular);
}

/* Ribbon group (toolbar.rs): a classic ribbon's labelled group, the name under the
 * commands. */
.perspective-RibbonGroup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.perspective-RibbonGroup[hidden] {
  display: none;
}
.perspective-RibbonGroup__commands {
  display: flex;
  align-items: center;
  gap: 2px;
}
.perspective-RibbonGroup__label {
  color: var(--colorNeutralForeground3);
  font-size: var(--fontSizeBase200);
  line-height: var(--lineHeightBase200);
  white-space: nowrap;
}

/* Stacked groups (toolbar.rs, #347): small commands two high (STACK), a large one across
 * both rows, its icon over a 12 px label of two lines at most, as a collapsed group's
 * drop-down; the fit's guesses count on these sizes. */
[data-stacked] {
  padding-block: 0;
}
[data-stacked] .perspective-RibbonGroup__commands {
  display: grid;
  grid: repeat(2, 32px) / auto-flow;
  gap: 4px 0;
  justify-items: start;
}
[data-large],
[data-large] :is(.p-RibbonCommand, .fui-SplitButton) {
  grid-row: 1 / -1;
  align-items: stretch;
}
:is([data-large] .fui-Button[data-has-icon], [data-stacked] .perspective-RibbonGroup__collapse button) {
  display: inline-grid;
  grid-template-columns: auto auto;
  place-content: center;
  justify-items: center;
  gap: 4px 2px;
  min-width: 48px;
  max-width: 96px;
  padding: 4px 8px;
  font-size: var(--fontSizeBase200);
  line-height: var(--lineHeightBase200);
}
[data-large] button {
  height: 68px;
}
[data-stacked] .perspective-RibbonGroup__collapse {
  min-height: 68px;
}
:is([data-large] .fui-Button[data-has-icon], [data-stacked] .perspective-RibbonGroup__collapse) .fui-Button__icon {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 24px;
  width: 24px;
  height: 24px;
}
[data-large] .perspective-OverflowLabel {
  grid-column: 1 / -1;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-align: center;
}
/* A large command that opens a menu (compose's Paste and Signature, #316): the chevron
 * sits after the label, on the label's row, not on a third row of the button. */
[data-large] .fui-MenuButton .perspective-OverflowLabel {
  grid-column: 1;
}
[data-large] .fui-MenuButton .fui-MenuButton__menuIcon {
  grid-column: 2;
  align-self: center;
  margin: 0;
}

/* The point a context menu opens at (menu.rs). */
.perspective-ContextMenuAnchor {
  position: fixed;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

/* A field's hint beside its control, under it on a short line (field.rs). */
.perspective-Field__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacingVerticalXXS) var(--spacingHorizontalM);
}
.perspective-Field__row > * {
  min-width: 0;
  margin-top: 0;
}

/* Vertical tab lists (tabs.rs): labels keep to the start, wrapped or not, also in the
 * cell that the hidden semibold copy of an unselected tab's label reserves. A button
 * centres its text. */
.fui-TabList[aria-orientation="vertical"] > .fui-Tab {
  text-align: start;
  overflow-wrap: break-word;
}
