/* ===========================================================================
   PRIMITIVES — the design system, ported 1:1 from the COFACTOR storefront's
   `globals.css` utilities and `ui/button.tsx` variants.

   Everything downstream composes from THIS ladder. If a page needs a size,
   weight or radius that isn't here, the spec is wrong — don't invent a value
   inline. Names match the source utilities so a component can be translated
   class-for-class.
   =========================================================================== */

/* ---------------------------------------------------------------------------
   THE MISSING HALF OF THE TOKEN SYSTEM.

   tokens.css (generated) carries COLOUR and ELEVATION only. The radius scale,
   the easing curves, the brand-tinted shadows and the chrome offsets lived in
   the Next app's `globals.css` @theme block — so porting tokens.css alone left
   every `var(--radius-*)` and `var(--ease-*)` UNDEFINED. Consequences, both
   silent: every radius computed to 0 (square corners sitewide), and every
   `transition: … var(--ease-out-quart)` was an invalid declaration, which
   drops the whole shorthand — so nothing animated at all.

   Values are copied verbatim from the reference. --radius is THE personality
   knob: 0.375rem reads as a spec panel, 0.75rem as friendly-consumer SaaS.
--------------------------------------------------------------------------- */
:root {
  --radius: 0.375rem;
  --radius-sm: calc(var(--radius) * 0.6);
  --radius-md: calc(var(--radius) * 0.8);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) * 1.4);
  --radius-2xl: calc(var(--radius) * 1.8);
  /* fixed micro-radii (chips, pips, ticks) — deliberately NOT scaled by --radius */
  --radius-2: 2px;
  --radius-3: 3px;
  --radius-4: 4px;
  --radius-5: 5px;
  --radius-circle: 100%;
  --radius-3xl-plus: 1.75rem;

  /* motion — the built-in CSS easings are too weak to read as intentional */
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out-quart: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out-back: cubic-bezier(0.34, 1.3, 0.64, 1);
  --ease-brand: cubic-bezier(0.25, 1, 0.5, 1);

  /* elevation aliases — the reference names shadows `--shadow-*` and maps them
     onto the generated `--elevation-*` set */
  --shadow-key: var(--elevation-key);
  --shadow-whisper: var(--elevation-whisper);
  --shadow-card: var(--elevation-card);
  --shadow-pop: var(--elevation-pop);
  --shadow-lift: var(--elevation-lift);
  /* brand-tinted glow — CTA hover only, never decoration */
  --shadow-brand:
    0 8px 24px -8px color-mix(in oklab, var(--brand) 40%, transparent),
    0 2px 8px -2px color-mix(in oklab, var(--brand) 20%, transparent);
  --shadow-ring-brand: inset 0 0 0 1px var(--brand);
  --shadow-glass-top: inset 0 1px 0 color-mix(in oklab, white 12%, transparent);
  --shadow-glass-faint: inset 0 1px 0 color-mix(in oklab, white 8%, transparent);
  --shadow-stage: 0 16px 20px color-mix(in oklab, black 55%, transparent);

  /* sticky-chrome offset — the one number every sticky bar docks against */
  --site-header-h: 4rem;
  --site-chrome-h: var(--site-header-h);
}
@media (min-width: 1024px) {
  :root { --site-header-h: 5rem; }
}

/* Border-box everywhere. TT5 does NOT set this globally, so any element with
   width:100% plus padding/border rendered wider than its slot — it made every
   `1fr` grid button overflow its column by exactly (padding + border). Fixing
   it here rather than per-component, because the bug is systemic. */
*, *::before, *::after { box-sizing: border-box; }

