/* adia:primitive/space — Spacing primitive scale (L1).
   Parametric: each token = --a-density × base. At d=1, values match the
   original fixed scale. Base unit 0.5rem (8px); named by multiplier of
   0.25rem. The --a-density knob is registered here (it is fundamentally
   the spatial-scale multiplier; --a-size-* in size.css also reads it).
   Moved verbatim out of tokens.css (v0.6.48 foundation reorg, ADR-0035). */

@property --a-density {
  syntax: "<number>";
  inherits: true;
  initial-value: 1;
}

/* Gap-scale knob — multiplies every named gap (--a-gap-{xs,sm,md,lg,xl}).
   k=1 (default) = the base value; <1 tightens, >1 loosens (k=0 → 0). Inherits,
   so set it at a provider boundary (e.g. style="--a-gap-k:1.5") to retune all
   named gaps — but note custom props compute at their declaration site, so a
   subtree override only re-scales gaps re-declared in that scope (same as
   --a-density). */
@property --a-gap-k {
  syntax: "<number>";
  inherits: true;
  initial-value: 1;
}

/* Padding/margin-scale knobs — multiply the named [padding]/[margin] scale
   (--a-{padding,margin}-{xs,sm,md,lg,xl}), same form + semantics as --a-gap-k.
   k=1 (default) = base; <1 tightens, >1 loosens (k=0 → 0). Per-dimension so a
   provider can retune box padding/margin independently of gap. Inherits — set
   at a provider boundary (declaration-site compute, as with --a-density). */
@property --a-padding-k {
  syntax: "<number>";
  inherits: true;
  initial-value: 1;
}
@property --a-margin-k {
  syntax: "<number>";
  inherits: true;
  initial-value: 1;
}

:root {
  /* ── Spacing ── */
  --a-space-0: 0;
  --a-space-px: 1px;
  --a-space-0-5: calc(var(--a-density) * 0.125rem); /*  2px at d=1 */
  --a-space-1: calc(var(--a-density) * 0.25rem); /*  4px at d=1 */
  --a-space-1-5: calc(var(--a-density) * 0.375rem); /*  6px at d=1 */
  --a-space-2: calc(var(--a-density) * 0.5rem); /*  8px at d=1 */
  --a-space-2-5: calc(var(--a-density) * 0.625rem); /* 10px at d=1 */
  --a-space-3: calc(var(--a-density) * 0.75rem); /* 12px at d=1 */
  --a-space-3-5: calc(var(--a-density) * 0.875rem); /* 14px at d=1 */
  --a-space-4: calc(var(--a-density) * 1rem); /* 16px at d=1 */
  --a-space-4-5: calc(var(--a-density) * 1.125rem); /* 18px at d=1 */
  --a-space-5: calc(var(--a-density) * 1.25rem); /* 20px at d=1 */
  --a-space-6: calc(var(--a-density) * 1.5rem); /* 24px at d=1 */
  --a-space-7: calc(var(--a-density) * 1.75rem); /* 28px at d=1 */
  --a-space-8: calc(var(--a-density) * 2rem); /* 32px at d=1 */
  --a-space-9: calc(var(--a-density) * 2.25rem); /* 36px at d=1 */
  --a-space-10: calc(var(--a-density) * 2.5rem); /* 40px at d=1 */
  --a-space-12: calc(var(--a-density) * 3rem); /* 48px at d=1 */
  --a-space-16: calc(var(--a-density) * 4rem); /* 64px at d=1 */

  /* ── Inset — regular register (compressed range; sm/md/lg = 14/16/18). ── */
  --a-inset-sm: var(--a-space-3-5); /* 14px */
  --a-inset-md: var(--a-space-4);   /* 16px */
  --a-inset-lg: var(--a-space-4-5); /* 18px */
  --a-inset: var(--a-inset-md);

  /* ── Gaps — parametric named scale (value × --a-gap-k). k=1 (default) is the
     base value; k scales linearly (k=0 → 0, k=2 → 2×). At k=1: 8/10/12/14/16px.
     Verse shares this gap scale (only inset differs); prose runs one rung up.
     Composes on --a-density (baked into --a-space-*). See spec §5.2. ── */
  --a-gap-xs: calc(var(--a-space-2)   * var(--a-gap-k)); /*  8px @k=1 */
  --a-gap-sm: calc(var(--a-space-2-5) * var(--a-gap-k)); /* 10px @k=1 */
  --a-gap-md: calc(var(--a-space-3)   * var(--a-gap-k)); /* 12px @k=1 */
  --a-gap-lg: calc(var(--a-space-3-5) * var(--a-gap-k)); /* 14px @k=1 */
  --a-gap-xl: calc(var(--a-space-4)   * var(--a-gap-k)); /* 16px @k=1 */
  --a-gap: var(--a-gap-md);

  /* ── Padding / margin — parametric named scale (value × --a-{padding,margin}-k),
     xs–xl. Same FORM as the gap scale above, on the larger box-spacing rungs.
     sm/md/lg keep their prior literal values (16/24/32px) so existing
     [padding|margin="sm|md|lg"] are behavior-neutral; xs (8) + xl (40) are new.
     Composes on --a-density (baked into --a-space-*). At k=1: 8/16/24/32/40px.
     Consumed via the [padding] / [margin] attribute API (api/sizing.css). ── */
  --a-padding-xs: calc(var(--a-space-2)  * var(--a-padding-k)); /*  8px @k=1 */
  --a-padding-sm: calc(var(--a-space-4)  * var(--a-padding-k)); /* 16px @k=1 */
  --a-padding-md: calc(var(--a-space-6)  * var(--a-padding-k)); /* 24px @k=1 */
  --a-padding-lg: calc(var(--a-space-8)  * var(--a-padding-k)); /* 32px @k=1 */
  --a-padding-xl: calc(var(--a-space-10) * var(--a-padding-k)); /* 40px @k=1 */
  --a-margin-xs:  calc(var(--a-space-2)  * var(--a-margin-k));  /*  8px @k=1 */
  --a-margin-sm:  calc(var(--a-space-4)  * var(--a-margin-k));  /* 16px @k=1 */
  --a-margin-md:  calc(var(--a-space-6)  * var(--a-margin-k));  /* 24px @k=1 */
  --a-margin-lg:  calc(var(--a-space-8)  * var(--a-margin-k));  /* 32px @k=1 */
  --a-margin-xl:  calc(var(--a-space-10) * var(--a-margin-k));  /* 40px @k=1 */
}
