:root {
  color-scheme: light dark;
  --paper: #FFFFFF;
  --ink: #0E0E0E;
  --soft: #5C5C5C;
  --accent: #0000FF;

  /* one grotesk for everything; size, weight and tracking make the hierarchy */
  --text: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  /* five steps: small, text, middle, large, and the display sizes that fill a width */
  --small: 15px;
  --body: clamp(17px, 0.25vw + 16px, 19px);
  --middle: clamp(22px, 1.6vw + 12px, 34px);
  --large: clamp(40px, 4.4vw, 72px);

  --margin: clamp(20px, 3.4vw, 48px);
  --gap: clamp(20px, 2.4vw, 40px);
  /* the share of the first screen the portrait or product picture takes */
  --cover: 44vw;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101010;
    --ink: #F2F2F2;
    --soft: #A0A0A0;
    --accent: #6F8FFF;
  }
}

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

html { background: var(--paper); -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font: 400 var(--body)/1.55 var(--text);
  color: var(--ink);
  background: var(--paper);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3 { font-weight: 400; }
h2 { font: 600 var(--large)/1 var(--text); letter-spacing: -0.04em; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; }
ul { list-style: none; }
figcaption { font-size: var(--small); color: var(--soft); }
figcaption { margin-top: 14px; max-width: 40em; }
.lead { font: 500 var(--middle)/1.25 var(--text); letter-spacing: -0.02em; }

/* the one action in the top row is a plain underlined link with a full-size target */
.button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: underline;
  text-underline-offset: 0.25em;
  white-space: nowrap;
}

/* the first stop for the keyboard, out of sight until it is focused */
.skip { position: absolute; z-index: 3; left: var(--margin); top: 12px; padding: 8px 12px; background: var(--paper); transform: translateY(-200%); }
.skip:focus { transform: none; }

/* === Pictures: printed in dots by a shader over the photograph, which stays for when there is no WebGL === */
.print { position: relative; overflow: hidden; }
.print img { display: block; width: 100%; height: 100%; object-fit: cover; transition: opacity 400ms; }
.print.printed img { opacity: 0; }
/* where no photograph fits, a dithered shape; flat colour without WebGL */
[data-shader="dither"] { background: color-mix(in srgb, var(--accent) 12%, var(--paper)); }

/* === The top row, over the half of the first screen that holds the name === */
.top {
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 20px var(--margin);
  font-size: var(--small);
}
.top { container-type: inline-size; }
.top a { white-space: nowrap; }
.top a:not(.button) { text-decoration: none; }
@container (max-width: 560px) { .top nav { display: none; } }
.mark { font-weight: 500; margin-right: auto; }
.top nav { display: flex; gap: 28px; }
.top:has(~ main .cover) { right: var(--cover); }

/* === First screen: the name as large as the half allows, the portrait printed to the edges beside it === */
.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 120px var(--margin) 56px;
}
.hero:has(.cover) { display: grid; grid-template-columns: minmax(0, 1fr) var(--cover); padding: 0; }
.title { display: flex; flex-direction: column; justify-content: center; padding: 120px var(--margin) 56px; container-type: inline-size; }
/* beside a picture the name never runs past its half: 19cqi fits the widest name, PhoneCode */
.title .name { font-size: min(clamp(64px, 10.6vw, 196px), 19cqi); }
.cover { position: relative; }
.cover > .print { position: absolute; inset: 0; }
/* a product screenshot is printed whole on a panel in the accent, in a box of its own shape with its own rounded corners,
   so nothing outside the screenshot prints; pointing at it closes up the dots and then shows the screenshot itself */
