/* ============================================================
   CrumpIT — Base
   Reset · typography · layout primitives · a11y helpers.
   Shared by every page. No component chrome here.
   ============================================================ */

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

  html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scrollbar-color: var(--accent) transparent;   /* Firefox: thumb #0093e2, transparent track */
    scrollbar-width: thin;
  }

  /* WebKit/Blink scrollbars — accent (#0093e2) thumb on a transparent track, site-wide */
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track,
  ::-webkit-scrollbar-corner { background: transparent; }
  ::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
  }
  ::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); background-clip: padding-box; }

  body {
    font-family: var(--font-body);
    font-size: var(--fs-16);
    line-height: var(--lh-body);
    color: var(--text);
    background-color: var(--bg);
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background-color var(--dur-base) var(--ease),
                color var(--dur-base) var(--ease);
  }

  /* Ambient 45deg accent line texture (~3% opacity).
     Fixed + pointer-events:none = GPU-safe, never repaints on scroll. */
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: var(--z-bg);
    pointer-events: none;
    background-image: repeating-linear-gradient(
      45deg,
      var(--accent) 0 1px,
      transparent 1px 26px
    );
    opacity: 0.03;
  }

  img, svg, canvas, video { display: block; max-width: 100%; }
  img { height: auto; }

  a { color: inherit; text-decoration: none; }

  h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: var(--lh-tight);
    letter-spacing: var(--ls-display);
    text-transform: uppercase;
    text-wrap: balance;
  }
  h1 { font-size: var(--fs-hero); font-weight: 900; }
  h2 { font-size: var(--fs-h2); }
  h3 { font-size: var(--fs-h3); }

  p { max-width: 65ch; }
  strong { font-weight: 600; }

  ul, ol { list-style: none; padding: 0; }

  button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
  input, textarea, select, button { font-family: var(--font-body); }

  /* Visible keyboard focus everywhere */
  :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 3px;
  }
  ::selection { background: var(--accent); color: #fff; }

  /* ---- Layout primitives ---- */
  .container {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: var(--sp-6);
  }
  .container--narrow { max-width: var(--container-narrow); }

  .section { padding-block: var(--sp-24); }

  /* Clears the fixed header — pages/heroes opt in as needed */
  .below-header { padding-top: calc(var(--header-h) + var(--sp-12)); }

  /* Content stacks above the fixed background canvas + texture */
  .site-header,
  main,
  .site-footer { position: relative; z-index: var(--z-content); }

  /* ---- Small shared helpers ---- */
  .eyebrow {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-3);
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: var(--fs-14);
    letter-spacing: var(--ls-ui);
    text-transform: uppercase;
    color: var(--accent);
  }
  .eyebrow::before {
    content: "";
    width: 24px;
    height: 2px;
    background: var(--accent);
    box-shadow: var(--glow-sm);
  }

  .u-accent { color: var(--accent); }
  .lead { font-size: var(--fs-18); color: var(--text-muted); }

  /* Scroll-reveal utility (driven by core.js IntersectionObserver) */
  [data-reveal] {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity var(--dur-slow) var(--ease),
                transform var(--dur-slow) var(--ease);
  }
  [data-reveal].is-visible { opacity: 1; transform: none; }

  /* ---- a11y ---- */
  .visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
  }
  /* WordPress convention alias — used by core/theme markup (comment-reply,
     icon-only button labels, "read more"). Mirrors .visually-hidden and
     reveals on focus for skip-style links. */
  .screen-reader-text {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
    word-wrap: normal !important;
  }
  .screen-reader-text:focus {
    position: fixed;
    top: var(--sp-4); left: var(--sp-4);
    width: auto; height: auto;
    clip: auto; margin: 0;
    z-index: var(--z-toast);
    background: var(--accent);
    color: #fff;
    padding: var(--sp-2) var(--sp-4);
    border-radius: var(--r-sm);
    font-family: var(--font-ui);
    font-weight: 600;
    letter-spacing: 0.04em;
  }
  .skip-link {
    position: fixed;
    top: -80px;
    left: var(--sp-4);
    z-index: var(--z-toast);
    background: var(--accent);
    color: #fff;
    padding: var(--sp-2) var(--sp-4);
    border-radius: var(--r-sm);
    font-family: var(--font-ui);
    font-weight: 600;
    letter-spacing: 0.04em;
    transition: top var(--dur-fast) var(--ease);
  }
  .skip-link:focus { top: var(--sp-4); }

  /* ---- Generic content utilities ----
     On-brand defaults for blog / search / 404 (the prototype ships no blog
     design). All token-based; additive — they don't touch component rules. */
  .cta-row { display: flex; flex-wrap: wrap; gap: var(--sp-4); margin-top: var(--sp-8); }
  .search-form { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-end; }
  .search-form .field { flex: 1 1 220px; margin-bottom: 0; }
  .post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--sp-8); }
  .page-header { margin-bottom: var(--sp-10); }
  .entry-title { margin-bottom: var(--sp-3); }
  .entry-meta { font-size: var(--fs-14); color: var(--text-muted); font-family: var(--font-ui); }
  .entry-content > * + * { margin-top: var(--sp-4); }
  .post-thumbnail { display: block; margin-bottom: var(--sp-5); border-radius: var(--r-sm); overflow: hidden; }
  .widget-area { margin-top: var(--sp-12); display: grid; gap: var(--sp-6); }
  .no-results { text-align: center; }
  .pagination { margin-top: var(--sp-12); display: flex; justify-content: center; flex-wrap: wrap; gap: var(--sp-2); font-family: var(--font-ui); font-weight: 600; }
  .pagination .page-numbers {
    display: inline-grid; place-items: center;
    min-width: 42px; padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--border); border-radius: var(--r-sm);
    color: var(--text-muted);
    transition: color var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease);
  }
  .pagination .page-numbers:hover { color: var(--text); border-color: var(--accent); }
  .pagination .page-numbers.current { background: var(--accent); color: #fff; border-color: var(--accent); }
}

/* ============================================================
   Reduced motion — global safety net (UNLAYERED so it wins).
   Content stays fully visible; canvas freezes via particles.js.
   ============================================================ */
@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;
  }
  [data-reveal] { opacity: 1 !important; transform: none !important; }
}
