/* ==========================================================================
   Narrative sections: the journey, the ROI calculator, the proof band, the
   portrait and the working-together steps. Depends on the tokens in
   styles.css, so that must be linked first.
   ========================================================================== */

/* ==========================================================================
   The journey. The one place on the page where scrolling drives motion:
   the stage holds while the use cases move past it, and the track marks
   position. Everything else on the site stays static by design.
   ========================================================================== */
.journey { display: grid; gap: var(--space-tight); }
@media (min-width: 900px) {
  .journey {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.4fr);
    gap: clamp(2rem, 6vw, 6rem);
    align-items: start;
  }
  .journey__stage { position: sticky; top: 5.5rem; }
}

.track { display: flex; gap: 0.5rem; margin-top: var(--space-tight); padding: 0; list-style: none; }
.track__dot {
  width: 100%;
  max-width: 3rem;
  height: 3px;
  background: var(--paper-edge);
  transition: background var(--dur-base) var(--ease-out);
}
.track__dot.is-active { background: var(--accent); }
.track__dot.is-done { background: var(--ink-mute); }

.journey__steps { display: grid; }
.step {
  padding-block: clamp(2rem, 1.5rem + 3vw, 4rem);
  border-bottom: 1px solid var(--paper-edge);
  transition: opacity var(--dur-base) var(--ease-out);
}
.step:first-child { padding-top: 0; }
.journey__steps.is-ready .step { opacity: 0.42; }
.journey__steps.is-ready .step.is-active { opacity: 1; }

.step__n { color: var(--accent-soft); margin-bottom: 0.75rem; }
.step__title {
  font-family: var(--font-display);
  font-size: var(--text-h3);
  line-height: 1.05;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  text-wrap: balance;
  margin-bottom: 1rem;
}
.step__tell, .step__fix { color: var(--ink-soft); max-width: var(--measure); text-wrap: pretty; }
.step__fix { margin-top: 0.9rem; color: var(--ink); }
.step__label {
  display: block;
  color: var(--ink-mute);
  margin-bottom: 0.3rem;
}

/* ==========================================================================
   ROI calculator. Numbers are the visitor's own; the page claims nothing.
   ========================================================================== */
.roi { display: grid; gap: clamp(1.25rem, 1rem + 1.5vw, 2.5rem); }
@media (min-width: 860px) { .roi { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }

.roi__legend { color: var(--ink-mute); margin-bottom: 1rem; }
.roi__inputs { display: grid; gap: 1rem; padding: clamp(1.25rem, 1rem + 1vw, 2rem); border: 2px solid var(--ink); border-radius: 14px; background: var(--card); }

.field { display: grid; gap: 0.35rem; }
.field label { font-weight: 600; font-size: var(--text-sm); }
.field__row { display: flex; gap: 0.5rem; }
.field__hint { color: var(--ink-mute); font-size: var(--text-sm); }
.field input, .field select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--paper-edge);
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.field select { width: auto; flex: 0 0 auto; }
.field input:focus, .field select:focus { border-color: var(--accent); }
.field input:invalid { border-color: var(--accent-ink); }

