/*
  Paolo Trimarchi. A short home page and a few subpages, one column.

  System: adapted from Fluid Functionalism (fluidfunctionalism.com).
    - one text family, one mono for every small label
    - six text sizes, each with its own line height
    - one measure: every block is the full width of the column
    - vertical rhythm: 48px header to content and between sections,
      12px from a label to what it labels, 16px between paragraphs
    - three text tones (primary, secondary, tertiary) and a hairline
    - spacing on a 4px grid
    - motion: 160ms for hover, 400ms for the first-load rise
  Fonts are self-hosted in fonts/ (see the @font-face rules below).
*/

@font-face {
  font-family: "Text";
  src: url("fonts/Switzer-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Text";
  src: url("fonts/Switzer-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Label";
  src: url("fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  /* colour: warm greys */
  --bg: #fbfaf8;
  --primary: #1b1a18;
  --secondary: #5d5a54;
  --tertiary: #6f6b64;
  --line: #e8e5df;
  --hover: #f2efea;
  --focus: #1b1a18;
  --selection: #ffe9a3;
  --miro: #ffd02f;

  /* type: size / line height */
  --t-title: 26px;   --lh-title: 32px;
  --t-intro: 18px;   --lh-intro: 28px;
  --t-prose: 16px;   --lh-prose: 26px;
  --t-body: 15px;    --lh-body: 24px;
  --t-small: 14px;   --lh-small: 20px;
  --t-label: 12px;   --lh-label: 16px;
  --regular: 400;
  --medium: 500;
  --text: "Text", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Label", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* spacing, 4px grid */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px; --s5: 24px;
  --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;

  /* layout */
  --col: 600px;
  --gutter: 24px;
  --bleed: 12px;
  --radius: 8px;

  /* motion */
  --quick: 160ms;
  --slow: 400ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0c;
  --primary: #edebe6;
  --secondary: #a6a299;
  --tertiary: #8a867e;
  --line: #22211f;
  --hover: #181716;
  --focus: #edebe6;
  --selection: #5b4a12;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0c;
    --primary: #edebe6;
    --secondary: #a6a299;
    --tertiary: #8a867e;
    --line: #22211f;
    --hover: #181716;
    --focus: #edebe6;
    --selection: #5b4a12;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--primary);
  font-family: var(--text);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  font-weight: var(--regular);
  font-feature-settings: "kern", "liga", "calt";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--selection); color: var(--primary); }

.wrap {
  width: 100%;
  max-width: calc(var(--col) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

p { margin: 0 0 var(--s4); text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--tertiary) 50%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: text-decoration-color var(--quick) var(--ease), color var(--quick) var(--ease), background-color var(--quick) var(--ease);
}
a:hover { text-decoration-color: var(--primary); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: var(--s2);
  background: var(--primary);
  color: var(--bg);
  padding: var(--s2) var(--s3);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: var(--t-label);
  text-decoration: none;
  z-index: 20;
}
.skip:focus { left: var(--s3); }

/* Small mono labels: nav, section labels, years, tags, breadcrumb, footer. */

.label, .bar, .crumb, .page-label, .page-meta, .tags, .item-when, .links, .hero-note, .site-footer {
  font-family: var(--mono);
  font-size: var(--t-label);
  line-height: var(--lh-label);
  font-weight: var(--regular);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

/* Header: who on the left, theme on the right, then a bar with the two pages and the time. */

.site-header { padding-top: var(--s7); }

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
}

.who {
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
  text-decoration: none;
  min-width: 0;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  display: block;
  flex: none;
}

.who-text { display: flex; flex-direction: column; min-width: 0; }

.who-name {
  font-size: var(--t-body);
  line-height: 22px;
  font-weight: var(--medium);
  letter-spacing: -0.01em;
  margin: 0;
}

.who-role {
  font-size: var(--t-small);
  line-height: var(--lh-small);
  color: var(--secondary);
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-right: -8px;
  color: var(--tertiary);
  background: none;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  transition: color var(--quick) var(--ease), background-color var(--quick) var(--ease);
}
.theme-toggle:hover { color: var(--primary); background: var(--hover); }
.theme-toggle svg { display: block; transition: transform var(--slow) var(--ease); }
:root[data-theme="dark"] .theme-toggle svg { transform: rotate(180deg); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle svg { transform: rotate(180deg); }
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  margin-top: var(--s5);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--tertiary);
}

/* The two pages are tabs: the current one is in the primary tone and sits on a line. */

.nav { display: flex; align-items: stretch; gap: var(--s5); }
.nav a {
  color: var(--tertiary);
  text-decoration: none;
  padding: var(--s3) 0;
  margin-bottom: -1px;
  border-bottom: 1px solid transparent;
  transition: color var(--quick) var(--ease), border-color var(--quick) var(--ease);
}
.nav a:hover { color: var(--primary); }
.nav a[aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); }

.clock { margin: 0; white-space: nowrap; }
.clock time { color: var(--secondary); }

/* Vertical rhythm. One gap from the header to the content and between sections. */

main > * { margin-top: var(--s7); margin-bottom: 0; }

.label {
  color: var(--tertiary);
  margin: 0 0 var(--s3);
}

/* Home: one line about me, the photo, then what I do at Miro. */

.intro p {
  font-size: var(--t-intro);
  line-height: var(--lh-intro);
  letter-spacing: -0.005em;
  margin: 0;
}
.intro .intro-more { color: var(--secondary); }

.hero {
  position: relative;
  aspect-ratio: 16 / 10;
  margin: var(--s5) 0;
  border-radius: var(--radius);
  background: var(--hover);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.hero-note { color: var(--tertiary); }
.hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.miro {
  text-decoration-color: var(--tertiary);
  border-radius: 3px;
}
.miro:hover {
  color: var(--primary);
  text-decoration-color: var(--miro);
  text-decoration-thickness: 2px;
  background: color-mix(in srgb, var(--miro) 28%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--miro) 28%, transparent);
}

/* Rows. Name and year on the first line, the description under them.
   The hover background bleeds past the column; the text stays on its edges. */

.items { list-style: none; margin: 0; padding: 0; }

.item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--s4);
  align-items: baseline;
  margin: 0 calc(-1 * var(--bleed));
  padding: var(--s3) var(--bleed);
  border-radius: var(--radius);
  text-decoration: none;
  transition: background-color var(--quick) var(--ease);
}
a.item:hover { background: var(--hover); }

