/* ==========================================================================
   UNIRAY - reset, typography, layout primitives
   ========================================================================== */
@layer base {

  *, *::before, *::after { box-sizing: border-box; }

  html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + 24px);
  }

  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
  }

  body {
    margin: 0;
    min-height: 100svh;
    background: var(--ink-950);
    color: var(--text);
    font-family: var(--font-body);
    font-size: var(--fs-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: clip;
  }

  /* ambient engineering grid + noise, sits behind everything */
  body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: var(--z-grid);
    pointer-events: none;
    background-image:
      linear-gradient(to right, rgba(255,255,255,.035) 1px, transparent 1px),
      linear-gradient(to bottom, rgba(255,255,255,.035) 1px, transparent 1px);
    background-size: 80px 80px;
    mask-image: radial-gradient(ellipse 120% 90% at 50% 0%, #000 30%, transparent 78%);
  }

  @media (max-width: 767px) {
    body::before { background-size: 48px 48px; }
  }

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

  button, input, select, textarea { font: inherit; color: inherit; }
  button { background: none; border: 0; cursor: pointer; }

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

  h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; text-wrap: balance; }
  p { margin: 0; text-wrap: pretty; }
  ul, ol { margin: 0; padding: 0; list-style: none; }

  :target { scroll-margin-top: calc(var(--header-h) + 24px); }

  /* ---- focus ------------------------------------------------------------ */
  :focus { outline: none; }
  :focus-visible {
    outline: 2px solid var(--lime);
    outline-offset: 3px;
    border-radius: var(--radius-xs);
  }

  ::selection { background: var(--lime-soft); color: var(--ink-950); }

  /* ---- global finishing details ----------------------------------------
     One consistent lime accent for every native control, and a thin custom
     scrollbar so the browser default (a bright grey slab) stops breaking the
     dark theme. Firefox gets the standard property, Chromium the -webkit one. */
  :root {
    accent-color: var(--lime);
    caret-color: var(--lime);
    scrollbar-color: var(--lime-soft) var(--ink-900);
    scrollbar-width: thin;
  }
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: var(--ink-900); }
  ::-webkit-scrollbar-thumb {
    background: var(--lime-soft);
    border-radius: 999px;
    border: 3px solid var(--ink-900);
  }
  ::-webkit-scrollbar-thumb:hover { background: var(--lime); }
  ::-webkit-scrollbar-corner { background: var(--ink-900); }

  button, [role="button"], summary, label[for], a { cursor: pointer; }
  :disabled, [aria-disabled="true"] { cursor: not-allowed; opacity: .5; }
  /* the browser's blue flash on tap does not belong on a dark brand surface */
  a, button, [role="button"], input, select, textarea {
    -webkit-tap-highlight-color: transparent;
  }

  /* ---- typographic finishing -------------------------------------------- */
  p, li, dd, figcaption, .lead { text-wrap: pretty; }
  /* every number, code and measurement lines up in columns */
  .u-mono, .u-num, table, .keyspec__value, .pcard__code, .spec__value,
  .compat, .stepper__value, time, .section__meta {
    font-variant-numeric: tabular-nums;
  }

  /* ---- typography ------------------------------------------------------- */
  .u-display { font-family: var(--font-display); }
  .u-mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: .02em;
  }

  .eyebrow {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: var(--fs-eyebrow);
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--lime);
    margin: 0 0 var(--head-eyebrow);
    display: flex;
    align-items: center;
    gap: .6em;
  }
  .eyebrow::before {
    content: '';
    width: 22px;
    height: 1px;
    background: var(--lime);
    opacity: .7;
    flex: none;
  }

  .h1 {
    font-family: var(--font-display);
    font-size: var(--fs-h1);
    font-weight: 500;
    line-height: .95;
    letter-spacing: -.01em;
  }
  .h2 {
    font-family: var(--font-display);
    font-size: var(--fs-h2);
    font-weight: 600;
    line-height: 1.03;
    letter-spacing: -.01em;
  }
  .h3 {
    font-family: var(--font-display);
    font-size: var(--fs-h3);
    font-weight: 600;
    line-height: 1.2;
  }

  .lead {
    font-size: var(--fs-lead);
    color: var(--text-2);
    max-width: var(--measure);
  }
  .muted { color: var(--text-2); }
  .dim { color: var(--text-3); }

  .prose { max-width: var(--measure); }
  .prose p + p { margin-top: 1em; }
  .prose a { color: var(--lime); text-decoration: underline; text-underline-offset: 3px; }

  /* ---- layout ----------------------------------------------------------- */
  .wrap {
    width: 100%;
    max-width: var(--maxw);
    margin-inline: auto;
    padding-inline: var(--gutter);
  }

  /* ---- section rhythm ---------------------------------------------------
     ONE declaration owns the space between two sections. Sections set no
     vertical padding of their own, so a boundary can never be the sum of one
     section's padding-bottom and the next one's padding-top - which is how
     pass 2 ended up with ~320px bands. Everything on every page, SR and EN,
     is --section-gap apart; the exceptions below are deliberate and listed
     in REPORT.md. */
  .section {
    padding-block: 0;
    position: relative;
    z-index: var(--z-content);
  }
  /* .section--tight is kept for markup compatibility but no longer changes
     the rhythm: the owner asked for one identical gap everywhere. */
  .section--tight { padding-block: 0; }

  main > * + * { margin-block-start: var(--section-gap); }
  /* the assistant panel is a fixed overlay that happens to live inside main */
  main > .assistant,
  main > [data-assistant] { margin-block-start: 0; }
  /* hero / banner is the first child, so it needs no rule: the first section
     below it gets exactly --section-gap from the same declaration. */

  /* full-bleed marquee strips sit tighter, above and below */
  main > .marquee + *,
  main > * + .marquee { margin-block-start: var(--section-gap-tight); }

  /* pre-footer CTA band -> footer has its own, smaller spacing */
  .site-footer { margin-block-start: var(--section-gap); }

  /* no stray first/last margins inside a section can add to the gap */
  .section > :first-child,
  .section > .wrap > :first-child { margin-block-start: 0; }
  .section > :last-child,
  .section > .wrap > :last-child { margin-block-end: 0; }

  .section__head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: clamp(16px, 3vw, 40px);
    margin-bottom: var(--head-content);
  }
  .section__head > div { min-width: 0; }

  /* ---- section header system -------------------------------------------
     mono index eyebrow + a hairline that draws from the left on enter +
     an optional right-aligned mono meta ("42 ARTIKLA"). */
  .eyebrow--indexed {
    font-family: var(--font-mono);
    letter-spacing: .16em;
    align-items: center;
    gap: 10px;
  }
  .eyebrow--indexed::before { display: none; }
  .eyebrow__idx { color: var(--lime); opacity: .85; }
  .eyebrow__dash {
    display: inline-block;
    width: 18px; height: 1px;
    background: currentColor;
    opacity: .5;
  }
  /* The hairline is a pseudo-element on the header itself - no extra markup,
     so it can never desynchronise from the heading it belongs to. It draws
     from the left when the header enters (ui.js adds .is-in). */
  /* The hairline sits 18px under the head; that 18px is part of the 48px
     head-to-content rhythm rather than an extra on top of it. */
  .section__head { position: relative; padding-bottom: 18px; margin-bottom: calc(var(--head-content) - 18px); }
  /* eyebrow -> 16 -> H2 -> 20 -> intro -> 48 -> content */
  .section__head:has(+ .lead),
  .section__head:has(+ .prose) { margin-bottom: calc(var(--head-intro) - 18px); }
  .lead + *, .prose.lead + * { margin-block-start: var(--head-content); }
  .section__head::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 1px;
    background: var(--line);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform .9s var(--ease-out);
  }
  .section__head.is-in::after { transform: scaleX(1); }
  /* no JS / no IntersectionObserver: the line is simply there */
  html:not(.has-rules) .section__head::after { transform: scaleX(1); }
  .section__meta {
    font-family: var(--font-mono);
    font-size: var(--fs-eyebrow);
    font-variant-numeric: tabular-nums;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-3);
    white-space: nowrap;
  }
  @media (prefers-reduced-motion: reduce) {
    .section__head::after { transform: scaleX(1); transition: none; }
  }

  /* ---- ambient cursor light (pointer:fine only, off under reduced motion) */
  .amb {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity .6s var(--ease-out);
    background: radial-gradient(260px 260px at var(--amb-x, 50%) var(--amb-y, 50%),
                                rgba(166, 206, 57, .08), transparent 70%);
  }
  .amb.is-on { opacity: 1; }
  @media (pointer: coarse), (prefers-reduced-motion: reduce) {
    .amb { display: none; }
  }

  .grid { display: grid; gap: clamp(14px, 1.6vw, 24px); }
  .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  @media (max-width: 1023px) {
    .grid--4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media (max-width: 719px) {
    .grid--4, .grid--3, .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media (max-width: 479px) {
    .grid--4, .grid--3 { grid-template-columns: 1fr; }
  }

  .stack > * + * { margin-top: var(--stack-gap, 1rem); }
  .flow > * + * { margin-top: clamp(14px, 2vw, 22px); }

  /* ---- a11y helpers ----------------------------------------------------- */
  .visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  .skip-link {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: calc(var(--z-preloader) + 1);
    padding: .7em 1.2em;
    background: var(--lime);
    color: var(--ink-950);
    font-weight: 600;
    border-radius: var(--radius-pill);
    transform: translateY(-160%);
    transition: transform var(--dur-2) var(--ease-out);
  }
  .skip-link:focus-visible { transform: translateY(0); }

  /* ---- ambient lime glow blobs ----------------------------------------- */
  /* overflow:clip keeps the -5% inset bleed from widening the document */
  .glow-field { position: relative; isolation: isolate; overflow: clip; }
  .glow-field::after {
    content: '';
    position: absolute;
    inset: -10% -5%;
    z-index: -1;
    pointer-events: none;
    background:
      radial-gradient(38% 46% at 12% 18%, rgba(166,206,57,.13), transparent 70%),
      radial-gradient(34% 40% at 88% 72%, rgba(134,169,42,.10), transparent 72%);
    filter: blur(18px);
  }

  /* Pass 2 put content-visibility:auto on nearly every section. Measured, it
     cost more than it bought: an off-screen section reported exactly its
     720px contain-intrinsic-size placeholder instead of its real height, so
     the document grew and shrank as the visitor scrolled and every
     ScrollTrigger position - including the process pin - was computed against
     a layout that did not exist. The class is kept as a no-op so any stray
     markup is harmless; nothing in the generated pages uses it. */
  .cv-auto { content-visibility: visible; }

  /* ---- print ------------------------------------------------------------ */
  @media print {
    body { background: #fff; color: #000; }
    body::before,
    .site-header, .tabbar, .fab-row, .preloader, .hero__pager, .cta-band { display: none !important; }
  }
}
