/* Black and white. Light by default, dark from the system or the toggle. */
:root {
  --bg: #ffffff; --panel: #f4f4f4; --border: #e2e2e2;
  --ink: #0a0a0a; --text: #2b2b2b; --muted: #595959; --faint: #767676;
  --wire: #b9b9b9;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0b0b; --panel: #161616; --border: #2a2a2a;
  --ink: #fafafa; --text: #dcdcdc; --muted: #ababab; --faint: #8a8a8a;
  --wire: #4a4a4a;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0b; --panel: #161616; --border: #2a2a2a;
    --ink: #fafafa; --text: #dcdcdc; --muted: #ababab; --faint: #8a8a8a;
    --wire: #4a4a4a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 88px; }
body { background: var(--bg); color: var(--text); font: 16px/1.65 Geist, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { color: var(--ink); text-wrap: balance; }
p { text-wrap: pretty; }
::selection { background: var(--ink); color: var(--bg); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 4px; }
.mono { font-family: "Geist Mono", ui-monospace, monospace; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 32px; }
.u { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--wire); transition: text-decoration-color .15s; }
.u:hover { text-decoration-color: var(--ink); }
.nowrap { white-space: nowrap; }

/* Top bar */
.bar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.bar .wrap { display: flex; justify-content: space-between; align-items: center; height: 60px; gap: 16px; }
.brand { font-weight: 500; color: var(--ink); white-space: nowrap; }
.bar .right { display: flex; align-items: center; gap: 24px; }
.bar nav { display: flex; gap: 4px; font-size: 15px; }
.bar nav a { color: var(--muted); padding: 6px 12px; border-radius: 8px; transition: color .15s, background-color .15s; }
.bar nav a:hover { color: var(--ink); background: var(--panel); }
.bar nav a[aria-current="page"] { color: var(--ink); font-weight: 500; background: var(--panel); }
.tools { display: flex; align-items: center; gap: 4px; padding-left: 16px; border-left: 1px solid var(--border); }
.tools a, .tools button { font: inherit; font-size: 13px; font-weight: 500; color: var(--faint); background: none; border: 0; cursor: pointer; height: 32px; min-width: 32px; padding: 0 6px; border-radius: 6px; display: grid; place-items: center; transition: color .15s, background-color .15s; }
.tools a:hover, .tools button:hover { color: var(--ink); background: var(--panel); }
.tools a[aria-current] { color: var(--ink); }
.tools svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.tools .moon { display: none; }
:root[data-theme="dark"] .tools .sun { display: none; }
:root[data-theme="dark"] .tools .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tools .sun { display: none; }
  :root:not([data-theme="light"]) .tools .moon { display: block; }
}
.bar .right > .tools:first-child { border-left: 0; padding-left: 0; } /* no nav before it, e.g. on the 404 page */

/* Buttons */
.btn { display: inline-flex; align-items: center; font: inherit; font-size: 15px; font-weight: 500; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--border); background: none; color: var(--ink); cursor: pointer; transition: border-color .15s, background-color .15s, opacity .15s, transform .1s; }
.btn:hover { border-color: var(--ink); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { opacity: .84; }

/* Home hero: who I am on the left, the systems I connected on the right */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 56px; align-items: center; padding: 96px 0 72px; }
.hero h1 { font-size: clamp(2.75rem, 6vw, 4.25rem); line-height: 1; letter-spacing: -.045em; font-weight: 600; }
.hero .lede { font-size: 20px; line-height: 1.55; margin-top: 24px; max-width: 56ch; color: var(--muted); }
.hero .lede b { color: var(--ink); font-weight: 500; }
.links { display: flex; align-items: center; gap: 24px; margin-top: 32px; flex-wrap: wrap; font-size: 15px; color: var(--ink); }
.links a:not(.btn) { display: inline-flex; align-items: center; gap: 8px; }
.links svg { width: 16px; height: 16px; fill: currentColor; }

