/* Aivars Valgers, portfolio
   Layout: one measure (max 1240px) on a 12-column grid; text never wider than 66ch.
   One bold thing: the signal line, the AV mark drawn as a trace that dips and recovers higher than it started.
   Everything else stays quiet: near-monochrome, carmine only for the signal, focus and active states.
   The mark's stroke angle (64°) drives the image wipes and the hatching in empty image slots. */

:root {
  --paper: #F7F7F5;
  --ink: #16161B;
  --ink-2: #5D5D66;
  --rule: #E0DFDB;
  --slot: #EEEDEA;
  --signal: #A32D3A;      /* Latvian carmine */
  --signal-tint: #F4E4E5;
  --header: rgba(247, 247, 245, 0.86);

  --font: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --t-xs: 0.8125rem;
  --t-sm: 0.9375rem;
  --t-base: 1.0625rem;
  --t-md: 1.3125rem;
  --t-lg: clamp(1.5rem, 1.1rem + 1.4vw, 2.125rem);
  --t-xl: clamp(2.125rem, 1.4rem + 3vw, 3.75rem);
  --t-hero: clamp(2.75rem, 1.2rem + 6.4vw, 7rem);

  --max: 1240px;
  --gutter: clamp(16px, 4vw, 48px);
  --measure: 66ch;
  --header-h: 64px;

  --ease: cubic-bezier(0.2, 0.75, 0.15, 1);
  --ease-io: cubic-bezier(0.65, 0, 0.35, 1);
  --slant: 0.488; /* 1 / tan(64°): how far the mark's strokes lean */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111114;
    --ink: #ECEBE8;
    --ink-2: #A3A2A9;
    --rule: #2A2A31;
    --slot: #19191E;
    --signal: #EE6F78;
    --signal-tint: #2C1B1E;
    --header: rgba(17, 17, 20, 0.84);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #111114;
  --ink: #ECEBE8;
  --ink-2: #A3A2A9;
  --rule: #2A2A31;
  --slot: #19191E;
  --signal: #EE6F78;
  --signal-tint: #2C1B1E;
  --header: rgba(17, 17, 20, 0.84);
  color-scheme: dark;
}

/* ---------- Fonts (self-hosted, SIL OFL) ---------- */
@font-face {
  font-family: "Schibsted Grotesk";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("../fonts/schibsted-grotesk-latin-wght-normal.woff2?v=4c8b93f431") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Schibsted Grotesk";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("../fonts/schibsted-grotesk-latin-ext-wght-normal.woff2?v=ee9eeb232c") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Schibsted Grotesk";
  font-style: italic;
  font-weight: 400 900;
  font-display: swap;
  src: url("../fonts/schibsted-grotesk-latin-wght-italic.woff2?v=4c72510c1a") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Schibsted Grotesk";
  font-style: italic;
  font-weight: 400 900;
  font-display: swap;
  src: url("../fonts/schibsted-grotesk-latin-ext-wght-italic.woff2?v=30f8012bb4") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--t-base)/1.6 var(--font);
  font-kerning: normal;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 30;
  background: var(--paper);
}
img, video { max-width: 100%; display: block; }
[id] { scroll-margin-top: calc(var(--header-h) + 24px); }
h1, h2, h3 { margin: 0; font-weight: 700; text-wrap: balance; }
p { margin: 0; }
p + p { margin-top: 1em; }
ul, ol { margin: 0; padding: 0; }
a { color: inherit; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: var(--signal); }
strong { font-weight: 650; }
button { font: inherit; color: inherit; }
::selection { background: var(--signal); color: var(--paper); }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; border-radius: 3px; }
/* Sections that receive focus from in-page links (so keyboard users continue from there) need no ring. */
[tabindex="-1"]:focus { outline: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.muted { color: var(--ink-2); }

.wrap {
  width: 100%;
  max-width: calc(var(--max) + 2 * var(--gutter));
  margin-inline: auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}

.skip {
  position: absolute; left: 16px; top: -100px; z-index: 50;
  background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 6px;
  text-decoration: none; font-weight: 600;
}
.skip:focus { top: calc(env(safe-area-inset-top, 0px) + 12px); }

/* Placeholders for copy that still needs real numbers or facts. */
mark.fill {
  background: var(--signal-tint);
  color: inherit;
  padding: 0.04em 0.28em;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--signal) 32%, transparent);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* ---------- The mark ---------- */