/* ---------------------------------------------------------------------------
   TYPE SCALE
   headings: title-2xl 40 · title-xl 28 · title-lg 24 · title-md 20 · title-sm 18
   body:     body-lg 18 · body-base 16 · body-sm 15 · caption 13
   All headings carry 600 — DM Sans ships 400/500/600/700, so off-grid weights
   silently round up and break the ladder.
--------------------------------------------------------------------------- */
.display-xl   { font-size: clamp(3rem, 6.4vw, 5.75rem); line-height: 1;    letter-spacing: -0.04em;  font-weight: 600; }
.display-hero { font-size: clamp(2.75rem, 5vw, 5rem);   line-height: 1.02; letter-spacing: -0.04em;  font-weight: 600; }
.display-lg   { font-size: clamp(2.25rem, 4.2vw, 3.75rem); line-height: 1.02; letter-spacing: -0.035em; font-weight: 600; }
.display-md   { font-size: clamp(1.75rem, 2.8vw, 2.5rem); line-height: 1.08; letter-spacing: -0.025em; font-weight: 600; }

.title-2xl { font-size: clamp(1.875rem, 3vw, 2.5rem); line-height: 1.1;  letter-spacing: -0.025em; font-weight: 600; text-wrap: balance; }
.title-xl  { font-size: clamp(1.5rem, 2vw, 1.75rem);  line-height: 1.18; letter-spacing: -0.02em;  font-weight: 600; text-wrap: balance; }
.title-lg  { font-size: 1.5rem;   line-height: 1.25; letter-spacing: -0.018em; font-weight: 600; text-wrap: balance; }
.title-md  { font-size: 1.25rem;  line-height: 1.3;  letter-spacing: -0.014em; font-weight: 600; }
.title-sm  { font-size: 1.125rem; line-height: 1.35; letter-spacing: -0.01em;  font-weight: 600; }

.body-lg   { font-size: 1.125rem;  line-height: 1.6; letter-spacing: -0.005em; }
.body-base { font-size: 1rem;      line-height: 1.6; }
.body-sm   { font-size: 0.9375rem; line-height: 1.55; }
.caption   { font-size: 0.8125rem; line-height: 1.5; }

/* micro steps used by chips/labels (named for their px value).
   Each carries its paired line-height: Tailwind's font-size utilities bundle
   one, so porting the sizes alone drifts vertical rhythm on every surface. */
.text-10 { font-size: 10px;      line-height: 14px; }
.text-11 { font-size: 11px;      line-height: 16px; }
.text-13 { font-size: 0.8125rem; line-height: 1.125rem; }
.text-15 { font-size: 0.9375rem; line-height: 1.375rem; }
.text-17 { font-size: 1.0625rem; line-height: 1.625rem; }

/* the Tailwind size/leading pairs the ported components rely on */
.t-xs   { font-size: 0.75rem;  line-height: 1rem; }
.t-sm   { font-size: 0.875rem; line-height: 1.25rem; }
.t-base { font-size: 1rem;     line-height: 1.5rem; }
.t-lg   { font-size: 1.125rem; line-height: 1.75rem; }
.t-xl   { font-size: 1.25rem;  line-height: 1.75rem; }
.t-2xl  { font-size: 1.5rem;   line-height: 2rem; }

/* tracking scale (em × 100) */
.tracking-4  { letter-spacing: 0.04em; }
.tracking-6  { letter-spacing: 0.06em; }
.tracking-8  { letter-spacing: 0.08em; }
.tracking-10 { letter-spacing: 0.10em; }
.tracking-12 { letter-spacing: 0.12em; }

/* mono is the house signal for DATA — always tabular so figures never shift */
.mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.eyebrow {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-3); margin: 0;
}
.mono-label {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
}

/* ink ladder */
.text-ink-2 { color: var(--ink-2); }
.text-ink-3 { color: var(--ink-3); }
.text-ink-4 { color: var(--ink-4); }
.text-brand { color: var(--brand); }
.text-muted { color: var(--muted-foreground); }