/* The wiring diagram (inline SVG) */
.wires { max-width: 560px; }
.wires svg { display: block; width: 100%; height: auto; overflow: visible; }
.wires .lane { font: 12px "Geist Mono", ui-monospace, monospace; fill: var(--faint); }
.wires .node rect { fill: var(--bg); stroke: var(--border); }
.wires .node text { font: 500 13px "Geist Mono", ui-monospace, monospace; fill: var(--ink); }
.wires .node .sub { font: 11.5px Geist, system-ui, sans-serif; fill: var(--muted); }
.wires .core rect { fill: var(--ink); stroke: var(--ink); }
.wires .core text { fill: var(--bg); }
.wires .wire { fill: none; stroke: var(--wire); stroke-width: 1.5; }
.wires .packet { fill: var(--ink); }
@media (prefers-reduced-motion: reduce) { .wires .packet { display: none; } }

/* "Now" card, right of the hero */
.now { padding: 24px; border: 1px solid var(--border); border-radius: 16px; }
.now h2 { font-size: 15px; font-weight: 500; margin-bottom: 16px; }
.now dl { display: grid; gap: 16px; font-size: 15px; color: var(--ink); }
.now dt { color: var(--faint); font-size: 13px; margin-bottom: 2px; }
.now time { color: var(--muted); font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink); margin-right: 8px; vertical-align: 1px; }

/* Sections: title in a left rail, content on the right */
main > section { padding: 72px 0; border-top: 1px solid var(--border); }
main > section:has(> .head), main > section.story { display: grid; grid-template-columns: 200px minmax(0, 1fr); column-gap: 56px; }
main > section:has(> .head) > *, main > section.story > * { grid-column: 2; }
main > section > .head { grid-column: 1; grid-row: 1 / span 12; align-self: start; position: sticky; top: 92px; }
h2.title { font-size: 20px; font-weight: 500; letter-spacing: -.015em; line-height: 1.3; }
.head p { color: var(--faint); font-size: 14px; margin-top: 6px; line-height: 1.45; }
.more { display: inline-block; justify-self: start; margin-top: 24px; font-weight: 500; font-size: 15px; color: var(--ink); }

/* Sub-page header */
.page-head { padding: 88px 0 64px; }
.page-head h1 { font-size: clamp(2.5rem, 5vw, 3.5rem); line-height: 1.02; letter-spacing: -.045em; font-weight: 600; }
.page-head p { font-size: 20px; line-height: 1.5; color: var(--muted); margin-top: 20px; max-width: 54ch; }
.story p { max-width: 62ch; font-size: 17px; color: var(--muted); }
.story p:first-child { font-size: 21px; line-height: 1.5; color: var(--text); }
.story p + p { margin-top: 16px; }
.story b { color: var(--ink); font-weight: 500; }

/* What I do */
.do { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; }
.do div { border-top: 2px solid var(--ink); padding-top: 16px; }
.do h3 { font-size: 18px; font-weight: 500; letter-spacing: -.01em; }
.do p { color: var(--muted); font-size: 15px; margin-top: 8px; }
.do .tools-used { font: 12.5px/1.6 "Geist Mono", ui-monospace, monospace; color: var(--faint); margin-top: 16px; }

/* Organisation logos (official site icons, in img/logos/) */
.logo { width: 20px; height: 20px; border-radius: 4px; background: #fff; object-fit: contain; vertical-align: -4px; margin-right: 8px; box-shadow: 0 0 0 1px var(--border); }
.logo.sm { width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 4px; box-shadow: none; }
.logo.lg { width: 40px; height: 40px; border-radius: 10px; margin: 0; vertical-align: 0; }
a.org:hover b { text-decoration: underline; text-underline-offset: 3px; }

/* Short experience list on the home page */
.xp-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 16px 12px; margin: 0 -12px; border-radius: 12px; transition: background-color .15s; }
.xp-row + .xp-row { margin-top: 4px; }
a.xp-row:hover { background: var(--panel); }
.xp-title { color: var(--muted); font-size: 17px; line-height: 1.4; }
.xp-title b { color: var(--ink); font-weight: 500; }
.xp-note { color: var(--muted); font-size: 15px; }
.xp-when { color: var(--faint); font: 13px "Geist Mono", ui-monospace, monospace; white-space: nowrap; }

