/* ============================================================
   NEARWIT — Blueprint & Workshop design system
   Core: tokens, base, drafting primitives, nav, footer, motion
   ============================================================ */

:root {
  /* Ink (page) surfaces */
  --ink-950: oklch(15% 0.03 262);
  --ink-900: oklch(18.5% 0.033 262);
  --ink-850: oklch(22% 0.035 262);
  --ink-800: oklch(26% 0.037 262);

  /* Drafting linework */
  --line: oklch(82% 0.05 250 / 0.13);
  --line-strong: oklch(85% 0.05 250 / 0.32);
  --grid: oklch(82% 0.05 250 / 0.055);

  /* Text */
  --text: oklch(96% 0.006 250);
  --text-2: oklch(81% 0.022 255);
  --text-3: oklch(70% 0.03 258);

  /* Accents */
  --blue: oklch(62% 0.19 262);
  --blue-bright: oklch(72% 0.15 258);
  --cyan: oklch(80% 0.10 230);
  --amber: oklch(82% 0.14 80);

  /* Drawing-sheet (paper) surfaces */
  --paper: oklch(95% 0.008 255);
  --paper-2: oklch(90% 0.012 255);
  --paper-ink: oklch(24% 0.03 262);
  --paper-line: oklch(24% 0.03 262 / 0.18);

  /* Type */
  --font-sans: "Archivo", system-ui, sans-serif;
  --font-mono: "Martian Mono", ui-monospace, monospace;

  /* Rhythm */
  --space-section: clamp(6rem, 12vw, 10rem);
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --measure: 66ch;

  /* Z scale */
  --z-nav: 100;
  --z-menu: 110;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Base ---------- */

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink-950);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

/* Blueprint grid over the whole page */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 56px 56px;
  z-index: 0;
}

main { position: relative; z-index: 1; }

h1, h2, h3, h4 {
  font-weight: 750;
  line-height: 1.08;
  letter-spacing: -0.025em;
  margin: 0 0 0.6em;
  text-wrap: balance;
}

p { margin: 0 0 1em; max-width: var(--measure); text-wrap: pretty; }

a { color: var(--blue-bright); text-decoration: none; }
a:hover { color: var(--cyan); }

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

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

::selection { background: var(--blue); color: var(--text); }

.container {
  width: min(1180px, 100% - 2 * var(--gutter));
  margin-inline: auto;
}

.section { padding-block: var(--space-section); position: relative; }

/* ---------- Drafting primitives ---------- */

/* Sheet reference label — the ONE brand kicker system:
   mono, with tick rules either side, like a drawing title strip */
.sheet-ref {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 2.2rem;
}
.sheet-ref::before,
.sheet-ref::after {
  content: "";
  height: 1px;
  background: var(--line-strong);
  flex: 0 0 2.2rem;
  position: relative;
}
.sheet-ref::after { flex: 1; }
.sheet-ref b { font-weight: 700; color: var(--text); }

/* Dimension-line divider between sections */
.dim-divider {
  position: relative;
  height: 1px;
  background: var(--line);
  margin-block: 0;
}
.dim-divider::before,
.dim-divider::after {
  content: "";
  position: absolute;
  top: -5px;
  width: 1px;
  height: 11px;
  background: var(--line-strong);
}
.dim-divider::before { left: var(--gutter); }
.dim-divider::after { right: var(--gutter); }

/* Crosshair registration mark */
.crosshair {
  position: absolute;
  width: 22px;
  height: 22px;
  pointer-events: none;
  opacity: 0.55;
}
.crosshair::before,
.crosshair::after {
  content: "";
  position: absolute;
  background: var(--line-strong);
}
.crosshair::before { left: 50%; top: 0; width: 1px; height: 100%; }
.crosshair::after { top: 50%; left: 0; height: 1px; width: 100%; }

/* Display + heading scale */
.display {
  font-size: clamp(2.7rem, 6.4vw, 5.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.02;
}
.h-section {
  font-size: clamp(1.9rem, 4vw, 3rem);
  font-weight: 780;
}
.lede {
  font-size: clamp(1.1rem, 1.6vw, 1.3rem);
  color: var(--text-2);
  line-height: 1.6;
}

.mono-note {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--text-3);
}

.accent { color: var(--blue-bright); }
.accent-amber { color: var(--amber); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.95rem 1.6rem;
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: border-color 0.25s var(--ease-out), background 0.25s var(--ease-out), color 0.25s var(--ease-out);
}
.btn .btn-tick { color: var(--amber); transition: transform 0.3s var(--ease-out); }
.btn:hover { border-color: var(--cyan); color: var(--text); background: oklch(80% 0.10 230 / 0.06); }
.btn:hover .btn-tick { transform: translateX(4px); }

.btn--solid {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--text);
}
.btn--solid:hover {
  background: var(--blue-bright);
  border-color: var(--blue-bright);
  color: var(--ink-950);
}

