/*
 * Healthier Essex — base: fonts, reset, typography, layout primitives
 */

@font-face {
  font-family: "GT America";
  src: url("../assets/fonts/GT-America-Standard-Light.woff2") format("woff2");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "GT America";
  src: url("../assets/fonts/GT-America-Standard-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "GT America Mono";
  src: url("../assets/fonts/GT-America-Mono-Light.woff2") format("woff2");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "GT America Mono";
  src: url("../assets/fonts/GT-America-Mono-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
:root[data-simplified="true"] html,
:root[data-simplified="true"] {
  scroll-behavior: auto;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-weight: 300;
  font-size: clamp(14px, 1.25vw, 20px);
  line-height: 1.125;
  letter-spacing: -0.02em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body.is-locked {
  overflow: hidden;
}

h1, h2, h3, h4, p, ul, ol, figure {
  margin: 0;
}
ul, ol {
  padding: 0;
  list-style: none;
}
a {
  color: inherit;
  text-decoration: none;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
img, svg {
  display: block;
  max-width: 100%;
}
input {
  font: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Typography (Text styles) ----------
   Figma desktop values are for 1280 px; sizes scale with the viewport
   (clamp min ≈ phone, max ≈ 1920 px). Line-heights are the unitless ratio
   of each Figma line-height / size pair. */
.t-title  { font-weight: 500; font-size: clamp(44px, 5.625vw, 100px);  line-height: 0.97;  letter-spacing: -0.03em; }
.t-h1     { font-weight: 500; font-size: clamp(36px, 4.375vw, 76px);   line-height: 0.9;   letter-spacing: -0.02em; }
.t-strap  { font-weight: 500; font-size: clamp(26px, 3.125vw, 54px);   line-height: 1.05;  letter-spacing: -0.02em; }
.t-h2     { font-weight: 500; font-size: clamp(22px, 2.5vw, 42px);     line-height: 1.06;  letter-spacing: -0.02em; }
.t-quote  { font-weight: 300; font-size: clamp(22px, 2.5vw, 42px);     line-height: 1.06;  letter-spacing: -0.03em; }
.t-h3     { font-weight: 500; font-size: clamp(20px, 1.875vw, 32px);   line-height: 1.08;  letter-spacing: -0.03em; }
.t-body   { font-weight: 300; font-size: clamp(17px, 1.5625vw, 26px);  line-height: 1.2;   letter-spacing: -0.02em; }
.t-xs     { font-weight: 300; font-size: clamp(14px, 1.25vw, 20px);    line-height: 1.125; letter-spacing: -0.015em; }
.t-spec   { font-weight: 300; font-size: clamp(11px, 0.9375vw, 15px);  line-height: 1.17;  letter-spacing: -0.015em; }
.t-mono   { font-family: var(--font-mono); font-weight: 300; font-size: 12px; line-height: 12px; letter-spacing: 0; text-transform: uppercase; }
.t-medium { font-weight: 500; }
.t-light  { font-weight: 300; }
.t-muted  { color: var(--fg-muted); }
.t-center { text-align: center; }

.link-essex {
  color: var(--link);
}
.link-u {
  text-decoration: underline;
  text-underline-position: from-font;
}
.link-u:hover {
  color: var(--accent-text);
}

/* ---------- Layout primitives ---------- */
.wrap {
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
}
.pad {
  padding-inline: var(--margin);
}
.section {
  padding-block: var(--section-pad);
}
.section--alt {
  background: var(--bg-alt);
  --fg-muted: var(--fg-muted-alt);
}
body.page-explore {
  --fg-muted: var(--fg-muted-alt);
}
.chapter {
  padding-left: var(--margin);
  padding-right: var(--chapter-pad-right);
}

/* Skip link — visible only when focused */
.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 200;
  padding: 8px 12px;
  border-radius: 2px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 500;
  translate: 0 -200%;
  transition: translate 0.2s;
}
.skip-link:focus {
  translate: 0 0;
}

/* Cross-document view transitions: the top bar persists, content cross-fades */
@view-transition {
  navigation: auto;
}
.topbar {
  view-transition-name: topbar;
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation-duration: 0.001s !important;
  }
}

/* Metered connections: no hero video */
@media (prefers-reduced-data: reduce) {
  .hero__squares {
    display: none !important;
  }
}

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

/* ---------- Simplified: no motion ---------- */
:root[data-simplified="true"] *,
:root[data-simplified="true"] *::before,
:root[data-simplified="true"] *::after {
  animation: none !important;
  transition: none !important;
}