.mark { display: block; overflow: visible; }
.mark polygon { fill: currentColor; }
.mark__line {
  fill: none;
  stroke: var(--signal);
  stroke-width: 14;
  stroke-linejoin: miter;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  background: var(--paper);
  background: var(--header);
  -webkit-backdrop-filter: saturate(1.3) blur(14px);
  backdrop-filter: saturate(1.3) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s;
}
.site-header.is-scrolled { border-bottom-color: var(--rule); }
.header-row {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: var(--header-h);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  margin-right: auto;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand__mark { width: 27px; height: auto; transition: transform 0.45s var(--ease); }
.brand:hover .brand__mark { transform: translateY(-2px); }
.nav ul { display: flex; gap: 2px; list-style: none; }
.nav a {
  display: block;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--ink-2);
  font-size: var(--t-sm);
  font-weight: 550;
  text-decoration: none;
  transition: color 0.18s, background-color 0.18s;
}
.nav a:hover { color: var(--ink); background: var(--slot); }
.nav a[aria-current="page"] { color: var(--ink); }
.header-tools { display: flex; align-items: center; gap: 6px; }
.theme-toggle, .menu-toggle {
  display: inline-grid;
  place-items: center;
  height: 38px;
  min-width: 38px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: border-color 0.18s, background-color 0.18s;
}
.theme-toggle:hover, .menu-toggle:hover { border-color: var(--ink-2); }
.theme-toggle svg { width: 18px; height: 18px; transition: transform 0.6s var(--ease); }
.theme-toggle circle { fill: none; stroke: currentColor; stroke-width: 1.5; }
.theme-toggle path { fill: currentColor; }
.theme-toggle[data-state="dark"] svg { transform: rotate(180deg); }
.menu-toggle { display: none; padding: 0 14px; font-size: var(--t-sm); font-weight: 600; }

@media (max-width: 960px) {
  .menu-toggle { display: inline-grid; }
  .nav {
    position: absolute;
    left: 0; right: 0; top: 100%;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    padding: 8px max(var(--gutter), env(safe-area-inset-right, 0px)) 16px max(var(--gutter), env(safe-area-inset-left, 0px));
    display: none;
  }
  .nav.is-open { display: block; }
  .nav ul { flex-direction: column; gap: 0; }
  .nav a { padding: 12px 0; border-radius: 0; font-size: var(--t-md); color: var(--ink); border-bottom: 1px solid var(--rule); }
  .nav a:hover { background: transparent; }
}

/* ---------- Buttons and links ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font: 600 var(--t-sm)/1 var(--font);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.18s, color 0.18s, border-color 0.18s, transform 0.12s;
}
.btn:hover { background: transparent; color: var(--ink); }
.btn:active { transform: scale(0.97); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn--ghost:hover { border-color: var(--ink); }

/* The trace: the mark's line in miniature, used on links that take you somewhere. */
.trace {
  display: inline-block;
  width: 1.55em;
  height: 0.9em;
  vertical-align: -0.02em;
  overflow: visible;
}
.trace path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linejoin: miter;
  stroke-linecap: square;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}
a:hover .trace path, a:focus-visible .trace path { animation: retrace 0.55s var(--ease-io); stroke: var(--signal); }
@keyframes retrace {
  0% { stroke-dashoffset: 0; }
  45% { stroke-dashoffset: -1; }
  46% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-2);
  font-size: var(--t-sm);
  font-weight: 550;
  text-decoration: none;
}
.back:hover { color: var(--ink); }
.back__mark {
  width: 18px; height: 1px; background: currentColor; position: relative;
  transition: width 0.3s var(--ease);
}
.back__mark::before {
  content: ""; position: absolute; left: 0; top: -6px; width: 7px; height: 7px;
  border-left: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: rotate(45deg); transform-origin: 0 100%;
}
.back:hover .back__mark { width: 26px; }

/* ---------- Sections ---------- */
.section { padding-block: clamp(64px, 6rem + 2vw, 136px) 0; }
.section-head {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 16px clamp(24px, 4vw, 64px);
  align-items: end;
  margin-bottom: clamp(28px, 4vw, 52px);
}
.section-head h2 { font-size: var(--t-xl); line-height: 1.02; letter-spacing: -0.035em; font-weight: 750; }
.section-head p { color: var(--ink-2); max-width: 46ch; }
@media (max-width: 900px) { .section-head { grid-template-columns: 1fr; } }