.item-name { grid-column: 1; grid-row: 1; font-weight: var(--medium); letter-spacing: -0.005em; }
.item-when { grid-column: 2; grid-row: 1; color: var(--tertiary); text-align: right; white-space: nowrap; }
.item-line { grid-column: 1; grid-row: 2; color: var(--secondary); }

.item-arrow {
  grid-column: 2;
  grid-row: 2;
  justify-self: end;
  font-family: var(--mono);
  font-size: var(--t-label);
  line-height: var(--lh-body);
  color: var(--primary);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity var(--quick) var(--ease), transform var(--quick) var(--ease);
}
.item-out .item-arrow { transform: translate(-4px, 4px); }
a.item:hover .item-arrow, a.item:focus-visible .item-arrow { opacity: 1; transform: none; }

/* The next link on a work page: a mono label, the name, the arrow. */

.item-next { grid-template-columns: auto minmax(0, 1fr) auto; column-gap: var(--s3); }
.item-next .item-name {
  font-family: var(--mono);
  font-size: var(--t-label);
  font-weight: var(--regular);
  color: var(--tertiary);
  letter-spacing: 0;
}
.item-next .item-line { grid-column: 2; grid-row: 1; color: var(--primary); font-weight: var(--medium); }
.item-next .item-arrow { grid-column: 3; grid-row: 1; }

/* Running text: work pages, More, and How I work on the home page. */

.prose p {
  font-size: var(--t-prose);
  line-height: var(--lh-prose);
  margin: 0 0 var(--s4);
}
.prose p:last-child { margin-bottom: 0; }
.prose-quiet p { color: var(--secondary); }

/* Work pages. The breadcrumb is a path with slashes; the nav above is tabs. */

.crumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s2);
  color: var(--tertiary);
  margin-bottom: var(--s7);
}
.crumb a { color: var(--tertiary); text-decoration: none; }
.crumb a:hover { color: var(--primary); }
.crumb [aria-current="page"] { color: var(--secondary); }
.crumb .sep { opacity: 0.6; }

.page-label { color: var(--tertiary); margin: 0 0 var(--s2); }

.page-title {
  font-size: var(--t-title);
  line-height: var(--lh-title);
  font-weight: var(--medium);
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin: 0 0 var(--s4);
}

.page-meta {
  display: flex;
  gap: var(--s2);
  color: var(--secondary);
  margin: 0 0 var(--s2);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1) var(--s2);
  list-style: none;
  color: var(--tertiary);
  margin: 0 0 var(--s6);
  padding: 0;
}
.tags li + li::before { content: "/"; margin-right: var(--s2); opacity: 0.6; }

/* Images in the text, and the photo grid on More. A slot takes no space
   until its file has loaded, and is removed if the file is missing. */

.prose, .snaps { position: relative; }

.shot, .snap { margin: 0; }
.shot img, .snap img { display: block; width: 100%; border-radius: var(--radius); }

.shot:not(.is-in), .snap:not(.is-in) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}
.no-js .shot, .no-js .snap { display: none; }

.shot.is-in { margin: var(--s5) 0; }
.shot.is-in:last-child { margin-bottom: 0; }
.shot img { height: auto; border: 1px solid var(--line); }

.snaps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s3);
}
.snaps:has(.snap.is-in) { margin-top: var(--s5); }
.snap img { aspect-ratio: 4 / 5; height: auto; object-fit: cover; }

.links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s4);
  margin: var(--s5) 0 0;
}
.links a { color: var(--secondary); }
.links a::after { content: " \2197"; color: var(--tertiary); }
.links a:hover { color: var(--primary); }

