/* ============================================================
   GLOBAL — reset, drawing-sheet ground, and the shared
   primitives every page uses (nav, panels, buttons, tags,
   footer, focus, motion).

   Load order in every page's <head>:
     variables.css  →  global.css  →  site.css | contact.css
   Loaded as separate <link> tags so they download in parallel.
   ============================================================ */

/* ============================================================
   1. RESET
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

/* Smooth scroll is motion — it must respect the preference. */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* Anchored sections must clear the sticky nav. */
:target,
[id] { scroll-margin-top: calc(var(--nav-height) + var(--space-4)); }

body {
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--t-base);
  line-height: var(--lh-normal);
  color: var(--c-ink-muted);
  background-color: var(--c-void);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis-weight: none;
}

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

a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
}
button { cursor: pointer; background: none; border: none; }

h1, h2, h3, h4 {
  font-weight: 400;
  color: var(--c-ink);
  text-wrap: balance;
}

p { text-wrap: pretty; }

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

/* Inline code — mono is already the data typeface, so this only needs
   to separate the token from the prose around it. */
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--c-rule);
  border-radius: var(--r-xs);
  color: var(--c-ink);
  white-space: nowrap;
}

/* ============================================================
   2. FOCUS
   The old site had no focus styles at all — with underlines
   removed from links, keyboard navigation was invisible.
   ============================================================ */
:focus { outline: none; }

:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

/* Skip link — first tab stop on every page. */
.skip-link {
  position: absolute;
  left: var(--space-2);
  top: var(--space-2);
  z-index: 200;
  padding: 10px 18px;
  background: var(--c-accent);
  color: var(--c-on-accent);
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: var(--track-mono);
  text-transform: uppercase;
  border-radius: var(--r-sm);
  transform: translateY(calc(-100% - var(--space-4)));
  transition: transform var(--dur-fast) var(--ease-out);
}
.skip-link:focus-visible { transform: translateY(0); }

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

/* ============================================================
   3. THE DRAWING SHEET
   Replaces the old cosmic nebula + starfield. A CAD viewport
   grid: 8px minor, 64px major, masked so it fades out down the
   page rather than tiling forever behind the content.
   ============================================================ */
body {
  background-image:
    radial-gradient(ellipse 90% 55% at 50% -12%, var(--c-accent-a06) 0%, transparent 62%);
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.sheet-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(to right,  var(--grid-major) 0 1px, transparent 1px var(--grid-major-size)),
    repeating-linear-gradient(to bottom, var(--grid-major) 0 1px, transparent 1px var(--grid-major-size)),
    repeating-linear-gradient(to right,  var(--grid-minor) 0 1px, transparent 1px var(--grid-minor-size)),
    repeating-linear-gradient(to bottom, var(--grid-minor) 0 1px, transparent 1px var(--grid-minor-size));
  -webkit-mask-image: radial-gradient(ellipse 130% 85% at 50% 0%, #000 26%, transparent 76%);
          mask-image: radial-gradient(ellipse 130% 85% at 50% 0%, #000 26%, transparent 76%);
}

/* Everything that isn't the grid sits above it. */
.site-header,
.site-main,
.site-footer { position: relative; z-index: 10; }

/* ============================================================
   4. LAYOUT
   ============================================================ */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--page-margin);
}

.section { padding-block: var(--section-gap); }

/* A full-bleed hairline that spans the container. */
.rule-line {
  height: 1px;
  background: var(--c-rule);
  border: 0;
}

/* ============================================================
   5. TYPE PRIMITIVES
   ============================================================ */

/* Mono micro-label. The workhorse of the datasheet look:
   used for eyebrows, IDs, dates, tool lists, counts. */
.mono {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  font-weight: 500;
  letter-spacing: var(--track-mono);
  text-transform: uppercase;
  color: var(--c-ink-faint);
  font-variant-numeric: tabular-nums;
}

.mono--accent { color: var(--c-accent); }

/* Section eyebrow: a rule, then a mono label. Reads as a
   drawing-sheet section callout. */
.eyebrow {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  font-weight: 500;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--c-accent);
  margin-bottom: var(--space-3);
}
.eyebrow::before {
  content: '';
  flex-shrink: 0;
  width: 28px;
  height: 1px;
  background: var(--c-accent-a40);
}
.eyebrow::after {
  content: '';
  flex-grow: 1;
  height: 1px;
  background: var(--c-rule);
}

.h-page {
  font-family: var(--font-display);
  font-size: var(--t-3xl);
  line-height: var(--lh-tight);
  letter-spacing: var(--track-display);
}

.h-section {
  font-family: var(--font-display);
  font-size: var(--t-2xl);
  line-height: var(--lh-snug);
  letter-spacing: var(--track-display);
}