/* ---------- Hero ---------- */
.hero { padding-block: clamp(48px, 3rem + 5vw, 128px) 0; position: relative; }
.hero > .wrap:first-child { position: relative; }
.hero__title {
  font-size: clamp(2.5rem, 1rem + 4.9vw, 5.75rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
  font-weight: 800;
  max-width: 15ch;
}
/* The headline types itself, with a carmine caret that blinks while it rests. */
.typer__caret {
  display: inline-block;
  width: 0.06em;
  height: 0.78em;
  margin-left: 0.06em;
  vertical-align: -0.03em;
  border-radius: 1px;
  background: var(--signal);
}
@media (prefers-reduced-motion: reduce) { .typer__caret { display: none; } }
.typer.is-idle .typer__caret { animation: caret 1.05s steps(1, end) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.hero__measure {
  position: absolute;
  visibility: hidden;
  pointer-events: none;
  left: 0;
  top: 0;
}
.signal {
  position: relative;
  display: block;
  width: 100%;
  height: clamp(132px, 18vw, 300px);
  margin-block: clamp(20px, 3vw, 40px) clamp(28px, 4vw, 56px);
  overflow: visible;
}
/* On wide screens the peak rises into the space beside the headline. */
@media (min-width: 1200px) {
  .signal { margin-top: calc(-1 * clamp(96px, 9vw, 150px)); }
}
.signal path {
  fill: none;
  stroke: var(--signal);
  stroke-width: 2;
  stroke-linejoin: miter;
  stroke-miterlimit: 8;
  vector-effect: non-scaling-stroke;
}
.signal circle { fill: var(--signal); transform-box: fill-box; transform-origin: center; }
.signal.is-drawing circle { opacity: 0; }
.signal.is-drawn circle { animation: beat 0.7s var(--ease) both; }
@keyframes beat {
  0% { opacity: 0; transform: scale(0); }
  45% { opacity: 1; transform: scale(1.9); }
  100% { opacity: 1; transform: scale(1); }
}
.hero__grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 32px 24px;
  align-items: start;
}
.hero__intro { grid-column: 1 / span 7; max-width: 52ch; }
.hero__intro p:first-child { font-size: var(--t-md); line-height: 1.5; max-width: 46ch; }
.hero__links { display: flex; flex-wrap: wrap; gap: 10px 28px; margin-top: 24px; }
.hero__links a { text-decoration: none; }
.facts { grid-column: 9 / span 4; margin: 0; display: grid; border-top: 1px solid var(--rule); }
.facts > div { display: grid; grid-template-columns: 7.75em minmax(0, 1fr); gap: 12px; padding-block: 11px; border-bottom: 1px solid var(--rule); }
.facts dt { font-weight: 700; font-variant-numeric: tabular-nums; }
.facts dd { margin: 0; color: var(--ink-2); font-size: var(--t-sm); padding-top: 0.12em; }
@media (max-width: 900px) {
  .hero__intro, .facts { grid-column: 1 / -1; }
}

/* ---------- Selected work ---------- */
.work {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(24px, 4vw, 64px);
  align-items: start;
}
.work-list { list-style: none; border-top: 1px solid var(--rule); }
.work-item a {
  display: grid;
  gap: 8px;
  padding-block: 26px 24px;
  border-bottom: 1px solid var(--rule);
  color: inherit;
  text-decoration: none;
}
.work-item__name { font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); transition: color 0.2s; }
.work-item__title {
  font-size: var(--t-lg);
  line-height: 1.1;
  letter-spacing: -0.025em;
  font-weight: 720;
  transition: transform 0.45s var(--ease);
}
.work-item__foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 6px;
  font-size: var(--t-xs);
}
.work-item__tags { color: var(--ink-2); }
.go { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; }
.work-item.is-active .work-item__name, .work-item a:hover .work-item__name { color: var(--signal); }
.work-item a:hover .work-item__title { transform: translateX(10px); }
.work-item .work-thumb { display: none; }