/* Contact and footer */

.contact {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s5);
  margin: 0;
}

.site-footer {
  margin-top: var(--s8);
  padding-bottom: var(--s7);
  color: var(--tertiary);
}
.site-footer p {
  margin: 0;
  padding-top: var(--s4);
  border-top: 1px solid var(--line);
}

/* First load: each block rises 8px and fades in, one after the other. */

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.js .rise {
  animation: rise var(--slow) var(--ease) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

/* Small screens */

@media (max-width: 560px) {
  :root { --gutter: 20px; }

  .site-header { padding-top: var(--s5); }
  .crumb { margin-bottom: var(--s6); }
  .page-title { font-size: 24px; line-height: 30px; }
  .snaps { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* No hover on touch: the description uses the full width. */
  .item-line { grid-column: 1 / -1; }
  .item-arrow { display: none; }
  .item-next .item-line { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  .js .rise { animation: none; }
  * { transition: none !important; }
}

@media print {
  .theme-toggle, .skip, .bar { display: none; }
  .js .rise { animation: none; }
}

/* Photo pile on the More page: tilted cards you can drag anywhere on the page. */
.pile {
  position: relative;
  height: 320px;
  margin: var(--s8) 0 var(--s7);
  z-index: 20;
}
.pile .card {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 172px;
  margin: 0;
  padding: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 10px 28px rgba(0, 0, 0, 0.12);
  transform: translate(var(--dx, 0px), var(--dy, 0px)) rotate(var(--r));
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: box-shadow var(--moderate, 0.16s) ease;
}
.pile .card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 7px;
  pointer-events: none;
}
.pile .card.is-held {
  cursor: grabbing;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08), 0 18px 44px rgba(0, 0, 0, 0.2);
}
.pile .card:nth-child(1) { --x: 2%;  --y: 36px; }
.pile .card:nth-child(2) { --x: 21%; --y: 6px; }
.pile .card:nth-child(3) { --x: 40%; --y: 44px; }
.pile .card:nth-child(4) { --x: 59%; --y: 10px; }
.pile .card:nth-child(5) { --x: 76%; --y: 40px; }
@media (max-width: 640px) {
  .pile { height: 420px; }
  .pile .card { width: 138px; }
  .pile .card:nth-child(1) { --x: 0%;  --y: 20px; }
  .pile .card:nth-child(2) { --x: 34%; --y: 0px; }
  .pile .card:nth-child(3) { --x: 58%; --y: 40px; }
  .pile .card:nth-child(4) { --x: 8%;  --y: 210px; }
  .pile .card:nth-child(5) { --x: 46%; --y: 220px; }
}

/* Work page header is now just title and meta: give the meta room before the text. */
.page-meta { margin-bottom: var(--s6); }

/* Speaking photo: a portrait card in the top right. On wide screens it sits in the
   margin beside the header and intro; on narrower screens it floats inside the column. */
.intro { position: relative; }
.hero {
  aspect-ratio: 4 / 5;
  width: 190px;
  float: right;
  margin: 4px 0 var(--s4) var(--s5);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 10px 28px rgba(0, 0, 0, 0.14);
  transform: rotate(2deg);
}
.intro::after { content: ""; display: block; clear: both; }
@media (min-width: 1180px) {
  .hero {
    float: none;
    position: absolute;
    top: -150px;
    left: calc(100% + 56px);
    width: 250px;
    margin: 0;
    transform: rotate(3deg);
  }
}
@media (max-width: 480px) {
  .hero { width: 132px; margin-left: var(--s4); }
}
.intro p + p, .intro figure + p + p { margin-top: var(--s4); }
.hero { aspect-ratio: 2 / 3; }
/* Professional treatment for the speaking photo: straight, no drop shadow, hairline edge. */
.hero {
  transform: none;
  box-shadow: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
@media (min-width: 1180px) {
  .hero { transform: none; top: -148px; left: calc(100% + 64px); width: 240px; }
}
@media (min-width: 1180px) { .hero { top: -159px; } }

/* Weather line in the bar. */
.clock-temp { color: var(--primary); }
.clock-icon { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }


/* Video in a work page figure. */
.shot video { display: block; width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--hover); }
.shot { margin-bottom: var(--s5); }
/* Seven cards in the pile. */
.pile { height: 340px; }
.pile .card { width: 150px; }
.pile .card:nth-child(1) { --x: 0%;  --y: 40px; }
.pile .card:nth-child(2) { --x: 14%; --y: 6px; }
.pile .card:nth-child(3) { --x: 28%; --y: 48px; }
.pile .card:nth-child(4) { --x: 42%; --y: 10px; }
.pile .card:nth-child(5) { --x: 56%; --y: 52px; }
.pile .card:nth-child(6) { --x: 68%; --y: 8px; }
.pile .card:nth-child(7) { --x: 80%; --y: 44px; }
@media (max-width: 640px) {
  .pile { height: 640px; }
  .pile .card { width: 132px; }
  .pile .card:nth-child(1) { --x: 0%;  --y: 10px; }
  .pile .card:nth-child(2) { --x: 34%; --y: 0px; }
  .pile .card:nth-child(3) { --x: 60%; --y: 30px; }
  .pile .card:nth-child(4) { --x: 6%;  --y: 210px; }
  .pile .card:nth-child(5) { --x: 44%; --y: 220px; }
  .pile .card:nth-child(6) { --x: 0%;  --y: 420px; }
  .pile .card:nth-child(7) { --x: 50%; --y: 430px; }
}
/* Pile: spread a little past the column, and keep the photos of people on top. */
@media (min-width: 641px) {
  .pile .card:nth-child(1) { --x: -9%; --y: 44px; z-index: 2; }
  .pile .card:nth-child(2) { --x: 8%;  --y: 4px; }
  .pile .card:nth-child(3) { --x: 24%; --y: 50px; z-index: 2; }
  .pile .card:nth-child(4) { --x: 41%; --y: 6px; }
  .pile .card:nth-child(5) { --x: 57%; --y: 52px; z-index: 2; }
  .pile .card:nth-child(6) { --x: 73%; --y: 4px; }
  .pile .card:nth-child(7) { --x: 88%; --y: 46px; z-index: 2; }
}

/* Home: text and photo sit side by side and are centred together as one block. */
@media (min-width: 1040px) {
  body[data-page="home"] .wrap { position: relative; left: -152px; }
  body[data-page="home"] .hero {
    float: none;
    position: absolute;
    top: -159px;
    left: calc(100% + 64px);
    width: 240px;
    margin: 0;
  }
}
/* Final hero layout: the photo sits inside the column, to the right of the intro,
   at every width. The text wraps beside it. This overrides the earlier variants. */
body[data-page="home"] .wrap { position: static; left: auto; }
body[data-page="home"] .hero,
.hero {
  position: relative;
  top: auto;
  left: auto;
  float: right;
  width: 168px;
  aspect-ratio: 2 / 3;
  margin: 4px 0 var(--s4) var(--s5);
  transform: none;
  box-shadow: none;
}
@media (max-width: 480px) {
  body[data-page="home"] .hero, .hero { width: 124px; margin-left: var(--s4); }
}

/* Product screenshots in work pages: hairline frame, and narrower sizes for tall images. */
.shot img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.shot-narrow { max-width: 300px; }
.shot-mid { max-width: 440px; }

/* Work pages: text first, then the images together at the bottom, each with a short caption. */
.gallery { margin-top: var(--s7); display: grid; gap: var(--s6); }
.gallery .shot { margin: 0; }
.gallery figcaption {
  margin-top: var(--s2);
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: var(--t-label, 12px);
  color: var(--tertiary);
}

/* Photo pile: cards float gently, pause while held, and glide when thrown. */
@keyframes bob {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  50% { translate: 0 -9px; rotate: 1.2deg; }
}
.pile .card { animation: bob 6s ease-in-out infinite; will-change: transform, translate; }
.pile .card:nth-child(2n) { animation-duration: 7.5s; animation-delay: -2s; }
.pile .card:nth-child(3n) { animation-duration: 5.2s; animation-delay: -3.4s; }
.pile .card:nth-child(5n) { animation-duration: 8.4s; animation-delay: -1.1s; }
.pile .card.is-held { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) { .pile .card { animation: none; } }

/* Mini carousel: swipe or scroll sideways, one image at a time. */
.carousel {
  display: flex;
  gap: var(--s4);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  padding-bottom: var(--s2);
  border-radius: var(--radius);
}
.carousel .slide { flex: 0 0 86%; margin: 0; scroll-snap-align: start; }
.carousel .slide img {
  display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top left;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--hover);
}
.carousel:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* Carousel slides: show the whole image, zoomed out, on a dotted canvas. */
.carousel .slide img {
  object-fit: contain;
  object-position: center;
  padding: var(--s5);
  box-sizing: border-box;
  background-color: var(--hover);
  background-image: radial-gradient(circle, var(--line) 1px, transparent 1.4px);
  background-size: 14px 14px;
}

