/* =====================================================================
   Keystone Reg Advisory — base.css
   Design tokens, reset, typography, links, accessibility primitives.
   ===================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* Ink / navy (depth) */
  --ink-950: #070B15;
  --ink-900: #0B1120;
  --ink-800: #121A2E;
  --navy-700: #1C2546;

  /* Paper (surfaces) */
  --ivory-50: #FAF8F3;
  --ivory-100: #F4F0E7;
  --stone-200: #E7E0D1;
  --stone-300: #D5CBB6;

  /* Neutrals */
  --graphite-800: #2B303B;
  --graphite-700: #3D4350;
  --graphite-500: #5A5F6D;
  --mist-200: #C9CEDA;
  --mist-300: #A7AEC1;
  --mist-500: #7D849A;

  /* Restrained metallic accent — used for marks, indices and states only */
  --bronze-300: #C9AA7C;
  --bronze-500: #A8875A;
  --bronze-700: #7A5B33;

  /* Type */
  --serif: 'Newsreader', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --sans: 'Schibsted Grotesk', 'Helvetica Neue', Helvetica, Arial, sans-serif;

  --step--1: clamp(0.8125rem, 0.79rem + 0.1vw, 0.875rem);
  --step-0: clamp(1rem, 0.97rem + 0.15vw, 1.0625rem);
  --step-1: clamp(1.125rem, 1.06rem + 0.32vw, 1.3125rem);
  --step-2: clamp(1.375rem, 1.22rem + 0.7vw, 1.8125rem);
  --step-3: clamp(1.75rem, 1.42rem + 1.5vw, 2.75rem);
  --step-4: clamp(2.125rem, 1.55rem + 2.6vw, 4rem);
  --step-5: clamp(2.75rem, 1.7rem + 4.6vw, 6.25rem);

  /* Space */
  --margin: clamp(1.25rem, 4.6vw, 5rem);
  --gutter: clamp(1rem, 1.7vw, 2rem);
  --max: 1440px;
  --section-y: clamp(5rem, 3.2rem + 8vw, 11rem);
  --nav-h: 76px;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-micro: 0.25s;
  --dur-ui: 0.5s;
  --dur-reveal: 1.1s;

  color-scheme: light;
}

@media (max-width: 899px) {
  :root { --nav-h: 64px; }
}

/* ---------- Surface themes ---------- */
[data-theme] { background-color: var(--bg); color: var(--fg); }

[data-theme="ink"] {
  --bg: var(--ink-900);
  --fg: var(--ivory-100);
  --fg-2: var(--mist-300);
  --fg-3: var(--mist-500);
  --rule: rgba(244, 240, 231, 0.13);
  --rule-2: rgba(244, 240, 231, 0.3);
  --rule-faint: rgba(244, 240, 231, 0.045);
  --accent: var(--bronze-300);
  --wash: rgba(244, 240, 231, 0.035);
}
[data-theme="ivory"],
[data-theme="stone"],
[data-theme="vellum"] {
  --fg: var(--ink-900);
  --fg-2: var(--graphite-700);
  --fg-3: var(--graphite-500);
  --rule: rgba(11, 17, 32, 0.12);
  --rule-2: rgba(11, 17, 32, 0.26);
  --rule-faint: rgba(11, 17, 32, 0.05);
  --accent: var(--bronze-700);
  --wash: rgba(11, 17, 32, 0.025);
}
[data-theme="ivory"] { --bg: var(--ivory-100); }
[data-theme="stone"] { --bg: var(--stone-200); }
[data-theme="vellum"] { --bg: var(--ivory-50); }

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

html {
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* No global scroll-behavior: smooth — it interferes with ScrollTrigger
     measurement. In-page anchors are smoothed in main.js instead. */
  scroll-padding-top: calc(var(--nav-h) + 1rem);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ivory-100);
  color: var(--ink-900);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.6;
  font-weight: 400;
  font-feature-settings: "kern" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

h1, h2, h3, h4, p, ol, ul, dl, dd, figure, blockquote { margin: 0; }
ol, ul { padding: 0; list-style: none; }
img, svg, picture { display: block; max-width: 100%; }
img { height: auto; }
a { color: inherit; }
button { font: inherit; color: inherit; }
em { font-style: italic; }

::selection { background: var(--bronze-300); color: var(--ink-900); }

/* ---------- Typography ---------- */
.serif { font-family: var(--serif); }

h1, h2, h3 { text-wrap: balance; font-weight: 400; }
p { text-wrap: pretty; }

.label {
  display: flex;
  align-items: baseline;
  gap: 0.85em;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg-2);
}
.label__mark {
  font-family: var(--serif);
  font-size: 1.2em;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--accent);
  white-space: nowrap;
}
.label--quiet { color: var(--fg-3); }

.lead {
  font-size: var(--step-1);
  line-height: 1.55;
  color: var(--fg-2);
  max-width: 40ch;
}

.num { font-variant-numeric: lining-nums tabular-nums; }

/* ---------- Links ---------- */
/* Underlined text link: faint hairline at rest, accent line draws over it on hover */
.ulink {
  color: inherit;
  text-decoration: none;
  background-image:
    linear-gradient(var(--accent), var(--accent)),
    linear-gradient(var(--rule-2), var(--rule-2));
  background-size: 0% 1px, 100% 1px;
  background-position: 0 100%, 0 100%;
  background-repeat: no-repeat;
  padding-bottom: 0.15em;
  transition: background-size 0.6s var(--ease-out), color var(--dur-micro);
  font-variant-numeric: lining-nums;
  overflow-wrap: anywhere;
}
.ulink:hover { background-size: 100% 1px, 100% 1px; }

/* Arrow link — navigational, never persuasive */
.arrow-link {
  display: inline-flex;
  align-items: center;
  gap: 0.9em;
  min-height: 44px;
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--fg);
  text-decoration: none;
}
.arrow-link > span {
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  padding-bottom: 0.15em;
  transition: background-size 0.6s var(--ease-out);
}
.arrow-link:hover > span { background-size: 100% 1px; }

.arrow {
  width: 1.7em;
  height: 0.75em;
  flex: none;
  overflow: visible;
  color: var(--accent);
  transition: transform 0.6s var(--ease-out);
}
.arrow path { fill: none; stroke: currentColor; stroke-width: 1.1; stroke-linecap: square; }
.arrow-link:hover .arrow { transform: translateX(0.35em); }

/* ---------- Accessibility ---------- */
:focus-visible {
  outline: 2px solid var(--accent, var(--bronze-500));
  outline-offset: 4px;
}
:focus:not(:focus-visible) { outline: none; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 200;
  padding: 0.75rem 1rem;
  background: var(--ink-900);
  color: var(--ivory-100);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 0.3s var(--ease-out);
}
.skip-link:focus { transform: none; }
