/* ============================================================
   Ferrox Labs · site.css
   Editorial Foundry Dark · shared chrome for every page.
   Tokens, grain, skip link, top nav, footer, reveal, hex divider.
   Page-specific rules stay inline on each page and load AFTER
   this sheet, so they win any tie. Source of truth: DESIGN.md.
   ============================================================ */

:root {
  --canvas:        #0a0a0a;
  --canvas-2:      #0d0d0d;
  --surface:       #131313;
  --elevated:      #181818;
  --text:          #ededed;
  --text-bright:   #ffffff;
  --text-muted:    #8a8a8a;
  --text-quiet:    #8f8f8f;
  --text-dim:      #8f8f8f;
  --border:        #1a1a1a;
  --border-strong: #262626;
  --forge:         #ff6b35;
  --forge-soft:    #ff8255;
  --forge-deep:    #c84a1f;
  --gutter: 56px;
  --nav-height: 88px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
*::selection { background: var(--forge); color: var(--canvas); }

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-variation-settings: 'opsz' 16, 'wght' 400;
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  position: relative;
  letter-spacing: -0.005em;
}

/* Atmospheric grain · forge soot */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.03;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

main, header, footer, nav, article { position: relative; z-index: 2; }

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

img { max-width: 100%; height: auto; }

a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--forge);
  outline-offset: 3px;
}

.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;
}

/* ---------- SKIP LINK ---------- */
.skip-link {
  position: absolute;
  top: -100px; left: 16px;
  background: var(--forge);
  color: var(--canvas);
  padding: 12px 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
  border: none;
  z-index: 300;
  transition: top 180ms ease;
  text-decoration: none;
}
.skip-link:focus { top: 12px; color: var(--canvas); }

/* ---------- TOP NAV ---------- */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 10, 0.78);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.topnav-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}
.topnav-brand { display: flex; align-items: center; }
.topnav-brand img { height: 48px; width: auto; display: block; }
.topnav-links { display: flex; align-items: center; gap: 30px; }
.topnav-link {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 180ms ease;
  padding: 8px 2px;   /* padded hit area */
}
.topnav-link:hover { color: var(--text-bright); }
.topnav-cta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--forge);
  background: transparent;
  padding: 9px 17px;
  border: 1px solid var(--forge);
  border-radius: 0;
  transition: background 180ms ease, color 180ms ease;
  text-decoration: none;
  white-space: nowrap;
}
.topnav-cta:hover { background: var(--forge); color: var(--canvas); }

/* ---------- HEX DIVIDER · smithcraft ---------- */
.hex-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  padding: 24px 0;
  color: var(--text-dim);
}
.hex-divider svg { display: block; }

/* ---------- SCROLL REVEAL ----------
   Content is visible at rest in every render mode. The hidden
   state only exists once site.js tags <html class="js">, so
   nothing can ever rest hidden without JS. */
@media (prefers-reduced-motion: no-preference) {
  html.js .reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 700ms ease-out, transform 700ms ease-out;
  }
  html.js .reveal.in-view { opacity: 1; transform: translateY(0); }
}

/* ---------- SITE FOOTER · one canonical implementation ---------- */
footer.site-footer {
  border-top: 1px solid var(--border-strong);
  padding: 64px 0 48px;
}
.site-footer .footer-grid {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 48px;
  flex-wrap: wrap;
}
.site-footer .footer-mark img { height: 44px; width: auto; display: block; opacity: 0.96; }
.site-footer .footer-cols {
  display: flex;
  gap: 48px;
  flex-wrap: wrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: var(--text-muted);
}
.site-footer .footer-col { display: flex; flex-direction: column; gap: 8px; }
.site-footer .footer-col .label {
  color: var(--text-quiet);
  letter-spacing: 0.18em;
  font-size: 10px;
  text-transform: uppercase;
}
.site-footer .footer-col a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: color 200ms ease;
}
.site-footer .footer-col a:hover { color: var(--forge-soft); }
.site-footer .footer-products { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.site-footer .footer-products a { display: inline-flex; align-items: center; gap: 7px; }
.site-footer .footer-products img { width: 17px; height: 17px; display: block; flex: none; }
.site-footer .copy-row {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-quiet);
}

/* ---------- RESPONSIVE CHROME ---------- */
@media (max-width: 880px) {
  :root { --gutter: 24px; --nav-height: 104px; }
  .topnav-brand img { height: 42px; }

  /* MOBILE NAV. This rule used to read `.topnav-link { display: none }`, which left the logo as
     the only way back to anywhere on every page of the site below 880px. Measured at 390px the
     row genuinely cannot hold them: 343px of content width against a 211px brand and a 78px CTA.
     So the links get their own row instead of being deleted.

     `display: contents` dissolves .topnav-links so its five children become flex items of
     .topnav-inner directly. That is what lets the CTA stay up on the brand row while the four
     links wrap below it, without touching the markup on 53 pages. */
  .topnav-inner { flex-wrap: wrap; gap: 4px 16px; }
  .topnav-links { display: contents; }
  .topnav-brand { order: 1; flex: 0 0 auto; }
  .topnav-cta { order: 2; white-space: nowrap; }
  .topnav-link {
    order: 3;
    font-size: 10px;
    letter-spacing: 0.12em;
    white-space: nowrap;
    /* Keeps the tap target at/above the 24px WCAG 2.5.8 minimum. Measured at 16px without it. */
    padding: 4px 0;
  }
  /* Force the links onto their own line however wide the brand renders. */
  .topnav-inner::after { content: ''; order: 2; flex-basis: 100%; height: 0; margin: 0; }
}
@media (max-width: 620px) {
  .site-footer .footer-cols { gap: 28px; }
  .site-footer .copy-row { flex-direction: column; align-items: flex-start; gap: 10px; }
}
@media (max-width: 480px) {
  /* Row gap stays tight here or the two-row mobile nav above grows a sticky 100px tall.
     This block loads after the 880px one, so its shorthand `gap` was silently winning. */
  .topnav-inner { max-width: 100%; padding: 9px 16px; gap: 4px 12px; }
  .topnav-brand { min-width: 0; }
  .topnav-brand img { height: 34px; max-width: 100%; object-fit: contain; object-position: left; }
  .topnav-cta { padding: 8px 12px; font-size: 10px; letter-spacing: 0.14em; }
}

/* Small phones. Without this the brand pushes the CTA onto its own line and the four links wrap
   to two, giving a four-row 144px sticky nav at 320px. Measured, not guessed: at 320 there are
   288px of content width, and the brand alone was 211 of them. */
@media (max-width: 360px) {
  .topnav-brand img { height: 28px; }
  .topnav-inner { gap: 4px 8px; }
  /* padding keeps the tap target >= the 24px WCAG 2.5.8 floor at this size; measured 22px without. */
  .topnav-link { font-size: 9px; letter-spacing: 0.08em; padding: 5px 0; }
  .topnav-cta { padding: 7px 10px; font-size: 9px; letter-spacing: 0.1em; }
}

/* ---------- REDUCED MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
