/* Reset, base elements, stage classes, grain overlay. */

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

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: var(--size-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img,
picture,
svg {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

table {
  border-collapse: collapse;
  width: 100%;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.08;
}

.font-tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

/* Stages */
.stage-dark {
  background: var(--ground);
  color: var(--cream);
}

.stage-deepest {
  background: var(--deepest);
  color: var(--cream);
}

.stage-paper {
  background: var(--paper);
  color: var(--paper-ink);
}

/* Grain overlay */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: var(--grain-opacity);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@media (prefers-reduced-motion: reduce) {
  .grain {
    display: none;
  }
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--sand);
  color: var(--deepest);
  padding: var(--space-2) var(--space-3);
  z-index: 1000;
  font-family: var(--font-mono);
  font-size: var(--size-fine);
}

.skip-link:focus {
  left: var(--space-3);
  top: var(--space-3);
}

/* Focus rings */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--sand);
  outline-offset: 2px;
}

/* No-JS: ensure reveal-gated elements are visible */
.no-js .reveal,
.no-js .reveal-fade {
  opacity: 1 !important;
  transform: none !important;
}

.no-js .rail-station {
  opacity: 1 !important;
}

/* Visually hidden but available to assistive tech. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
