/*
 * PIYAVE Labs — base layer
 * Reset, self-hosted faces, the section 04 type scale, containers and the
 * section 11 graphic elements. Everything reads from tokens.css.
 */

/* ---- Faces --------------------------------------------------------------
 * Three variable families, Latin + Latin-Ext only, swap. Latin-Ext is a
 * separate file with its own unicode-range so it is fetched only when a page
 * actually contains those glyphs. */

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('../fonts/space-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 Grotesk';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('../fonts/space-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: 'Geist';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/geist-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: 'Geist';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/geist-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: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url('../fonts/jetbrains-mono-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: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url('../fonts/jetbrains-mono-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;
}

/* ---- Reset --------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* The sticky header must not cover the target of an in-page link. */
  scroll-padding-top: calc(var(--nav-height) + var(--space-6));
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  font-weight: var(--weight-regular);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-ligatures: common-ligatures;
  font-optical-sizing: auto;
  /* Nothing scrolls horizontally except a deliberately scrollable region. */
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }
ul[class], ol[class] { list-style: none; margin: 0; padding: 0; }

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
  /* Photography and figures are always square — a brand signature. */
  border-radius: var(--radius-none);
}

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

/* ---- Focus ---------------------------------------------------------------
 * 2px Electric Blue ring at 2px offset, identical on every focusable element,
 * appearing instantly. Never transitioned, never removed. */

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  transition: none;
}
:focus:not(:focus-visible) { outline: none; }

/* ---- Skip link — first focusable element on every page ------------------- */

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: calc(-1 * var(--space-20));
  z-index: var(--z-tooltip);
  padding: var(--space-3) var(--space-4);
  background: var(--neutral-950);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.skip-link:focus { top: var(--space-4); }

/* ---- Type scale — section 04 --------------------------------------------
 * Sizes step down by breakpoint per section 26. Display and headings are
 * Space Grotesk; H5/H6 drop to Geist. */

.display-2xl, .display-xl, h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--text);
  /* No widows on headlines. */
  text-wrap: balance;
}

.display-2xl {
  font-size: var(--text-3xl);
  line-height: var(--leading-none);
  letter-spacing: var(--tracking-tighter);
  font-weight: var(--weight-bold);
}
.display-xl {
  font-size: var(--text-2xl);
  line-height: 1.04;
  letter-spacing: -0.035em;
  font-weight: var(--weight-semibold);
}
h1, .h1 {
  font-size: 1.875rem; /* 30 at mobile */
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: var(--weight-semibold);
}
h2, .h2 {
  font-size: var(--text-2xl);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  font-weight: var(--weight-semibold);
}
h3, .h3 {
  font-size: 1.25rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: var(--weight-semibold);
}
h4, .h4 {
  font-size: var(--text-xl);
  line-height: var(--leading-snug);
  letter-spacing: -0.015em;
  font-weight: var(--weight-semibold);
}
h5, .h5 {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  line-height: 1.4;
  letter-spacing: -0.01em;
  font-weight: var(--weight-semibold);
}
h6, .h6 {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.4;
  letter-spacing: var(--tracking-normal);
  font-weight: var(--weight-semibold);
}

@media (min-width: 640px) {
  .display-2xl { font-size: var(--text-4xl); }
  .display-xl { font-size: var(--text-3xl); }
  h1, .h1 { font-size: var(--text-3xl); }
  h2, .h2 { font-size: 1.75rem; }
  h3, .h3 { font-size: var(--text-xl); }
}
@media (min-width: 1024px) {
  .display-2xl { font-size: var(--text-5xl); }
  .display-xl { font-size: 3.25rem; }
  h1, .h1 { font-size: 2.75rem; }
  h2, .h2 { font-size: 2rem; }
  h3, .h3 { font-size: 1.625rem; }
}
@media (min-width: 1440px) {
  .display-2xl { font-size: var(--text-6xl); }
  .display-xl { font-size: var(--text-5xl); }
  h1, .h1 { font-size: var(--text-4xl); }
  h2, .h2 { font-size: var(--text-3xl); }
  h3, .h3 { font-size: var(--text-2xl); }
  body { font-size: 1.0625rem; line-height: var(--leading-relaxed); }
}

/* ---- Body text ----------------------------------------------------------- */

