/* ============================================================
   justinchatfield.com: Design System
   Single stylesheet. Mobile-first. No frameworks.
   ============================================================ */

/* ── Fonts ─────────────────────────────────────────────────── */
/* Loaded from the HTML head (preconnect + link), not @import, so the
   browser can fetch fonts in parallel with this stylesheet. */

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
  /* Colour */
  --ink:          #141414;
  --paper:        #FAFAF7;
  --yellow:       #FFD400;
  --yellow-dark:  #E6BF00;
  --grey:         #6B6B6B;
  --white:        #FFFFFF;
  --line:         rgba(20, 20, 20, 0.12);

  /* Type */
  --font-head: 'Archivo', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;

  /* Spacing */
  --section-y:      120px;
  --section-y-sm:    72px;
  --max-w:         1100px;
  --gutter:          24px;
  --gap:             32px;

  /* UI */
  --radius:    6px;
  --ease:      0.2s ease;
  --nav-h:     64px;
}

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

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

img, svg, video { display: block; max-width: 100%; }
a { color: inherit; }
ul, ol { list-style: none; }
button { font-family: inherit; }

/* ── Layout ─────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

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

@media (max-width: 768px) {
  .section { padding-block: var(--section-y-sm); }
}

/* ── Typography ─────────────────────────────────────────────── */
.eyebrow {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--grey);
  display: block;
  margin-bottom: 16px;
}

h1, .h1 {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: clamp(2.8rem, 6vw, 5rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ink);
}

h2, .h2 {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--ink);
}

h3, .h3 {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(1.3rem, 2.5vw, 1.8rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.sub-headline {
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  font-weight: 400;
  color: var(--grey);
  line-height: 1.5;
}

p { line-height: 1.7; }

/* ── Logo mark ──────────────────────────────────────────────── */
/* Full name in Archivo Black, uppercase. Cream on the dark nav and
   footer. No box, no yellow (per DESIGN.md the logo stays monochrome). */
.logo {
  font-family: 'Archivo Black', var(--font-head);
  font-weight: 400;
  font-style: normal;
  text-transform: uppercase;
  font-size: 1.05rem;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--paper);
  text-decoration: none;
  white-space: nowrap;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  padding: 14px 28px;
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  border: 2px solid transparent;
  transition:
    background  var(--ease),
    color       var(--ease),
    border-color var(--ease),
    transform   var(--ease);
  white-space: nowrap;
  line-height: 1;
}

.btn-arrow::after {
  content: '→';
  transition: transform var(--ease);
}
.btn-arrow:hover::after {
  transform: translateX(3px);
}

/* Primary */
.btn-primary {
  background: var(--yellow);
  color: var(--ink);
  border-color: var(--yellow);
}
.btn-primary:hover {
  background: var(--yellow-dark);
  border-color: var(--yellow-dark);
  transform: translateY(-1px);
}

/* Secondary */
.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}
.btn-secondary:hover {
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-1px);
}

/* Secondary on dark backgrounds */
.btn-secondary-light {
  background: transparent;
  color: var(--paper);
  border-color: var(--paper);
}
.btn-secondary-light:hover {
  background: var(--paper);
  color: var(--ink);
  transform: translateY(-1px);
}

/* ── Highlighter, OPTION A: SVG (RECOMMENDED) ──────────────
   A hand-drawn yellow marker stroke sits behind key words.
   The SVG path has deliberately irregular top/bottom edges
   and overshoots the text at both ends.
   Uses preserveAspectRatio="none" so it stretches to any
   text width without breaking the layout.
   ─────────────────────────────────────────────────────────── */
.highlight {
  position: relative;
  /* inline-block gives the span a single box even if the surrounding sentence
     wraps, the ::before always covers the full highlighted text, not just
     the first line's inline fragment */
  display: inline-block;
  isolation: isolate;
}

/* Text wrapper, sits above the swipe in the local stacking context */
.highlight__text {
  position: relative;
  display: inline;
  z-index: 1;
}

