/* ==========================================================================
   Base: reset, typography, accessibility primitives
   Cross-browser floor: Chrome/Edge 90+, Firefox 90+, Safari 14+, Samsung
   Internet 14+. No :has(), no container queries, no subgrid.
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;      /* iOS: stop auto-inflation on rotate */
  text-size-adjust: 100%;
  -moz-tab-size: 4;
  tab-size: 4;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: var(--size-base);
  line-height: var(--lh-base);
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Long Ukrainian institution names must not blow out narrow screens */
  overflow-wrap: break-word;
  word-wrap: break-word;
}

h1, h2, h3, h4 {
  margin: 0 0 var(--sp-3);
  line-height: var(--lh-tight);
  font-weight: 700;
  letter-spacing: -0.01em;
}

h1 { font-size: var(--size-2xl); }
h2 { font-size: var(--size-xl); }
h3 { font-size: var(--size-lg); }

p  { margin: 0 0 var(--sp-4); max-width: var(--measure); }

ul, ol { margin: 0 0 var(--sp-4); padding-left: 1.25em; }
li { margin-bottom: var(--sp-2); }

a {
  color: var(--primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover { color: var(--primary-dark); }

img, svg { max-width: 100%; height: auto; }

/* Focus must always be visible. :focus-visible with a :focus fallback for
   browsers that predate it. */
:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

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

.skip-link {
  position: absolute;
  left: var(--sp-3);
  top: -100vh;
  z-index: 100;
  padding: var(--sp-3) var(--sp-4);
  background: var(--primary);
  color: var(--on-primary);
  border-radius: var(--radius);
}
.skip-link:focus { top: var(--sp-3); }

.muted   { color: var(--text-muted); }
.text-sm { font-size: var(--size-sm); }

/* High-contrast / forced-colors mode (Windows) must keep borders visible */
@media (forced-colors: active) {
  .tile, .card, .step { border: 1px solid CanvasText; }
}