/* Photo cards: no frame, just the photo with soft corners and a shadow. */
.pile .card { padding: 0; border: 0; background: none; border-radius: 12px; overflow: hidden; }
.pile .card img { border-radius: 0; }
html, body { overflow-x: hidden; }

/* While a card is being dragged, do not select text underneath it. */
.is-dragging, .is-dragging * { user-select: none !important; -webkit-user-select: none !important; cursor: grabbing !important; }

/* Gallery as cards: a two-column grid that reaches a little past the text column.
   Videos play when you point at them; click a card to see it large with a note. */
.gallery { grid-template-columns: 1fr; }
@media (min-width: 820px) {
  .gallery { grid-template-columns: 1fr 1fr; gap: var(--s5); margin-left: -72px; margin-right: -72px; }
}
.gallery .shot, .gallery .shot-narrow, .gallery .shot-mid { max-width: none; }
.js .gallery .shot {
  cursor: zoom-in;
  transition: transform var(--moderate, 0.16s) ease;
}
.js .gallery .shot:nth-child(odd) { transform: rotate(-0.8deg); }
.js .gallery .shot:nth-child(even) { transform: rotate(0.8deg); }
.js .gallery .shot:hover, .js .gallery .shot:focus-visible { transform: rotate(0deg) translateY(-3px); outline: none; }
.gallery .shot img, .gallery .shot video {
  width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top center;
  border-radius: 12px; border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 10px 28px rgba(0, 0, 0, 0.12);
  background: var(--hover);
}
.gallery .shot:hover img, .gallery .shot:hover video { box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08), 0 18px 44px rgba(0, 0, 0, 0.2); }