.lede {
  font-size: var(--t-lg);
  line-height: var(--lh-loose);
  color: var(--c-ink-muted);
  max-width: var(--measure);
  margin-top: var(--space-2);
}

.prose {
  max-width: var(--measure);
  line-height: var(--lh-loose);
  color: var(--c-ink-muted);
}
.prose > * + * { margin-top: var(--space-2); }
.prose strong { color: var(--c-ink); font-weight: 600; }
.prose a {
  color: var(--c-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.prose a:hover { color: var(--c-accent-bright); }

/* ============================================================
   6. PANEL — the card primitive.
   Near-square corners, hairline border, no glassmorphism blur.
   A panel is a sheet of paper on a drawing board, not glass.
   ============================================================ */
.panel {
  position: relative;
  background: var(--c-surface-2);
  border: 1px solid var(--c-rule);
  border-radius: var(--r-md);
  transition:
    border-color var(--dur-mid) var(--ease-out),
    background-color var(--dur-mid) var(--ease-out),
    transform var(--dur-mid) var(--ease-out);
}

@media (prefers-reduced-motion: no-preference) {
  .panel--interactive:hover { transform: translateY(-3px); }
}

.panel--interactive:hover,
.panel--interactive:focus-within {
  border-color: var(--c-accent-a40);
  background: var(--c-surface-3);
}

/* Registration marks — the small corner ticks found on a
   drawing sheet. Applied to feature panels only; on every
   panel it would become noise. */
.panel--marked::before,
.panel--marked::after {
  content: '';
  position: absolute;
  width: 9px;
  height: 9px;
  border-color: var(--c-accent-a40);
  border-style: solid;
  opacity: 0;
  transition: opacity var(--dur-mid) var(--ease-out);
  pointer-events: none;
}
.panel--marked::before {
  top: -1px; left: -1px;
  border-width: 1px 0 0 1px;
}
.panel--marked::after {
  bottom: -1px; right: -1px;
  border-width: 0 1px 1px 0;
}
.panel--marked:hover::before,
.panel--marked:hover::after,
.panel--marked:focus-within::before,
.panel--marked:focus-within::after { opacity: 1; }

.panel__body { padding: var(--card-padding); }

/* ============================================================
   7. BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 22px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: var(--track-mono);
  text-transform: uppercase;
  white-space: nowrap;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}
.btn svg { flex-shrink: 0; }

.btn--primary {
  background: var(--c-accent);
  color: var(--c-on-accent);
}
.btn--primary:hover { background: var(--c-accent-bright); }
.btn--primary:active { background: var(--c-accent-deep); }

.btn--ghost {
  background: transparent;
  border-color: var(--c-rule-strong);
  color: var(--c-ink);
}
.btn--ghost:hover {
  border-color: var(--c-accent);
  color: var(--c-accent);
  background: var(--c-accent-a06);
}

/* Inline "go" link with a nudging arrow. */
.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: var(--track-mono);
  text-transform: uppercase;
  color: var(--c-accent);
  transition: color var(--dur-fast) var(--ease-out);
}
.link-arrow svg {
  flex-shrink: 0;
  transition: transform var(--dur-fast) var(--ease-out);
}
.link-arrow:hover { color: var(--c-accent-bright); }
@media (prefers-reduced-motion: no-preference) {
  .link-arrow:hover svg { transform: translateX(3px); }
}

/* ============================================================
   8. TAGS & STATUS CHIPS
   ============================================================ */
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-block;
  padding: 4px 9px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--c-rule);
  border-radius: var(--r-xs);
  font-family: var(--font-mono);
  font-size: var(--t-2xs);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--c-ink-faint);
  white-space: nowrap;
}

/* Status chip — teal is reserved for this and nothing else. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-size: var(--t-2xs);
  font-weight: 600;
  letter-spacing: var(--track-mono);
  text-transform: uppercase;
}
.chip::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.chip--live {
  background: var(--c-signal-a12);
  border: 1px solid var(--c-signal-a32);
  color: var(--c-signal);
}
.chip--pending {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--c-rule);
  color: var(--c-ink-faint);
}

/* ============================================================
   9. SITE HEADER / NAV
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--c-void) 88%, transparent);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--c-rule);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  height: var(--nav-height);
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--page-margin);
}

/* Monogram set as a drawing-sheet part number. */
.nav__logo {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--t-sm);
  font-weight: 600;
  letter-spacing: var(--track-mono);
  color: var(--c-ink);
  transition: color var(--dur-fast) var(--ease-out);
}
.nav__logo:hover { color: var(--c-accent); }
.nav__logo span {
  font-size: var(--t-2xs);
  font-weight: 400;
  color: var(--c-ink-faint);
  letter-spacing: var(--track-label);
}