.highlight::before {
  content: '';
  position: absolute;
  /* Overshoot left and right of text */
  left:  -6px;
  right: -6px;
  /* Vertically centred, covering ~65% of line height */
  top: 50%;
  height: 68%;
  transform: translateY(-48%) rotate(-1.5deg);
  /* z-index:0 keeps the swipe above the section background but below
     .highlight__text (z-index:1), all contained by the isolation layer */
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 500 40' preserveAspectRatio='none'%3E%3Cpath d='M -3,8 C 30,5 80,7 140,6 C 200,5 260,8 320,6 C 370,5 430,7 503,7 L 503,31 C 430,34 370,31 320,33 C 260,35 200,32 140,33 C 80,32 30,34 -3,31 Z' fill='%23FFD400' opacity='0.78'/%3E%3C/svg%3E");
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

/* ── Highlighter, OPTION B: CSS only ───────────────────────
   Irregular border-radius + skew approximates hand-drawn feel.
   No SVG dependency. Simpler but less authentically rough.
   ─────────────────────────────────────────────────────────── */
.highlight-css {
  position: relative;
  display: inline-block;
  isolation: isolate;
}

.highlight-css__text {
  position: relative;
  display: inline;
  z-index: 1;
}

.highlight-css::before {
  content: '';
  position: absolute;
  left:  -5px;
  right: -5px;
  top: 50%;
  height: 65%;
  transform: translateY(-48%) rotate(-1.5deg) skewX(-1.5deg);
  z-index: 0;
  background: var(--yellow);
  opacity: 0.85;
  /* Deliberately asymmetric radius to feel imperfect */
  border-radius: 2px 4px 3px 2px / 4px 2px 5px 3px;
}

/* ── Scroll reveal ───────────────────────────────────────────
   Elements with .reveal fade + rise in when they enter
   the viewport. Runs once. JS hooks .visible onto them.
   Disabled when prefers-reduced-motion is set.
   ─────────────────────────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.reveal.visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ── Nav ─────────────────────────────────────────────────────
   Sticky. --ink background. Shadow appears on scroll (JS
   adds .scrolled). Mobile: MENU button opens a full-screen overlay.
   ─────────────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--ink);
  height: var(--nav-h);
  display: flex;
  align-items: center;
  transition: box-shadow var(--ease);
}
.nav.scrolled {
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.22);
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 28px;
}
.nav__links a {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--paper);
  text-decoration: none;
  transition: color var(--ease);
  letter-spacing: 0.01em;
}
.nav__links a:hover { color: var(--white); }

/* Nav CTA button (compact, in nav) */
.nav__cta {
  padding: 9px 20px;
  font-size: 0.9rem;
}
/* Keep ink text + ink arrow on the yellow fill. `.nav__links a` sets cream
   on nav links and would otherwise win on specificity, dropping white text
   onto yellow (fails contrast). DESIGN.md: the yellow CTA uses ink, never
   white. Cover :hover too so it does not flip to white on hover. */
.nav__links a.nav__cta,
.nav__links a.nav__cta:hover {
  color: var(--ink);
}

/* MENU toggle button (mobile only). Boxed chip: cream outline, no fill.
   Label toggles Menu/Close in JS. */
.nav__toggle {
  display: none;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--paper);
  background: none;
  border: 1.5px solid currentColor;
  border-radius: var(--radius);
  padding: 8px 14px;
  line-height: 1;
  cursor: pointer;
  transition: opacity var(--ease);
}
.nav__toggle:hover { opacity: 0.8; }

/* Full-screen mobile overlay. Sits at z 90, just below the sticky nav
   (z 100), so the MENU/Close button stays visible and tappable above it.
   Both surfaces are --ink, so the seam is invisible. */
.nav__overlay {
  position: fixed;
  inset: 0;
  background: var(--ink);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--nav-h) var(--gutter) 40px;
  overflow-y: auto;
  /* Hidden by default. JS adds .open */
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.nav__overlay.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.nav__overlay-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}
.nav__overlay-link {
  position: relative;
  font-family: 'Archivo Black', var(--font-head);
  font-weight: 400;
  font-size: clamp(2rem, 9vw, 3.25rem);
  color: var(--paper);
  text-decoration: none;
  letter-spacing: -0.02em;
  line-height: 1;
  transition: color var(--ease);
}
.nav__overlay-link:hover { color: var(--white); }
/* The pattern break: the single yellow square marks the active item. */
.nav__overlay-link--active::before {
  content: "";
  display: inline-block;
  width: 0.5em;
  height: 0.5em;
  margin-right: 0.4em;
  background: var(--yellow);
  vertical-align: 0.08em;
}
.nav__overlay-cta {
  margin-top: 12px;
  font-size: 1rem;
  padding: 12px 26px;
}

@media (max-width: 860px) {
  .nav__links  { display: none; }
  .nav__toggle { display: inline-block; }
  /* Logo name swap: Justin by default, Chatfield while the overlay is open. */
  .logo__chatfield { display: none; }
  body.menu-open .logo__justin    { display: none; }
  body.menu-open .logo__chatfield { display: inline; }
}

/* Lock page scroll while the overlay is open. */
body.menu-open { overflow: hidden; }

/* ── Footer ──────────────────────────────────────────────────
   --ink background. Three-column: logo / nav links / contact.
   Stacks to single column on mobile.
   ─────────────────────────────────────────────────────────── */
.footer {
  background: var(--ink);
  color: var(--paper);
  border-top: 1px solid var(--line);
  padding-top: 56px;
  padding-bottom: 32px;
}

.footer__main {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: var(--gap);
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: var(--gutter);
  padding-bottom: 40px;
}

.footer__nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.footer__nav a {
  font-size: 0.88rem;
  color: rgba(250, 250, 247, 0.6);
  text-decoration: none;
  transition: color var(--ease);
}
.footer__nav a:hover { color: var(--paper); }

.footer__contact {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.footer__contact a {
  font-size: 0.88rem;
  color: rgba(250, 250, 247, 0.6);
  text-decoration: none;
  transition: color var(--ease);
}
.footer__contact a:hover { color: var(--paper); }

.footer__bottom {
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: var(--gutter);
  padding-top: 24px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: center;
  font-size: 0.78rem;
  color: rgba(250, 250, 247, 0.35);
  letter-spacing: 0.02em;
}

@media (max-width: 768px) {
  .footer__main {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .footer__nav     { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 14px; }
  .footer__contact { align-items: center; }
}
