/* Layout: an operations ledger on a spruce masthead. The header and the home hero sit on a dark spruce band with sand
   highlights (the tone of the portrait's background); below it, flat sheets with a heavy top rule, hairline-ruled
   rows and a fixed label column, like a shipping manifest. Monospace labels state the kind of each figure (actual,
   projected, targeted) and metadata such as employer, account and year. Shared by the home page and both demo pages. */
:root {
  --bg: #f3f5f4;          /* cool paper */
  --card: #ffffff;
  --fg: #14201c;          /* ink with a green bias */
  --muted: #53615c;
  --line: #d8dfdb;
  --accent: #0b6652;      /* petrol green */
  --accent-fg: #ffffff;
  --accent-soft: #efe9df; /* sand tint */
  --label: #8a5a00;       /* amber for projected / targeted labels */
  --ok: #1d7a3a; --warn: #9a5b00; --bad: #a32020;
  --band: #0f332c;        /* spruce masthead */
  --band-fg: #f1f6f4;
  --band-muted: #cbd0c8;
  --band-accent: #d8cbb6; /* sand, from the portrait's background */
  --band-line: rgb(255 255 255 / .16);
  --band-btn: rgb(241 246 244 / .6);
  --font-display: "IBM Plex Sans Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 3px;
  --label-col: 13rem;     /* the ledger's label column (case rows, job dates) */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1311; --card: #141d1a; --fg: #e5ebe8; --muted: #9daba5; --line: #26322e;
    --accent: #d8cbb6; --accent-fg: #14201c; --accent-soft: #2a2720; --label: #eda54a;
    --ok: #6fd18f; --warn: #e0a84a; --bad: #f07a7a;
    --band: #112622; --band-fg: #eef4f1; --band-muted: #b7beb8; --band-accent: #d8cbb6;
    --band-line: rgb(255 255 255 / .12); --band-btn: rgb(238 244 241 / .5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1311; --card: #141d1a; --fg: #e5ebe8; --muted: #9daba5; --line: #26322e;
  --accent: #d8cbb6; --accent-fg: #14201c; --accent-soft: #2a2720; --label: #eda54a;
  --ok: #6fd18f; --warn: #e0a84a; --bad: #f07a7a;
  --band: #112622; --band-fg: #eef4f1; --band-muted: #b7beb8; --band-accent: #d8cbb6;
  --band-line: rgb(255 255 255 / .12); --band-btn: rgb(238 244 241 / .5); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 400 17px/1.6 var(--font-body); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--band); }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
b, strong { font-weight: 600; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.12; margin: 0 0 .5rem; text-wrap: balance; }
h1 { font-size: clamp(2.4rem, 6vw, 3.4rem); font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: clamp(1.75rem, 4vw, 2.375rem); font-weight: 600; letter-spacing: -.01em; margin-bottom: .9rem; }
h3 { font-size: 1.25rem; font-weight: 600; }
p { margin: 0 0 1rem; }
code { font-family: var(--font-mono); font-size: .88em; }
.wrap { max-width: 70rem; margin: 0 auto; padding-left: max(18px, env(safe-area-inset-left, 0px)); padding-right: max(18px, env(safe-area-inset-right, 0px)); }
body:has(> main.wrap) .wrap { max-width: 56rem; } /* demo pages keep their narrower column, so their charts keep their size */
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.eyebrow, .tag, .label { font-family: var(--font-mono); font-size: .75rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }
.eyebrow { color: var(--muted); display: block; margin-bottom: .5rem; }
section > .wrap > .muted { max-width: 45rem; margin-bottom: 2rem; }