.work-previews {
  /* its shape comes from site.workThumbRatio (an r-… class) */
  position: sticky;
  top: calc(env(safe-area-inset-top, 0px) + var(--header-h) + 28px);
  max-width: 100%;
}
.frame {
  position: absolute;
  inset: 0;
  z-index: 1;
  /* hidden: a sliver along the mark's left stroke */
  clip-path: polygon(0 0, 0 0, -37% 100%, -37% 100%);
  transition: clip-path 0s linear 0.7s;
}
.frame.is-active {
  z-index: 2;
  clip-path: polygon(0 0, 137% 0, 100% 100%, -37% 100%);
  transition: clip-path 0.7s var(--ease);
}
.frame > .media, .frame > .slot { width: 100%; height: 100%; }

@media (max-width: 900px) {
  .work { grid-template-columns: 1fr; }
  .work-previews { display: none; }
  .work-item .work-thumb { display: flex; order: -1; margin-bottom: 8px; }
  .work-item img.work-thumb, .work-item video.work-thumb { display: block; }
  .work-item a:hover .work-item__title { transform: none; }
}

/* ---------- Image slots and media ---------- */
.slot, .media {
  width: 100%;
  max-width: 100%;
  border-radius: 4px;
  background-color: var(--slot);
}
.media { height: auto; object-fit: cover; }
.slot {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  padding: clamp(12px, 2vw, 20px);
  overflow: hidden;
  color: var(--ink-2);
  /* hatching at the mark's stroke angle */
  background-image: repeating-linear-gradient(116deg, transparent 0 15px, color-mix(in srgb, var(--rule) 70%, transparent) 15px 16px);
}
.slot__name { color: var(--ink); font-weight: 700; font-size: var(--t-lg); letter-spacing: -0.02em; line-height: 1.1; }
.slot__file { font-size: var(--t-xs); overflow-wrap: anywhere; }
.r-16x9 { aspect-ratio: 16 / 9; }
.r-3x2 { aspect-ratio: 3 / 2; }
.r-4x3 { aspect-ratio: 4 / 3; }
.r-1x1 { aspect-ratio: 1 / 1; }
.r-4x5 { aspect-ratio: 4 / 5; }
.fig { margin: 0; display: grid; gap: 10px; min-width: 0; }
.fig figcaption { font-size: var(--t-sm); color: var(--ink-2); max-width: 60ch; }
.fig .slot__name { font-size: var(--t-md); }

/* ---------- Testimonials ---------- */
.quotes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(24px, 3vw, 48px);
}
.quote { margin: 0; display: grid; gap: 18px; align-content: start; padding-top: 18px; border-top: 1px solid var(--ink); }
.quote blockquote { margin: 0; font-size: var(--t-md); line-height: 1.42; letter-spacing: -0.01em; }
.quote blockquote p { text-indent: -0.42em; }
.quote figcaption { display: grid; font-size: var(--t-sm); }
.quote__who { font-weight: 650; }
.quote__role { color: var(--ink-2); }
@media (max-width: 900px) { .quotes { grid-template-columns: 1fr; } }

