/* ═══════════════════════════════════════════════════════════════════════════
   VALIDURE ERP — base: reset, typography, focus, forms baseline
   owner: UI Designer · consumes tokens.css only
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── reset ──────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-gutter: stable;
  background: var(--e-bg);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--e-bg);
  color: var(--e-fg);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  font-weight: var(--fw-regular);
  line-height: var(--lh-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-synthesis-weight: none;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

button:disabled {
  cursor: not-allowed;
}

/* zero specificity so any component class can set its own list padding */
:where(ul[class], ol[class]) {
  list-style: none;
  padding: 0;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

fieldset {
  border: 0;
  padding: 0;
  min-width: 0;
}

legend {
  padding: 0;
}

[hidden] {
  display: none !important;
}

/* ── typography ─────────────────────────────────────────────────────────── */
h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--e-fg);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  text-wrap: balance;
}

/* Page titles and statement headings speak in the display voice. */
h1 {
  font-family: var(--font-display);
  font-stretch: var(--display-stretch);
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
  font-size: var(--fs-2xl);
  line-height: var(--lh-tight);
}

h2 {
  font-size: var(--fs-lg);
  letter-spacing: -0.005em;
}

h3 {
  font-size: var(--fs-md);
}

h4,
h5,
h6 {
  font-size: var(--fs-sm);
}

p {
  text-wrap: pretty;
}

small {
  font-size: var(--fs-sm);
}

strong,
b {
  font-weight: var(--fw-semibold);
}

a {
  color: var(--e-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  transition: color var(--dur-fast) var(--ease-out), text-decoration-color var(--dur-fast) var(--ease-out);
}

a:hover {
  color: var(--e-primary-dark);
  text-decoration-color: currentColor;
}

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.92em;
  font-variant-ligatures: none;
}

pre {
  overflow-x: auto;
  tab-size: 2;
}

hr {
  border: 0;
  border-top: 1px solid var(--e-border);
}

abbr[title] {
  text-decoration: underline dotted;
  text-underline-offset: 0.2em;
  cursor: help;
}

/* Money and figures never jitter: tabular numerals in every data context. */
table,
.num,
.money,
.kpi__value,
input[type="number"],
input[inputmode="decimal"],
input[inputmode="numeric"],
time {
  font-variant-numeric: tabular-nums;
}

/* ── selection & focus ──────────────────────────────────────────────────── */
::selection {
  background: var(--e-primary);
  color: var(--e-on-primary);
}

/* One visible, consistent ring everywhere. --e-focus is ≥ 3:1 on bg, raised
   and surface in every theme; inside the dark sidebar the ring switches to the
   sidebar foreground. Never remove an outline without replacing it. */
:focus-visible {
  outline: 2px solid var(--e-focus);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

.sidebar,
[data-surface="inverse"] {
  --e-focus: var(--e-sidebar-fg);
}

/* Targets of in-page links land below any sticky topbar. */
:target {
  scroll-margin-top: calc(var(--topbar-h) + var(--sp-4));
}

/* ── forms baseline (components.css styles the classes) ─────────────────── */
::placeholder {
  color: var(--e-faint);
  opacity: 1;
}

input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}

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;
}

label {
  cursor: default;
}

textarea {
  resize: vertical;
}

/* Native controls pick up the brand colour where they are left unstyled. */
:root {
  accent-color: var(--e-primary);
}

/* ── accessibility helpers ──────────────────────────────────────────────── */
.visually-hidden:not(:focus):not(:active) {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Skip link: first focusable element of every layout. */
.skip-link {
  position: absolute;
  left: var(--sp-3);
  top: var(--sp-3);
  z-index: calc(var(--z-toast) + 1);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--e-primary);
  color: var(--e-on-primary);
  font-weight: var(--fw-semibold);
  text-decoration: none;
  translate: 0 -200%;
}

.skip-link:focus {
  translate: 0 0;
}

/* ── scrollbars: quiet, theme-aware ─────────────────────────────────────── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--e-border-strong) transparent;
}

/* ── reduced motion: designed, not broken ───────────────────────────────── */
@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;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html:focus-within {
    scroll-behavior: smooth;
  }
}