/* sticky header, on the band */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 9; background: var(--band); color: var(--band-fg); border-bottom: 1px solid var(--band-line); }
.top .wrap { display: flex; gap: 0 1.5rem; align-items: center; justify-content: space-between; min-height: 4rem; flex-wrap: wrap; }
.top .brand { font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; color: var(--band-fg); text-decoration: none; padding-block: .5rem; }
.brand-row { display: flex; align-items: center; gap: .9rem; }
.lang-switch { display: inline-flex; gap: .1rem; padding: .12rem; border: 1px solid var(--band-line); border-radius: 999px; font-family: var(--font-mono); font-size: .75rem; letter-spacing: .06em; }
.lang-switch b, .lang-switch a { padding: .15rem .55rem; border-radius: 999px; line-height: 1.4; }
.lang-switch b { background: var(--band-accent); color: var(--band); font-weight: 500; }
.lang-switch a { color: var(--band-muted); text-decoration: none; }
.lang-switch a:hover { color: var(--band-fg); }
.top .back { font-family: var(--font-mono); font-size: .85rem; text-decoration: none; color: var(--band-accent); white-space: nowrap; padding-block: .75rem; }
.top nav { display: flex; gap: 0 1.875rem; flex-wrap: wrap; font-size: 1.0625rem; font-weight: 500; }
.top nav a { color: var(--band-muted); text-decoration: none; padding: .55rem 0; }
.top nav a:hover, .top nav a[aria-current="page"] { color: var(--band-fg); }
.top nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--band-accent); }
.top :focus-visible, .masthead :focus-visible { outline-color: var(--band-accent); }
@media (max-width: 600px) {
  html { scroll-padding-top: 6.5rem; }
  .top .wrap { column-gap: 1.25rem; }
  .top nav { font-size: 1rem; column-gap: .875rem; }
}
@media (max-width: 420px) {
  .top nav { font-size: .9rem; column-gap: .7rem; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  .top nav a { white-space: nowrap; }
}

section { padding-block: 4rem; border-bottom: 1px solid var(--line); }
section:last-of-type { border-bottom: 0; }

/* hero: plain on the demo pages, a spruce masthead on the home page (.hero.masthead) */
.hero { padding-block: 3rem 2.75rem; }
.lede { font-size: 1.15rem; max-width: 44rem; }
.masthead { background: var(--band); color: var(--band-fg); padding-block: clamp(2.25rem, 6vw, 4.5rem); border-bottom: 0; }
.masthead .eyebrow { color: var(--band-muted); margin-bottom: .85rem; }
.masthead h1 { font-size: clamp(2.75rem, 7vw, 4.75rem); line-height: 1; margin: 0; }
.masthead .lede { font-size: clamp(1.1rem, 2.2vw, 1.22rem); line-height: 1.55; margin: 1.75rem 0 0; }
.hero-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1.5rem 3rem; align-items: end; }
.hero-head > div { grid-column: 1; grid-row: 1; min-width: 0; }
.portrait { grid-column: 2; grid-row: 1; width: 168px; height: 168px; margin: 9px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 8px var(--band), 0 0 0 9px var(--band-accent); max-width: 100%; }
.kicker { font-family: var(--font-display); font-size: clamp(1.35rem, 3.2vw, 1.75rem); font-weight: 500; line-height: 1.25; color: var(--accent); margin: .85rem 0 0; }
.masthead .kicker { color: var(--band-accent); }
@media (min-width: 641px) {
  /* home: the portrait spans the name block and the intro, in its own column */
  .masthead .wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 3rem; }
  .masthead .hero-head { display: contents; }
  .masthead .lede { grid-column: 1; grid-row: 2; }
  .masthead .portrait { grid-row: 1 / span 2; align-self: center; width: clamp(168px, 20vw, 240px); height: auto; aspect-ratio: 1; }
  .masthead .stats, .masthead .actions { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .hero-head { grid-template-columns: 1fr; }
  .portrait { grid-column: 1; width: 104px; height: 104px; margin: 7px; box-shadow: 0 0 0 6px var(--band), 0 0 0 7px var(--band-accent); }
  .hero-head > div { grid-row: 2; }
}