.roi__out {
  display: block;
  padding: clamp(1.25rem, 1rem + 1vw, 2rem);
  background: var(--ink);
  color: var(--paper);
  border-radius: 14px;
}
.roi__out .roi__legend { color: color-mix(in oklab, var(--paper) 62%, transparent); }
.roi__big {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 1.5rem + 4.5vw, 4.5rem);
  line-height: 0.95;
  letter-spacing: -0.015em;
  color: var(--accent-soft);
  font-variant-numeric: tabular-nums;
}
.roi__rows { display: grid; gap: 0; margin-top: 1.5rem; }
.roi__rows > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.6rem;
  border-bottom: 1px solid color-mix(in oklab, var(--paper) 20%, transparent);
}
.roi__rows dt { color: color-mix(in oklab, var(--paper) 62%, transparent); }
.roi__rows dd { font-weight: 600; font-variant-numeric: tabular-nums; }
.roi__read {
  margin-block: 1.25rem;
  color: color-mix(in oklab, var(--paper) 78%, transparent);
  text-wrap: pretty;
}
.roi__out .btn { --btn-bg: var(--accent); --btn-fg: #fff; border-color: var(--accent); }
.roi__out .btn:hover { box-shadow: 0 8px 0 -2px var(--paper); }

/* ==========================================================================
   Proof band. Sits directly under the hero because a prospect needs the
   track record before they will read anything else. Editorial rather than a
   four-card stat grid: the numbers carry it, the rules divide it.
   ========================================================================== */
.proof { border-block: var(--edge); }
.proof__grid { display: grid; }
@media (min-width: 620px) { .proof__grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .proof__grid { grid-template-columns: repeat(4, 1fr); } }

.proof__item {
  padding: clamp(1.25rem, 1rem + 1.4vw, 2rem) 0;
  border-bottom: var(--edge);
}
@media (min-width: 620px) {
  .proof__item { padding-inline: clamp(1rem, 2vw, 2rem); border-left: var(--edge); }
  .proof__item:first-child { padding-left: 0; border-left: 0; }
}
@media (min-width: 1000px) {
  .proof__item { border-bottom: 0; }
}

.proof__n {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 1.6rem + 3.4vw, 4rem);
  line-height: 0.9;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
}
.proof__plus { color: var(--accent); }
.proof__k { color: var(--ink-mute); margin-top: 0.75rem; }
.proof__d { color: var(--ink-soft); font-size: var(--text-sm); margin-top: 0.35rem; max-width: 26ch; text-wrap: pretty; }
.proof__d a { color: inherit; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.proof__d a:hover { color: var(--accent-ink); }

/* ==========================================================================
   Logo rail. Same clone-and-translate loop as the word band, so one code path
   drives both. Marks keep their own colours: a single grey weight killed the
   white ones outright.
   ========================================================================== */
.logos {
  border-bottom: var(--edge);
  padding-block: clamp(1.5rem, 1.1rem + 1.8vw, 2.75rem);
  overflow: hidden;
}
.logos__title, .logos__foot { color: var(--ink-mute); }
.logos__foot { margin-top: 1.25rem; }

.logos__rail { margin-top: 1.25rem; overflow: hidden; }
.logos__track { display: flex; width: max-content; }
.logos__track.is-ready { animation: marquee 38s linear infinite; }
.logos__rail:hover .logos__track { animation-play-state: paused; }

.logos__group { display: flex; align-items: center; flex-shrink: 0; }
.logos__logo {
  height: clamp(28px, 2.2vw, 40px);
  width: auto;
  margin-inline: clamp(1.5rem, 3vw, 3rem);
  object-fit: contain;
  /* Left in their own colours: greyed out, a white mark disappears entirely
     and the rest read as washed out rather than deliberate. */
  opacity: 0.88;
  transition: opacity var(--dur, 220ms) ease;
}
.logos__logo:hover { opacity: 1; }
/* A square mark needs more height than a wordmark to read at the same weight. */
.logos__logo--square { height: clamp(38px, 3vw, 54px); }

@media (prefers-reduced-motion: reduce) {
  .logos__track { animation: none; flex-wrap: wrap; width: 100%; }
  .logos__group { flex-wrap: wrap; justify-content: center; }
}

/* --- Credentials: current vs lapsed --------------------------------------- */
.certs__label {
  color: var(--ink-mute);
  margin-bottom: 1rem;
}
.certs + .certs__label { margin-top: var(--space-tight); }

/* WCAG 2.2 asks for a 24px minimum target. These sat at 18, so the link gets
   padding rather than the text getting bigger. */
.cert__name a {
  display: inline-block;
  padding-block: 0.2rem;
  color: inherit;
  text-decoration-color: var(--badge, var(--accent));
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.cert__name a:hover { color: var(--accent-ink); }

/* Lapsed credentials stay listed because they were genuinely held, but they
   are visibly demoted so nothing reads as a current claim. */
.certs--lapsed { opacity: 0.72; }
.cert.is-lapsed { border-style: dashed; }
.cert__lapsed {
  display: block;
  margin-top: 0.2rem;
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-ink);
}

/* ==========================================================================
   Portrait. The section is about a person, so it should contain one.
   ========================================================================== */
.portrait { margin: 0; max-width: 320px; }
.portrait__img {
  width: 100%;
  /* Without this the HTML height attribute wins over aspect-ratio and the
     browser reserves the image's full intrinsic height before it loads. */
  height: auto;
  aspect-ratio: 9 / 11;
  object-fit: cover;
  border-radius: 14px;
  border: 2px solid var(--ink);
  background: var(--paper-2);
}
.portrait__cap { display: grid; gap: 0.2rem; margin-top: 0.9rem; }
.portrait__name { font-family: var(--font-display); font-size: 1.05rem; letter-spacing: -0.01em; text-transform: uppercase; }
.portrait__role { color: var(--ink-mute); }

/* No photo supplied yet: render a deliberate monogram rather than a broken
   image icon. app.js sets this once the load actually fails. */
.portrait.is-empty .portrait__img { display: none; }
.portrait.is-empty::before {
  content: "MA";
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 9 / 11;
  border-radius: 14px;
  border: 2px dashed var(--paper-edge);
  background: var(--ink);
  color: transparent;
  -webkit-text-stroke: 2px color-mix(in oklab, var(--paper) 70%, transparent);
  font-family: var(--font-display);
  font-size: clamp(3rem, 6vw, 5rem);
  letter-spacing: -0.02em;
}

/* ==========================================================================
   Working together. Three steps, so a buyer knows what emailing costs them.
   ========================================================================== */
.steps {
  display: grid;
  gap: clamp(1rem, 0.6rem + 1.4vw, 1.75rem);
  padding: 0;
  list-style: none;
  counter-reset: step;
}
@media (min-width: 820px) { .steps { grid-template-columns: repeat(3, 1fr); } }

.stepcard {
  display: grid;
  align-content: start;
  gap: 0.6rem;
  padding: clamp(1.25rem, 1rem + 1vw, 1.75rem);
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 14px;
  /* Stacked offset, so the row reads as a sequence rather than three tiles. */
  box-shadow: 0 1px 0 0 var(--paper-edge);
  transition: transform var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out);
}
@media (hover: hover) {
  .stepcard:hover { transform: translateY(-3px); box-shadow: 0 8px 0 -2px var(--accent); }
}
.stepcard__n { color: var(--accent-ink); }
.stepcard__t {
  font-family: var(--font-display);
  font-size: var(--text-h3);
  line-height: 1.05;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  text-wrap: balance;
}
.stepcard__d { color: var(--ink-soft); text-wrap: pretty; }

