/* ============================================================
   Stuart Trouton — resume site
   Light editorial: paper, ink, one accent
   ============================================================ */

:root {
  --paper:     #f3f4f1;
  --paper-2:   #e9ebe6;
  --ink:       #191a1c;
  --muted:     #575c61;
  --faint:     #6e7378;
  --rule:      rgba(25, 26, 28, 0.16);
  --rule-soft: rgba(25, 26, 28, 0.09);
  --accent:    #1c4d9e; /* drafting blue, a blueprint nod */

  --maxw: 1080px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", system-ui, sans-serif;
}

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

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Faint engineering grid over the paper */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--rule-soft) 1px, transparent 1px),
    linear-gradient(to bottom, var(--rule-soft) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.35;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0,0,0,0.35) 40%, rgba(0,0,0,0.15) 100%);
  mask-image: linear-gradient(180deg, #000 0%, rgba(0,0,0,0.35) 40%, rgba(0,0,0,0.15) 100%);
}

main, .nav, .footer, .thread { position: relative; z-index: 1; }

/* Typography helpers ---------------------------------------------- */
.kicker-style,
.section__kicker,
.feature__badge,
.tl__years,
.writing__meta {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

em { font-style: italic; }

/* Buttons --------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.8rem 1.5rem;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.92rem;
  text-decoration: none;
  border-radius: 3px;
  border: 1px solid var(--ink);
  transition: background 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.btn--primary {
  background: var(--ink);
  color: var(--paper);
}
.btn--primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--ghost {
  background: transparent;
  color: var(--ink);
}
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }

/* Nav ------------------------------------------------------------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem clamp(1.2rem, 4vw, 3rem);
  z-index: 90;
  transition: background 0.35s var(--ease), border-color 0.35s var(--ease), padding 0.35s var(--ease);
  border-bottom: 1px solid transparent;
}
.nav.is-scrolled {
  background: rgba(247, 245, 240, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom-color: var(--rule);
  padding-top: 0.75rem; padding-bottom: 0.75rem;
}
.nav__brand {
  display: flex; align-items: center; gap: 0.6rem;
  text-decoration: none; color: var(--ink);
  font-family: var(--font-display); font-weight: 600; font-size: 1.05rem;
}
.nav__mark { width: 9px; height: 9px; background: var(--accent); }
.nav__links { display: flex; align-items: center; gap: 1.7rem; }
.nav__links a {
  color: var(--muted); text-decoration: none;
  font-size: 0.9rem; font-weight: 500;
  transition: color 0.25s; position: relative;
}
.nav__links a:not(.nav__cta)::after {
  content: ""; position: absolute; left: 0; bottom: -5px; height: 1px; width: 0;
  background: var(--accent); transition: width 0.3s var(--ease);
}
.nav__links a:hover { color: var(--ink); }
.nav__links a:not(.nav__cta):hover::after { width: 100%; }
.nav__cta {
  padding: 0.45rem 1.05rem;
  border: 1px solid var(--ink); border-radius: 3px;
  color: var(--ink) !important;
}
.nav__cta:hover { border-color: var(--accent); color: var(--accent) !important; }

.nav__toggle { display: none; flex-direction: column; gap: 5px; background: none; border: 0; cursor: pointer; padding: 6px; }
.nav__toggle span { width: 24px; height: 2px; background: var(--ink); transition: 0.3s var(--ease); }
.nav__toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav__toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav__toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Hero ------------------------------------------------------------ */
.hero {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(8rem, 16vh, 12rem) clamp(1.2rem, 4vw, 3rem) clamp(3rem, 6vh, 5rem);
  display: grid;
  grid-template-columns: 1.5fr 0.8fr;
  align-items: start;
  gap: clamp(2rem, 5vw, 5rem);
}
.hero__title {
  font-family: var(--font-display);
  font-weight: 560;
  font-size: clamp(2.1rem, 5vw, 3.6rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin-bottom: 1.8rem;
}
.hero__title em { color: var(--accent); font-weight: 500; }
.hero__lede {
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.12rem);
  max-width: 52ch;
  margin-bottom: 2.4rem;
}
.hero__lede strong { color: var(--ink); font-weight: 600; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 0.9rem; margin-bottom: 3.5rem; }

.hero__stats {
  list-style: none;
  display: flex; flex-wrap: wrap;
  gap: clamp(1.5rem, 4vw, 3.5rem);
  border-top: 1px solid var(--rule);
  padding-top: 1.5rem;
}
.hero__stats li { display: flex; flex-direction: column; }
.stat__num {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.7rem, 2.8vw, 2.3rem);
  line-height: 1;
}
.stat__label { font-size: 0.8rem; color: var(--faint); margin-top: 0.45rem; max-width: 16ch; }

