/* Minborg — light, print-influenced. Plain CSS, no build step.
   Order: tokens, base, layout, header, hero, components, bands, rail,
   scene, motion, utilities, media. One print block, one reduced-motion block. */

:root {
  color-scheme: light;

  --paper:      #ffffff;
  --ink:        #15181c;   /* body text */
  --ink-soft:   #4d545e;   /* secondary prose */
  --ink-faint:  #6b737d;   /* labels, footnotes: 5:1 on white, safe for small text */
  --line:       #e4e7ea;
  --line-soft:  #eef0f2;
  --tint:       #f2f4ee;   /* brand-tinted neutral band */
  --tint-line:  #e6eadf;
  --accent:     #2b3a26;   /* brand forest green */
  --accent-lit: #3c5136;
  --gold:       #c6a672;   /* brand gold: on dark green, or as rules; too light for text on white */
  --gold-deep:  #8a6c36;   /* darkened gold, legible for small text on white */

  --measure:  36rem;       /* ~68 characters */
  --radius:   8px;
  --header-h: 4.25rem;
}

/* ---------- base ---------- */

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-family: "Source Serif 4", Georgia, "Times New Roman", serif; }
h1, h2 {
  font-weight: 600;
  line-height: 1.14;
  letter-spacing: -0.015em;
  margin: 0 0 0.55em;
  text-wrap: balance;
}
h1 { font-size: clamp(2.25rem, 5vw, 3.35rem); }
h2 { font-size: clamp(1.55rem, 3vw, 2.15rem); }
h3 {
  font-family: inherit;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 0 0 0.4em;
}

p { margin: 0 0 1.15em; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-lit); }

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

/* ---------- layout ---------- */

.wrap   { width: min(66rem, 100% - 2.75rem); margin-inline: auto; }
.narrow { max-width: var(--measure); }

section { padding: clamp(3.75rem, 8vw, 6.5rem) 0; border-top: 1px solid var(--line-soft); }
section:first-of-type { border-top: 0; }
section[id] { scroll-margin-top: calc(var(--header-h) + 0.5rem); }

.eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1.05rem;
}

/* ---------- header ---------- */

header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.05rem 0; }

.mark { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; }
.mark-glyph { width: 2.1rem; height: 2.1rem; display: block; flex: none; }
.mark-text { display: flex; flex-direction: column; line-height: 1; }
.mark-name {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 1.12rem; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink);
}

header nav { display: flex; gap: 1.55rem; font-size: 0.95rem; transition: opacity .2s ease, visibility .2s ease; }
header nav a {
  color: var(--ink-soft);
  text-decoration: none;
  padding-bottom: 3px;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size .28s ease, color .16s ease;
}
header nav a:hover { color: var(--accent); background-size: 100% 1px; }

/* Once the side rail has taken over, the horizontal nav steps aside. */
header.is-scrolled nav { opacity: 0; visibility: hidden; }

/* ---------- hero ---------- */

.hero { padding-top: clamp(3.25rem, 7vw, 5.75rem); }
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 19rem);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
}
.hero h1 { max-width: 19ch; }
.hero .lede {
  font-size: clamp(1.1rem, 2vw, 1.26rem);
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 34rem;
}
.hero-aside { margin-top: 1.35rem; font-size: 0.93rem; color: var(--ink-faint); max-width: 34rem; }
.hero-aside a { font-weight: 600; }

.hero-portrait { margin: 0; position: relative; }
.hero-portrait img { display: block; width: 100%; height: auto; border-radius: 10px; }
.hero-portrait::before {
  content: "";
  position: absolute;
  inset: 1.25rem -1.25rem -1.25rem 1.25rem;
  background: #edf0e7;
  border-radius: 10px;
  z-index: -1;
  transform: translate3d(0, var(--panel-shift, 0px), 0);
}
.hero-portrait figcaption { margin-top: 0.9rem; font-size: 0.82rem; color: var(--ink-faint); letter-spacing: 0.01em; }

/* ---------- buttons ---------- */

.cta-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }

.btn {
  display: inline-block;
  padding: 0.78rem 1.45rem;
  border-radius: var(--radius);
  font-size: 0.97rem; font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background .16s ease, border-color .16s ease, color .16s ease;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-lit); color: #fff; }