/* ---------- Other projects (expandable rows) ---------- */
.rows { list-style: none; border-top: 1px solid var(--rule); }
.row { border-bottom: 1px solid var(--rule); }
.row__h { font: inherit; }
.row__btn {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 2fr) minmax(0, 3fr) 28px;
  gap: 8px 24px;
  align-items: center;
  width: 100%;
  padding: 20px 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.row__name {
  font-size: var(--t-md);
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.25;
  transition: transform 0.4s var(--ease);
}
.row__where, .row__kind { color: var(--ink-2); font-size: var(--t-sm); }
.row__btn:hover .row__name { transform: translateX(8px); }
.row__icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}
.row__icon svg { width: 14px; height: 14px; overflow: visible; transition: transform 0.45s var(--ease); }
.row__icon path { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.row__btn:hover .row__icon { border-color: var(--ink); }
.row__btn:hover .row__icon svg { transform: translateY(1.5px); }
.row.is-open .row__icon { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.row.is-open .row__icon svg { transform: rotate(180deg); }
.row.is-open .row__btn:hover .row__icon svg { transform: rotate(180deg) translateY(1.5px); }
.row__panel { display: grid; grid-template-rows: 1fr; }
.js .row__panel { grid-template-rows: 0fr; transition: grid-template-rows 0.5s var(--ease); }
.js .row.is-open .row__panel { grid-template-rows: 1fr; }
.row__inner { overflow: hidden; min-height: 0; }
/* A closed row isn't rendered at all, so its images and videos don't download until it opens. */
.js .row__panel[data-collapsed] .row__body { display: none; }
.row__body {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 5fr) 28px;
  gap: 16px 24px;
  padding-bottom: 28px;
}
.row__body > p { max-width: 52ch; color: var(--ink); }
.row__figs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; align-items: start; align-content: start; }
.row__figs .fig figcaption { font-size: var(--t-xs); }
@media (max-width: 760px) {
  .row__btn { grid-template-columns: minmax(0, 1fr) 28px; }
  .row__name { grid-column: 1; }
  .row__where, .row__kind { grid-column: 1; grid-row: auto; }
  .row__where { display: none; }
  .row__icon { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  .row__body { grid-template-columns: 1fr; }
}
@media (max-width: 480px) { .row__figs { grid-template-columns: 1fr; } }

/* ---------- Initiatives ---------- */
.inits {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(40px, 5vw, 72px) clamp(24px, 3vw, 44px);
}
.init { display: grid; gap: 14px; align-content: start; min-width: 0; }
.init h3 { font-size: var(--t-md); letter-spacing: -0.015em; padding-top: 4px; }
.init p { color: var(--ink-2); }
.init .fig { margin-bottom: 4px; }
.init__links { list-style: none; display: grid; gap: 14px; }
.init__links li { display: grid; gap: 2px; }
.init__links a, .init__link-title { font-weight: 650; }
.init__note { color: var(--ink-2); font-size: var(--t-sm); }
@media (max-width: 1000px) { .inits { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .inits { grid-template-columns: 1fr; } }

/* ---------- Footer / contact ---------- */
.site-footer { margin-top: clamp(80px, 8rem + 2vw, 176px); border-top: 1px solid var(--rule); padding-block: clamp(56px, 6vw, 96px) 28px; }
.contact__heading { font-size: var(--t-xl); line-height: 1.02; letter-spacing: -0.035em; font-weight: 750; max-width: 17ch; }
.contact__text { color: var(--ink-2); max-width: 54ch; margin-top: 18px; }
.email-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 20px; margin-top: clamp(28px, 4vw, 44px); }
.email {
  font-size: clamp(1.375rem, 0.9rem + 2.4vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  text-decoration: none;
  overflow-wrap: anywhere;
  background: linear-gradient(var(--signal), var(--signal)) 0 100% / 0 2px no-repeat;
  transition: background-size 0.45s var(--ease);
}
.email:hover { background-size: 100% 2px; }
.tick { width: 14px; height: 14px; display: none; overflow: visible; }
.tick path { fill: none; stroke: currentColor; stroke-width: 2; stroke-dasharray: 1; stroke-dashoffset: 1; }
.is-copied .tick { display: block; }
.is-copied .tick path { animation: tick 0.35s var(--ease) forwards; }
@keyframes tick { to { stroke-dashoffset: 0; } }
.contact-links { list-style: none; display: flex; flex-wrap: wrap; gap: 10px 28px; margin-top: 28px; font-weight: 600; }
.footnote {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  margin-top: clamp(56px, 7vw, 104px);
  padding-top: 20px;
  border-top: 1px solid var(--rule);
  color: var(--ink-2);
  font-size: var(--t-xs);
}
.footnote p + p { margin-top: 0; }

/* ---------- Case study ---------- */
.case-head { padding-block: clamp(36px, 2rem + 4vw, 96px) 0; }
.case-head__name { margin-top: clamp(28px, 4vw, 52px); font-weight: 650; color: var(--signal); display: flex; flex-wrap: wrap; gap: 6px 14px; }
.case-head__count { color: var(--ink-2); font-weight: 500; }
.case-head h1 {
  margin-top: 12px;
  font-size: clamp(2.25rem, 1.2rem + 4.4vw, 5.25rem);
  line-height: 0.98;
  letter-spacing: -0.04em;
  font-weight: 800;
  max-width: 17ch;
}
.case-head__lede { margin-top: 22px; font-size: var(--t-md); line-height: 1.5; color: var(--ink-2); max-width: 52ch; }
.meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 18px 32px;
  margin: clamp(32px, 4vw, 52px) 0 0;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
}
.meta dt { font-size: var(--t-xs); color: var(--ink-2); }
.meta dd { margin: 4px 0 0; font-weight: 550; font-size: var(--t-sm); line-height: 1.45; }
.case-hero { margin-top: clamp(32px, 4vw, 56px); }

.case-body {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 9fr);
  gap: clamp(24px, 5vw, 88px);
  margin-top: clamp(48px, 6vw, 96px);
  align-items: start;
}
.toc {
  position: sticky;
  top: calc(env(safe-area-inset-top, 0px) + var(--header-h) + 28px);
  font-size: var(--t-sm);
}
.toc__title { color: var(--ink-2); margin-bottom: 12px; font-size: var(--t-xs); }
.toc ol { list-style: none; display: grid; gap: 2px; border-left: 1px solid var(--rule); }
.toc a {
  position: relative;
  display: block;
  padding: 5px 0 5px 16px;
  color: var(--ink-2);
  text-decoration: none;
  transition: color 0.2s;
}
.toc a::before {
  content: "";
  position: absolute;
  left: -1px; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--signal);
  transform: scaleY(0);
  transition: transform 0.35s var(--ease);
}
.toc a:hover { color: var(--ink); }
.toc a[aria-current="true"] { color: var(--ink); font-weight: 600; }
.toc a[aria-current="true"]::before { transform: scaleY(1); }

