/*
  system.css — one token/grid/type/button/card system for the whole site.
  Adapted from the taste-skill design system for a personal engineering site.
  Do not add a second grid, spacing scale, type scale, radius scale, button or card style.
*/

:root {
  /* palette — dark is default */
  --p-bg: #0e1013;
  --p-surface: #15181c;
  --p-ink: #eceae4;
  --p-muted: #9aa0a6;
  --p-accent: #6f97ff;
  --p-accent-ink: #0e1013;
  --p-action: #6f97ff;
  --p-action-ink: #0e1013;
  --p-line: color-mix(in oklab, var(--p-ink) 14%, transparent);
  --p-line-strong: color-mix(in oklab, var(--p-ink) 26%, transparent);

  --font-display: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-text: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --display-weight: 500;
  --display-tracking: -0.02em;

  --nav: 72px;
  --padt: 120px;
  --padb: 72px;
  --hgap: 48px;
  --hpadb: 64px;

  --container: 1200px;
  --gut: 80px;
  --gutter: 24px;

  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px; --s-5: 24px;
  --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px; --s-10: 128px;
  --head-gap: 48px;
  --card-pad: 24px;
  --card-gap: 24px;

  --t-label: 13px;
  --t-small: 14px;
  --t-body: 16px;
  --t-lead: 19px;
  --t-card: 18px;
  --t-h3: 24px;
  --t-h2: clamp(28px, 1.6vw + 22px, 44px);
  --t-h1: clamp(36px, 3.2vw + 24px, 64px);
  --t-stat: clamp(26px, 0.9vw + 22px, 34px);

  /* sharp radius — precise, technical */
  --r-sm: 4px; --r-md: 6px; --r-lg: 10px; --r-btn: 4px;

  --btn-h: 44px;
  --btn-h-sm: 36px;
  --icon: 16px;

  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-enter: cubic-bezier(.22, 1, .36, 1);
  --dur: 160ms;
}

/* light grade */
:root[data-theme="light"] {
  --p-bg: #f7f6f3;
  --p-surface: #eeece6;
  --p-ink: #16181c;
  --p-muted: #5b5f66;
  --p-accent: #2f5fd1;
  --p-accent-ink: #ffffff;
  --p-action: #2f5fd1;
  --p-action-ink: #ffffff;
  --p-line: color-mix(in oklab, var(--p-ink) 11%, transparent);
  --p-line-strong: color-mix(in oklab, var(--p-ink) 22%, transparent);
}

@media (max-width: 639px) {
  :root { --nav: 56px; --padt: 72px; --padb: 48px; --hgap: 32px; --hpadb: 32px; --gut: 24px; --gutter: 12px; --card-gap: 16px; --head-gap: 32px; --card-pad: 20px; }
}
@media (min-width: 640px) and (max-width: 1023px) {
  :root { --gut: 40px; }
}
@media (min-width: 1024px) {
  :root { --gut: 80px; --t-lead: 20px; --t-card: 20px; --t-h3: 28px; }
}

:root, .ground-base {
  --bg: var(--p-bg); --surface: var(--p-surface); --ink: var(--p-ink); --muted: var(--p-muted);
  --accent: var(--p-accent); --accent-ink: var(--p-accent-ink); --card: var(--p-surface);
  --action: var(--p-action); --action-ink: var(--p-action-ink);
  --line: var(--p-line); --line-strong: var(--p-line-strong);
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: auto; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 var(--t-body)/1.6 var(--font-text);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: clip;
  transition: background-color 200ms ease, color 200ms ease;
}
img, svg, video, canvas { display: block; max-width: 100%; }
[hidden] { display: none !important; }
img, video { height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; }
h1, h2, h3, h4, p, ul, ol, figure, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1, h2, h3, h4 {
  font-family: var(--font-display); font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking); text-wrap: balance; overflow-wrap: break-word;
}
h1, .t-h1 { font-size: var(--t-h1); line-height: 1.05; }
h2, .t-h2 { font-size: var(--t-h2); line-height: 1.12; }
h3, .t-h3 { font-size: var(--t-h3); line-height: 1.25; }
h4, .t-card { font-family: var(--font-text); font-weight: 600; font-size: var(--t-card); line-height: 1.3; letter-spacing: -0.01em; }
p { text-wrap: pretty; }
.t-lead  { font-size: var(--t-lead); line-height: 1.55; }
.t-body  { font-size: var(--t-body); line-height: 1.6; }
.t-small { font-size: var(--t-small); line-height: 1.5; }
.t-label { font-family: var(--font-mono); font-size: var(--t-label); font-weight: 500; line-height: 1.4; letter-spacing: 0.03em; text-transform: uppercase; }
.t-stat  { font-family: var(--font-mono); font-weight: 500; font-size: var(--t-stat); line-height: 1; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.mono  { font-family: var(--font-mono); }
.measure { max-width: 62ch; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; border-radius: 2px; }
::selection { background: color-mix(in oklab, var(--accent) 30%, transparent); }

/* ---------------------------------------------------------------- grid */
.wrap { width: min(100% - 2 * var(--gut), var(--container)); margin-inline: auto; }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gutter); row-gap: var(--card-gap); }
.grid > * { min-width: 0; }
@media (min-width: 1024px) {
  .span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
  .span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; }
}

