/*
 * BASE — font loading, reset, bare element defaults, focus, a11y utilities.
 * Reads tokens.css only. No raw hex and no raw px font sizes live here:
 * if a value is missing, add a token rather than a literal.
 */

/* ---------- Fonts ------------------------------------------------------- *
 * Self-hosted rather than loaded from Google Fonts, so the site makes zero
 * third-party requests (check.sh asserts this).
 *
 * latin-ext is NOT optional: MON-3's AI examples contain Czech characters
 * (Tomáš, Rohlík) outside the latin subset. unicode-range keeps the extra
 * file off pages that do not need it.
 *
 * Hanken Grotesk is the variable file — one download covers weights 400–800.
 */

@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/assets/fonts/hanken-grotesk-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/assets/fonts/hanken-grotesk-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Space Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/space-mono-400-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

@font-face {
  font-family: "Space Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/space-mono-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Space Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/space-mono-700-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

@font-face {
  font-family: "Space Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/space-mono-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Reset (mirrors monksuite's) --------------------------------- */

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

* {
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--ms-bg);
  color: var(--ms-text);
  font-family: var(--ms-font-sans);
  font-size: var(--ms-text-body-sm);
  font-weight: var(--ms-weight-regular);
  line-height: var(--ms-leading-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

button,
input,
select,
textarea {
  font-family: inherit;
  color: inherit;
}

::selection {
  background: var(--ms-text);
  color: var(--ms-on-light);
}

/* ---------- Headings ---------------------------------------------------- *
 * Sizes are set per-context by the components that use them. What lives
 * here is only what is true of every heading on the site.
 */

h1,
h2,
h3,
h4,
h5 {
  font-weight: var(--ms-weight-bold);
  line-height: var(--ms-leading-tight);
  letter-spacing: var(--ms-tracking-heading);
  text-wrap: balance;
}

h1 {
  font-size: var(--ms-text-display-2);
  font-weight: var(--ms-weight-black);
  letter-spacing: var(--ms-tracking-display);
}

h2 {
  font-size: var(--ms-text-h2);
  font-weight: var(--ms-weight-black);
}

h3 {
  font-size: var(--ms-text-h3);
  letter-spacing: var(--ms-tracking-title);
}

h4 {
  font-size: var(--ms-text-h4);
  line-height: var(--ms-leading-title);
  letter-spacing: var(--ms-tracking-title);
}

h5 {
  font-size: var(--ms-text-h5);
  letter-spacing: var(--ms-tracking-title);
}

/* ---------- Prose ------------------------------------------------------- */

p {
  text-wrap: pretty;
}

strong,
b {
  color: var(--ms-text);
  font-weight: var(--ms-weight-bold);
}

/* Links default to inherit — monksuite has no blue underlined link anywhere.
   Anything that should read as a link says so with .ms-link or a button. */
a {
  color: inherit;
  text-decoration: none;
}

code,
pre,
kbd {
  font-family: var(--ms-font-mono);
  font-size: var(--ms-text-code);
}

hr {
  height: 1px;
  border: 0;
  background: var(--ms-line-soft);
}

/* ---------- Focus ------------------------------------------------------- *
 * One focus treatment for the whole site. Never remove it without a
 * replacement — every focusable element must show a >=3px ring.
 */

:focus-visible {
  outline: var(--ms-focus-w) solid var(--ms-focus);
  outline-offset: var(--ms-focus-offset);
  border-radius: var(--ms-radius-sm);
}

/* Mouse users do not get the ring; keyboard users always do. */
:focus:not(:focus-visible) {
  outline: none;
}

/* ---------- Skip link --------------------------------------------------- *
 * First focusable element on every page. Off-screen until focused, then it
 * must be genuinely visible — not a 1px sliver.
 */

.ms-skip {
  position: absolute;
  top: var(--ms-space-md);
  left: var(--ms-space-md);
  z-index: 100;
  padding: var(--ms-space-md) var(--ms-space-3xl);
  border-radius: var(--ms-radius-full);
  background: var(--ms-text);
  color: var(--ms-on-light);
  font-size: var(--ms-text-btn-sm);
  font-weight: var(--ms-weight-semibold);
  transform: translateY(calc(-100% - var(--ms-space-9xl)));
}

.ms-skip:focus {
  transform: translateY(0);
}

/* ---------- A11y utilities ---------------------------------------------- */

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

/* ---------- Scroll reveal ----------------------------------------------- *
 * The initial opacity: 0 is gated behind .js on <html>, which main.js sets.
 * With JavaScript off there is no observer to reveal anything, so ungated
 * this would strand every section invisible.
 */

.js .ms-reveal {
  opacity: 0;
  transform: translateY(var(--ms-reveal-y));
  transition:
    opacity var(--ms-dur-reveal),
    transform var(--ms-dur-reveal);
}

.js .ms-reveal.is-in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .js .ms-reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}
