/* Elementregeln: gelten überall, auch auf noch nicht umgebauten Seiten. */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  img, svg { display: block; max-width: 100%; }
  button, input, select, textarea { font: inherit; color: inherit; }
  button { background: none; border: 0; cursor: pointer; }
  table { border-collapse: collapse; border-spacing: 0; }
  ul[role="list"], ol[role="list"], menu { list-style: none; }
}

@layer base {
  html { height: 100%; scroll-padding-top: calc(var(--kopf-h) + var(--s-3)); scroll-padding-bottom: calc(var(--tab-h) + var(--s-4)); }

  body {
    min-height: 100%;
    font-family: var(--schrift);
    font-size: var(--schrift-basis);
    line-height: 1.45;
    color: var(--f-text);
    background: var(--f-grund);
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
  }

  h1 { font-size: var(--schrift-xl); font-weight: 650; line-height: 1.2; letter-spacing: -0.012em; text-wrap: balance; }
  h2 { font-size: var(--schrift-m); font-weight: 650; line-height: 1.3; }
  h3 { font-size: var(--schrift-basis); font-weight: 650; line-height: 1.35; }
  p { text-wrap: pretty; }
  small { font-size: var(--schrift-s); }
  strong, b { font-weight: 650; }

  a { color: var(--f-akzent-schrift); text-decoration: none; text-underline-offset: 2px; }
  a:hover { text-decoration: underline; }

  hr { border: 0; border-top: 1px solid var(--f-rand); margin-block: var(--s-4); }

  code, kbd, samp { font-family: var(--schrift-mono); font-size: 0.92em; }
  kbd {
    display: inline-flex; align-items: center; min-width: 20px; height: 20px; padding: 0 5px; justify-content: center;
    font-size: var(--schrift-xs); color: var(--f-text-2);
    background: var(--f-flaeche-2); border: 1px solid var(--f-rand); border-bottom-width: 2px; border-radius: var(--r-1);
  }

  /* Ein Fokusring für alles, was die Tastatur erreicht. */
  :focus-visible { outline: 2px solid var(--f-fokus); outline-offset: 2px; border-radius: var(--r-1); }
  :focus:not(:focus-visible) { outline: none; }

  ::selection { background: var(--f-akzent-flaeche); color: var(--f-text); }

  /* Eingabefelder */
  label { display: block; font-size: var(--schrift-s); font-weight: 600; color: var(--f-text-2); margin-bottom: var(--s-1); }

  input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"]),
  select, textarea {
    width: 100%;
    min-height: var(--feld-h);
    padding: 0 10px;
    font-size: var(--schrift-basis);
    font-weight: 400;   /* Felder erben sonst die Schriftstärke eines umschließenden <label> */
    color: var(--f-text);
    background: var(--f-flaeche);
    border: 1px solid var(--f-rand-stark);
    border-radius: var(--r-2);
    transition: border-color var(--tempo), box-shadow var(--tempo);
  }
  textarea { padding-block: 7px; line-height: 1.45; resize: vertical; min-height: 72px; }
  select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
  input::placeholder, textarea::placeholder { color: var(--f-text-3); opacity: 1; }
  input:hover, select:hover, textarea:hover { border-color: var(--f-text-3); }
  input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--f-fokus); outline-offset: 0; border-color: var(--f-fokus); border-radius: var(--r-2); }
  input:disabled, select:disabled, textarea:disabled { color: var(--f-text-3); background: var(--f-flaeche-2); border-color: var(--f-rand); cursor: not-allowed; }
  input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--f-gefahr); box-shadow: inset 0 0 0 1px var(--f-gefahr); }

  input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--f-akzent); vertical-align: -3px; }
  input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
  input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

  @media (pointer: coarse) {
    input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
  }
  /* Unter 16 px zoomt iOS beim Antippen in das Feld. Gilt für Fingerbedienung und für schmale Fenster,
     und zwar auch gegen Altklassen mit eigener Schriftgröße – deshalb !important (in der Ebene „base“
     schlägt es jede spätere Ebene). Felder mit bewusst größerer Schrift nehmen sich aus: data-gross
     (Bestätigungscode) bzw. die Klassen der Zählmaske im Altbestand. */
  @media (pointer: coarse), (max-width: 767px) {
    input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"], [data-gross], .inv-qty, .inv-scan), select, textarea { font-size: 16px !important; }
  }

  /* Wer weniger Bewegung wünscht, bekommt keine. */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  }

  /* Sprungmarke für Tastatur und Vorleseprogramme */
  .ui-sprung {
    position: fixed; top: var(--s-2); left: var(--s-2); z-index: 1000;
    padding: var(--s-2) var(--s-4); font-weight: 600;
    color: var(--f-akzent-text); background: var(--f-akzent); border-radius: var(--r-2);
    transform: translateY(-200%);
  }
  .ui-sprung:focus { transform: none; text-decoration: none; }
}
