/* ==========================================================================
   MW Valli — Portfolio
   Design tokens, layout, components
   ========================================================================== */

:root {
  --ink: #0b1f33;
  --ink-2: #263b52;
  --muted: #5b6b7a;
  --line: #dfe3e6;
  --paper: #f7f6f2;
  --card: #ffffff;
  --accent: #0e7c66;
  --accent-2: #0a5c4c;
  --accent-soft: #e6f2ee;
  --gold: #b98d2c;
  --gold-soft: #f6efdd;
  --risk: #b4442f;
  --risk-soft: #f8e9e5;

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Inter Tight", "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(11, 31, 51, .04), 0 8px 24px rgba(11, 31, 51, .06);
  --wrap: 1120px;
  --read: 760px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-2); }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 .5em; }
h1 { font-size: clamp(2.3rem, 5vw, 3.6rem); font-weight: 700; }
h2 { font-size: clamp(1.6rem, 3vw, 2.1rem); font-weight: 700; }
h3 { font-size: 1.2rem; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
ul, ol { padding-left: 1.2em; margin: 0 0 1em; }
li { margin-bottom: .35em; }
strong { font-weight: 650; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.read { max-width: var(--read); }
.eyebrow {
  font-family: var(--font-mono);
  font-size: .74rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .9rem;
  display: inline-block;
}
.lede { font-size: 1.2rem; color: var(--ink-2); max-width: 680px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }

/* ---------- Skip link ---------- */
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 6px; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(247, 246, 242, .88);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.site-header.scrolled { border-bottom-color: var(--line); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; background: var(--ink); color: #fff;
  display: grid; place-items: center; font-size: .78rem; font-weight: 700; letter-spacing: .02em;
}
.nav { display: flex; gap: 26px; align-items: center; }
.nav a { color: var(--ink-2); text-decoration: none; font-size: .93rem; font-weight: 500; }
.nav a:hover { color: var(--accent); }
.nav .btn { color: #fff; }
.nav-toggle { display: none; background: none; border: 0; padding: 8px; cursor: pointer; color: var(--ink); }

@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav {
    position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; align-items: flex-start; gap: 0;
    background: var(--paper); border-bottom: 1px solid var(--line);
    padding: 8px 24px 18px; display: none;
  }
  .nav.open { display: flex; }
  .nav a { padding: 10px 0; width: 100%; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--ink); color: #fff; text-decoration: none;
  padding: 11px 18px; border-radius: 999px; font-weight: 600; font-size: .93rem;
  border: 1px solid var(--ink); transition: transform .15s, background .15s;
}
.btn:hover { background: var(--accent-2); border-color: var(--accent-2); color: #fff; transform: translateY(-1px); }
.btn.ghost { background: transparent; color: var(--ink); border-color: #c9cfd4; }
.btn.ghost:hover { background: #fff; color: var(--ink); border-color: var(--ink); }
.btn.small { padding: 7px 14px; font-size: .86rem; }

/* ---------- Sections ---------- */
section { padding: 88px 0; }
section.tight { padding: 56px 0; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 40px; flex-wrap: wrap; }
.section-head p { margin: 0; max-width: 520px; color: var(--muted); }
.band { background: var(--ink); color: #e9eef3; }
.band h2, .band h3 { color: #fff; }
.band .eyebrow { color: #7fd1bd; }
.band .muted { color: #a9b6c3; }
.white { background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }

/* ---------- Hero ---------- */
.hero { padding: 40px 0 72px; }
.hero h1 { max-width: 880px; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .actions { display: flex; gap: 12px; margin-top: 28px; flex-wrap: wrap; }
.hero-id { display: flex; justify-content: space-between; align-items: center; gap: 18px 28px; flex-wrap: wrap; padding: 0 0 22px; margin-bottom: 34px; border-bottom: 1px solid var(--line); }
.hero-id p { margin: 0; }
.hero-id .name { font-family: var(--font-head); font-weight: 700; font-size: 1.45rem; letter-spacing: -0.015em; color: var(--ink); line-height: 1.2; }
.hero-loc { display: flex; align-items: center; gap: 8px; margin-top: 6px !important; color: var(--muted); font-size: .92rem; }
.hero-loc .sep { color: #b9c3cc; }
.hero-contact { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border: 1px solid #c9cfd4; border-radius: 999px; color: var(--ink); text-decoration: none; font-size: .86rem; font-weight: 500; background: #fff; transition: border-color .2s, color .2s; }
.chip:hover { border-color: var(--accent); color: var(--accent-2); }
.chip svg { flex: none; }
.btn.cv { gap: 7px; }
@media (max-width: 640px) { .hero-id { margin-bottom: 24px; } .chip span { display: none; } .chip[href^="mailto"] span, .chip.phone span { display: inline; } }
.hero-meta { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 30px; color: var(--muted); font-size: .92rem; }
.hero-meta span { display: inline-flex; align-items: center; gap: 7px; }
.hero-flow { margin: 40px 0 0; padding: 18px 20px 10px; background: #eef2f5; border: 1px solid var(--line); border-radius: var(--radius); }
.hero-flow svg { display: block; width: 100%; height: auto; overflow: visible; }
.hf-tangle { fill: none; stroke: #7d8894; stroke-width: 2.5; stroke-linecap: round; }
.hf-path { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linejoin: round; }
.hf-arrow { fill: var(--accent); }
.hf-step rect { fill: #fff; stroke: var(--ink); stroke-width: 1.6; }
.hf-step text { font-family: var(--font-head); font-weight: 650; font-size: 17px; fill: var(--ink); text-anchor: middle; }
.hf-note { font-family: var(--font-sans); font-size: 15px; fill: var(--muted); }
.hf-end { font-family: var(--font-mono); font-size: 14px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; fill: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .hf-tangle { stroke-dasharray: 1200; stroke-dashoffset: 1200; animation: hf-draw 1.1s ease-out .2s forwards; }
  .hf-path { stroke-dasharray: 900; stroke-dashoffset: 900; animation: hf-draw 1.4s ease-in-out 1s forwards; }
  .hf-step, .hf-arrow, .hf-end { opacity: 0; animation: hf-in .45s ease-out forwards; animation-delay: var(--d, 2.2s); }
}
@keyframes hf-draw { to { stroke-dashoffset: 0; } }
@keyframes hf-in { to { opacity: 1; } }
.hf-narrow { display: none !important; }
@media (max-width: 640px) {
  .hero-flow { padding: 14px 10px 8px; margin-top: 28px; }
  .hf-wide { display: none !important; }
  .hf-narrow { display: block !important; max-width: 360px; margin: 0 auto; }
  .hf-narrow .hf-step text { font-size: 15px; }
  .hf-narrow .hf-note { font-size: 13px; }
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; box-shadow: 0 0 0 4px var(--accent-soft); }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat { padding: 26px 20px 24px 0; }
.stat + .stat { padding-left: 20px; border-left: 1px solid var(--line); }
.stat b { display: block; font-family: var(--font-head); font-size: 2.2rem; font-weight: 700; letter-spacing: -0.03em; color: var(--ink); line-height: 1.05; }
.stat span { font-size: .86rem; color: var(--muted); line-height: 1.4; display: block; margin-top: 6px; }
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat, .stat + .stat { padding: 20px 16px; border-left: 0; border-top: 1px solid var(--line); }
  .stat:nth-child(even) { border-left: 1px solid var(--line); }
  .stat:first-child, .stat:nth-child(2) { border-top: 0; }
}

/* ---------- Case study cards ---------- */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; }
@media (max-width: 820px) { .cards { grid-template-columns: 1fr; } }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; display: flex; flex-direction: column; gap: 14px;
  text-decoration: none; color: var(--ink); box-shadow: var(--shadow);
  transition: transform .2s, border-color .2s, box-shadow .2s;
}
a.card:hover { transform: translateY(-3px); border-color: var(--accent); color: var(--ink); box-shadow: 0 2px 4px rgba(11,31,51,.05), 0 18px 40px rgba(11,31,51,.10); }
.card h3 { font-size: 1.35rem; margin: 0; }
.card p { margin: 0; color: var(--ink-2); font-size: .97rem; }
.card .tags { margin-top: auto; padding-top: 6px; }
.card .metric-row { display: flex; gap: 20px; flex-wrap: wrap; padding: 14px 0 4px; border-top: 1px dashed var(--line); }
.card .metric-row div b { font-family: var(--font-head); font-size: 1.5rem; display: block; letter-spacing: -0.02em; line-height: 1.1; }
.card .metric-row div span { font-size: .8rem; color: var(--muted); }
.card .metric-row { flex-wrap: nowrap; gap: 16px; }
.card .metric-row div { flex: 1 1 0; min-width: 0; line-height: 1.35; }
.card .metric-row div b { font-size: 1.35rem; }
.more-links { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; margin-top: 22px; }
.more-link { display: flex; flex-direction: column; gap: 10px; padding: 22px 26px; border-radius: var(--radius); border: 1px dashed #b9c3cc; background: #fbfaf7; color: var(--ink); text-decoration: none; transition: border-color .2s, background .2s; }
.more-link:hover { border-color: var(--accent); border-style: solid; background: #fff; color: var(--ink); }
.more-link .kind { background: var(--gold-soft); color: #7a5b14; }
.more-link h3 { margin: 0; font-size: 1.2rem; }
.more-link p { margin: 0; font-size: .94rem; color: var(--ink-2); }
.more-link .go { font-weight: 600; font-size: .92rem; color: var(--accent); }
@media (max-width: 820px) { .more-links { grid-template-columns: 1fr; } }
.card .go { font-weight: 600; font-size: .92rem; color: var(--accent); }

.kind {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  font-family: var(--font-mono); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase;
  padding: 5px 10px; border-radius: 999px; font-weight: 600;
}
.kind.delivered { background: var(--accent-soft); color: var(--accent-2); }
.kind.approach { background: var(--gold-soft); color: #7a5b14; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: .76rem; background: #f0f2f3; color: var(--ink-2); padding: 4px 9px; border-radius: 6px; }
.band .tag { background: rgba(255,255,255,.08); color: #dbe4ec; }

/* ---------- Method ---------- */
.method { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; counter-reset: step; }
.method li { list-style: none; padding: 22px 20px 6px 0; border-top: 2px solid rgba(255,255,255,.18); position: relative; margin: 0; }
.method li::before {
  counter-increment: step; content: "0" counter(step);
  font-family: var(--font-mono); font-size: .78rem; color: #7fd1bd; display: block; margin-bottom: 10px;
}
.method li:first-child { border-top-color: #7fd1bd; }
.method h3 { font-size: 1.1rem; margin-bottom: 6px; }
.method p { font-size: .9rem; color: #b8c4cf; margin: 0 0 10px; }
.method .small { color: #8fa0b0; font-size: .8rem; }
@media (max-width: 900px) { .method { grid-template-columns: 1fr 1fr; gap: 0 20px; } }
@media (max-width: 560px) { .method { grid-template-columns: 1fr; } }

/* ---------- Grids ---------- */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; }
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.panel h3 { margin-bottom: 10px; }
.panel ul { margin: 0; padding-left: 1.1em; font-size: .94rem; color: var(--ink-2); }

/* ---------- Experience timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 30px 26px; margin: 0; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); }
.timeline li:first-child::before { background: var(--accent); }
.timeline .when { font-family: var(--font-mono); font-size: .76rem; color: var(--muted); letter-spacing: .04em; }
.timeline h3 { margin: 4px 0 4px; font-size: 1.08rem; }
.timeline p { margin: 0; font-size: .94rem; color: var(--ink-2); }

/* ---------- Footer / contact ---------- */
.contact { text-align: left; }
.contact h2 { font-size: clamp(2rem, 4vw, 2.8rem); max-width: 720px; }
.contact-links { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 26px; }
.band .btn { background: #fff; color: var(--ink); border-color: #fff; }
.band .btn:hover { background: #7fd1bd; border-color: #7fd1bd; color: var(--ink); }
.band .btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.45); }
.band .btn.ghost:hover { background: rgba(255,255,255,.1); color: #fff; border-color: #fff; }
.btn svg { flex: none; }

/* Contact facts */
.contact-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin-top: 40px; border-top: 1px solid rgba(255,255,255,.14); }
.contact-facts div { padding: 20px 24px 4px 0; }
.contact-facts div + div { padding-left: 24px; border-left: 1px solid rgba(255,255,255,.14); }
.contact-facts dt { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: #7fd1bd; margin-bottom: 6px; }
.contact-facts dd { margin: 0; color: #dbe4ec; font-size: .94rem; line-height: 1.5; }
.contact-facts dd strong { color: #fff; }
@media (max-width: 760px) {
  .contact-facts { grid-template-columns: 1fr; }
  .contact-facts div, .contact-facts div + div { padding: 16px 0 0; border-left: 0; }
}
footer.site-footer { padding: 26px 0 40px; color: #8fa0b0; font-size: .84rem; background: var(--ink); border-top: 1px solid rgba(255,255,255,.08); }
footer.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
footer.site-footer a { color: #b8c4cf; }

/* ==========================================================================
   Case study pages
   ========================================================================== */
.cs-hero { padding: 64px 0 40px; }
.cs-hero h1 { font-size: clamp(2rem, 4.4vw, 3.1rem); max-width: 900px; }
.back { display: flex; width: max-content; gap: 6px; align-items: center; font-size: .9rem; color: var(--muted); text-decoration: none; margin-bottom: 26px; }
.back:hover { color: var(--accent); }

.snapshot {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-top: 34px; overflow: hidden;
}
.snapshot div { padding: 18px 20px; border-left: 1px solid var(--line); }
.snapshot div:first-child { border-left: 0; }
.snapshot dt { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.snapshot dd { margin: 0; font-size: .94rem; font-weight: 500; line-height: 1.45; }
@media (max-width: 820px) {
  .snapshot { grid-template-columns: 1fr 1fr; }
  .snapshot div:nth-child(3) { border-left: 0; }
  .snapshot div:nth-child(n+3) { border-top: 1px solid var(--line); }
}

.cs-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 56px; padding: 40px 0 80px; }
.toc { position: sticky; top: 92px; align-self: start; font-size: .88rem; }
.toc p { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.toc ol { list-style: none; padding: 0; margin: 0; border-left: 1px solid var(--line); }
.toc li { margin: 0; }
.toc a { display: block; padding: 6px 0 6px 14px; color: var(--muted); text-decoration: none; margin-left: -1px; border-left: 2px solid transparent; }
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
@media (max-width: 960px) { .cs-layout { grid-template-columns: 1fr; gap: 0; } .toc { display: none; } }

.cs-body > section { padding: 0 0 64px; scroll-margin-top: 90px; }
.cs-body h2 { font-size: 1.75rem; margin-bottom: .6em; }
.cs-body h2 .num { font-family: var(--font-mono); font-size: .8rem; color: var(--accent); display: block; letter-spacing: .1em; margin-bottom: 8px; font-weight: 500; }
.cs-body h3 { margin-top: 1.6em; }
.cs-body p, .cs-body li { color: var(--ink-2); }

.callout { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 16px 20px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 22px 0; font-size: .96rem; }
.callout.gold { border-color: var(--gold); background: var(--gold-soft); }
.callout.risk { border-color: var(--risk); background: var(--risk-soft); }
.callout p:last-child { margin: 0; }
.callout strong { color: var(--ink); }

.problem-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 18px 0; }
.problem-list div { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; font-size: .92rem; color: var(--ink-2); }
.problem-list b { display: block; color: var(--risk); font-family: var(--font-head); margin-bottom: 4px; font-size: .98rem; }
@media (max-width: 720px) { .problem-list { grid-template-columns: 1fr; } }

/* Diagrams */
figure.diagram { margin: 26px 0 30px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 20px 14px; overflow-x: auto; }
figure.diagram .mermaid { display: flex; justify-content: center; min-height: 80px; }
figure.diagram .mermaid svg { height: auto; }
figure.diagram figcaption { font-size: .84rem; color: var(--muted); margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
figure.diagram figcaption b { color: var(--ink); font-weight: 600; }
.mermaid:not([data-processed]) { color: transparent; font-size: 0; }

/* Results */
.results { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 20px 0 26px; }
.results div { background: var(--ink); color: #fff; border-radius: var(--radius-sm); padding: 20px; }
.results b { font-family: var(--font-head); font-size: 2rem; display: block; letter-spacing: -0.03em; line-height: 1.05; color: #7fd1bd; }
.results span { font-size: .86rem; color: #c3cfda; display: block; margin-top: 6px; line-height: 1.4; }
.results.targets div { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.results.targets b { color: var(--gold); }
.results.targets span { color: var(--muted); }
@media (max-width: 720px) { .results { grid-template-columns: 1fr; } }

/* Tables */
.table-wrap { overflow-x: auto; margin: 18px 0 26px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f3f5f6; font-weight: 600; color: var(--ink); font-size: .82rem; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td { color: var(--ink-2); }
td.c, th.c { text-align: center; }
.raci { font-family: var(--font-mono); font-weight: 600; }
.score-hi { background: var(--accent-soft); font-weight: 700; color: var(--accent-2); }

/* User stories */
.story { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 18px 20px; margin: 14px 0; }
.story .id { font-family: var(--font-mono); font-size: .74rem; color: var(--accent); letter-spacing: .06em; }
.story p { margin: 6px 0 10px; font-weight: 500; color: var(--ink); }
.story pre { margin: 0; background: #f6f7f8; border-radius: 6px; padding: 12px 14px; font-family: var(--font-mono); font-size: .8rem; line-height: 1.6; white-space: pre-wrap; color: var(--ink-2); }
.story pre b { color: var(--accent-2); }

/* Phases */
.phases { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 20px 0; }
.phases div { background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 16px; }
.phases .when { font-family: var(--font-mono); font-size: .72rem; color: var(--muted); }
.phases h4 { margin: 6px 0 8px; font-size: 1rem; }
.phases ul { margin: 0; padding-left: 1em; font-size: .86rem; }
.phases li { margin-bottom: 3px; }
@media (max-width: 820px) { .phases { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .phases { grid-template-columns: 1fr; } }

/* Next / prev */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; border-top: 1px solid var(--line); padding-top: 32px; }
.pager a { display: block; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; text-decoration: none; color: var(--ink); }
.pager a:hover { border-color: var(--accent); }
.pager span { font-size: .78rem; color: var(--muted); font-family: var(--font-mono); letter-spacing: .06em; text-transform: uppercase; }
.pager b { display: block; margin-top: 4px; font-family: var(--font-head); }
.pager .next { text-align: right; }
@media (max-width: 600px) { .pager { grid-template-columns: 1fr; } .pager .next { text-align: left; } }

/* Reveal */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } html { scroll-behavior: auto; } }


/* Journey map */
.journey { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 10px; min-width: 760px; }
.j-stage { display: flex; flex-direction: column; gap: 8px; }
.j-head { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: #fff; background: var(--ink); padding: 7px 10px; border-radius: 6px; }
.j-step { display: flex; gap: 10px; align-items: flex-start; font-size: .84rem; line-height: 1.35; padding: 10px; border-radius: 6px; border: 1px solid; }
.j-score { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .78rem; color: #fff; }
.j-step.lo { background: var(--risk-soft); border-color: #e9c3b9; }
.j-step.lo .j-score { background: var(--risk); }
.j-step.mid { background: var(--gold-soft); border-color: #e6d4a6; }
.j-step.mid .j-score { background: var(--gold); }
.j-step.hi { background: var(--accent-soft); border-color: #b9dccf; }
.j-step.hi .j-score { background: var(--accent); }

/* Saudi lens glossary */
.lens { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 22px 0 28px; }
.lens-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; background: var(--ink); color: #fff; font-family: var(--font-head); font-weight: 650; }
.lens-head small { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: #7fd1bd; font-weight: 500; }
.lens table { font-size: .9rem; }
.lens th { background: #f3f5f6; }
.lens td:first-child { width: 34%; font-weight: 600; color: var(--ink); }
@media (max-width: 720px) { .lens table { table-layout: fixed; width: 100%; } .lens td, .lens th { overflow-wrap: anywhere; hyphens: auto; } }
.cs-body { min-width: 0; }

/* Artefacts & deliverables */
.artefacts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0 26px; }
.artefact { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; }
.artefact .code { display: inline-block; font-family: var(--font-mono); font-size: .68rem; font-weight: 600; letter-spacing: .08em; color: var(--accent-2); background: var(--accent-soft); padding: 3px 8px; border-radius: 5px; margin-bottom: 8px; }
.artefact h4 { margin: 0 0 4px; font-size: .98rem; }
.artefact p { margin: 0; font-size: .86rem; color: var(--muted); line-height: 1.5; }
@media (max-width: 820px) { .artefacts { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .artefacts { grid-template-columns: 1fr; } }

.kind.fm { background: #e8eef6; color: #23466e; }

/* ==========================================================================
   Print / PDF: keeps the on-screen design (colours, grids) on A4
   ========================================================================== */

/* Transformation frame (case study heroes) */
.frame { margin-top: 18px; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius-sm); overflow: hidden; }
.frame-head { display: flex; align-items: baseline; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); font-family: var(--font-head); font-weight: 650; }
.frame-head small { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); font-weight: 500; }
.frame dl { margin: 0; }
.frame dl > div { display: grid; grid-template-columns: 210px 1fr; gap: 16px; padding: 11px 18px; border-top: 1px solid var(--line); }
.frame dl > div:first-child { border-top: 0; }
.frame dt { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding-top: 3px; }
.frame dd { margin: 0; font-size: .94rem; line-height: 1.5; }
@media (max-width: 720px) { .frame dl > div { grid-template-columns: 1fr; gap: 4px; } }
em.est { font-style: normal; font-family: var(--font-mono); font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; color: var(--gold); background: var(--gold-soft); padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
.results .base { display: block; margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.14); font-style: normal; font-size: .76rem; color: #e3c77d; line-height: 1.4; }


/* One-page artefacts (benefits case) */
.onepage-body { padding-bottom: 56px; }
.bc-h { font-size: 1.25rem; margin: 26px 0 12px; }
.bc-top { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.bc-box { background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 14px 16px; }
.bc-box h4 { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
.bc-box p { margin: 0; font-size: .92rem; line-height: 1.5; }
table.register { font-size: .86rem; background: #fff; }
table.register td, table.register th { vertical-align: top; }
.bc-bottom { display: grid; grid-template-columns: 1.3fr 1fr; gap: 28px; }
.bc-road { list-style: none; margin: 0; padding: 0; counter-reset: road; }
.bc-road li { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: .9rem; line-height: 1.45; }
.bc-road li:first-child { border-top: 0; }
.bc-road b { font-family: var(--font-head); color: var(--accent-2); }
.bc-bottom ul { margin: 0; padding-left: 18px; }
.bc-bottom li { margin-bottom: 6px; }
@media (max-width: 820px) { .bc-top, .bc-bottom { grid-template-columns: 1fr; } }

/* KSA readiness */
.ready-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 18px 0 8px; }
.ready-grid .panel h3 { font-size: 1.05rem; margin-bottom: 6px; }
.ready-grid .panel p { font-size: .92rem; margin: 0 0 8px; }
.ready-grid .panel p:last-child { margin-bottom: 0; }
.ready-grid .panel .apply { color: var(--accent-2); }
@media (max-width: 720px) { .ready-grid { grid-template-columns: 1fr; } }
.sources { font-size: .84rem; color: var(--muted); }
.sources li { margin-bottom: 4px; }

@media print {
  @page { size: A4; margin: 12mm 12mm 13mm; }
  html { font-size: 12px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { font-size: 12.5px; line-height: 1.55; background: var(--paper); }
  .site-header, .toc, .pager, .nav-toggle, .skip, .back, .card .go, .more-link .go, .hero .actions a[href="#work"] { display: none !important; }
  .reveal { opacity: 1 !important; transform: none !important; }
  .wrap { max-width: none; padding: 0; }
  section { padding: 26px 0; }
  .hero { padding: 6px 0 22px; }
  .hero h1 { font-size: 2.3rem; }
  .hero-flow { margin-top: 12px; padding: 6px 14px 2px; break-inside: avoid; }
  .hero-flow svg { max-height: 24mm; width: auto; margin: 0 auto; }
  .hero .actions { margin-top: 14px; }
  .hero-id { padding-bottom: 10px; margin-bottom: 12px; gap: 8px 20px; }
  .chip { padding: 4px 10px; font-size: .8rem; }
  .hero-id .name { font-size: 1.3rem; }
  .btn.cv, .hero .actions { display: none !important; }
  #work { padding-top: 4px; }
  #work .section-head { margin-bottom: 14px; gap: 6px; }
  #work .section-head h2 { font-size: 1.6rem; margin-bottom: 0; }
  #work .section-head p { font-size: .9rem; margin: 0; }
  .card { padding: 14px 16px; gap: 8px; }
  .card p { font-size: .9rem; }
  .card .metric-row { padding-top: 10px; }
  .more-link { break-inside: avoid; }
  .more-links { break-inside: avoid; }
  .hero-meta { margin-top: 14px; }
  .hf-tangle, .hf-path { stroke-dashoffset: 0 !important; animation: none !important; }
  .hf-step, .hf-arrow, .hf-end { opacity: 1 !important; animation: none !important; }
  .lede { font-size: 1.12rem; }
  .hero .lede { font-size: 1rem; line-height: 1.5; }

  /* Keep desktop grids on the narrower page */
  .stats { grid-template-columns: repeat(5, 1fr); }
  .stat, .stat + .stat, .stat:nth-child(even) { padding: 14px 10px 12px; border-top: 0; border-left: 1px solid var(--line); }
  .stat:first-child { border-left: 0; padding-left: 0; }
  .stat b { font-size: 1.7rem; }
  .cards, .more-links { grid-template-columns: 1fr 1fr; gap: 14px; }
  .more-link { padding: 16px 18px; }
  .card { padding: 18px; box-shadow: none; gap: 10px; }
  .card h3 { font-size: 1.2rem; }
  .method { grid-template-columns: repeat(5, 1fr); gap: 0 14px; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  #experience .grid-2 { gap: 28px !important; }
  .snapshot { grid-template-columns: repeat(4, 1fr); margin-top: 22px; }
  .snapshot div, .snapshot div:nth-child(3), .snapshot div:nth-child(n+3) { border-left: 1px solid var(--line); border-top: 0; padding: 12px 14px; }
  .snapshot div:first-child { border-left: 0; }
  .frame dl > div { grid-template-columns: 170px 1fr; padding: 8px 14px; }
  .frame { break-inside: avoid; }
  .cs-hero { padding: 6px 0 18px; }
  .cs-hero h1 { font-size: 2.3rem; }
  .cs-layout { grid-template-columns: 1fr; gap: 0; padding: 10px 0 0; }
  .onepage { padding-bottom: 4px; }
  .onepage .lede { font-size: 1rem; }
  .onepage h1 { font-size: 1.9rem; }
  .onepage-body { padding-bottom: 0; }
  .bc-h { margin: 14px 0 8px; font-size: 1.1rem; }
  .bc-top { grid-template-columns: repeat(3, 1fr); }
  .bc-bottom { grid-template-columns: 1.3fr 1fr; }
  .onepage-body figure.diagram { margin: 8px 0 10px; padding: 8px; }
  .onepage-body figure.diagram .mermaid svg { max-height: 50mm; }
  .onepage-body .table-wrap { margin: 0; }
  .onepage-body .bc-bottom { gap: 20px; }
  .onepage-body .bc-bottom ul li { margin-bottom: 3px; font-size: .84rem; }
  .onepage .back, .onepage + .onepage-body figcaption { display: none; }
  .onepage { padding-top: 0; }
  .onepage h1 { font-size: 1.6rem; margin-bottom: 6px; }
  .onepage .lede { font-size: .95rem; margin-bottom: 4px; }
  .onepage p.small { margin: 0; }
  .bc-box { padding: 9px 12px; }
  .bc-box p { font-size: .85rem; }
  table.register { font-size: .8rem; }
  table.register td, table.register th { padding: 5px 7px; }
  .bc-road li { padding: 4px 0; font-size: .84rem; }
  .ready-grid { grid-template-columns: 1fr 1fr; }
  .ready-grid .panel { break-inside: avoid; }
  .cs-body > section { padding: 0 0 26px; }
  .cs-body h2 { font-size: 1.55rem; }
  .problem-list { grid-template-columns: repeat(3, 1fr); }
  .results { grid-template-columns: repeat(3, 1fr); }
  .artefacts { grid-template-columns: repeat(3, 1fr); }
  .phases { grid-template-columns: repeat(4, 1fr); }
  .journey { min-width: 0; grid-template-columns: repeat(5, 1fr); }
  .table-wrap, figure.diagram { overflow: visible; }
  figure.diagram { padding: 14px 14px 10px; margin: 16px 0 18px; }
  figure.diagram .mermaid svg { max-width: 100% !important; max-height: 175mm; width: auto; }

  /* Dark bands become rounded panels inside the page margins */
  .band { border-radius: 12px; padding: 26px 24px; }
  .contact-facts { grid-template-columns: repeat(3, 1fr); }
  .contact-facts div { padding: 16px 16px 4px 0; }
  .contact-facts div + div { padding-left: 16px; border-left: 1px solid rgba(255,255,255,.14); }
  footer.site-footer { background: none; color: var(--muted); border-top: 1px solid var(--line); padding: 12px 0 0; }
  footer.site-footer a { color: var(--accent); }

  /* Home page: compact sections and clean page breaks */
  section.white { break-inside: avoid; padding-top: 4px; padding-bottom: 10px; }
  #experience { padding-top: 22px; }
  #experience .grid-2, section.contact, .band#approach { break-inside: avoid; }
  .timeline li { padding-bottom: 16px; }
  #experience .panel { padding: 18px; }
  #experience .panel .tags { margin-bottom: 12px !important; }
  #experience .panel h3 { margin-bottom: 6px; font-size: 1.05rem; }

  #experience { padding-top: 8px; }
  #experience h2 { font-size: 1.45rem; }
  #experience p.muted { margin-bottom: 12px !important; font-size: .92rem; }
  .timeline p { font-size: .86rem; }
  .timeline li { padding-bottom: 12px; }
  #experience .tag { font-size: .7rem; padding: 3px 7px; }
  footer.site-footer { break-before: avoid; padding-top: 8px; }
  .cs-body > section:last-of-type { padding-bottom: 6px; }
  .cs-layout { padding-bottom: 0; }

  /* Page breaks */
  h2, h3, .eyebrow, .section-head { break-after: avoid; break-inside: avoid; }
  figure.diagram, .card, .panel, .story, .artefact, .results, .lens, .phases, .timeline li,
  .method li, .stats, .problem-list, .contact-facts, .snapshot, .callout, tr, .journey { break-inside: avoid; }
}
