/* ==========================================================================
   base.css — reset, typography, page layout helpers, accessibility helpers.
   Styles plain HTML elements (h1, p, a, ...) and small layout utilities.
   Components (buttons, cards, navbar...) live in components.css.
   Colors/spacing come from variables.css — don't hard-code them here.
   ========================================================================== */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Anchor links (e.g. #gates) shouldn't hide under the sticky header */
  scroll-padding-top: calc(var(--header-height) + 1rem);
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  flex: 1 0 auto;
}

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

svg {
  max-width: 100%;
}

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

button {
  cursor: pointer;
}

/* ---------- Typography ---------- */
h1,
h2,
h3,
h4 {
  color: var(--color-heading);
  line-height: var(--leading-tight);
  font-weight: var(--weight-bold);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-3xl);
  font-weight: var(--weight-black);
  letter-spacing: -0.02em;
}

h2 {
  font-size: var(--text-2xl);
  letter-spacing: -0.015em;
}

h3 {
  font-size: var(--text-xl);
  line-height: var(--leading-snug);
}

h4 {
  font-size: var(--text-lg);
  line-height: var(--leading-snug);
}

p {
  max-width: 68ch;
  text-wrap: pretty;
}

a {
  color: var(--color-link);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 0.08em;
}

a:hover {
  color: var(--color-link-hover);
  text-decoration-thickness: 0.14em;
}

ul,
ol {
  padding-left: 1.25em;
}

li + li {
  margin-top: var(--space-1);
}

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

small {
  font-size: var(--text-sm);
}

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
}

/* Quantum "ket" symbols like |0⟩ — JS wraps them in <span class="ket"> */
.ket {
  font-family: var(--font-math);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  line-height: 1; /* the math font is tall: keeps lines with |0⟩ from growing taller than other lines */
}

/* ---------- Focus (keyboard users MUST be able to see where they are) ---------- */
:focus-visible {
  outline: 3px solid var(--focus-ring-color);
  outline-offset: 3px;
}

/* Dark sections switch the focus ring to yellow so it stays visible */
.surface-dark {
  --focus-ring-color: var(--color-focus-on-dark);
  color: var(--color-on-dark);
}

.surface-dark h1,
.surface-dark h2,
.surface-dark h3,
.surface-dark h4 {
  color: var(--color-on-dark);
}

.surface-dark a:not(.btn) {
  color: var(--color-on-dark-quantum);
}

.surface-dark a:not(.btn):hover {
  color: #ffffff;
}

[hidden] {
  display: none !important;
}

/* ---------- Accessibility helpers ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* "Skip to main content" link: invisible until a keyboard user tabs to it */
.skip-link {
  position: absolute;
  left: var(--space-3);
  top: -4rem;
  z-index: 2000;
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--ink-900);
  color: #ffffff;
  font-weight: var(--weight-bold);
  text-decoration: none;
  --focus-ring-color: var(--color-focus-on-dark);
}

.skip-link:focus {
  top: var(--space-3);
  color: #ffffff;
}

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

/* ---------- Layout helpers ---------- */
/* Centered page column with side padding */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

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

/* A full-width band of the page; add .section--alt for a tinted background */
.section {
  padding-block: var(--space-7);
}

.section--alt {
  background: var(--color-bg-alt);
}

@media (min-width: 900px) {
  .section {
    padding-block: var(--space-8);
  }
}

/* Adds vertical space between direct children: <div class="stack"> */
.stack > * + * {
  margin-top: var(--stack-gap, var(--space-4));
}

/* Row of items that wraps on small screens */
.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cluster-gap, var(--space-3));
}

/* Responsive grids. .grid--cards fits as many 17rem-wide columns as there is room for. */
.grid {
  display: grid;
  gap: var(--grid-gap, var(--space-5));
}

.grid--cards {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
}

@media (min-width: 600px) {
  .grid--2,
  .grid--3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Section titles: small eyebrow label + heading + intro paragraph */
.section-heading {
  max-width: 46rem;
  margin-bottom: var(--space-6);
}

.section-heading > * + * {
  margin-top: var(--space-3);
}

.eyebrow {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-quantum);
}

.surface-dark .eyebrow {
  color: var(--color-on-dark-quantum);
}

.lead {
  font-size: var(--text-lg);
  line-height: var(--leading-snug);
  color: var(--color-text-muted);
}

.surface-dark .lead {
  color: var(--color-on-dark-muted);
}

.text-muted {
  color: var(--color-text-muted);
}

.surface-dark .text-muted {
  color: var(--color-on-dark-muted);
}