/* ---------------------------------------------------------------- section rhythm */
main > section {
  position: relative;
  padding: var(--padt) 0 var(--padb);
}
.section-head { max-width: 760px; margin-bottom: var(--head-gap); display: grid; gap: var(--s-4); }
.section-head p { color: var(--muted); font-size: var(--t-lead); line-height: 1.5; max-width: 60ch; }
.section-head .t-label { color: var(--accent); margin-bottom: var(--s-2); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: var(--btn-h); padding: 0 var(--s-5); border-radius: var(--r-btn); border: 1px solid transparent;
  font: 500 var(--t-body)/1 var(--font-text); letter-spacing: 0; white-space: nowrap; cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn--primary { background: var(--action); color: var(--action-ink); }
.btn--primary:hover { background: color-mix(in oklab, var(--action) 86%, var(--ink)); }
.btn--secondary { background: none; border-color: transparent; color: var(--ink); padding-inline: var(--s-2);
  text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--line-strong); }
.btn--secondary:hover { text-decoration-color: currentColor; }
.btn--sm { height: var(--btn-h-sm); padding: 0 var(--s-4); font-size: var(--t-small); }
@media (hover: hover) and (pointer: fine) {
  .btn--primary:hover { transform: translateY(-1px); }
}
.btn:active { transform: translateY(1px) scale(.985); }
.m-arrow { flex: none; width: 12px; height: 12px; margin-right: -2px; overflow: visible;
           fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
           transition: transform var(--dur) var(--ease); }
@media (hover: hover) and (pointer: fine) { .btn:hover .m-arrow, .link:hover .m-arrow { transform: translateX(3px); } }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--s-4); align-items: center; }
@media (max-width: 639px) {
  .btn-row { flex-direction: column; align-items: stretch; width: 100%; }
  .btn-row > .btn { width: 100%; }
}

.link { display: inline-flex; align-items: center; gap: var(--s-2); font-weight: 500; color: var(--ink);
        text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 4px;
        transition: text-decoration-color var(--dur) var(--ease); }
.link:hover { text-decoration-color: currentColor; }

.pill { display: inline-flex; align-items: center; gap: var(--s-2); height: 32px; padding: 0 var(--s-3);
        border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--card);
        font-family: var(--font-mono); font-size: var(--t-label); color: var(--ink); }

/* ---------------------------------------------------------------- cards */
.card {
  display: flex; flex-direction: column; gap: var(--s-3); min-width: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--card-pad);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.card > h3, .card > h4, .card > .card-title { font-family: var(--font-text); font-weight: 600; font-size: var(--t-card); line-height: 1.3; letter-spacing: -0.01em; }
.card > p { color: var(--ink); font-size: var(--t-body); max-width: 56ch; }
a.card:hover, .card.is-linked:hover {
  border-color: var(--line-strong);
  box-shadow: 0 10px 24px -16px rgb(0 0 0 / .35);
}
@media (hover: hover) and (pointer: fine) {
  a.card:hover, .card.is-linked:hover { transform: translateY(-2px); }
}

/* ---------------------------------------------------------------- forms/contrast etc. */
.hr { height: 1px; background: var(--line); border: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