.cover { background: color-mix(in srgb, var(--accent) 10%, var(--paper)); }
.shot { position: absolute; inset: 0; display: grid; place-items: center; padding: clamp(40px, 6vw, 96px); container-type: size; }
.shot .print { width: min(100cqw, 100cqh * var(--ar)); aspect-ratio: var(--ar); outline: 1px solid color-mix(in srgb, var(--ink) 12%, transparent); }
.shot .print.printed:hover img { opacity: 1; transition-delay: 220ms; }
.name {
  font: 600 clamp(64px, 10.6vw, 196px)/0.86 var(--text);
  letter-spacing: -0.055em;
  view-transition-name: name;
}
/* standing alone, the name runs the width of the page */
.hero:not(:has(.cover)) .name { font-size: 24vw; }
/* each line rises from behind its own baseline */
/* at 0.86 line height a descender reaches 1.005em below the line top, so each mask leaves 1.02em and gives the extra back */
.name .line { display: block; overflow: hidden; padding-bottom: 0.16em; margin-bottom: -0.09em; }
.name .line > span { display: inline-block; }
.name .ch { display: inline-block; }
@media (prefers-reduced-motion: no-preference) {
  /* main.js splits the name into letters that rise one after another; if it never runs, the whole line rises late instead */
  .js .name .line > span { animation: rise 900ms 1200ms var(--ease) both; }
  .js .name.split .line > span { animation: none; }
  .js .name .ch { animation: rise 1100ms calc(120ms + var(--i) * 32ms) var(--ease) both; }
}
.hero-line { max-width: 26ch; margin-top: 32px; font: 500 var(--middle)/1.25 var(--text); letter-spacing: -0.02em; }
.js .hero-line { animation: appear 700ms 450ms var(--ease) both; }
.js .cover .print { animation: appear 900ms 150ms var(--ease) both; }

@keyframes rise { from { transform: translateY(110%) rotate(4deg); } }
@keyframes appear { from { opacity: 0; transform: translateY(12px); } }

/* === Byala Slatina across the page === */
.about { padding: 160px 0 0; }
/* each section opens on a full-width rule, the grid's one line */
.about::before, .showcase::before, .ledger::before, .lineup::before {
  content: '';
  grid-column: 1 / -1;
  display: block;
  height: 1px;
  margin-bottom: 24px;
  background: var(--ink);
}
.about::before { margin: 0 var(--margin) 24px; }
.band { position: relative; }
.band .print { height: min(72svh, 56vw); }
.band figcaption { padding-inline: var(--margin); }
/* where a pointer can hover, a picture names its source only when pointed at */
@media (hover: hover) {
  .band figcaption {
    position: absolute;
    left: var(--margin);
    bottom: 16px;
    margin: 0;
    padding: 8px 12px;
    background: var(--paper);
    color: var(--ink);
    opacity: 0;
    transition: opacity 200ms;
  }
  .band:hover figcaption, .band:focus-within figcaption { opacity: 1; }
}

/* === Epigenesis: the words on the left, a dithered print on the right === */
.showcase {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 16px;
  padding: 200px var(--margin) 0;
}
.showcase h2 { grid-column: 1 / -1; margin-bottom: 56px; }
.showcase .copy { grid-column: 1 / 6; }
.copy p + p { margin-top: 1em; }
.copy .lead { margin-bottom: 1em; }
.specimen { grid-column: 7 / 13; }
.specimen { aspect-ratio: 4 / 3; }

/* === Work: two panels side by side, each headed by its own moving print === */
.ledger {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 72px var(--gap);
  padding: 200px var(--margin) 0;
}
.group > .print { aspect-ratio: 16 / 10; margin-bottom: 36px; }
.group h2 { margin-bottom: 20px; }
.group .intro { max-width: 30em; margin-bottom: 28px; }
.group ul { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 28px; }
.group li { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-items: baseline; padding: 12px 0; transition: opacity 200ms; }
.group li > :first-child { font: 500 var(--middle)/1.15 var(--text); letter-spacing: -0.02em; text-decoration: none; }
/* pointing at one row quiets the others */
.group ul:has(a:hover) li:not(:has(a:hover)) { opacity: 0.4; }
/* a product page's single panel reads across the page */
.ledger:not(:has(.group + .group)) { grid-template-columns: minmax(0, 860px); }

