/* ==========================================================
   Jesse Becker - Personal Site  |  base.css
   Reset, document typography, layout primitives, the paper
   grain overlay, and the accessibility layer.
   Depends on: tokens.css
   ========================================================== */

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.6;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--dur-mid) var(--ease-out),
              color var(--dur-mid) var(--ease-out);
}

/* Paper grain. Fixed overlay above the page, below dialogs.
   Replaces the old blurred-orb background entirely. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: var(--grain-opacity);
  filter: invert(var(--grain-invert));
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.55 0'/></filter><rect width='220' height='220' filter='url(%23n)'/></svg>");
}

a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 560;
  line-height: 1.15;
  letter-spacing: -.02em;
  color: var(--ink);
}

p { color: var(--ink-soft); line-height: 1.7; }

::selection { background: var(--accent); color: var(--on-accent); }

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

.container {
  position: relative;
  z-index: 1;
  max-width: var(--container-w);
  margin: 0 auto;
  padding: 0 var(--sp-6);
}

.section { padding: var(--sp-12) 0; }
.section-alt { background: var(--surface-sunken); }

/* Anchor targets clear the sticky navbar */
#projects,
#main,
.project-card[id] {
  scroll-margin-top: calc(var(--nav-h) + var(--sp-4));
}

/* -- Section headings -------------------------------------- */

.section-head {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  margin-bottom: var(--sp-8);
}

.section-num {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--accent-deep);
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  font-weight: 560;
  letter-spacing: -.02em;
}

.section-rule { flex: 1; height: 1px; background: var(--hairline); }

.section-subtitle {
  max-width: 60ch;
  font-size: var(--fs-base);
  color: var(--ink-soft);
}

/* When a subtitle follows the rule, it needs breathing room
   above the content it introduces. */
.section-head + .section-subtitle { margin: calc(var(--sp-8) * -1 + var(--sp-2)) 0 var(--sp-8); }

.section-note {
  max-width: 60ch;
  margin-top: var(--sp-4);
  font-size: var(--fs-xs);
  font-style: italic;
  color: var(--ink-faint);
}

/* Centred variant, used where a section header sits alone */
.section-header { margin-bottom: var(--sp-8); }
.section-header .section-subtitle { margin-inline: 0; }

.section-label {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.section-label::before {
  content: "";
  width: 2.5rem;
  height: 1px;
  background: var(--accent);
}

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

.u-serif { font-family: var(--font-display); }
.u-italic { font-style: italic; }
.u-accent { color: var(--accent-deep); }

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

/* ==========================================================
   Accessibility
   ========================================================== */

.skip-link {
  position: fixed;
  top: var(--sp-2);
  left: 50%;
  z-index: 300;
  transform: translateX(-50%) translateY(-150%);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--bg);
  font-size: var(--fs-sm);
  font-weight: 600;
  box-shadow: var(--shadow-lift);
  transition: transform var(--dur-fast) var(--ease-out);
}

.skip-link:focus { transform: translateX(-50%) translateY(0); }

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

/* ==========================================================
   Reduced motion
   Strips the decorative layer: grain, paper stacks, page tilt,
   entrance animations, and smooth scrolling.
   ========================================================== */

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

  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }

  body::after { display: none; }

  .stack::before,
  .stack::after { display: none; }

  .reveal { opacity: 1 !important; transform: none !important; }
}