/* Experience on About: short paragraphs, not a CV */
.exp p { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); gap: 24px; padding: 20px 0; border-top: 1px solid var(--border); color: var(--muted); }
.exp p:first-child { border-top: 0; padding-top: 0; }
.exp p > span:first-child { color: var(--faint); font: 13px/1.9 "Geist Mono", ui-monospace, monospace; }
.exp b { color: var(--ink); font-weight: 500; }
.exp .tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.exp .tags i { font-style: normal; font-size: 13px; padding: 2px 8px; border-radius: 6px; background: var(--panel); color: var(--muted); }

/* GitHub activity heatmap (data fetched live in site.js; section stays hidden if it fails) */
.heatmap-wrap { overflow-x: auto; padding-bottom: 8px; }
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, auto); grid-auto-columns: minmax(11px, 1fr); gap: 3px; min-width: max-content; }
.heatmap i { aspect-ratio: 1; }
.heatmap i, .heat-legend i { border-radius: 2px; background: var(--panel); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 6%, transparent); }
.heatmap i[data-l="1"], .heat-legend i[data-l="1"] { background: color-mix(in srgb, var(--ink) 25%, var(--bg)); }
.heatmap i[data-l="2"], .heat-legend i[data-l="2"] { background: color-mix(in srgb, var(--ink) 45%, var(--bg)); }
.heatmap i[data-l="3"], .heat-legend i[data-l="3"] { background: color-mix(in srgb, var(--ink) 70%, var(--bg)); }
.heatmap i[data-l="4"], .heat-legend i[data-l="4"] { background: var(--ink); }
.heatmap i.pad { visibility: hidden; }
.heat-legend { display: flex; align-items: center; gap: 4px; margin-top: 12px; font-size: 13px; color: var(--faint); }
.heat-legend i { width: 11px; height: 11px; display: inline-block; }
.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--ink); color: var(--bg); font-size: 12px; line-height: 1.4; padding: 4px 8px; border-radius: 4px; white-space: nowrap; transform: translate(-50%, calc(-100% - 8px)); opacity: 0; transition: opacity .1s; }
.tip.on { opacity: 1; }

/* Featured project */
.feature { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; align-items: center; border: 1px solid var(--border); border-radius: 16px; padding: 32px; }
.feature .repo { font-size: 13px; color: var(--muted); }
.feature h3 { font-size: 26px; font-weight: 500; letter-spacing: -.02em; line-height: 1.2; margin-top: 8px; }
.feature p { color: var(--muted); margin-top: 12px; max-width: 48ch; }
.feature ul { list-style: none; margin-top: 16px; display: grid; gap: 8px; font-size: 15px; color: var(--text); }
.feature li { display: grid; grid-template-columns: 16px 1fr; }
.feature li::before { content: "–"; color: var(--faint); }
.feature .meta { display: flex; gap: 8px 16px; flex-wrap: wrap; margin-top: 20px; font-size: 13px; color: var(--muted); align-items: center; }
.visual { background: var(--panel); border-radius: 8px; padding: 28px 12px; display: grid; place-items: center; }
.flow { display: grid; gap: 8px; width: 100%; font-size: 12px; }
.flow .row { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.flow span { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px; white-space: nowrap; color: var(--ink); }
.flow .core { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 500; padding: 8px 12px; }
.flow .arrow { text-align: center; color: var(--faint); line-height: 1; }

/* Code deck: real excerpts from the CRM repo, one tab per file */
.deck { grid-column: 1 / -1; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; min-width: 0; }
.deck-tabs { display: flex; background: var(--panel); border-bottom: 1px solid var(--border); overflow-x: auto; }
.deck-tabs button { font: 13px "Geist Mono", ui-monospace, monospace; padding: 10px 16px; color: var(--muted); background: none; border: 0; border-right: 1px solid var(--border); cursor: pointer; white-space: nowrap; transition: color .15s, background-color .15s; }
.deck-tabs button:hover { color: var(--ink); }
.deck-tabs button[aria-selected="true"] { color: var(--ink); background: var(--bg); }
.deck pre { margin: 0; padding: 20px; overflow-x: auto; font: 13px/1.65 "Geist Mono", ui-monospace, monospace; tab-size: 2; color: var(--text); }
.deck pre .c { color: var(--faint); }
.deck figcaption { font-size: 13px; color: var(--faint); padding: 10px 20px; border-top: 1px solid var(--border); }

/* Repo cards, GitHub style */
.repos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.repo-card { border: 1px solid var(--border); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 8px; min-width: 0; transition: border-color .15s; }
a.repo-card:hover { border-color: var(--ink); }
.repo-card .top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.repo-card .name { min-width: 0; font-size: 14px; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; white-space: nowrap; }
.repo-card p { color: var(--muted); font-size: 15px; flex: 1; }
.repo-card .meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); align-items: center; margin-top: 4px; }
.lang::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 8px; vertical-align: -1px; }
.repo-card.wide, .repos > :only-child { grid-column: 1 / -1; }
.side-intro { color: var(--muted); max-width: 62ch; margin-bottom: 16px; font-size: 17px; }
.side-intro b { color: var(--ink); font-weight: 500; }