/* === Open source: what it is on the left, every pull request at one size on the right === */
.lineup {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 16px;
  align-items: start;
  padding: 200px var(--margin);
}
.lineup .side { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; grid-template-rows: auto 1fr; align-items: start; }
.lineup .side > h2, .lineup .side > .lead { grid-column: 1 / 6; }
.lineup .side > .lead { margin-top: 28px; }
.lineup .side > .table { grid-column: 7 / 13; grid-row: 1 / span 2; }
.table { font-size: var(--middle); line-height: 1.5; }
.table h3 { font: inherit; color: var(--accent); margin: 56px 0 12px; }
.table h3:first-child { margin-top: 0; }
.table a { display: grid; grid-template-columns: 4.6em 1fr; text-decoration: none; }
.table a span:first-child { font-variant-numeric: tabular-nums; color: var(--soft); }
.table a span { transition: color 150ms; }
.table a:hover span { color: var(--accent); }

/* a product page's download block */
.lineup .head { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; row-gap: 24px; }
.lineup .head h2 { grid-column: 1 / 6; }
.lineup .head .copy { grid-column: 7 / 13; }
.copy .links { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-top: 16px; }
.legal { display: flex; gap: 24px; margin-top: 28px; font-size: var(--small); color: var(--soft); }

/* === Legal pages: one readable column under the top row === */
.doc { max-width: calc(720px + 2 * var(--margin)); margin: 0 auto; padding: 160px var(--margin) 160px; }
.doc h1 { font: 600 var(--large)/1 var(--text); letter-spacing: -0.04em; }
.doc .date { margin: 20px 0 72px; font-size: var(--small); color: var(--soft); }
.doc h2 { font: 500 var(--middle)/1.2 var(--text); letter-spacing: -0.02em; margin: 64px 0 16px; }
.doc p + p, .doc ul + p, .doc p + ul { margin-top: 1em; }
.doc ul { list-style: disc; padding-left: 1.2em; }
.doc li + li { margin-top: 0.5em; }

/* === The close: the address as display type on the dark ground === */
.close {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  padding: 40px var(--margin);
  background: var(--ink);
  color: var(--paper);
  overflow: hidden;
}
.close a:hover { color: var(--accent); }
@media (prefers-color-scheme: dark) {
  .close { background: color-mix(in srgb, var(--accent) 14%, var(--paper)); color: var(--ink); }
}
.ask { max-width: 22ch; font: 500 var(--middle)/1.25 var(--text); letter-spacing: -0.02em; }
.email {
  align-self: end;
  font: 600 11.4vw/0.9 var(--text);
  letter-spacing: -0.055em;
  white-space: nowrap;
  text-decoration: none;
  transition: color 200ms;
}
.corners { display: flex; justify-content: space-between; gap: 24px; padding-top: 28px; font-size: var(--small); }
.corners span:last-child { display: flex; gap: 20px; }
.credits { max-width: 62em; margin-top: 48px; font-size: var(--small); opacity: 0.7; }

/* === Entrances: each block rises once as it comes into view === */
/* words lift in, headings rise out of their own line, pictures open from the bottom, rows follow one another */
.armed [data-reveal] { opacity: 0; transform: translateY(32px); transition: opacity 800ms var(--ease), transform 1100ms var(--ease); }
.armed [data-reveal].in { opacity: 1; transform: none; }
.armed .copy[data-reveal].in, .armed .group + .group[data-reveal].in { transition-delay: 90ms; }
.armed [data-reveal] h2 { clip-path: inset(-0.2em -0.2em 100% -0.2em); transform: translateY(0.4em); transition: clip-path 1100ms var(--ease), transform 1100ms var(--ease); }
.armed [data-reveal].in h2 { clip-path: inset(-0.2em -0.2em -0.3em -0.2em); transform: none; }
.armed .print[data-reveal], .armed [data-reveal] > .print, .armed .band > .print { opacity: 1; transform: none; clip-path: inset(100% 0 0 0); transition: clip-path 1400ms var(--ease); }
.armed .print[data-reveal].in, .armed [data-reveal].in > .print, .armed .band.in > .print { clip-path: inset(0); }
.armed .specimen[data-reveal].in { transition-delay: 160ms; }
.armed :is(.print[data-reveal], [data-reveal] > .print, .band > .print) > * { scale: 1.12; transition: scale 1800ms var(--ease), opacity 400ms; }
.armed .in.print > *, .armed .in > .print > * { scale: 1; }
.armed [data-reveal] :is(li, .table > *) { opacity: 0; translate: 0 14px; transition: opacity 700ms var(--ease), translate 900ms var(--ease); transition-delay: calc(200ms + var(--i, 0) * 55ms); }
.armed [data-reveal].in :is(li, .table > *) { opacity: 1; translate: none; }
.armed :is(.about, .showcase, .ledger, .lineup)::before { transform: scaleX(0); transform-origin: left; transition: transform 1400ms var(--ease); }
.armed :is(.about, .showcase, .ledger, .lineup).in::before { transform: none; }