/* The zoomed view. */
.zoom {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: var(--s5);
  background: rgba(10, 10, 10, 0.78);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  cursor: zoom-out;
}
.zoom[hidden] { display: none; }
.zoom-card {
  width: min(1040px, 100%); max-height: 100%; overflow: auto;
  background: var(--bg); color: var(--primary, inherit);
  border: 1px solid var(--line); border-radius: 14px; padding: var(--s4);
  cursor: default;
}
.zoom-media img, .zoom-media video {
  display: block; width: 100%; max-height: 68vh; object-fit: contain;
  border-radius: 8px; background: var(--hover);
}
.zoom-title { margin: var(--s4) 0 var(--s1); font-weight: 500; }
.zoom-more { margin: 0; color: var(--secondary); max-width: 60ch; }
.zoom-close {
  float: right; margin: 0 0 var(--s2) var(--s2); padding: 4px 10px;
  font: inherit; font-size: 13px; color: var(--secondary);
  background: none; border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
}
.zoom-close:hover { color: var(--primary, inherit); }

.zoom-media img, .zoom-media video { height: auto; max-width: 100%; margin: 0 auto; width: auto; max-height: 68vh; }
.zoom-media { display: grid; place-items: center; clear: both; }

/* Zoomed view: solid card on a darker backdrop, so the note is easy to read. */
.zoom { background: rgba(8, 8, 8, 0.9); -webkit-backdrop-filter: none; backdrop-filter: none; }
.zoom-card { background: var(--bg); box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5); }
.zoom-title { color: var(--primary); font-size: 16px; }
.zoom-more { color: var(--primary); opacity: 0.86; }
/* Gallery cards sit straight; they only move when you point at them. */
.js .gallery .shot:nth-child(odd), .js .gallery .shot:nth-child(even) { transform: none; }
.js .gallery .shot:hover, .js .gallery .shot:focus-visible { transform: translateY(-3px); }

/* Project pages: the project's logo to the right of the title. */
.title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s5); }
.title-row .page-title { margin-bottom: 0; }
.title-logo { flex: none; width: 56px; height: 56px; border-radius: 14px; object-fit: cover; }
.title-row + .page-meta { margin-top: var(--s3); }
@media (max-width: 480px) { .title-logo { width: 44px; height: 44px; border-radius: 11px; } }

/* Project logos that hold their contrast in both themes. */
.title-logo-nonna {
  display: grid; place-items: center; width: 104px; height: 56px; padding: 0 12px; box-sizing: border-box;
  background: #fbeec9; border: 1px solid rgba(0, 0, 0, 0.06); border-radius: 14px;
}
.title-logo-nonna img { display: block; width: 100%; height: auto; }
.title-logo-sera .tile { fill: var(--primary); }
.title-logo-sera .mark { fill: var(--bg); }

