/* =========================================================
   JUSPIRE — BASE

   Defines global document, typography, link, focus, and
   selection behavior for the Juspire experience.
   ========================================================= */

@layer ja-base {
  /* =======================================================
     DOCUMENT
     ======================================================= */

  html {
    background: var(--ja-surface-base);
    color: var(--ja-ink);

    scroll-padding-block-start: calc(
      var(--ja-header-height) + var(--ja-space-md)
    );

    font-synthesis: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  /* =======================================================
     SCROLL BEHAVIOR

     Smooth scrolling is an enhancement only and is disabled
     whenever motion is explicitly off.
     ======================================================= */

  @media (prefers-reduced-motion: no-preference) {
    html:not([data-motion="off"]) {
      scroll-behavior: smooth;
    }
  }

  body {
    min-block-size: 100dvh;

    font: var(--ja-weight-regular) var(--ja-type-body) / var(--ja-leading-body)
      var(--ja-font-text);

    font-stretch: var(--ja-stretch-normal);
    font-optical-sizing: auto;
    text-rendering: optimizeLegibility;
  }

  /* =======================================================
     HEADINGS
     ======================================================= */

  h1,
  h2,
  h3 {
    font-family: var(--ja-font-display);
    font-stretch: var(--ja-stretch-tight);
    line-height: var(--ja-leading-tight);
    letter-spacing: var(--ja-tracking-tight);
    text-wrap: balance;
  }

  h1 {
    font-size: var(--ja-type-h1);
    font-weight: var(--ja-weight-bold);
  }

  h2 {
    font-size: var(--ja-type-h2);
    font-weight: var(--ja-weight-bold);
  }

  h3 {
    font-size: var(--ja-type-h3);
    font-weight: var(--ja-weight-medium);
    line-height: var(--ja-leading-snug);
  }

  /* =======================================================
     BODY COPY
     ======================================================= */

  p {
    max-inline-size: var(--ja-measure-prose);
    text-wrap: pretty;
  }

  /* =======================================================
     LINKS
     ======================================================= */

  a {
    color: var(--ja-primary-ink);
    text-underline-offset: 0.2em;
  }

  a:hover {
    color: var(--ja-primary);
  }

  /* =======================================================
     FOCUS
     ======================================================= */

  :where(
    a,
    button,
    input,
    select,
    textarea,
    summary,
    [tabindex]
  ):focus-visible {
    outline: var(--ja-stroke-base) solid var(--ja-focus-ring);
    outline-offset: 3px;
  }

  /* =======================================================
     SELECTION
     ======================================================= */

  ::selection {
    background: var(--ja-primary);
    color: var(--ja-ink-on-primary);
  }
}