/* scrolling away, the name drifts up behind the page; scrolling in, the address slides home */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .hero .name { animation: drift linear both; animation-timeline: view(); animation-range: exit 0% exit 100%; }
    .email { animation: arrive linear both; animation-timeline: view(); animation-range: entry 0% entry 100%; }
  }
}
@keyframes drift { to { transform: translateY(-18%); opacity: 0.2; } }
@keyframes arrive { from { transform: translateX(12%); } }

/* going from page to page, the name stays and becomes the next one */
@view-transition { navigation: auto; }

/* === Tablets: panels stack before their columns get too narrow to read === */
@media (max-width: 1024px) {
  .showcase .copy { grid-column: 1 / 9; }
  .specimen { grid-column: 1 / -1; margin-top: 56px; aspect-ratio: 16 / 9; }
  .ledger { grid-template-columns: minmax(0, 1fr); }
  .lineup .side > h2, .lineup .side > .lead, .lineup .side > .table { grid-column: 1 / -1; }
  .lineup .side > .table { grid-row: auto; margin-top: 56px; }
  .lineup .side > .lead { max-width: 34em; }
}

/* === The phone gets its own composition === */
@media (max-width: 720px) {
  /* one column on the margins; pictures run to the edges of the screen */
  .top, .top:has(~ main .cover) { right: 0; min-height: 52px; padding: 0 var(--margin); background: var(--paper); }
  .top nav { display: none; }
  .hero { padding: 76px var(--margin) 40px; }
  .hero:has(.cover) { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; padding: 52px 0 0; }
  .cover { grid-row: 1; aspect-ratio: 4 / 5; }
  /* a whole screenshot keeps its own shape instead of floating in paper */
  .cover:has(.shot) { aspect-ratio: auto; }
  .shot { position: relative; height: min(calc((100vw - 2 * var(--margin)) / var(--ar) + 64px), 62svh); padding: 32px var(--margin); }
  .title { padding: 28px var(--margin) 48px; }
  .name, .hero:not(:has(.cover)) .name { font-size: 20.5vw; }
  /* a product's one long word gets the width a two-line name gets per line */
  .title .name:not(:has(.line + .line)) { font-size: 15vw; }
  .hero-line { margin-top: 20px; font-size: 20px; }

  .about, .showcase, .ledger, .lineup { padding-top: 72px; }
  .band .print { height: auto; aspect-ratio: 4 / 3; }

  .showcase h2 { margin-bottom: 24px; }
  .showcase .copy, .lineup .head h2, .lineup .head .copy { grid-column: 1 / -1; }
  .specimen { grid-column: 1 / -1; margin: 40px calc(-1 * var(--margin)) 0; }

  .ledger { grid-template-columns: 1fr; row-gap: 72px; }
  .group > .print { margin: 0 calc(-1 * var(--margin)) 28px; }
  .group ul { display: block; }
  .group li { grid-template-columns: 1fr; row-gap: 2px; padding: 10px 0; }
  .doc { padding-top: 112px; }

  .lineup { padding-bottom: 96px; }
  .lineup .side > h2, .lineup .side > .lead, .lineup .side > .table { grid-column: 1 / -1; }
  .lineup .side > .table { grid-row: auto; margin-top: 48px; }
  .table { font-size: 20px; }
  .table h3 { margin-top: 40px; }
  .table a { grid-template-columns: 4em 1fr; padding: 4px 0; }

  .close { min-height: 80svh; }
  .email { font-size: 11.2vw; }
  .corners { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  @view-transition { navigation: none; }
}

@media print {
  .top, [data-shader="dither"] { display: none; }
  .hero, .close { min-height: 0; }
  .close { background: none; color: inherit; }
  .print.printed img { opacity: 1; }
  .print canvas { display: none; }
}