/* Sera wordmark, as on eatsera.nl: Cormorant Garamond, wide tracking, flame red. */
@font-face {
  font-family: "Cormorant Garamond"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/CormorantGaramond-600.woff2") format("woff2");
}
.title-wordmark-sera {
  flex: none; align-self: center;
  font-family: "Cormorant Garamond", Georgia, serif; font-weight: 600;
  font-size: 34px; line-height: 1; letter-spacing: 0.3em; margin-right: -0.3em;
  color: #c93a18; white-space: nowrap;
}
[data-theme="dark"] .title-wordmark-sera { color: #e2512c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .title-wordmark-sera { color: #e2512c; } }
@media (max-width: 480px) { .title-wordmark-sera { font-size: 24px; } }

/* Home page rows: the cursor turns into the row's own mark. */
.cur-spaces { cursor: url("assets/cursors/spaces.png") 16 16, pointer; cursor: -webkit-image-set(url("assets/cursors/spaces.png") 1x, url("assets/cursors/spaces@2x.png") 2x) 16 16, pointer; }
.cur-organization { cursor: url("assets/cursors/organization.png") 16 16, pointer; cursor: -webkit-image-set(url("assets/cursors/organization.png") 1x, url("assets/cursors/organization@2x.png") 2x) 16 16, pointer; }
.cur-trials { cursor: url("assets/cursors/trials.png") 16 16, pointer; cursor: -webkit-image-set(url("assets/cursors/trials.png") 1x, url("assets/cursors/trials@2x.png") 2x) 16 16, pointer; }
.cur-programs { cursor: url("assets/cursors/programs.png") 16 16, pointer; cursor: -webkit-image-set(url("assets/cursors/programs.png") 1x, url("assets/cursors/programs@2x.png") 2x) 16 16, pointer; }
.cur-nonna { cursor: url("assets/cursors/nonna.png") 30 14, pointer; cursor: -webkit-image-set(url("assets/cursors/nonna.png") 1x, url("assets/cursors/nonna@2x.png") 2x) 30 14, pointer; }
.cur-sera { cursor: url("assets/cursors/sera.png") 38 14, pointer; cursor: -webkit-image-set(url("assets/cursors/sera.png") 1x, url("assets/cursors/sera@2x.png") 2x) 38 14, pointer; }

/* Sera: every card is vertical, like the phone it was made for. */
.gallery-vertical { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 820px) { .gallery-vertical { grid-template-columns: repeat(3, 1fr); } }
.gallery-vertical .shot img, .gallery-vertical .shot video { aspect-ratio: 9 / 16; object-position: center; }

/* The link to the next page: a clear, large card at the end of each page. */
.next { margin: var(--s8) 0 var(--s7); }
.next-card {
  display: grid; grid-template-columns: 1fr auto; column-gap: var(--s5); align-items: center;
  padding: var(--s5) var(--s5); border: 1px solid var(--line); border-radius: 14px;
  text-decoration: none; color: var(--primary); background: var(--hover);
  transition: transform 0.16s ease, border-color 0.16s ease;
}
.next-card:hover, .next-card:focus-visible { transform: translateY(-2px); border-color: var(--tertiary); }
.next-label { grid-column: 1; font-family: var(--mono, ui-monospace, Menlo, monospace); font-size: 12px; color: var(--tertiary); }
.next-name { grid-column: 1; font-size: 24px; line-height: 1.25; letter-spacing: -0.01em; margin-top: 4px; }
.next-line { grid-column: 1; color: var(--secondary); margin-top: 2px; }
.next-arrow { grid-column: 2; grid-row: 1 / span 3; font-size: 26px; color: var(--secondary); transition: transform 0.16s ease; }
.next-card:hover .next-arrow { transform: translateX(4px); color: var(--primary); }

/* Small company marks next to the year. */
.co { display: inline-block; height: 15px; width: auto; vertical-align: -3px; margin-right: 7px; }
.co-miro { width: 15px; }
.co-sf { height: 16px; width: 23px; vertical-align: -3.5px; }
.item-when { white-space: nowrap; }
.co-wrap { white-space: nowrap; }

/* Gallery lines up with the text column: same left and right edge as everything else. */
@media (min-width: 820px) { .gallery { margin-left: 0; margin-right: 0; gap: var(--s4); } }

/* Nine cards in the pile: two loose rows on desktop, three rows of three on phones. */
@media (min-width: 641px) {
  .pile { height: 470px; }
  .pile .card:nth-child(1) { --x: -9%; --y: 30px; z-index: 2; }
  .pile .card:nth-child(2) { --x: 11%; --y: 0px; z-index: 1; }
  .pile .card:nth-child(3) { --x: 31%; --y: 34px; z-index: 2; }
  .pile .card:nth-child(4) { --x: 51%; --y: 4px; z-index: 1; }
  .pile .card:nth-child(5) { --x: 70%; --y: 36px; z-index: 2; }
  .pile .card:nth-child(6) { --x: 0%;  --y: 232px; z-index: 1; }
  .pile .card:nth-child(7) { --x: 21%; --y: 250px; z-index: 2; }
  .pile .card:nth-child(8) { --x: 44%; --y: 236px; z-index: 2; }
  .pile .card:nth-child(9) { --x: 84%; --y: 240px; z-index: 2; }
}
@media (max-width: 640px) {
  .pile { height: 600px; }
  .pile .card { width: 112px; }
  .pile .card:nth-child(1) { --x: 0%;  --y: 10px; }  .pile .card:nth-child(2) { --x: 34%; --y: 0px; }   .pile .card:nth-child(3) { --x: 66%; --y: 20px; }
  .pile .card:nth-child(4) { --x: 2%;  --y: 200px; } .pile .card:nth-child(5) { --x: 35%; --y: 210px; } .pile .card:nth-child(6) { --x: 66%; --y: 196px; }
  .pile .card:nth-child(7) { --x: 0%;  --y: 396px; } .pile .card:nth-child(8) { --x: 34%; --y: 404px; } .pile .card:nth-child(9) { --x: 66%; --y: 392px; }
}
@media (min-width: 641px) {
  .pile .card:nth-child(6) { --x: 2%;  --y: 232px; }
  .pile .card:nth-child(7) { --x: 25%; --y: 250px; }
  .pile .card:nth-child(8) { --x: 48%; --y: 234px; }
  .pile .card:nth-child(9) { --x: 71%; --y: 246px; }
}

/* One text size and one measure everywhere: every paragraph is 16px and fills the 600px column. */
main p, .intro p, .prose p, .intro .intro-more { font-size: 16px; line-height: 26px; letter-spacing: 0; max-width: none; text-wrap: wrap; }
.page-meta, .links, .contact, main p.clock { text-wrap: wrap; }

/* Moving between pages: the header stays put and only the content changes. */
.js .site-header .rise { animation: none; opacity: 1; transform: none; }
@view-transition { navigation: auto; }
.site-header { view-transition-name: site-header; }
main { view-transition-name: page-content; }
::view-transition-old(site-header), ::view-transition-new(site-header) { animation: none; }
::view-transition-old(page-content) { animation: 0.12s ease both vt-out; }
::view-transition-new(page-content) { animation: 0.22s ease 0.06s both vt-in; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; } }