.portrait__img[data-fallback] { background: var(--ink); }

/* ==========================================================================
   The journey as a book. journey.js builds this when motion is allowed; the
   list above remains the no-JS and reduced-motion version, and stays in the
   DOM, visually hidden, for screen readers and find-in-page.

   One spread per use case: the situation on the left page, what replaces it
   on the right. Scrolling turns the right-hand page, laying the next
   situation down on the left and uncovering its answer beneath. Narrow
   screens bind the book along the top instead, like a flip pad.
   ========================================================================== */
.journey.is-book {
  display: block;
  position: relative;
  /* One screen for the opening spread, then one page turn per 92% of a screen. */
  height: calc(100svh + var(--turns, 5) * 92svh);
}

.journey__pin {
  position: sticky;
  top: var(--nav-h, 4.5rem);
  height: calc(100svh - var(--nav-h, 4.5rem));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(0.75rem, 2.5vh, 2rem);
  padding-block: clamp(0.75rem, 3vh, 2.25rem);
}

.journey.is-book .journey__steps {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The header folds into a single band above the book. */
.journey.is-book .journey__stage {
  position: static;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  column-gap: clamp(1.5rem, 4vw, 4rem);
  align-items: end;
}
.journey.is-book .journey__stage .section__num { grid-column: 1; grid-row: 1; }
.journey.is-book .pinned__title {
  grid-column: 1;
  grid-row: 2 / span 2;
  font-size: clamp(1.6rem, 0.9rem + 2.2vw, 3rem);
  line-height: 0.95;
}
.journey.is-book .pinned__title br { display: none; }
.journey.is-book .pinned__note { display: none; }
.journey.is-book .track { grid-column: 2; grid-row: 3; margin-top: 0.75rem; }

/* --- The book ------------------------------------------------------------- */
.book {
  /* Paper on the dark chapter: flip the inverted tokens back to light. */
  --paper: #f7f8fc;
  --paper-2: #e9ecf5;
  --paper-edge: #d5dae9;
  --card: #ffffff;
  --ink: #0D1B2A;
  --ink-soft: #33475E;
  --ink-mute: #5F7088;
  --accent-ink: #1F5FBF;

  container-type: size;
  display: grid;
  place-items: center;
  min-height: 0;
}

.book__spread {
  position: relative;
  /* The largest 8:5 open book that fits the space under the header. */
  width: min(100cqw, 160cqh);
  height: min(100cqh, 62.5cqw);
  perspective: 5000px;
  /* Viewed from above, the way a book lies on a table: the lifted page grows
     down the screen instead of rising into the header above it. */
  perspective-origin: 50% 20%;
}
/* The open book's shadow on the table. */
.book__spread::before {
  content: "";
  position: absolute;
  inset: 4% 1% -1%;
  border-radius: 16px;
  box-shadow: 0 44px 80px -34px rgba(0, 0, 0, 0.75);
  pointer-events: none;
}

.book__base,
.leaf { position: absolute; }
.book__base--l { inset: 0 50% 0 0; }
.book__base--r,
.leaf { inset: 0 0 0 50%; }

/* A leaf hinges on the spine and swings over towards the reader. */
.leaf {
  transform-style: preserve-3d;
  transform-origin: left center;
  transform: rotateY(calc(var(--flip, 0) * -180deg));
}
.journey.is-live .leaf { will-change: transform; }

.leaf__face {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.leaf__face--back { transform: rotateY(180deg); }

/* --- Pages ---------------------------------------------------------------- */
.page {
  position: absolute;
  inset: 0;
  container-type: size;
  display: flex;
  flex-direction: column;
  padding: 7% 8% 10%;
  background: var(--card);
  color: var(--ink);
  overflow: hidden;
}

/* The gutter: a soft shadow where each page curves into the binding. */
.page--l {
  border-radius: 14px 0 0 14px;
  box-shadow: inset -36px 0 40px -32px rgba(19, 34, 87, 0.34);
}
.page--r {
  border-radius: 0 14px 14px 0;
  box-shadow: inset 36px 0 40px -32px rgba(19, 34, 87, 0.34);
}

/* Shade that falls across a page while it is lifted mid-turn. */
.page::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: var(--shade, 0);
}
.page--r::after { background: linear-gradient(to right, rgba(19, 34, 87, 0.5), rgba(19, 34, 87, 0.05) 72%); }
.page--l::after { background: linear-gradient(to left, rgba(19, 34, 87, 0.5), rgba(19, 34, 87, 0.05) 72%); }

.page__n { color: var(--accent-ink); }
.page__title {
  margin-top: 0.55em;
  font-family: var(--font-display);
  font-size: calc(clamp(1rem, 8cqh, 3.1rem) * var(--page-scale, 1));
  line-height: 1;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  text-wrap: balance;
}
.page__label {
  margin: auto 0 0.5em;
  color: var(--ink-mute);
}
.page__body {
  font-size: calc(clamp(0.8rem, 4.3cqh, 1.4rem) * var(--page-scale, 1));
  line-height: 1.5;
  color: var(--ink-soft);
  text-wrap: pretty;
}

/* The answer page: the resolution, set larger and darker than the problem. */
.page--answer .page__label { margin-top: 0; color: var(--accent-ink); }
.page--answer .page__body {
  font-size: calc(clamp(0.9rem, 6.2cqh, 2.2rem) * var(--page-scale, 1));
  line-height: 1.38;
  color: var(--ink);
}
.page__turn {
  margin-top: auto;
  padding-top: 1em;
  color: var(--accent-ink);
}
.page__folio {
  position: absolute;
  bottom: 4%;
  color: var(--ink-mute);
}
.page--l .page__folio { left: 8%; }
.page--r .page__folio { right: 8%; }

/* --- Narrow screens: bound along the top ---------------------------------- */
@media (max-width: 779px) {
  .journey.is-book .journey__stage {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 0.35rem;
  }
  .journey.is-book .journey__stage > * { grid-column: 1; grid-row: auto; }
  .journey.is-book .pinned__title { font-size: clamp(1.25rem, 5.5vw, 1.8rem); }
  .journey.is-book .track { margin-top: 0.2rem; }

  .book__spread {
    /* A flip pad has no fixed shape: take the room there is, within reason. */
    width: min(100cqw, 560px);
    height: min(100cqh, 760px);
  }
  .book__base--l { inset: 0 0 50% 0; }
  .book__base--r,
  .leaf { inset: 50% 0 0 0; }

  .leaf {
    transform-origin: center top;
    transform: rotateX(calc(var(--flip, 0) * 180deg));
  }
  .leaf__face--back { transform: rotateX(180deg); }

  .page { padding: 5% 7% 8%; }
  .page--l {
    border-radius: 14px 14px 0 0;
    box-shadow: inset 0 -30px 34px -28px rgba(19, 34, 87, 0.34);
  }
  .page--r {
    border-radius: 0 0 14px 14px;
    box-shadow: inset 0 30px 34px -28px rgba(19, 34, 87, 0.34);
  }
  .page--r::after { background: linear-gradient(to bottom, rgba(19, 34, 87, 0.5), rgba(19, 34, 87, 0.05) 72%); }
  .page--l::after { background: linear-gradient(to top, rgba(19, 34, 87, 0.5), rgba(19, 34, 87, 0.05) 72%); }
  .page--l .page__folio { left: auto; right: 8%; }
  .page__title { font-size: clamp(0.95rem, 9cqh, 1.6rem); }
}

/* ==========================================================================
   The diagnostic offer. The page's only ask that costs the visitor nothing,
   so it sits apart from the three-step process rather than inside it.
   ========================================================================== */
.offer {
  margin-top: clamp(2rem, 1.5rem + 2vw, 3.5rem);
  padding: clamp(1.5rem, 1.1rem + 1.8vw, 2.5rem);
  background: var(--card);
  border: var(--edge);
  border-left: 4px solid var(--accent);
  display: grid;
  gap: clamp(1.25rem, 1rem + 1.5vw, 2.5rem);
}
@media (min-width: 860px) { .offer { grid-template-columns: 1.6fr 1fr; align-items: center; } }

.offer__label { color: var(--ink-mute); }
.offer__title {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2.1rem);
  line-height: 1.05;
  margin-top: 0.5rem;
}
.offer__d { color: var(--ink-soft); margin-top: 0.75rem; max-width: 52ch; text-wrap: pretty; }