.prose { min-width: 0; }
.case-section + .case-section { margin-top: clamp(56px, 6vw, 96px); }
.case-section > h2 { font-size: var(--t-lg); line-height: 1.12; letter-spacing: -0.025em; margin-bottom: 18px; }
.case-section > p, .case-section .decision p { max-width: var(--measure); }
#in-short > p:first-of-type { font-size: var(--t-md); line-height: 1.5; }
.metrics, .stats { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; }
.metrics li {
  padding: 8px 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: var(--t-sm);
  font-weight: 550;
}
.stats { margin-top: 24px; gap: 24px 40px; }
.stats li { font-size: var(--t-lg); font-weight: 750; letter-spacing: -0.02em; }
.decisions { display: grid; gap: 30px; }
.decision { display: grid; gap: 6px; padding-left: 22px; position: relative; }
.decision::before {
  /* a short stroke at the mark's angle */
  content: "";
  position: absolute;
  left: 4px; top: 0.25em;
  width: 2px; height: 1.05em;
  background: var(--signal);
  transform: skewX(-26deg);
}
.decision h3 { font-size: var(--t-md); letter-spacing: -0.015em; line-height: 1.3; }
.figs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(24px, 3vw, 40px) clamp(16px, 2vw, 28px);
  margin-top: clamp(28px, 3vw, 44px);
  align-items: start;
}
.fig--wide { grid-column: 1 / -1; }
.pull { margin: clamp(36px, 4vw, 56px) 0 0; padding-top: 22px; border-top: 1px solid var(--ink); max-width: 44ch; }
.pull blockquote { margin: 0; font-size: var(--t-lg); line-height: 1.25; letter-spacing: -0.02em; font-weight: 600; }
.pull figcaption { margin-top: 14px; color: var(--ink-2); font-size: var(--t-sm); }

.next-case {
  /* A quiet hand-off to the next story: one line of title and a small picture, so it doesn't compete with the contact section below. */
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(150px, 20vw, 260px);
  gap: 16px clamp(24px, 4vw, 56px);
  align-items: center;
  margin-top: clamp(64px, 8vw, 120px);
  padding-top: clamp(24px, 3vw, 36px);
  border-top: 1px solid var(--rule);
  text-decoration: none;
  color: inherit;
}
.next-case__text { display: grid; gap: 8px; }
/* On hover the thumbnail's top corner is cut at the mark's 64° angle. */
.next-case__thumb { transition: transform 0.55s var(--ease), clip-path 0.55s var(--ease); clip-path: polygon(0 0, 100% 0, 100% 0, 100% 100%, 0 100%); }
.next-case:hover .next-case__thumb { clip-path: polygon(0 0, 86.5% 0, 100% 37%, 100% 100%, 0 100%); transform: translateX(-6px); }
@media (max-width: 760px) {
  .next-case { grid-template-columns: minmax(0, 1fr) 104px; gap: 16px; }
}
.next-case__label { color: var(--ink-2); font-size: var(--t-sm); font-weight: 550; }
.next-case__title {
  font-size: var(--t-lg);
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 700;
  max-width: 30ch;
  transition: transform 0.45s var(--ease);
}
.next-case:hover .next-case__title { transform: translateX(8px); }
.next-case .trace { width: 1.1em; height: 0.62em; margin-left: 0.2em; }
.next-case__thumb .slot__name, .next-case .slot__name { font-size: var(--t-sm); }
.next-case .slot__file { display: none; }
@media (max-width: 760px) { .next-case__title { font-size: var(--t-md); } }
/* On case pages the contact section follows the next case closely. */
[data-page="case"] .site-footer { margin-top: clamp(64px, 7vw, 112px); }