/* A small zoom when you point at the avatar or the speaking photo. */
.masthead img, .hero img { transition: transform 0.25s ease; }
.masthead a, .masthead .avatar, .hero { overflow: hidden; }
.masthead img:hover { transform: scale(1.12); }
.hero:hover img { transform: scale(1.06); }
@media (prefers-reduced-motion: reduce) { .masthead img:hover, .hero:hover img { transform: none; } }

/* The More view inside the home page. */
main[hidden] { display: none; }

/* Next card sits after the contact block. */
.next { margin: var(--s7) 0 var(--s6); }

/* Miro logo inline in the intro sentence */
.co.co-inline { width: 1em; height: 1em; display: inline-block; vertical-align: -0.14em; margin: 0 0.08em 0 0; }

/* Zoom note uses the full width of the card. */
.zoom-more { max-width: none; line-height: 26px; }

/* Subpages: a calmer ending. Links get air, then the Next card, then one footer line with the contact links. */
article .links { margin-top: var(--s6); }
.next { margin: var(--s8) 0 var(--s8); }
.site-footer-contact { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); flex-wrap: wrap; }
.site-footer-contact p { margin: 0; }
.footer-contact { display: flex; gap: var(--s4); }
.footer-contact a { color: var(--secondary); text-decoration: none; }
.footer-contact a:hover { color: var(--primary); }
.site-footer-contact { gap: 0; flex-wrap: nowrap; }
.site-footer-contact p:first-child { flex: 1; }
.site-footer-contact .footer-contact { padding-top: var(--s4); border-top: 1px solid var(--line); }
.site-footer { margin-top: 0; }

/* One ending for every page: the hello, the contact links, and the year at the right. */
.site-end { margin-top: var(--s8); padding-bottom: var(--s8); }
.end-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); flex-wrap: wrap; }
.end-row p { margin: 0; }
.end-note { font-family: var(--mono, ui-monospace, Menlo, monospace); font-size: 12px; color: var(--tertiary); white-space: nowrap; }
.next { margin: var(--s8) 0 0; }

/* Project links sit on the meta row, right aligned. */
.meta-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); flex-wrap: wrap; margin: 0 0 var(--s6); }
.meta-row .page-meta, .meta-row .links { margin: 0; }
.title-row + .meta-row { margin-top: var(--s3); }

/* Project pages: the text folds after two paragraphs so the pictures show early. */
.prose.is-clamped {
  overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 calc(100% - 40px), transparent);
  mask-image: linear-gradient(#000 calc(100% - 40px), transparent);
}
.more-toggle {
  display: block; margin: var(--s3) auto 0; padding: 6px 14px;
  font-family: var(--mono); font-size: var(--t-label); line-height: var(--lh-label);
  color: var(--secondary); background: none; border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
  transition: color var(--quick) var(--ease), border-color var(--quick) var(--ease);
}
.more-toggle::before { content: "+ "; color: var(--tertiary); }
.more-toggle[aria-expanded="true"]::before { content: "\2212 "; }
.more-toggle:hover, .more-toggle:focus-visible { color: var(--primary); border-color: var(--tertiary); }
.more-toggle + .gallery { margin-top: var(--s6); }