.offer__cta { display: flex; flex-direction: column; align-items: flex-start; gap: 0.75rem; }
.offer__note { color: var(--ink-mute); }

.roi__cta { display: flex; flex-wrap: wrap; gap: 0.75rem; }

/* --- The first week ------------------------------------------------------- */
/* Buyers hesitate because they cannot picture the start. Days, not phases. */
.week { margin-top: clamp(2rem, 1.5rem + 2vw, 3rem); }
.week__label { color: var(--ink-mute); }
.week__list {
  list-style: none;
  margin-top: 1rem;
  display: grid;
  gap: 0.85rem;
}
.week__list li {
  display: grid;
  gap: 0.15rem 1.25rem;
  color: var(--ink-soft);
  padding-left: 1rem;
  border-left: 2px solid var(--paper-edge);
  text-wrap: pretty;
}
@media (min-width: 720px) { .week__list li { grid-template-columns: 9rem 1fr; } }
.week__d { color: var(--ink); }

/* --- Questions ------------------------------------------------------------ */
/* Plain headings and paragraphs rather than accordions: an answer engine reads
   what is in the document, and a collapsed answer is one a reader has to work
   for. */
.faq { display: grid; gap: clamp(1.25rem, 1rem + 1vw, 2rem); }
@media (min-width: 900px) { .faq { grid-template-columns: repeat(2, 1fr); gap: 2rem clamp(2rem, 4vw, 4rem); } }
.faq__q {
  font-size: clamp(1.05rem, 0.95rem + 0.4vw, 1.25rem);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.faq__a { color: var(--ink-soft); margin-top: 0.5rem; max-width: 60ch; text-wrap: pretty; }

/* --- The book, right to left ---------------------------------------------- */
/* An Arabic book opens the other way: the spine sits on the right, pages turn
   from the left edge, so the leaf hinges on its right and rotates the other
   way. Without this the pages turn backwards under Arabic copy. */
[dir="rtl"] .leaf { transform-origin: right center; transform: rotateY(calc(var(--flip, 0) * 180deg)); }
[dir="rtl"] .leaf__face--back { transform: rotateY(-180deg); }
@media (max-width: 779px) {
  [dir="rtl"] .leaf { transform-origin: center top; transform: rotateX(calc(var(--flip, 0) * 180deg)); }
}

/* --- Latest writing ------------------------------------------------------- */
/* The newest post, surfaced on the home page. Written by scripts/daily-post.mjs
   between the latest markers on every publish, so it never goes stale. */
.latest { padding-block: clamp(1.75rem, 1.2rem + 2vw, 3rem); border-top: var(--edge); }
.latest__label { color: var(--ink-mute); }
.latest__link {
  display: grid;
  gap: 0.35rem;
  margin-top: 1rem;
  padding: 1.25rem;
  background: var(--card);
  border: var(--edge);
  border-left: 4px solid var(--accent);
  text-decoration: none;
  color: inherit;
  transition: box-shadow var(--dur, 220ms) ease, transform var(--dur, 220ms) ease;
}
.latest__link:hover { box-shadow: 0 8px 0 -2px var(--ink); transform: translateY(-2px); }
.latest__date { color: var(--ink-mute); font-size: var(--text-sm); }
.latest__title {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 1rem + 1vw, 1.8rem);
  line-height: 1.05;
}
.latest__dek { color: var(--ink-soft); max-width: 68ch; text-wrap: pretty; }
.latest__more { margin-top: 0.85rem; }
.latest__more a { color: var(--ink-mute); }
.latest__more a:hover { color: var(--accent-ink); }
