/* Owner: B (design system). Reset, element defaults, typography, links, focus, selection, icons, tabular figures,
   utilities and reduced motion (spec §2.5, §2.9, §2.10, §12.1). Layers: reset, base, utilities – the order of all
   layers is fixed once in tokens.css. No colour values (tokens only). */

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body, h1, h2, h3, h4, h5, h6, p, ul, ol, dl, dd, figure, blockquote, fieldset, legend, pre { margin: 0; }
  ul, ol { padding: 0; }
  fieldset { border: 0; padding: 0; min-width: 0; }
  legend { padding: 0; }
  button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
  button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
  table { border-collapse: separate; border-spacing: 0; }
  th { font-weight: inherit; text-align: left; }
  summary { list-style: none; cursor: pointer; }
  summary::-webkit-details-marker { display: none; }
  dialog { padding: 0; border: 0; color: inherit; background: none; max-width: none; max-height: none; }
  mark { color: inherit; background: none; }
  [hidden] { display: none !important; }
}

@layer base {
  /* 100 % keeps the reader's own font size; the interface works in rem from a 14 px base (spec §2.5).
     Scroll geometry (spec §3.8): what gets the focus or is jumped to stops 16 px below whatever sticks at the top –
     the phone header (--kopf-hoehe of layout.css: 48 px under 760 px, 0 on low screens) and the sticky head of the
     list on the page (--klebkopf; WCAG 2.4.11, ergebnis §6.3 R7). */
  html {
    font-size: 100%; font-family: var(--font-ui); background: var(--bg); color: var(--text);
    scroll-padding-top: calc(var(--kopf-hoehe, 0px) + var(--klebkopf, 0px) + 16px);
  }
  /* The sticky list heads: table head 34 px (components.css), month head of the mail history of a Vorgang 36 px (may
     wrap) and month of the chronicle 40 px (akte.css). Below 560 px of height none of them sticks (spec §3.2). The
     attachment page keeps its file bar clear with the scroll-margin of its targets (lesen.css). */
  @media (min-height: 560px) {
    :root:has(.tabelle th) { --klebkopf: 34px; }
    :root:has(.monatskopf, .monat) { --klebkopf: 40px; }
  }
  body {
    min-height: 100vh;
    font-size: var(--fs-14);
    line-height: 20px;
    letter-spacing: -0.006em;
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }

  /* Headings: defaults of the type scale (spec §2.5); components and pages set their own roles */
  h1, h2, h3, h4 { font-weight: 600; color: var(--text); }
  h1 { font-size: var(--fs-22); line-height: 30px; letter-spacing: -0.019em; }
  h2 { font-size: var(--fs-15); line-height: 22px; letter-spacing: -0.01em; }
  h3, h4 { font-size: var(--fs-14); line-height: 20px; letter-spacing: -0.006em; }
  @media (max-width: 759px) { h1 { font-size: var(--fs-20); line-height: 28px; } }
  h1:focus { outline: none; }   /* focus target on a route change (tabindex=-1), never a control */
  h1:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 2px; }
  strong, b { font-weight: 600; }

  /* Links: no underline in the interface; running text (the answer, the index card) underlines them (components.css) */
  a { color: var(--accent-text); text-decoration: none; }
  :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
  ::selection { background: var(--accent-subtle-hover); color: var(--text); }
  input::placeholder, textarea::placeholder { color: var(--text-3); opacity: 1; }
  code, kbd, samp, pre { font-family: var(--font-mono); }
  hr { border: 0; border-top: 1px solid var(--border); margin: 0; }

  /* Icons (js/core/icons.js, Lucide, stroke currentColor): 16 px with stroke 1.75 in the interface; components set
     14 px (meta, deadline marks, chips), 12 px with stroke 2.25 (pills, tags, marks) and 20 px (phone header, empty
     state) – or a page picks a size with .icon--12/14/20. The icon never takes the click (no ev.target pitfalls). */
  .icon { width: 16px; height: 16px; flex-shrink: 0; stroke-width: 1.75; pointer-events: none; }
  .icon--12 { width: 12px; height: 12px; stroke-width: 2.25; }
  .icon--13 { width: 13px; height: 13px; stroke-width: 2; }
  .icon--14 { width: 14px; height: 14px; }
  .icon--16 { width: 16px; height: 16px; }
  .icon--20 { width: 20px; height: 20px; }

  /* Tabular figures only where numbers are compared (dates, times, counters, #Nr, numeric columns) – never on
     containers that also hold names or file names (Inter widens "-" and ":" with tnum). */
  time, .tnum { font-variant-numeric: tabular-nums; }
  .zahl { font-variant-numeric: tabular-nums; white-space: nowrap; }
  .liste { list-style: none; }
  .vh {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  .text-2 { color: var(--text-2); }
  .text-3 { color: var(--text-3); }
  .nowrap { white-space: nowrap; }
  .umbruch { overflow-wrap: anywhere; }

  /* Before the frame stands (index.html, main.js): the loading line and an error of the start */
  .startmeldung { padding: 48px 32px; color: var(--text-2); font-size: var(--fs-14); }
  .startfehler { max-width: 640px; margin: 48px auto; padding: 0 16px; }
}

@layer utilities {
  .ml-auto { margin-left: auto; }

  /* Reduced motion (spec §2.9): every duration 1 ms, no repetitions, no smooth scrolling – what moves becomes a
     cross-fade at most. Skeletons drop their shimmer in components.css. */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      transition-duration: 1ms !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important;
      scroll-behavior: auto !important;
    }
  }
}