/* A longer, softer fade over the folded text. */
.prose.is-clamped {
  -webkit-mask-image: linear-gradient(#000 calc(100% - 110px), transparent 96%);
  mask-image: linear-gradient(#000 calc(100% - 110px), transparent 96%);
}
.more-toggle { margin-top: 0; position: relative; }

/* Project pages: a tighter top, so the text and pictures start sooner. */
main > article:first-child { margin-top: var(--s6); }
.crumb { margin-bottom: var(--s5); }
.page-title { margin-bottom: var(--s2); }
.title-row + .meta-row { margin-top: var(--s2); }
.meta-row { margin-bottom: var(--s5); }
@media (max-width: 640px) { .crumb { margin-bottom: var(--s4); } }
/* The breadcrumb belongs to the title, so it sits right on top of it. */
.crumb { margin-bottom: var(--s2); }
@media (max-width: 640px) { .crumb { margin-bottom: var(--s2); } }
/* Pages without links keep the same spacing under the meta line. */
.page-meta { margin-bottom: var(--s5); }
.title-row + .page-meta { margin-top: var(--s2); }

/* Sera cursor: the box takes the same grey as the row hover, per theme. */
.cur-sera { cursor: url("assets/cursors/sera-light.png") 38 14, pointer; cursor: -webkit-image-set(url("assets/cursors/sera-light.png") 1x, url("assets/cursors/sera-light@2x.png") 2x) 38 14, pointer; }
:root[data-theme="dark"] .cur-sera { cursor: url("assets/cursors/sera-dark.png") 38 14, pointer; cursor: -webkit-image-set(url("assets/cursors/sera-dark.png") 1x, url("assets/cursors/sera-dark@2x.png") 2x) 38 14, pointer; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cur-sera { cursor: url("assets/cursors/sera-dark.png") 38 14, pointer; cursor: -webkit-image-set(url("assets/cursors/sera-dark.png") 1x, url("assets/cursors/sera-dark@2x.png") 2x) 38 14, pointer; }
}
.meta-row .links { margin-left: auto; }
.meta-row .links:only-child { margin-left: 0; }

/* Photo pile: a tighter heap, cards are allowed to overlap. */
@media (min-width: 641px) {
  .pile { height: 350px; }
  .pile .card:nth-child(1) { --x: 0%;  --y: 24px; z-index: 1; }
  .pile .card:nth-child(2) { --x: 18%; --y: 0px;  z-index: 2; }
  .pile .card:nth-child(3) { --x: 37%; --y: 30px; z-index: 1; }
  .pile .card:nth-child(4) { --x: 56%; --y: 4px;  z-index: 2; }
  .pile .card:nth-child(5) { --x: 75%; --y: 28px; z-index: 1; }
  .pile .card:nth-child(6) { --x: 9%;  --y: 150px; z-index: 3; }
  .pile .card:nth-child(7) { --x: 28%; --y: 166px; z-index: 4; }
  .pile .card:nth-child(8) { --x: 47%; --y: 148px; z-index: 3; }
  .pile .card:nth-child(9) { --x: 66%; --y: 160px; z-index: 4; }
}
@media (min-width: 641px) {
  .pile { height: 372px; }
  .pile .card:nth-child(6) { --y: 170px; }
  .pile .card:nth-child(7) { --y: 184px; }
  .pile .card:nth-child(8) { --y: 168px; }
  .pile .card:nth-child(9) { --y: 178px; }
}
@media (max-width: 640px) {
  .pile { height: 450px; }
  .pile .card { width: 128px; }
  .pile .card:nth-child(1) { --x: 0%;  --y: 12px;  z-index: 1; } .pile .card:nth-child(2) { --x: 31%; --y: 0px;   z-index: 2; } .pile .card:nth-child(3) { --x: 62%; --y: 16px;  z-index: 1; }
  .pile .card:nth-child(4) { --x: 4%;  --y: 138px; z-index: 3; } .pile .card:nth-child(5) { --x: 33%; --y: 150px; z-index: 4; } .pile .card:nth-child(6) { --x: 60%; --y: 134px; z-index: 3; }
  .pile .card:nth-child(7) { --x: 0%;  --y: 268px; z-index: 5; } .pile .card:nth-child(8) { --x: 30%; --y: 280px; z-index: 6; } .pile .card:nth-child(9) { --x: 62%; --y: 264px; z-index: 5; }
}
/* Ten cards. */
@media (min-width: 641px) {
  .pile .card:nth-child(6) { --x: 2%; }
  .pile .card:nth-child(7) { --x: 21%; }
  .pile .card:nth-child(8) { --x: 39%; }
  .pile .card:nth-child(9) { --x: 58%; }
  .pile .card:nth-child(10) { --x: 76%; --y: 182px; z-index: 5; }
}
@media (max-width: 640px) {
  .pile { height: 560px; }
  .pile .card:nth-child(10) { --x: 31%; --y: 384px; z-index: 7; }
}
/* Eleven cards. */
@media (min-width: 641px) { .pile .card:nth-child(11) { --x: 30%; --y: 96px; z-index: 6; } }
@media (max-width: 640px) {
  .pile .card:nth-child(10) { --x: 10%; }
  .pile .card:nth-child(11) { --x: 52%; --y: 396px; z-index: 8; }
}

/* Phones: the photo sits beside the opening sentence only; the next paragraph starts below it, full width.
   Tighter vertical padding throughout. */
@media (max-width: 640px) {
  body[data-page="home"] .hero, .hero { width: 116px; margin: 2px 0 var(--s3) var(--s4); }
  .intro .intro-more { clear: right; }
  main > * { margin-top: var(--s6); }
  main > article:first-child { margin-top: var(--s5); }
  .site-header { padding-top: var(--s4); }
  .bar { margin-top: var(--s4); }
  .next { margin-top: var(--s7); }
  .site-end { margin-top: var(--s7); padding-bottom: var(--s7); }
  .gallery { gap: var(--s4); }
}