@media (max-width: 900px) {
  .case-body { grid-template-columns: 1fr; }
  .toc { display: none; }
  .figs { grid-template-columns: 1fr; }
}

/* Reading progress runs through the mark in the header on case pages. */
[data-page="case"] .brand .mark__line { stroke-dashoffset: calc(1 - var(--progress, 0)); }

/* ---------- About ---------- */
.about-intro {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
  gap: clamp(28px, 5vw, 88px);
  padding-block: clamp(40px, 2rem + 4vw, 104px) 0;
  align-items: start;
}
.about-intro__photo { position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--header-h) + 28px); }
.about-intro__text h1 { font-size: var(--t-hero); line-height: 0.96; letter-spacing: -0.045em; font-weight: 800; margin-bottom: clamp(24px, 3vw, 40px); }
.about-intro__text > p, .about-intro__text .lead p { max-width: var(--measure); }
.about-intro__text .lead { font-size: var(--t-md); line-height: 1.5; margin-bottom: 1em; }
.about-intro__cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
@media (max-width: 860px) {
  .about-intro { grid-template-columns: 1fr; }
  .about-intro__photo { position: static; max-width: 360px; }
}

.xp-list { list-style: none; border-top: 1px solid var(--rule); }
.xp { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 9fr); gap: 8px clamp(24px, 5vw, 88px); padding-block: 22px; border-bottom: 1px solid var(--rule); }
.xp__years { color: var(--ink-2); font-variant-numeric: tabular-nums; font-size: var(--t-sm); padding-top: 0.2em; }
.xp h3 { font-size: var(--t-md); letter-spacing: -0.015em; line-height: 1.3; }
.xp__place { font-weight: 450; color: var(--ink-2); }
.xp__roles { list-style: none; margin-top: 8px; display: grid; gap: 2px; font-size: var(--t-sm); }
.xp__dates { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.xp__points { margin-top: 12px; padding-left: 1.1em; display: grid; gap: 6px; max-width: var(--measure); }
.xp__points li::marker { color: var(--ink-2); }
@media (max-width: 700px) { .xp { grid-template-columns: 1fr; } }

.skills { margin: 0; border-top: 1px solid var(--rule); }
.skills > div { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 9fr); gap: 8px clamp(24px, 5vw, 88px); padding-block: 16px; border-bottom: 1px solid var(--rule); }
.skills dt { font-weight: 650; }
.skills dd { margin: 0; color: var(--ink-2); max-width: var(--measure); }
@media (max-width: 700px) { .skills > div { grid-template-columns: 1fr; } }

.dated { list-style: none; border-top: 1px solid var(--rule); }
.dated li { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 9fr); gap: 8px clamp(24px, 5vw, 88px); padding-block: 13px; border-bottom: 1px solid var(--rule); }
.dated__y { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 560px) { .dated li { grid-template-columns: 4.5em minmax(0, 1fr); gap: 12px; } }

