/*
 * den-ui base: what every page using the kit gets. Load after tokens.css.
 * Zero specificity (:where), so a product's own rules win.
 */

/* Motion: every animation and transition uses the duration tokens, so
   one rule stops them all when the person asks for less motion. */
@media (prefers-reduced-motion: reduce) {
  :where(:root) {
    --dur-fast: 0ms;
    --dur: 0ms;
    --dur-cue: 0ms;
  }
}

/* Japanese: keep words whole, break a run only where it would overflow,
   strict kinsoku. Chromium keeps phrases whole (auto-phrase); WebKit has
   keep-all. break-word, not anywhere: anywhere lets a table column shrink
   to one character, so a short header breaks inside its word. */
:where(:lang(ja)) {
  word-break: keep-all;
  overflow-wrap: break-word;
  line-break: strict;
}
@supports (word-break: auto-phrase) {
  :where(:lang(ja)) {
    word-break: auto-phrase;
  }
}

/* An open modal dialog is as tall as its content, and centred. The
   browser's own box (inset-block 0, height fit-content) is not enough: on
   an iPad a pop-up still ran the window's full height, even with height:
   fit-content. So the box is placed by hand and owes nothing to the
   browser's inset or height:
   - fixed, top 50%, moved up by half its own height; bottom auto, so no
     inset pair can stretch it;
   - height auto, capped at the window less 32 px (vh first, for an older
     iPad without dvh), and it scrolls inside.
   Each dialog keeps its own width and its own smaller max-height. Zero
   specificity, so a sheet's own rules win; a bottom sheet sets
   transform: none (Report at phone width). A dialog placed by its anchor
   (.den-pop, .den-toplayer: the admin-password prompt) is left alone. */
:where(dialog:modal:not(.den-pop):not(.den-toplayer)) {
  position: fixed;
  inset-block: auto;
  inset-inline: 0;
  top: 50%;
  transform: translateY(-50%);
  margin: 0 auto;
  height: auto;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
}

/* UK-3, one placement for Report (issue 94). Where it sits is the kit's,
   for every page and pop-up, in Den and in any product on the kit:
   - top bar: right group, in the order Report, bell, account, at every
     width; the shortcut shows beside the word only where there is room
     (the tooltip always has it);
   - dialog, drawer and popover: first in the footer, on the left, and
     the pop-up's other buttons follow;
   - never only in a menu. */
:where(.den-rb-top) {
  flex: none;
  margin: 0;
}
@media (max-width: 720px) {
  :where(.den-rb-top kbd) {
    display: none;
  }
}
:where(.den-rb-in) {
  order: -1;
  margin-right: auto;
}
:where(.den-rb-foot) {
  justify-content: flex-start;
}