/* ---------------------------------------------------------------------------
   BUTTONS — base + variants + sizes, matching ui/button.tsx exactly.
   Base is rounded-lg (= --radius), a transparent 1px border so outlined and
   filled variants share identical box metrics, and font-weight 500.
--------------------------------------------------------------------------- */
.btn {
  display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center;
  gap: 0.5rem; white-space: nowrap; text-decoration: none; cursor: pointer;
  border: 1px solid transparent; border-radius: var(--radius-lg);
  background-clip: padding-box;
  font-family: inherit; font-size: 0.875rem; font-weight: 500;
  user-select: none;
  transition: transform 150ms var(--ease-out-quart),
              background-color 150ms var(--ease-out-quart),
              border-color 150ms var(--ease-out-quart),
              box-shadow 200ms var(--ease-out-quart),
              color 150ms var(--ease-out-quart),
              opacity 150ms var(--ease-out-quart);
}
.btn:focus-visible { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 30%, transparent); }
.btn:disabled, .btn[aria-disabled="true"] { pointer-events: none; opacity: 0.5; }
.btn svg { flex-shrink: 0; pointer-events: none; width: 1rem; height: 1rem; }
/* every pressable control confirms the press — 150ms, scale 0.98 */
.btn:active { transform: scale(0.98); }

.btn--cta       { background: var(--brand); color: var(--brand-foreground); box-shadow: var(--elevation-key); }
.btn--cta:hover { background: var(--brand-hover); color: var(--brand-foreground); }
.btn--ink       { background: var(--foreground); color: var(--background); box-shadow: var(--elevation-key); }
.btn--ink:hover { background: color-mix(in oklab, var(--foreground) 90%, transparent); color: var(--background); }
.btn--outline   { border-color: var(--border-strong); background: var(--background); color: var(--foreground); }
.btn--outline:hover { background: var(--muted); color: var(--foreground); }
.btn--secondary { background: var(--secondary); color: var(--secondary-foreground); }
.btn--secondary:hover { background: color-mix(in oklch, var(--secondary), var(--foreground) 5%); }
.btn--soft      { background: var(--brand-muted); color: var(--brand); }
.btn--soft:hover{ background: color-mix(in oklab, var(--brand-muted), var(--brand) 10%); }
.btn--ghost     { background: transparent; color: var(--foreground); }
.btn--ghost:hover { background: var(--muted); }
.btn--glass {
  border-color: color-mix(in oklab, white 15%, transparent);
  background: color-mix(in oklab, white 10%, transparent);
  color: #fff; backdrop-filter: blur(12px); box-shadow: var(--shadow-glass-top);
}
.btn--glass:hover { background: color-mix(in oklab, white 15%, transparent); }

/* sizes — `default` is the 44px WCAG touch floor; `sm` (36px) is for
   desktop-dense contexts only. */
.btn--xs  { height: 1.75rem; gap: 0.375rem; padding-inline: 0.625rem; font-size: 0.8125rem; border-radius: var(--radius-md); }
.btn--sm  { height: 2.25rem; gap: 0.375rem; padding-inline: 0.75rem;  font-size: 0.8125rem; }
.btn--md  { height: 2.75rem; padding-inline: 1rem; }
.btn--lg  { height: 2.75rem; gap: 0.5rem; padding-inline: 1.25rem; font-size: 0.9375rem; }
.btn--xl  { height: 3rem;    gap: 0.5rem; padding-inline: 1.75rem; font-size: 1rem;      font-weight: 600; border-radius: var(--radius-xl); }
.btn--2xl { height: 3.5rem;  gap: 0.625rem; padding-inline: 2rem;  font-size: 1.0625rem; font-weight: 600; border-radius: var(--radius-xl); }
.btn--full { width: 100%; }

/* ---------------------------------------------------------------------------
   CONTROLS
--------------------------------------------------------------------------- */
.control {
  height: 2.75rem; width: 100%; min-width: 0;
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  background: var(--control); color: var(--foreground);
  font-family: inherit; font-size: 0.9375rem;
  padding-inline: 0.75rem;
  outline: none;
  transition: border-color 150ms var(--ease-out-quart), background-color 150ms var(--ease-out-quart), box-shadow 150ms var(--ease-out-quart);
}
.control::placeholder { color: var(--muted-foreground); }
.control:hover { border-color: color-mix(in oklab, var(--foreground) 20%, transparent); }
.control:focus-visible {
  border-color: var(--ring); background: var(--background);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 30%, transparent);
}

