/* ============================================================================
   Maskinportal — Base element styles + layout primitives ("Mark & Maskine").
   Loaded after tokens.css. Elderly-first: large type, high contrast, big targets.
   ========================================================================= */
@layer base {

  *, *::before, *::after { box-sizing: border-box; }
  /* The UA's [hidden] rule is not !important — any author display (`.btn { display:inline-flex }`)
     silently defeats it. JS-revealed controls (compare toggles) ship hidden and MUST stay so. */
  [hidden] { display: none !important; }
  html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
      animation-duration: 0.001ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.001ms !important;
    }
    /* Exempt: the hero progress line is INFORMATION (time until the next slide), not
       decorative motion — and it doubles as the rotation clock (app.js animationend).
       Squashing it to 0.001ms would both mislead and break rotation timing. */
    .hero__progress.is-running { animation-duration: 5s !important; }
    /* Exempt: the slide crossfade is a pure opacity fade — no translation, scale or
       parallax (the motion classes reduced-motion actually protects against). An
       instant swap reads as a glitch, not as reduced motion. */
    .hero__slide { transition-duration: 900ms !important; }
  }

  body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading);
    color: var(--ink-900);
    background: var(--bg);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    font-synthesis: none;
  }

  h1, h2, h3, h4 { line-height: var(--leading-tight); color: var(--ink-900); margin: 0 0 var(--sp-4); font-weight: 700; }
  h1, h2 { font-family: var(--font-display); letter-spacing: -0.02em; }
  h1 { font-size: var(--text-3xl); }
  h2 { font-size: var(--text-2xl); }
  h3 { font-size: var(--text-xl); }
  p { margin: 0 0 var(--sp-4); max-width: 68ch; }

  a { color: var(--color-link); text-decoration-thickness: 0.08em; text-underline-offset: 0.15em; }
  a:hover { color: var(--brand-800); }

  :focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
  /* FocusOnNavigate focuses the h1 programmatically on every navigation (screen-reader anchor);
     h1 is not tab-reachable, so hiding its ring costs keyboard users nothing. */
  h1:focus-visible { outline: none; }

  img { max-width: 100%; height: auto; display: block; }

  /* ---- Layout primitives ---- */
  .container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--sp-5); }
  .container--narrow { max-width: var(--container-narrow); }
  .container--wide { max-width: var(--container-wide); }
  .section { padding-block: var(--sp-10); }
  /* Pages open right under the sticky header — the first section keeps only a small
     top inset (breadcrumb/h1 close to the chrome); section-to-section rhythm is untouched.
     :first-of-type, NOT :first-child: pages emit an inline JSON-LD <script> into <main>
     before the section, which silently defeats :first-child. */
  main > .section:first-of-type { padding-top: var(--sp-5); }
  .stack > * + * { margin-top: var(--sp-4); }
  .stack--lg > * + * { margin-top: var(--sp-6); }
  .center-col { display: flex; flex-direction: column; align-items: center; text-align: center; }

  /* ---- Skip link (a11y): fully hidden until keyboard-focused ---- */
  .skip-link {
    position: absolute; left: var(--sp-4); top: var(--sp-4); z-index: var(--z-skip);
    background: var(--brand-700); color: #fff; padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-sm);
    transform: translateY(-250%); transition: transform 0.15s ease;
  }
  .skip-link:focus { transform: translateY(0); color: #fff; }

  /* ---- Visually hidden (screen-reader only) ---- */
  .sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }

  main { flex: 1 0 auto; }

  /* ---- One-time scroll reveal (progressive enhancement; see js/app.js).
     Only active when JS has stamped <html class="js"> — no-JS users see
     everything immediately. Reduced-motion users are never observed. ---- */
  html.js [data-reveal] {
    opacity: 0;
    translate: 0 12px;
  }
  html.js [data-reveal].is-revealed {
    opacity: 1;
    translate: 0 0;
    transition: opacity var(--dur-slow) var(--ease-out), translate var(--dur-slow) var(--ease-out);
    transition-delay: calc(var(--reveal-i, 0) * 40ms);
  }
  @media (prefers-reduced-motion: reduce) {
    html.js [data-reveal] { opacity: 1; translate: 0 0; }
  }

  /* ---- Blazor error bar (rendered from App.razor on every page) ---- */
  #blazor-error-ui {
    color-scheme: light only;
    background: var(--warn-050);
    color: var(--ink-900);
    border-top: 1px solid var(--line-strong);
    bottom: 0;
    box-shadow: var(--shadow-2);
    display: none;
    left: 0;
    padding: var(--sp-3) var(--sp-8) var(--sp-3) var(--sp-5);
    position: fixed;
    width: 100%;
    z-index: 1000;
  }
  #blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: var(--sp-4);
    top: var(--sp-3);
    font-weight: 700;
  }
}