.body-lg {
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}
.body-sm { font-size: var(--text-sm); line-height: 1.55; }
.caption { font-size: var(--text-xs); line-height: 1.5; color: var(--text-tertiary); }

/* Overline — mono, uppercase, Electric Blue. One per section. */
.overline {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.4;
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--accent);
}
.overline--muted { color: var(--text-tertiary); }

/* Data and figures — always tabular. */
.mono, .data {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

/* Measure: 60–75 characters, never justified. */
.prose-measure { max-width: 68ch; }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--duration-instant) var(--ease-standard);
}
a:hover { color: var(--accent-hover); }

/* Links inside body copy carry an underline, not just colour. */
.rich-text a, .prose a { text-decoration: underline; }

strong, b { font-weight: var(--weight-semibold); }

hr, .rule {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--space-12) 0;
}

/* ---- Layout -------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container-content);
  margin-inline: auto;
  padding-inline: var(--space-5);
}
@media (min-width: 768px) { .container { padding-inline: var(--space-8); } }
@media (min-width: 1024px) { .container { padding-inline: var(--space-10); } }

.container--prose { max-width: var(--container-prose); }
.container--wide { max-width: var(--container-wide); }

/* Section padding — 64 / 80 / 96 by breakpoint. Space grows sideways at the
 * largest tier, not down. */
.section { padding-block: var(--space-16); }
@media (min-width: 640px) { .section { padding-block: var(--space-20); } }
@media (min-width: 1024px) { .section { padding-block: var(--space-24); } }

.section--tight { padding-block: var(--space-12); }
@media (min-width: 1024px) { .section--tight { padding-block: var(--space-16); } }

/* Grounds alternate white → Neutral-50 → white. Major sections change ground
 * colour rather than carrying a rule between them. */
.section--subtle { background: var(--bg-subtle); }
.section--navy {
  background: var(--neutral-950);
  /* The one permitted gradient: a 12% vertical wash to prevent banding on
   * large flat navy fields. */
  background-image: linear-gradient(180deg, var(--neutral-950) 0%, #0d1322 100%);
}

.section__head { margin-bottom: var(--space-10); }
.section__head .overline { margin-bottom: var(--space-3); }
.section__head p {
  margin-top: var(--space-4);
  max-width: 68ch;
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}
@media (min-width: 1024px) { .section__head { margin-bottom: var(--space-12); } }

/* ---- Graphic elements — section 11 --------------------------------------
 * Four elements are approved and nothing else is. */

/* Blueprint grid: 24px, hairlines, max 8% opacity, behind content only. */
.blueprint {
  position: relative;
  isolation: isolate;
}
.blueprint::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--opacity-grid);
  background-image:
    linear-gradient(to right, var(--neutral-300) 1px, transparent 1px),
    linear-gradient(to bottom, var(--neutral-300) 1px, transparent 1px);
  background-size: 24px 24px;
  /* Fade the grid out before it reaches the section edge. */
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 55%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, #000 55%, transparent 100%);
}
.section--navy .blueprint::before,
.is-inverted .blueprint::before {
  background-image:
    linear-gradient(to right, #fff 1px, transparent 1px),
    linear-gradient(to bottom, #fff 1px, transparent 1px);
}

/* Section opener: 2px Electric Blue, 48px. */
.opener {
  display: block;
  width: 48px;
  height: 2px;
  background: var(--accent);
  border: 0;
  margin: 0 0 var(--space-6);
}

/* Layer motif — the stack at 20° skew. Section markers and dividers only. */
.layer-motif {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  width: 32px;
}
.layer-motif span {
  display: block;
  height: 6px;
  background: var(--neutral-300);
  transform: skewX(-20deg);
}
.layer-motif span:nth-child(2) { background: var(--accent); }

/* ---- Utilities ----------------------------------------------------------- */

.screen-reader-text,
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.stack > * + * { margin-top: var(--space-4); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }

/* Scroll reveal — one per section, 12px rise + fade over 240ms, triggered once
 * at 20% visibility. Disabled entirely under reduced motion. */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity var(--duration-slow) var(--ease-decelerate),
    transform var(--duration-slow) var(--ease-decelerate);
}
.reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
}

/* No-JS must never leave content hidden. */
.no-js .reveal { opacity: 1; transform: none; }