/* Portrait */
.hero__portrait { display: flex; justify-content: center; padding-top: 1rem; }
.portrait { position: relative; width: min(300px, 68vw); }
.portrait img {
  display: block;
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border: 1px solid var(--rule);
}
.portrait::before {
  content: "";
  position: absolute; top: 12px; left: 12px; right: -12px;
  aspect-ratio: 1;
  border: 1px solid var(--accent);
  z-index: -1;
}
.portrait__tag {
  margin-top: 1.1rem;
  font-size: 0.82rem; color: var(--muted); text-align: center;
}

/* Ticker ----------------------------------------------------------- */
.marquee {
  overflow: hidden;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: var(--paper-2);
  padding: 0.85rem 0;
}
.marquee__track {
  display: flex; align-items: center;
  white-space: nowrap; width: max-content;
  animation: marquee 44s linear infinite;
}
.marquee__track span {
  margin-right: 2.2rem;
  font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted);
}
.marquee__track span[aria-hidden] { color: var(--accent); }
@keyframes marquee { to { transform: translateX(-50%); } }

/* Sections -------------------------------------------------------- */
.section { max-width: var(--maxw); margin: 0 auto; padding: clamp(4.5rem, 10vh, 7.5rem) clamp(1.2rem, 4vw, 3rem); }
.section--alt { position: relative; }
.section--alt::before {
  content: ""; position: absolute; inset: 0 -50vw; z-index: -1;
  background: var(--paper-2);
  border-top: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule-soft);
}
.section__head { max-width: 720px; margin-bottom: 3.5rem; }
.section__kicker {
  display: inline-flex; align-items: center; gap: 0.7rem;
  margin-bottom: 1.2rem;
}
.section__kicker::before {
  content: ""; width: 2rem; height: 1px; background: var(--accent);
}
.section__title {
  font-family: var(--font-display); font-weight: 560;
  font-size: clamp(2rem, 4.5vw, 3.1rem);
  line-height: 1.06; letter-spacing: -0.01em;
  margin-bottom: 1.1rem;
}
.section__sub { color: var(--muted); font-size: clamp(1rem, 1.3vw, 1.08rem); }

/* Trademark note --------------------------------------------------- */
.cascade__tm { margin-top: 0.8rem; font-size: 0.72rem; color: var(--faint); }

/* Featured work entries -------------------------------------------- */
.feature {
  border-top: 1px solid var(--rule);
  padding: 2.2rem 0 2.6rem;
}
.feature:last-of-type { border-bottom: 1px solid var(--rule); }
.feature__meta { margin-bottom: 0.9rem; }
.feature__badge { display: block; color: var(--accent); margin-bottom: 0.6rem; }
.feature__title {
  font-family: var(--font-display); font-weight: 560;
  font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -0.01em;
}
.feature__body { color: var(--muted); font-size: clamp(0.98rem, 1.3vw, 1.05rem); max-width: 70ch; }
.feature__body strong { color: var(--ink); font-weight: 600; }
.feature__tags {
  margin-top: 1.1rem;
  font-size: 0.82rem; color: var(--faint);
  letter-spacing: 0.02em;
}
.feature__diagram { margin-top: 1.8rem; max-width: 600px; color: var(--ink); }
.feature__diagram svg { display: block; width: 100%; height: auto; }
.diagram__node { fill: var(--paper); stroke: var(--ink); stroke-width: 1.5; }
.diagram__node--accent { fill: var(--accent); stroke: var(--accent); }
.diagram__label {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  fill: var(--muted);
}
.diagram__label--accent { fill: var(--accent); }
.diagram__box { fill: var(--paper); stroke: var(--ink); stroke-width: 1.25; }
.diagram__stroke--accent { stroke: var(--accent); fill: none; }

/* Diagram animation (initial states only when JS is present) */
.js .diagram__draw { stroke-dasharray: 1; stroke-dashoffset: 1; }
.feature__diagram.is-visible .diagram__draw {
  animation: diagramDraw 0.7s var(--ease) forwards;
  animation-delay: var(--d, 0s);
}
@keyframes diagramDraw { to { stroke-dashoffset: 0; } }

.js .diagram__pop { transform: scale(0); transform-box: fill-box; transform-origin: center; }
.feature__diagram.is-visible .diagram__pop {
  animation: diagramPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  animation-delay: var(--d, 0s);
}
@keyframes diagramPop { to { transform: scale(1); } }

