/* HM System 1.0 · the kernel's registry (11-18, Finn: "a cleaned up micro type opacity only variation system, instead
   of relying on the background rectangles… all sharp corners… establish a kernel to adapt with clarity").

   Anchored on polestar.com as measured on 11-18 (computed styles, 1512 and 390 wide): ONE weight (400), five sizes
   (12 · 16 · 32 · 48/128), two inks through two opacities (100 · 60), no radius, 12 columns (margin 7.4 %, gutter 32)
   and 4 on a phone (margin 6 %, gutter 12). Adapted: Geist for Unica, so text leads at 1.25 rather than 1.13 and
   tracking stays at 0 below the title; two more rungs on the ladder (40 · 20) for meta and ghosts.

   Everything hangs off `.hm` inside a `.hm-root` (the container: a screen, an artboard, a card), so a 390 wide
   artboard and a 1440 one read their own phone / desktop values side by side. The --k-* multipliers are the tuning
   knobs (system/ board inspector); they default to 1. */

.hm-root {
  container: hm / inline-size;
}

.hm {
  /* ── colour: two inks. Hierarchy is the opacity ladder, never a second grey ── */
  --hm-paper: #ffffff;
  --hm-ink: #0a0a0a;

  /* ── the opacity ladder ── */
  --hm-o2: 0.6; /* labels, secondary */
  --hm-o3: 0.4; /* meta, index, placeholder */
  --hm-o4: 0.2; /* ghost, disabled, the rest of a progress */
  --hm-o-rule: 0.12; /* hairlines */
  --hm-o-field: 0.04; /* a field, a hover wash */

  /* ── type: one family, one weight, five sizes ── */
  --hm-font: 'Geist Variable', Geist, -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
  --hm-weight: 400;
  --hm-micro: calc(12px * var(--k-micro, 1));
  --hm-text: calc(16px * var(--k-text, 1));
  --hm-title: calc(32px * var(--k-title, 1));
  --hm-statement: calc(56px * var(--k-statement, 1));
  --hm-display: calc(128px * var(--k-display, 1));
  --hm-lh-micro: 1.34;
  --hm-lh-text: 1.25;
  --hm-lh-title: 1.06;
  --hm-lh-statement: 1;
  --hm-lh-display: 0.9;
  /* tracking: 0 below the title, never past this above it */
  --hm-track: -0.02em;

  /* ── grid ── */
  --hm-cols: 12;
  --hm-margin: calc(min(7.4cqw, 112px) * var(--k-margin, 1));
  --hm-gutter: calc(32px * var(--k-gutter, 1));

  /* ── space: a 4 px step ── */
  --hm-s1: 4px;
  --hm-s2: 8px;
  --hm-s3: 12px;
  --hm-s4: 16px;
  --hm-s5: 24px;
  --hm-s6: 32px;
  --hm-s7: 48px;
  --hm-s8: 64px;
  --hm-s9: 96px;
  --hm-s10: 128px;

  /* ── controls ── */
  --hm-h-s: 28px;
  --hm-h-m: 36px;
  --hm-h-l: 48px;
  --hm-nav: 48px;
  --hm-stroke: 1.25; /* icon stroke, in a 16 unit box */

  /* ── motion: functional, on state changes; scroll-linked moves are their own tokens ── */
  --hm-fast: 150ms;
  --hm-base: 250ms;
  --hm-slow: 600ms;
  --hm-ease: cubic-bezier(0.2, 0, 0, 1);
  --hm-parallax: 0.85; /* a picture's rate against the page's 1 */

  /* ── scrim: only under type on a bright picture; a ramp, never a box ── */
  --hm-scrim: 0.5;
  --hm-scrim-h: 62%;

  font-family: var(--hm-font);
  font-weight: var(--hm-weight);
  font-size: var(--hm-text);
  line-height: var(--hm-lh-text);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

@container hm (max-width: 699px) {
  .hm {
    --hm-title: calc(28px * var(--k-title, 1));
    --hm-statement: calc(36px * var(--k-statement, 1));
    --hm-display: calc(56px * var(--k-display, 1));
    --hm-cols: 4;
    --hm-margin: calc(6cqw * var(--k-margin, 1));
    --hm-gutter: calc(12px * var(--k-gutter, 1));
  }
}

/* ── surfaces: what the type stands on decides its ink; the ladder is the same on each ── */
.hm,
.hm-s-paper {
  --hm-fg: var(--hm-ink);
  --hm-bg: var(--hm-paper);
}
.hm-s-ink,
.hm-s-picture {
  --hm-fg: var(--hm-paper);
  --hm-bg: var(--hm-ink);
}
/* a light picture: the ink, and nothing painted (as .hm-s-picture is the paper on a dark one) */
.hm-s-light {
  --hm-fg: var(--hm-ink);
  --hm-bg: var(--hm-paper);
}
.hm,
.hm-s-paper,
.hm-s-ink,
.hm-s-picture,
.hm-s-light {
  --hm-c1: var(--hm-fg);
  --hm-c2: color-mix(in srgb, var(--hm-fg) calc(var(--hm-o2) * 100%), transparent);
  --hm-c3: color-mix(in srgb, var(--hm-fg) calc(var(--hm-o3) * 100%), transparent);
  --hm-c4: color-mix(in srgb, var(--hm-fg) calc(var(--hm-o4) * 100%), transparent);
  --hm-rule: color-mix(in srgb, var(--hm-fg) calc(var(--hm-o-rule) * 100%), transparent);
  --hm-field: color-mix(in srgb, var(--hm-fg) calc(var(--hm-o-field) * 100%), transparent);
  /* a status that is on: the ink itself by default (fill + absence); --hm-accent, when set, is the ONE saturated accent */
  --hm-signal: var(--hm-accent, var(--hm-fg));
  color: var(--hm-c1);
}
.hm-s-paper,
.hm-s-ink {
  background: var(--hm-bg);
}
