/* ============================================================================
   BASE — Reset, typography, element defaults (ERP.AI brutalist)
   ============================================================================ */

@layer base {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }

  ::selection {
    background: var(--primary);
    color: var(--primary-foreground);
  }

  html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: hidden;
  }

  /* Offset anchors for fixed nav + audience bar — see --scroll-stack in tokens.css. */
  [id] {
    scroll-margin-top: var(--scroll-stack);
  }

  body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--foreground);
    background-color: var(--background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    position: relative;
  }

  /* EB Garamond italic reads thin at hero sizes against brutalist uppercase
     headlines. Bump the utility to 600 (Semi-Bold) so every italic
     pull-quote has real presence without losing humanist character. */
  .font-serif {
    font-weight: 600;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    font-family: var(--font-display);
    font-weight: 500;
    line-height: 1.1;
    color: var(--foreground);
    letter-spacing: 0;
    text-wrap: balance;
  }
  h1 {
    font-size: var(--text-5xl);
  }
  h2 {
    font-size: var(--text-4xl);
  }
  h3 {
    font-size: var(--text-3xl);
  }
  h4 {
    font-size: var(--text-2xl);
  }

  p {
    margin-bottom: var(--space-4);
    text-wrap: pretty;
  }

  a {
    color: var(--foreground);
    text-decoration: none;
    transition: color var(--duration-fast) var(--ease-standard);
  }
  a:hover {
    color: var(--primary);
  }

  code,
  pre,
  kbd,
  samp {
    font-family: var(--font-mono);
    font-size: 0.9em;
  }
  pre {
    overflow-x: auto;
    padding: var(--space-4);
    background: var(--surface-container);
  }
  img,
  svg,
  video {
    display: block;
    max-width: 100%;
    height: auto;
  }
  button,
  input,
  select,
  textarea {
    font: inherit;
    color: inherit;
  }
  button {
    cursor: pointer;
  }
  :focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }

  .skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-4);
    padding: var(--space-2) var(--space-4);
    background: var(--primary);
    color: var(--primary-foreground);
    z-index: var(--z-skip);
    transition: top var(--duration-fast) var(--ease-standard);
  }
  .skip-link:focus {
    top: var(--space-2);
  }

  ::-webkit-scrollbar {
    width: 4px;
  }
  ::-webkit-scrollbar-track {
    background: var(--background);
  }
  ::-webkit-scrollbar-thumb {
    background: var(--foreground);
  }
  ::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
  }

  /* Code-block scrollbars — sleeker than Chrome's default ~14px chunk
     but chunkier than the page body's 4px hairline above. The beige-500
     thumb (mid gold, L 60) sits on a transparent track and reads with
     strong contrast against either light (--dark = beige-100, L 96.5)
     or dark (--dark = beige-800, L 22) code-panel backgrounds — same
     token value in both themes, so the bar reads consistently warm
     across light and dark mode.
     Targets <pre> directly when it is the scroll container (ops, modal,
     scenario-grid), and any element whose direct child is <pre> (the
     wrapping <div class="overflow-x-auto"> pattern in proto/sdk-01,
     byoa, proto/discovery, vcs/diff-view, etc.). `.overflow-x-auto`
     and `.scroll-thin` extend the same treatment to tables and other
     narrow-viewport scrollers whose contents aren't a <pre> (e.g.
     pricing matrices and proto/§09 cost-attribution grid table).
     Pseudo-element rules only render when the element actually
     overflows, so non-scrolling consumers are unaffected. */
  pre::-webkit-scrollbar,
  :has(> pre)::-webkit-scrollbar,
  .overflow-x-auto::-webkit-scrollbar,
  .scroll-thin::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }
  pre::-webkit-scrollbar-track,
  :has(> pre)::-webkit-scrollbar-track,
  .overflow-x-auto::-webkit-scrollbar-track,
  .scroll-thin::-webkit-scrollbar-track {
    background: transparent;
  }
  pre::-webkit-scrollbar-thumb,
  :has(> pre)::-webkit-scrollbar-thumb,
  .overflow-x-auto::-webkit-scrollbar-thumb,
  .scroll-thin::-webkit-scrollbar-thumb {
    background: var(--beige-500);
  }
  pre::-webkit-scrollbar-thumb:hover,
  :has(> pre)::-webkit-scrollbar-thumb:hover,
  .overflow-x-auto::-webkit-scrollbar-thumb:hover,
  .scroll-thin::-webkit-scrollbar-thumb:hover {
    background: var(--beige-600);
  }
  /* Firefox — `thin` is ~8–10px in Gecko, similar perceived weight. */
  pre,
  :has(> pre),
  .overflow-x-auto,
  .scroll-thin {
    scrollbar-width: thin;
    scrollbar-color: var(--beige-500) transparent;
  }

  /* Content width cap — section backgrounds bleed full, content is capped.
     Pages with .main--full-bleed skip the cap entirely. */
  #main-content:not(.main--full-bleed) > section > *,
  #main-content:not(.main--full-bleed) > header > *,
  #main-content:not(.main--full-bleed) > div > * {
    max-width: 90rem;
    margin-inline: auto;
  }
}

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