/* Device frames for side project screenshots */
.preview { height: 216px; margin: -8px -8px 8px; border-radius: 10px; background: var(--panel); overflow: hidden; display: flex; justify-content: center; align-items: flex-start; padding-top: 24px; }
.phone { width: 132px; flex-shrink: 0; padding: 5px; border-radius: 24px; background: #111; box-shadow: 0 0 0 1px var(--border), 0 12px 32px -16px rgba(0, 0, 0, .35); }
.phone img { display: block; width: 100%; height: auto; border-radius: 19px; }
.browser { width: min(560px, 88%); flex-shrink: 0; border-radius: 8px; overflow: hidden; background: var(--bg); box-shadow: 0 0 0 1px var(--border), 0 12px 32px -16px rgba(0, 0, 0, .35); }
.browser .chrome { display: flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-bottom: 1px solid var(--border); }
.browser .chrome i { width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.browser img { display: block; width: 100%; height: auto; }
.repo-card.wide .preview { height: 264px; }

/* Stack */
.stack { display: flex; flex-wrap: wrap; gap: 8px; }
.stack li { list-style: none; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 14px; color: var(--ink); }
.stack li::before { content: ""; width: 16px; height: 16px; background: var(--ink); -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }

/* Contact: the one inverted block, closes every page */
main > section.contact { background: var(--ink); color: var(--bg); border: 0; border-radius: 24px; padding: 64px 56px; margin: 24px 0 96px; }
.contact h2 { color: var(--bg); font-size: clamp(2rem, 4.4vw, 3.25rem); letter-spacing: -.04em; line-height: 1.05; font-weight: 600; max-width: 18ch; }
.contact p { color: color-mix(in srgb, var(--bg) 68%, var(--ink)); margin-top: 20px; max-width: 48ch; font-size: 17px; }
.contact .u { color: var(--bg); text-decoration-color: color-mix(in srgb, var(--bg) 40%, var(--ink)); }
.contact .u:hover { text-decoration-color: var(--bg); }
.contact .row { display: flex; gap: 12px; margin-top: 32px; flex-wrap: wrap; }
.contact .btn { color: var(--bg); border-color: color-mix(in srgb, var(--bg) 30%, var(--ink)); }
.contact .btn:hover { border-color: var(--bg); }
.contact .btn.primary { background: var(--bg); color: var(--ink); border-color: var(--bg); }
.contact :focus-visible { outline-color: var(--bg); }

/* Footer: one horizontal band (name, pages, social), then a slim legal line */
footer { border-top: 1px solid var(--border); padding: 28px 0 24px; }
.foot-main { display: flex; align-items: center; gap: 16px 40px; flex-wrap: wrap; }
.foot-name { font-size: 20px; font-weight: 600; letter-spacing: -.03em; color: var(--ink); margin-right: auto; }
.foot-nav { display: flex; gap: 4px; font-size: 15px; }
.foot-nav a { color: var(--muted); padding: 6px 12px; border-radius: 8px; transition: color .15s, background-color .15s; }
.foot-nav a:hover { color: var(--ink); background: var(--panel); }
.foot-nav a[aria-current] { color: var(--ink); }
.foot-social { display: flex; gap: 8px; }
.foot-social a { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 8px; color: var(--ink); transition: border-color .15s, background-color .15s; }
.foot-social a:hover { border-color: var(--ink); background: var(--panel); }
.foot-social svg { width: 16px; height: 16px; fill: currentColor; }
.foot-bottom { display: flex; align-items: center; gap: 8px 24px; flex-wrap: wrap; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--faint); }
.foot-note { margin-right: auto; }
.foot-langs { display: flex; gap: 16px; }
.foot-langs a, .foot-up { color: var(--muted); transition: color .15s; }
.foot-langs a:hover, .foot-langs a[aria-current], .foot-up:hover { color: var(--ink); }
.foot-up { display: inline-flex; align-items: center; gap: 4px; }
.foot-up svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.cta { display: flex; gap: 12px; flex-wrap: wrap; padding-bottom: 96px; } /* 404 actions */

/* Cinema: last film watched, the three before it, and the top 4 (generated by tools/letterboxd.py) */
.cinema-intro { max-width: 62ch; margin-bottom: 40px; }
.cinema-intro p { font-size: 17px; color: var(--muted); }
.cinema-intro p:first-child { font-size: 21px; line-height: 1.5; color: var(--text); }
.cinema-intro p + p { margin-top: 12px; }
.films { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 32px 56px; align-items: start; }
.films h3 { font-size: 13px; font-weight: 400; color: var(--faint); margin-bottom: 12px; }
.last { display: flex; align-items: center; gap: 16px; padding: 12px; margin-bottom: 28px; border: 1px solid var(--border); border-radius: 16px; transition: border-color .15s, background-color .15s; }
.last:hover { border-color: var(--ink); background: var(--panel); }
.last img { flex: none; width: 84px; height: auto; border-radius: 6px; }
.last > span { display: grid; gap: 2px; min-width: 0; }
.last b { font-size: 18px; font-weight: 500; letter-spacing: -.01em; line-height: 1.25; color: var(--ink); }
.last .yr { font-size: 14px; color: var(--faint); }
.last .stars { margin-top: 8px; font-size: 15px; color: var(--ink); }
.last time { font-size: 12px; color: var(--faint); }
.stars { letter-spacing: .04em; }
.watched { list-style: none; padding: 0; margin: 0; font-size: 15px; }
.watched li { display: flex; align-items: baseline; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.watched a { color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watched a:hover { text-decoration: underline; text-underline-offset: 3px; }
.watched .stars { flex: none; font-size: 13px; color: var(--muted); }
.watched time { flex: none; margin-left: auto; font-size: 12px; color: var(--faint); }
.posters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; list-style: none; padding: 0; margin: 0; }
.posters a { display: block; }
.posters img { display: block; width: 100%; height: auto; border-radius: 6px; outline: 1px solid var(--border); outline-offset: -1px; transition: transform .4s cubic-bezier(.2, .7, .2, 1); }
.posters span { display: block; margin-top: 8px; font-size: 12px; color: var(--faint); }
.posters b { display: block; font-size: 14px; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (hover: hover) { .posters a:hover img { transform: translateY(-4px); } }

/* Gallery: contact sheet grid + full-screen viewer */
.sheet { columns: 3; column-gap: 20px; padding-bottom: 32px; }
.frame { display: block; width: 100%; margin-bottom: 28px; break-inside: avoid; transition: opacity .3s; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: zoom-in; }
.frame .ph { display: block; overflow: hidden; border-radius: 6px; background: var(--panel); }
.frame img { display: block; width: 100%; height: auto; transition: transform .6s cubic-bezier(.2, .7, .2, 1); }
.frame .cap { transition: color .3s; }
/* Hover: the photo under the pointer zooms a little, the others step back */
@media (hover: hover) {
  .frame:hover img { transform: scale(1.04); }
  .frame:hover .cap { color: var(--ink); }
  .sheet:has(.frame:hover) .frame:not(:hover) { opacity: .5; }
}
.frame:focus-visible { outline: none; }
.frame:focus-visible .ph { outline: 2px solid var(--ink); outline-offset: 2px; }
.frame .cap { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.lightbox { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; color: #eee; }
.lightbox[open] { display: grid; place-items: center; }
.lightbox::backdrop { background: rgba(0, 0, 0, .92); }
.lightbox .lb-img { max-width: min(calc(100vw - 152px), 1400px); max-height: 84vh; width: auto; height: auto; object-fit: contain; border-radius: 4px; }
.lightbox .lb-cap { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 140px); text-align: center; font-size: 13px; color: #aaa; font-variant-numeric: tabular-nums; }
.lb-btn { position: fixed; display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 8px; background: rgba(255, 255, 255, .08); color: #eee; cursor: pointer; transition: background-color .15s; }
.lb-btn:hover { background: rgba(255, 255, 255, .16); }
.lb-btn:focus-visible { outline: 2px solid #eee; outline-offset: 2px; }
.lb-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lb-close { right: 16px; top: 16px; }

/* One entrance on page load: hero first, then sections. Nothing else moves. */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.hero-text > *, .wires, .now, .page-head > *, main > section { animation: rise .7s cubic-bezier(.2, .7, .2, 1) both; }
.hero-text > :nth-child(2), .page-head > :nth-child(2) { animation-delay: .08s; }
.hero-text > :nth-child(3) { animation-delay: .16s; }
.wires { animation-delay: .2s; }
.now { animation-delay: .3s; }
main > section { animation-delay: .38s; }
@media (prefers-reduced-motion: reduce) {
  .hero-text > *, .wires, .now, .page-head > *, main > section { animation: none; }
  .frame, .frame img, .posters img { transition: none; }
  .posters a:hover img { transform: none; }
  .frame:hover img { transform: none; }
}

@media (max-width: 900px) {
  .wrap { padding: 0 20px; }
  .hero { padding: 56px 0 48px; }
  .hero, main > section:has(> .head), main > section.story { display: block; }
  .now { margin-top: 40px; }
  main > section { padding: 56px 0; }
  main > section > .head { position: static; margin-bottom: 24px; }
  .page-head { padding: 56px 0 40px; }
  .feature { grid-template-columns: minmax(0, 1fr); padding: 20px; gap: 24px; }
  .repos, .do { grid-template-columns: minmax(0, 1fr); }
  .do { gap: 24px; }
  .exp p { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  main > section.contact { padding: 40px 24px; border-radius: 20px; margin-bottom: 64px; }
  .foot-name { width: 100%; }
  .foot-nav { margin: 0 auto 0 -12px; }
}
@media (max-width: 600px) {
  /* Two rows: brand + languages/theme on top, page links below */
  html { scroll-padding-top: 116px; }
  .bar .wrap { flex-wrap: wrap; height: auto; padding-top: 12px; padding-bottom: 8px; row-gap: 4px; }
  .bar .right { display: contents; }
  .tools { order: 2; border-left: 0; padding-left: 0; gap: 0; margin-right: -6px; }
  .bar nav { order: 3; width: 100%; margin: 0 -12px; }
  .bar nav .home { display: none; } /* the brand already links home */
  /* The diagram is scaled down here, so its text gets bigger and the sub-captions go */
  .wires .lane { font-size: 15px; }
  .wires .node text { font-size: 16px; }
  .wires .node .sub { display: none; }
  .wires .node image + text { transform: translateY(9px); }
  .xp-row { grid-template-columns: 40px minmax(0, 1fr); }
  .xp-when { grid-column: 2; }
  .films { grid-template-columns: minmax(0, 1fr); }
  .sheet { columns: 2; column-gap: 8px; }
  .frame { margin-bottom: 16px; }
  .lb-prev, .lb-next { top: auto; bottom: 16px; transform: none; }
  .lightbox .lb-img { max-width: 92vw; max-height: 72vh; }
  .lightbox .lb-cap { bottom: 30px; }
}
