@layer base, components, screens, motion;

@layer base {
  /* Minimal reset */
  *, *::before, *::after { box-sizing: border-box; }
  html, body { margin: 0; }

  html { scroll-behavior: smooth; }

  /* Safe-area: будущие фиксированные панели (topbar/tabbar/sheets) должны
     сами включать env(safe-area-inset-*) в свой padding; глобальный padding
     на body не добавляется. */
  body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.6;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  h1, h2, h3 {
    font-family: var(--font-display);
    letter-spacing: -0.01em;
  }

  /* The [hidden] attribute must win: any author `display` rule on a class
     (.topbar-exit, .icon-circle, …) outranks the UA sheet and would otherwise
     leave hidden chrome on screen. */
  [hidden] { display: none !important; }

  /* Типографические утилиты (§3.3) */
  .fs-hero {
    font-family: var(--font-display);
    font-size: var(--fs-hero);
    font-weight: 800;
    line-height: 1.04;
    letter-spacing: -0.02em;
    text-wrap: balance;
  }
  .fs-h1 {
    font-family: var(--font-display);
    font-size: var(--fs-h1);
    font-weight: 800;
    line-height: 1.15;
  }
  .fs-q {
    font-family: var(--font-body);
    font-size: var(--fs-q);
    font-weight: 600;
    line-height: 1.45;
  }
  .fs-h2 {
    font-family: var(--font-display);
    font-size: var(--fs-h2);
    font-weight: 700;
  }
  .fs-overline {
    font-family: var(--font-display);
    font-size: var(--fs-overline);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .u-tabular { font-variant-numeric: tabular-nums; }

  /* Brand hand-drawn yellow marker underline for H1 headings */
  .hero-mark {
    position: relative;
    white-space: nowrap;
  }
  .hero-marker {
    position: absolute;
    left: 0;
    bottom: -0.12em;
    width: 100%;
    height: 0.32em;
    color: var(--marker);
    overflow: visible;
  }

  /* Screen-reader-only text (live regions, chip labels that would otherwise be
     announced twice). */
  .sr-only {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0; border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  ::selection { background: var(--accent-soft); }

  /* Фокус (§7.2) */
  :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
  @media (forced-colors: active) {
    :focus-visible { outline-color: CanvasText; }
  }

  /* Appendix C (норматив) */
  @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;
    }
  }
}