.js .diagram__fade { opacity: 0; }
.feature__diagram.is-visible .diagram__fade {
  animation: diagramFade 0.6s ease forwards;
  animation-delay: var(--d, 0s);
}
@keyframes diagramFade { to { opacity: 1; } }

.feature__diagram.is-visible .diagram__flow { animation: diagramFlow 1.6s linear infinite; }
@keyframes diagramFlow { to { stroke-dashoffset: -14; } }

/* Timeline -------------------------------------------------------- */
.timeline { list-style: none; position: relative; margin-left: 0.25rem; padding-left: 2rem; }
.timeline::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 1px;
  background: var(--rule);
}
.tl { position: relative; padding-bottom: 2.6rem; }
.tl:last-child { padding-bottom: 0; }
.tl__dot {
  position: absolute; left: calc(-2rem - 4px); top: 7px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--paper); border: 1.5px solid var(--accent);
}
.tl__years { display: block; color: var(--accent); margin-bottom: 0.45rem; }
.tl h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; }
.tl__role { color: var(--ink); font-weight: 500; font-size: 0.95rem; margin-bottom: 0.5rem; }
.tl p:not(.tl__role) { color: var(--muted); font-size: 0.92rem; max-width: 62ch; }

.tl__highlights { list-style: none; margin-top: 0.7rem; display: flex; flex-direction: column; gap: 0.45rem; }
.tl__highlights li {
  position: relative; padding-left: 1.1rem;
  font-size: 0.9rem; color: var(--muted); line-height: 1.5; max-width: 62ch;
}
.tl__highlights li::before {
  content: ""; position: absolute; left: 0; top: 0.6em;
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent); opacity: 0.75;
}

/* Toolkit lists ---------------------------------------------------- */
.chips-wrap { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(2rem, 4vw, 3.5rem); }
.chips-group__title {
  font-family: var(--font-body);
  font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.1rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--rule);
}
.chips { list-style: none; }
.chips li {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--rule-soft);
  font-size: 0.92rem;
}
.chips li:last-child { border-bottom: 0; }

/* Writing --------------------------------------------------------- */
.writing { list-style: none; }
.writing li {
  border-top: 1px solid var(--rule);
  padding: 1.6rem 0;
}
.writing li:last-child { border-bottom: 1px solid var(--rule); }
.writing__meta { display: block; color: var(--accent); margin-bottom: 0.5rem; }
.writing h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; margin-bottom: 0.4rem; }
.writing p { color: var(--muted); font-size: 0.92rem; max-width: 62ch; }

/* Contact --------------------------------------------------------- */
.contact { text-align: center; }
.contact__inner { max-width: 680px; margin: 0 auto; }
.contact__inner .section__kicker { justify-content: center; }
.contact__title {
  font-family: var(--font-display); font-weight: 560;
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  line-height: 1.05; margin: 1rem 0 1.2rem; letter-spacing: -0.01em;
}
.contact__title em { color: var(--accent); }
.contact__sub { color: var(--muted); font-size: 1.08rem; margin-bottom: 2.2rem; }
.contact__actions { display: flex; flex-wrap: wrap; gap: 0.9rem; justify-content: center; }

/* Footer ---------------------------------------------------------- */
.footer {
  max-width: var(--maxw); margin: 0 auto;
  padding: 2.2rem clamp(1.2rem, 4vw, 3rem);
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.82rem; color: var(--muted);
}
.footer__note { color: var(--faint); }

/* Responsive ------------------------------------------------------ */
@media (max-width: 900px) {
  .nav__links {
    position: fixed; inset: 0 0 auto 0; top: 0;
    flex-direction: column; align-items: flex-start; gap: 1.2rem;
    padding: 5.5rem 2rem 2.5rem;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    transform: translateY(-100%); transition: transform 0.45s var(--ease); pointer-events: none;
  }
  .nav__links.is-open { transform: translateY(0); pointer-events: auto; }
  .nav__toggle { display: flex; z-index: 95; }

  .hero { grid-template-columns: 1fr; padding-top: 7.5rem; }
  .hero__portrait { order: -1; justify-content: flex-start; padding-top: 0; }
  .portrait { width: min(200px, 52vw); }

  .chips-wrap { grid-template-columns: 1fr; gap: 1.8rem; }
}

@media (max-width: 560px) {
  .hero__stats { gap: 1.4rem; }
  .footer { flex-direction: column; align-items: flex-start; }
  .thread { padding-left: 0.8rem; padding-right: 0.8rem; }
}