.btn-ghost { border-color: var(--line); color: var(--ink); background: #fff; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { transform: translateY(1px); }

/* ---------- cards ---------- */

.grid { display: grid; gap: 1.15rem; grid-template-columns: repeat(auto-fit, minmax(16.5rem, 1fr)); }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.35rem;
  transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease;
}
.card p { color: var(--ink-soft); font-size: 0.98rem; line-height: 1.65; }
.card:hover { transform: translateY(-2px); border-color: rgba(43,58,38,.35); box-shadow: 0 10px 26px rgba(20,30,26,.07); }

/* ---------- numbered steps ---------- */

.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li {
  counter-increment: step;
  display: grid; grid-template-columns: 2.6rem 1fr; gap: 1.15rem;
  padding: 1.35rem 0;
  border-top: 1px solid var(--line-soft);
}
.steps li:first-child { border-top: 0; padding-top: 0; }
.steps li::before {
  content: counter(step, decimal-leading-zero);
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 0.98rem;
  color: var(--gold-deep);
  padding-top: 0.2rem;
}
.steps p { color: var(--ink-soft); font-size: 0.98rem; }

/* ---------- terms table ---------- */

.terms { width: 100%; border-collapse: collapse; margin-top: 1.5rem; font-size: 0.98rem; }
.terms caption { caption-side: top; text-align: left; margin-bottom: 0.6rem; }
.terms th, .terms td { text-align: left; padding: 0.9rem 1rem 0.9rem 0; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.terms th { width: 33%; font-weight: 600; color: var(--ink); padding-right: 1.5rem; }
.terms td { color: var(--ink-soft); }
.table-scroll { overflow-x: auto; }

/* ---------- diagnostic list ---------- */

.quiz { margin: 2rem 0 0; padding: 0; list-style: none; counter-reset: q; }
.quiz li {
  counter-increment: q;
  position: relative;
  padding: 0.95rem 0 0.95rem 2.75rem;
  border-top: 1px solid var(--line);
  font-size: 1.02rem;
  line-height: 1.55;
}
.quiz li:first-child { border-top: 0; }
.quiz li::before {
  content: counter(q, decimal-leading-zero);
  position: absolute; left: 0; top: 1.05rem;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 0.9rem;
  color: var(--gold-deep);
}
.quiz-note {
  margin-top: 1.75rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-style: italic;
}

/* ---------- worked example ---------- */

.worked { margin-top: 2.5rem; padding: 1.6rem 0 1.6rem 1.6rem; border-left: 3px solid var(--gold); }
.worked p { color: var(--ink-soft); font-size: 0.99rem; }
.worked .worked-label {
  font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--gold-deep);
  margin-bottom: 0.7rem;
}
.worked .worked-note { font-size: 0.93rem; color: var(--ink-faint); }

/* ---------- scope of experience ---------- */

.spec { margin: 2rem 0 0; padding: 0; font-size: 0.97rem; }
.spec > div {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 1rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--line);
}
.spec > div:first-child { border-top: 0; }
.spec dt {
  margin: 0;
  font-size: 0.76rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-faint);
  padding-top: 0.18rem;
}
.spec dd { margin: 0; color: var(--ink-soft); }

/* ---------- contact ---------- */

.contact-list { list-style: none; margin: 1.75rem 0 0; padding: 0; display: grid; gap: 0.7rem; }
.contact-list li { display: flex; align-items: baseline; gap: 1rem; }
.contact-list .label {
  color: var(--ink-faint); font-size: 0.78rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  min-width: 6.25rem;
}
.contact-list a { font-weight: 600; text-decoration: none; }
.contact-list a:hover { text-decoration: underline; }

/* ---------- footer ---------- */

footer { border-top: 1px solid var(--line); padding: 2.5rem 0 3.25rem; color: var(--ink-faint); font-size: 0.9rem; }
footer p { margin: 0.25rem 0; }

/* ---------- colour bands ----------
   White, a brand-tinted neutral, and a deep green band that re-points the
   ink variables rather than overriding each rule.                          */

.band-tint { background: var(--tint); border-top-color: var(--tint-line); }