/* ---------- Nav ---------- */

.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: var(--z-nav);
  background: oklch(15% 0.03 262 / 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  font-weight: 800;
  font-size: 1.28rem;
  letter-spacing: -0.03em;
}
.brand:hover { color: var(--text); }
.brand .wit { color: var(--blue-bright); }

.nav-links {
  display: flex;
  align-items: center;
  gap: clamp(1.2rem, 2.5vw, 2.2rem);
  list-style: none;
  margin: 0; padding: 0;
}
.nav-links a {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
  padding-block: 0.4rem;
  border-bottom: 1px solid transparent;
}
.nav-links a:hover { color: var(--text); }
.nav-links a[aria-current="page"] {
  color: var(--amber);
  border-bottom-color: var(--amber);
}
.nav-links .nav-cta {
  border: 1px solid var(--line-strong);
  padding: 0.55rem 1rem;
  color: var(--text);
}
.nav-links .nav-cta:hover { border-color: var(--cyan); }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line-strong);
  color: var(--text);
  width: 44px; height: 44px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

@media (max-width: 780px) {
  .nav-toggle { display: grid; place-items: center; }
  .nav-links {
    position: fixed;
    top: 68px; left: 0; right: 0;
    z-index: var(--z-menu);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--ink-900);
    border-bottom: 1px solid var(--line-strong);
    padding: 0.5rem var(--gutter) 1.2rem;
    display: none;
  }
  .nav-links.is-open { display: flex; }
  .nav-links a { padding: 0.9rem 0; font-size: 0.85rem; border-bottom: 1px solid var(--line); }
  .nav-links .nav-cta { border: none; padding: 0.9rem 0; color: var(--amber); }
}

/* Offset for fixed nav on anchor jumps */
[id] { scroll-margin-top: 90px; }

/* ---------- Page header (inner pages) ---------- */

.page-head {
  padding-top: clamp(9rem, 16vw, 13rem);
  padding-bottom: clamp(3.5rem, 7vw, 6rem);
  position: relative;
}
.page-head .display { max-width: 16ch; }
.page-head .lede { max-width: 56ch; margin-top: 1.4rem; }

/* ---------- CTA band ---------- */

.cta-band {
  border-block: 1px solid var(--line-strong);
  background:
    radial-gradient(60% 120% at 80% 50%, oklch(62% 0.19 262 / 0.14), transparent 70%),
    var(--ink-900);
  padding-block: clamp(4rem, 8vw, 6.5rem);
  position: relative;
  overflow: clip;
}
.cta-band .h-section { max-width: 20ch; }
.cta-band-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2.5rem;
}

/* ---------- Footer: engineering title block ---------- */

.footer {
  border-top: 1px solid var(--line-strong);
  background: var(--ink-900);
  position: relative;
  z-index: 1;
}
.titleblock {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  border-inline: 1px solid var(--line);
}
.titleblock > div {
  padding: 1.4rem 1.5rem 1.5rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.titleblock .tb-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0.5rem;
}
.titleblock .tb-value { font-weight: 600; font-size: 0.95rem; color: var(--text); }
.titleblock .tb-value a { color: var(--text); border-bottom: 1px solid var(--line-strong); }
.titleblock .tb-value a:hover { color: var(--cyan); border-bottom-color: var(--cyan); }

.footer-base {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: center;
  justify-content: space-between;
  padding-block: 1.3rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--text-3);
}
.footer-base nav { display: flex; gap: 1.4rem; flex-wrap: wrap; }
.footer-base a { color: var(--text-3); text-transform: uppercase; }
.footer-base a:hover { color: var(--text); }

/* ---------- Motion ---------- */

/* Rise-in: JS adds .pre at init, removes on intersect.
   Without JS nothing is hidden. */
.pre {
  opacity: 0;
  transform: translateY(26px);
}
.rise {
  transition: opacity 0.8s var(--ease-out), transform 0.9s var(--ease-out);
  transition-delay: var(--d, 0s);
}

/* SVG plotter draw-in: JS measures path length and sets dasharray;
   .drawn triggers the sweep. Default state = fully drawn. */
.draw path, .draw line, .draw circle, .draw rect, .draw polyline {
  transition: stroke-dashoffset 1.6s var(--ease-out);
  transition-delay: var(--d, 0s);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .pre { opacity: 1; transform: none; }
  .rise, .draw path, .draw line, .draw circle, .draw rect, .draw polyline {
    transition: none !important;
    animation: none !important;
  }
  .spin, .sweep, .blink { animation: none !important; }
}

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 26s linear infinite; transform-origin: center; }

@keyframes blink { 50% { opacity: 0; } }
.blink { animation: blink 1.2s steps(1) infinite; }

@media print {
  body::before { display: none; }
  .nav, .cta-band { display: none; }
}