/* KPI strip: ruled columns, stacked rows on phones */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 3rem 0 2.25rem; padding: 0; list-style: none; border-top: 2px solid var(--fg); border-bottom: 1px solid var(--line); }
.stat { display: flex; flex-direction: column; gap: .35rem; padding: 1.25rem 1.75rem 1.5rem; border-left: 1px solid var(--line); min-width: 0; }
.stat:first-child { padding-left: 0; border-left: 0; }
.stat:last-child { padding-right: 0; }
.stat .label { color: var(--accent); }
.stat b { font-family: var(--font-display); font-size: clamp(2.6rem, 5vw, 3.5rem); font-weight: 600; letter-spacing: -.01em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.stat span:last-child { color: var(--muted); font-size: .94rem; line-height: 1.5; }
.masthead .stats { border-top-color: var(--band-accent); border-bottom-color: var(--band-line); }
.masthead .stat { border-left-color: var(--band-line); }
.masthead .stat .label { color: var(--band-accent); }
.masthead .stat span:last-child { color: var(--band-muted); }
@media (max-width: 760px) {
  .stats { grid-template-columns: 1fr; margin-top: 2rem; border-bottom: 0; }
  .stat, .stat:first-child, .stat:last-child { padding: 1rem 0 1.15rem; border-left: 0; border-bottom: 1px solid var(--line); }
  .masthead .stat { border-bottom-color: var(--band-line); }
}

/* buttons */
.actions { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.btn { display: inline-flex; align-items: center; gap: .4rem; min-height: 2.875rem; padding: 0 1.25rem; border-radius: var(--radius); border: 1.5px solid var(--fg); font: 600 .95rem/1.2 var(--font-body); text-decoration: none; cursor: pointer; background: transparent; color: var(--fg); }
.btn:hover { background: var(--accent-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.08); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.masthead .btn { border-color: var(--band-btn); color: var(--band-fg); }
.masthead .btn:hover { background: rgb(255 255 255 / .08); }
.masthead .btn.primary { background: var(--band-accent); border-color: var(--band-accent); color: var(--band); }
.copy-row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.copy-row code { user-select: all; display: inline-flex; align-items: center; min-height: 2.875rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 .85rem; font-size: .92rem; max-width: 100%; overflow-wrap: anywhere; }

/* cards: flat sheets with a heavy top rule */
.cards { display: grid; gap: 1.5rem; }
.card { background: var(--card); border: 1px solid var(--line); border-top: 3px solid var(--fg); border-radius: 2px; padding: 1.75rem 2rem 2rem; min-width: 0; }
.card .tag { color: var(--accent); display: block; margin-bottom: .5rem; }
.card h3 a { color: var(--fg); text-decoration-thickness: 1px; }
#demos .cards { grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); }
#demos .card { display: flex; flex-direction: column; }
#demos .card > .btn { margin-top: auto; align-self: flex-start; }

/* case cards: tag and manifest on one line, then ledger rows */
.manifest { font-family: var(--font-mono); font-size: .8rem; color: var(--muted); margin: 0; }
.case { display: grid; grid-template-columns: minmax(12rem, 1fr) minmax(0, auto); column-gap: 2rem; padding: 2rem 2.5rem 2.5rem; }
.case .tag { grid-column: 1; grid-row: 1; margin: 0; }
.case .manifest { grid-column: 2; grid-row: 1; text-align: right; }
.case h3 { grid-column: 1 / -1; grid-row: 2; font-size: clamp(1.6rem, 3.2vw, 2.25rem); line-height: 1.1; letter-spacing: -.01em; margin: .6rem 0 1.5rem; }
.case dl { grid-column: 1 / -1; grid-row: 3; margin: 0; display: grid; grid-template-columns: var(--label-col) minmax(0, 1fr); border-bottom: 1px solid var(--line); }
.case dt { font-family: var(--font-mono); font-size: .75rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 1.1rem 1.5rem 1rem 0; border-top: 1px solid var(--line); }
.case dd { margin: 0; min-width: 0; padding: .85rem 0 1rem; border-top: 1px solid var(--line); }
.case .links { grid-column: 1 / -1; grid-row: 4; margin-top: 1.75rem; display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.kind { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--label); border: 1px solid currentColor; border-radius: 3px; padding: 0 .35rem; white-space: nowrap; }
@media (max-width: 720px) {
  .card { padding: 1.4rem 1.15rem 1.5rem; }
  .case { display: block; }
  .case .manifest { text-align: left; margin: .35rem 0 1.1rem; }
  .case h3 { margin: .5rem 0 0; }
  .case dl { display: block; }
  .case dt { padding: .9rem 0 .25rem; }
  .case dd { border-top: 0; padding: 0 0 .9rem; }
}

/* skills: three ruled columns */
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 2rem 2.5rem; }
.skills > div { border-top: 2px solid var(--fg); padding-top: 1rem; min-width: 0; }
.skills h3 { font-size: 1.2rem; margin-bottom: .75rem; }
.skills > div > ul { list-style: none; padding: 0; margin: 0; }
.skills > div > ul > li { font-weight: 600; padding: .75rem 0; border-top: 1px solid var(--line); min-width: 0; }
.skills > div > ul > li > span { display: block; font-weight: 400; color: var(--muted); font-size: .92rem; line-height: 1.5; margin-top: .15rem; }
.tools { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0 0; padding: 0; list-style: none; }
.tools li { font-family: var(--font-mono); font-size: .74rem; font-weight: 400; border: 1px solid var(--line); background: var(--bg); border-radius: 2px; padding: .05rem .4rem; }

/* experience: dates in the label column, the role beside them */
.job { display: grid; grid-template-columns: var(--label-col) minmax(0, 1fr); column-gap: 2rem; padding-block: 1.25rem 1.5rem; border-top: 1px solid var(--line); }
.job:first-of-type { border-top: 2px solid var(--fg); }
.job h3 { grid-column: 2; grid-row: 1; margin: 0; font-size: 1.35rem; }
.job .when { grid-column: 1; grid-row: 1; font-family: var(--font-mono); color: var(--muted); font-size: .82rem; padding-top: .3rem; }
.job .org { grid-column: 2; grid-row: 2; color: var(--muted); }
.job ul { grid-column: 2; grid-row: 3; margin: .6rem 0 0; padding-left: 1.2rem; max-width: 46rem; }
.job li { margin-bottom: .4rem; }
.job li::marker { color: var(--muted); }
@media (max-width: 640px) {
  .job { grid-template-columns: 1fr; }
  .job h3, .job .when, .job .org, .job ul { grid-column: 1; grid-row: auto; }
  .job .when { padding-top: .2rem; }
}
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: 2rem 2.5rem; margin-top: 2.5rem; }
.cols > div { border-top: 2px solid var(--fg); padding-top: 1rem; min-width: 0; }
.cols h3 { font-size: 1.2rem; margin-bottom: .75rem; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { margin-bottom: .75rem; }
.about { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.5rem 3rem; }
.about p { max-width: 40rem; }
.about h3 { font-size: 1.05rem; margin: 0 0 .6rem; }
.about h3 + ul { margin-bottom: 1.4rem; }
.langs { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
.langs li { display: flex; gap: .65rem; align-items: center; }
.flag { width: 24px; height: 16px; flex: none; border-radius: 2px; box-shadow: 0 0 0 1px var(--line); }
.interests { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .45rem; }
.interests li { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: .25rem .75rem; font-size: .9rem; }
@media (max-width: 760px) { .about { grid-template-columns: 1fr; } }
.side-projects { margin-top: 2.5rem; border-top: 2px solid var(--fg); padding-top: 1rem; }
.side-projects h3 { font-size: 1.2rem; margin-bottom: .75rem; }
.side-projects .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 1rem; }
.proj-head { display: flex; gap: .8rem; align-items: center; margin-bottom: .6rem; }
.proj-head img { width: 48px; height: 48px; border-radius: 11px; flex: none; }
.proj-head h4 { margin: 0 0 .2rem; font-size: 1.1rem; }

footer { padding-block: 2rem 3rem; color: var(--muted); font-size: .9rem; border-top: 1px solid var(--line); }
footer .wrap { display: flex; gap: .5rem 1.5rem; flex-wrap: wrap; justify-content: space-between; align-items: baseline; }

/* CV viewer */
dialog.cv { width: min(900px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--line); border-top: 3px solid var(--fg); border-radius: 2px; background: var(--card); color: var(--fg); }
dialog.cv::backdrop { background: rgb(0 0 0 / .55); }
dialog.cv header { position: sticky; top: 0; display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: .75rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); }
dialog.cv .pages { display: grid; gap: 1rem; padding: 1rem; background: var(--bg); }
dialog.cv img { width: 100%; height: auto; border: 1px solid var(--line); background: #fff; }

/* tables (demo pages) */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: .05rem .5rem; border-radius: 99px; font: 600 .78rem/1.5 var(--font-mono); border: 1px solid currentColor; }
.pill.ok { color: var(--ok); } .pill.warn { color: var(--warn); } .pill.bad { color: var(--bad); }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