.band-deep {
  --ink:        #f3f1e9;
  --ink-soft:   #c9c8ba;
  --ink-faint:  #9a9a8b;
  --line:       #47563f;
  --line-soft:  #47563f;
  --accent:     #c6a672;
  --accent-lit: #dcc39a;
  background: #2b3a26;
  color: var(--ink);
  border-top-color: #2b3a26;
}
.band-deep .card { background: #33422c; border-color: #47563f; }
.band-deep .card:hover { border-color: #5f6f54; box-shadow: 0 10px 26px rgba(0,0,0,.18); }
.band-deep .steps li::before { color: var(--gold); }
.band-deep h2::after { content: ""; display: block; width: 3.25rem; height: 2px; margin-top: 1rem; background: var(--gold); }

/* Bands meet flush; no hairline where a band hands over to white. */
.band-tint + section,
.band-deep + section { border-top-color: transparent; }

/* ---------- side rail ----------
   Takes over from the header nav past the hero, on wide screens only.
   Carries its own surface so it stays legible over every band.            */

.rail {
  position: fixed;
  left: clamp(1rem, 2.5vw, 2.25rem);
  top: 50%;
  transform: translateY(-50%) translateX(-0.5rem);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s ease, transform .28s ease;
}
.rail.is-visible { opacity: 1; transform: translateY(-50%) translateX(0); pointer-events: auto; }
.rail nav {
  display: flex; flex-direction: column; gap: 0.1rem;
  padding: 0.85rem 0.95rem;
  background: rgba(255,255,255,0.86);
  backdrop-filter: saturate(1.6) blur(12px);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 6px 22px rgba(20,30,26,0.07);
}
.rail a {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.3rem 0.15rem;
  font-size: 0.86rem; line-height: 1.3;
  color: var(--ink-faint);
  text-decoration: none;
  white-space: nowrap;
  transition: color .16s ease;
}
.rail .dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: #cfd5d9; transition: background .16s ease, transform .16s ease; }
.rail a:hover, .rail a[aria-current] { color: var(--ink); }
.rail a:hover .dot, .rail a[aria-current] .dot { background: var(--accent); }
.rail a[aria-current] { font-weight: 600; }
.rail a[aria-current] .dot { transform: scale(1.5); }

/* ---------- back to top ---------- */

.to-top {
  position: fixed;
  right: clamp(1rem, 2.5vw, 2.25rem);
  bottom: clamp(1rem, 2.5vw, 2.25rem);
  z-index: 30;
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.9rem; height: 2.9rem; padding: 0;
  background: rgba(255,255,255,0.9);
  backdrop-filter: saturate(1.6) blur(12px);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(20,30,26,0.09);
  opacity: 0;
  transform: translateY(0.5rem);
  pointer-events: none;
  transition: opacity .24s ease, transform .24s ease, border-color .16s ease;
}
.to-top.is-visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.to-top:hover { border-color: var(--accent); }
.to-top svg { width: 1.15rem; height: 1.15rem; display: block; }

/* ---------- scroll scene ----------
   Without JavaScript (or with reduced motion) this is a short static panel.
   scene.js adds .is-live, which makes the section tall and pins the canvas
   so scrolling drives the animation instead of moving past it.            */

.scene { position: relative; padding: 0; border-top: 0; background: #fff; }
.scene-sticky { position: relative; height: 64vh; min-height: 420px; overflow: hidden; }
.scene.is-live { height: 250vh; }
.scene.is-live .scene-sticky { position: sticky; top: 0; height: 100vh; }
.scene-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }
.scene-sticky::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(90deg, #fff 0%, rgba(255,255,255,0.94) 30%, rgba(255,255,255,0) 58%);
}
.scene-captions { position: relative; z-index: 2; height: 100%; pointer-events: none; }
.scene-cap {
  position: absolute; left: 0; top: 50%;
  max-width: 25rem; margin: 0;
  opacity: 0;
  transform: translateY(calc(-50% + 14px));
  transition: opacity .5s ease, transform .5s ease;
}
.scene-cap.is-on { opacity: 1; transform: translateY(-50%); }
.scene-cap .eyebrow { display: block; }
.scene-line {
  display: block;
  font-family: "Source Serif 4", Georgia, serif;
  font-weight: 600;
  font-size: clamp(1.55rem, 3vw, 2.35rem);
  line-height: 1.2;
  letter-spacing: -0.012em;
  color: var(--ink);
  text-wrap: balance;
}

/* ---------- motion ----------
   Hero entrance is CSS; the scroll reveal is armed only once motion.js has
   run (.js-anim), so nothing is ever hidden without it. Reveal moves on
   `translate`, hover lift on `transform`, so the two never fight.          */

@keyframes minborg-rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
.hero-text > * { animation: minborg-rise .8s cubic-bezier(.2,.7,.2,1) both; }
.hero-text > :nth-child(1) { animation-delay: .05s; }
.hero-text > :nth-child(2) { animation-delay: .14s; }
.hero-text > :nth-child(3) { animation-delay: .26s; }
.hero-text > :nth-child(4) { animation-delay: .38s; }
.hero-portrait { animation: minborg-rise 1s cubic-bezier(.2,.7,.2,1) .22s both; }

.js-anim .reveal {
  transition-property: opacity, translate;
  transition-duration: .7s, .7s;
  transition-timing-function: cubic-bezier(.2,.7,.2,1), cubic-bezier(.2,.7,.2,1);
  transition-delay: var(--rd, 0ms), var(--rd, 0ms);
}
.js-anim .reveal:not(.is-in) { opacity: 0; translate: 0 var(--from, 16px); }
.js-anim .card.reveal {
  transition-property: opacity, translate, transform, border-color, box-shadow;
  transition-duration: .7s, .7s, .22s, .22s, .22s;
  transition-timing-function: cubic-bezier(.2,.7,.2,1), cubic-bezier(.2,.7,.2,1), ease, ease, ease;
  transition-delay: var(--rd, 0ms), var(--rd, 0ms), 0s, 0s, 0s;
}

/* ---------- utilities (replace inline styles so the CSP can forbid them) ---------- */

.mt-2   { margin-top: 2rem; }
.mt-225 { margin-top: 2.25rem; }
.mt-25  { margin-top: 2.5rem; }
.sub    { color: var(--ink-soft); }
.note   { margin-top: 2rem; color: var(--ink-faint); font-size: 0.92rem; }

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .rail { display: none; }
  header.is-scrolled nav { opacity: 1; visibility: visible; }
}

@media (max-width: 880px) {
  .hero-grid { grid-template-columns: 1fr; gap: 2.25rem; }
  .hero-portrait { max-width: 15rem; }
  .hero-portrait::before { inset: 1rem -1rem -1rem 1rem; }
  .scene.is-live { height: 210vh; }
  .scene-sticky::before { background: linear-gradient(0deg, #fff 0%, rgba(255,255,255,0.94) 32%, rgba(255,255,255,0) 58%); }
  .scene-cap { top: auto; bottom: 9vh; right: 0; max-width: none; transform: translateY(14px); }
  .scene-cap.is-on { transform: none; }
}

/* Phones: the nav becomes a second, side-scrolling row rather than vanishing. */
@media (max-width: 660px) {
  :root { --header-h: 6.1rem; }
  .bar { padding: 0.75rem 0 0; row-gap: 0.35rem; }
  header nav {
    flex-basis: 100%;
    gap: 1.15rem;
    overflow-x: auto;
    padding: 0.3rem 0 0.75rem;
    font-size: 0.9rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  header nav::-webkit-scrollbar { display: none; }
  header nav a { flex: none; }
}

@media (max-width: 560px) {
  .spec > div { grid-template-columns: 1fr; gap: 0.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-text > *, .hero-portrait { animation: none; }
  .hero-portrait::before { transform: none; }
  .rail, .to-top, .card, header nav a, .btn { transition: none; }
  .card:hover, .btn:active { transform: none; }
}

@media print {
  header, .cta-row, .rail, .to-top, .scene { display: none; }
  body { font-size: 11pt; }
  section { padding: 1.2rem 0; border-top: 1px solid #ccc; }
  a { color: #000; text-decoration: none; }
  .band-tint, .band-deep { background: #fff; color: #000; }
  .band-deep { --ink: #000; --ink-soft: #333; --accent: #000; }
  .band-deep .card { background: #fff; border-color: #ccc; }
  .js-anim .reveal:not(.is-in) { opacity: 1; translate: none; }
  .hero-text > *, .hero-portrait { animation: none; }
}