.nav__list {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.nav__link {
  position: relative;
  display: inline-block;
  padding-block: 6px;
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  font-weight: 500;
  letter-spacing: var(--track-mono);
  text-transform: uppercase;
  color: var(--c-ink-faint);
  transition: color var(--dur-fast) var(--ease-out);
}
.nav__link::after {
  content: '';
  position: absolute;
  left: 0; bottom: 0;
  width: 0; height: 1px;
  background: var(--c-accent);
  transition: width var(--dur-mid) var(--ease-out);
}
.nav__link:hover { color: var(--c-ink); }
.nav__link:hover::after { width: 100%; }

.nav__link[aria-current="page"] { color: var(--c-accent); }
.nav__link[aria-current="page"]::after { width: 100%; }

.nav__toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 9px;
  border: 1px solid var(--c-rule);
  border-radius: var(--r-sm);
}
.nav__toggle span {
  display: block;
  width: 100%;
  height: 1.5px;
  background: var(--c-ink);
  border-radius: 2px;
  transition: transform var(--dur-mid) var(--ease-out),
              opacity var(--dur-fast) var(--ease-out);
}
.nav__toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav__toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav__toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

@media (max-width: 860px) {
  .nav__toggle { display: flex; }

  .nav__menu {
    position: fixed;
    inset: var(--nav-height) 0 auto 0;
    display: none;
    padding: var(--space-3) var(--page-margin) var(--space-4);
    background: var(--c-surface-1);
    border-bottom: 1px solid var(--c-rule);
    box-shadow: var(--shadow-lg);
  }
  .nav__menu.is-open { display: block; }

  .nav__list {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }
  .nav__link {
    padding-block: var(--space-2);
    border-bottom: 1px solid var(--c-rule);
    font-size: var(--t-sm);
  }
  .nav__link::after { display: none; }

  /* The CTA moves INTO the menu on mobile rather than
     disappearing, which is what the old site did. */
  .nav__cta-desktop { display: none; }
  .nav__cta-mobile {
    display: flex;
    width: 100%;
    margin-top: var(--space-3);
  }
}

@media (min-width: 861px) {
  .nav__cta-mobile { display: none; }
}

/* ============================================================
   10. FOOTER
   ============================================================ */
.site-footer {
  margin-top: var(--section-gap);
  border-top: 1px solid var(--c-rule);
  padding-block: var(--space-8) var(--space-6);
}

.footer__grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: var(--space-6) var(--space-4);
}

.footer__name {
  font-family: var(--font-display);
  font-size: var(--t-xl);
  color: var(--c-ink);
  line-height: var(--lh-snug);
}

.footer__role {
  margin-top: 6px;
  max-width: 34ch;
  font-size: var(--t-sm);
  color: var(--c-ink-faint);
}

.footer__col-title {
  font-family: var(--font-mono);
  font-size: var(--t-2xs);
  font-weight: 600;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--c-ink-faint);
  margin-bottom: var(--space-2);
}

.footer__links {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer__links a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  font-size: var(--t-sm);
  color: var(--c-ink-muted);
  transition: color var(--dur-fast) var(--ease-out);
}
.footer__links a:hover { color: var(--c-accent); }

.footer__base {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-8);
  padding-top: var(--space-3);
  border-top: 1px solid var(--c-rule);
}

@media (max-width: 720px) {
  .footer__grid { grid-template-columns: 1fr; gap: var(--space-5); }
  .footer__base { justify-content: flex-start; }
}

/* ============================================================
   11. SCROLL ANIMATIONS
   Every animation is gated behind prefers-reduced-motion.
   Stagger is driven by --i set inline on the element, so it
   works for any number of siblings (the old rule only
   handled the first four).
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {
  /* The .js-reveal guard is set by transitions.js as its first
     statement. Without it these elements are never hidden, so a
     failed script request degrades to plain visible content
     rather than a blank page. */
  .js-reveal [data-animate] {
    opacity: 0;
    transform: translateY(20px);
    transition:
      opacity var(--dur-slow) var(--ease-out),
      transform var(--dur-slow) var(--ease-out);
    transition-delay: calc(var(--i, 0) * 70ms);
  }
  .js-reveal [data-animate].is-visible {
    opacity: 1;
    transform: none;
  }

  @keyframes page-in {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
  body.is-loaded .site-main { animation: page-in 380ms var(--ease-out) both; }
}

@media (prefers-reduced-motion: reduce) {
  [data-animate],
  .js-reveal [data-animate] { opacity: 1; transform: none; }
}

/* ============================================================
   12. PRINT — a portfolio gets printed to PDF by recruiters.
   ============================================================ */
@media print {
  .sheet-grid,
  .site-header,
  .skip-link,
  .nav__toggle { display: none !important; }

  body {
    background: #fff;
    color: #000;
  }
  .panel { border: 1px solid #bbb; background: #fff; }
  h1, h2, h3, .footer__name { color: #000; }
  a::after { content: ' (' attr(href) ')'; font-size: 10px; color: #555; }
}