/* ---------- Resume ---------- */
.resume { padding-block: clamp(32px, 4vw, 64px) 0; max-width: calc(980px + 2 * var(--gutter)); }
.resume__tools { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: clamp(28px, 4vw, 48px); }
.resume__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 16px 40px; padding-bottom: 20px; border-bottom: 2px solid var(--ink); }
.resume__head h1 { font-size: var(--t-xl); letter-spacing: -0.035em; line-height: 1; font-weight: 800; }
.resume__role { margin-top: 8px; color: var(--ink-2); }
.resume__contact { list-style: none; font-size: var(--t-sm); display: grid; gap: 4px; justify-items: end; }
.resume__contact a { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.resume__contact a:hover span { text-decoration: underline; text-decoration-color: var(--signal); }
.resume__contact .icon { width: 15px; height: 15px; flex: none; fill: none; stroke: var(--signal); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.resume__summary { margin-top: 20px; max-width: 76ch; }
.resume section { margin-top: 32px; }
.resume h2 { font-size: var(--t-md); letter-spacing: -0.015em; margin-bottom: 10px; }
.resume .xp-list, .resume .skills, .resume .dated { border-top: 0; }
.resume .xp { padding-block: 12px; }
.resume .xp h3 { font-size: var(--t-base); }
.skills--compact { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 40px; }
.skills--compact > div { grid-template-columns: 1fr; gap: 2px; padding-block: 9px; }
.dated--compact li { grid-template-columns: 5.5em minmax(0, 1fr); gap: 12px; padding-block: 7px; font-size: var(--t-sm); }
.resume__langs { color: var(--ink-2); }
@media (max-width: 760px) {
  .skills--compact { grid-template-columns: 1fr; }
  .resume__contact { justify-items: start; }
}

/* ---------- 404 ---------- */
.lost { padding-block: clamp(48px, 8vw, 128px) 0; }
.lost__line { width: min(600px, 100%); height: auto; overflow: visible; margin-bottom: 32px; }
.lost__line path { fill: none; stroke: var(--signal); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.1s var(--ease-io) 0.2s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.lost h1 { font-size: var(--t-xl); line-height: 1.02; letter-spacing: -0.035em; font-weight: 800; max-width: 18ch; }
.lost p { margin-top: 18px; color: var(--ink-2); max-width: 52ch; }

/* ---------- Page and theme transitions ---------- */
@view-transition { navigation: auto; }
::view-transition-group(*) { animation-duration: 0.5s; animation-timing-function: var(--ease); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.28s; }
html.theme-wipe::view-transition-old(root) { animation: none; }
html.theme-wipe::view-transition-new(root) { animation: wipe 0.62s var(--ease-io) both; }
@keyframes wipe {
  from { clip-path: polygon(0 0, 0 0, -49vh 100%, -49vh 100%); }
  to { clip-path: polygon(0 0, calc(100% + 49vh) 0, 100% 100%, -49vh 100%); }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}

/* ---------- Print (resume) ---------- */
@media print {
  @page { size: A4; margin: 14mm 15mm; }
  :root { --paper: #fff; --ink: #000; --ink-2: #444; --rule: #ccc; --signal: #000; --signal-tint: #fff; }
  html { font-size: 9.6pt; }
  body { background: #fff; }
  .site-header, .site-footer, .skip, .resume__tools, body::before { display: none !important; }
  .resume { padding: 0; max-width: none; }
  .resume .xp { break-inside: avoid; }
  .resume section + section { break-inside: avoid; }
  .resume section { margin-top: 14px; }
  .resume h2 { margin-bottom: 6px; }
  .resume .xp { padding-block: 9px; }
  .dated--compact li { padding-block: 4px; }
  .skills--compact > div { padding-block: 6px; }
  a { text-decoration: none; }
  mark.fill { background: none; box-shadow: none; padding: 0; }
}

/* generated */
@media (min-width: 901px) { .work-previews [data-vt="tellus"] { view-transition-name: hero-tellus; } }
@media (max-width: 900px) { .work-thumb[data-vt="tellus"] { view-transition-name: hero-tellus; } }
.case-hero [data-vt="tellus"], .next-case [data-vt="tellus"] { view-transition-name: hero-tellus; }
@media (min-width: 901px) { .work-previews [data-vt="if-app"] { view-transition-name: hero-if-app; } }
@media (max-width: 900px) { .work-thumb[data-vt="if-app"] { view-transition-name: hero-if-app; } }
.case-hero [data-vt="if-app"], .next-case [data-vt="if-app"] { view-transition-name: hero-if-app; }
@media (min-width: 901px) { .work-previews [data-vt="atlas-editor"] { view-transition-name: hero-atlas-editor; } }
@media (max-width: 900px) { .work-thumb[data-vt="atlas-editor"] { view-transition-name: hero-atlas-editor; } }
.case-hero [data-vt="atlas-editor"], .next-case [data-vt="atlas-editor"] { view-transition-name: hero-atlas-editor; }
@media (min-width: 901px) { .work-previews [data-vt="yourmenu"] { view-transition-name: hero-yourmenu; } }
@media (max-width: 900px) { .work-thumb[data-vt="yourmenu"] { view-transition-name: hero-yourmenu; } }
.case-hero [data-vt="yourmenu"], .next-case [data-vt="yourmenu"] { view-transition-name: hero-yourmenu; }