/* ---------------------------------------------------------------------------
   PILLS / CHIPS / STAGES
--------------------------------------------------------------------------- */
.pill {
  display: inline-flex; flex-shrink: 0; align-items: center; gap: 0.375rem;
  border-radius: 999px; padding: 0.5rem 0.875rem;
  font-size: 0.8125rem; font-weight: 500; white-space: nowrap; cursor: pointer;
  border: 1px solid var(--border); background: var(--background); color: var(--ink-3);
  transition: background-color 150ms var(--ease-out-quart), color 150ms var(--ease-out-quart),
              border-color 150ms var(--ease-out-quart), transform 150ms var(--ease-out-quart);
}
.pill:hover { border-color: color-mix(in oklab, var(--foreground) 20%, transparent); color: var(--foreground); }
.pill:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 30%, transparent);
}
.pill:active { transform: scale(0.98); }
.pill[aria-selected="true"] { background: var(--foreground); color: var(--background); border-color: transparent; }
.pill svg { width: 0.875rem; height: 0.875rem; flex-shrink: 0; color: var(--brand); }
.pill[aria-selected="true"] svg { color: var(--background); }
.pill__count { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--ink-4); }
.pill[aria-selected="true"] .pill__count { color: color-mix(in oklab, var(--background) 60%, transparent); }

/* the lit product stage — light and dark variants */
.stage-light {
  background: radial-gradient(120% 100% at 50% 0%,
    var(--p-stage-light-1) 0%, var(--p-stage-light-2) 60%, var(--p-stage-light-3) 100%);
}
.stage-dark {
  background: radial-gradient(130% 100% at 50% 0%,
    var(--p-stage-dark-1) 0%, var(--p-stage-dark-2) 55%, var(--p-stage-dark-3) 100%);
}

.chip-cat {
  display: inline-flex; align-items: center; flex-shrink: 0;
  border-radius: var(--radius-md); background: var(--secondary);
  padding: 0.25rem 0.5rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-3);
}

/* page axis */
.axis { box-sizing: border-box; width: 100%; max-width: calc(80rem + 2rem); margin-inline: auto; padding-inline: 1rem; }
@media (min-width: 640px) { .axis { max-width: calc(80rem + 3rem); padding-inline: 1.5rem; } }
.axis-tight { box-sizing: border-box; width: 100%; max-width: calc(80rem + 1.5rem); margin-inline: auto; padding-inline: 0.75rem; }
@media (min-width: 640px) { .axis-tight { max-width: calc(80rem + 3rem); padding-inline: 1.5rem; } }

/* ---------------------------------------------------------------------------
   FOCUS
   A click was leaving a hard rectangular ring behind on links and buttons.
   The fix is NOT to delete focus styling — that strands keyboard users, and a
   visible focus indicator is a WCAG 2.4.7 requirement. `:focus-visible` is
   exactly this split: the browser shows it for keyboard/assistive navigation
   and withholds it for pointer activation. So suppress the ring on :focus and
   define a deliberate one on :focus-visible.
   `outline` (not box-shadow) is used so it follows each element's own
   border-radius instead of drawing a square around a rounded control.
--------------------------------------------------------------------------- */
a:focus, button:focus, summary:focus, [tabindex]:focus,
input:focus, select:focus, textarea:focus { outline: none; }

a:focus-visible, button:focus-visible, summary:focus-visible, [tabindex]:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
/* Components that already draw their own focus treatment opt out of the
   generic outline so the two never stack. */
.btn:focus-visible, .control:focus-visible, .pill:focus-visible, .ms-slice:focus-visible { outline: none; }
