/* Sizes follow the 1728px-wide Figma artboard: calc(N * var(--s)) is N design pixels, scaled to the window. */
:root {
  --s: calc(min(100vw, 1728px) / 1728);
  --bg: #000;
  --fg: #fff;
  --muted: #8a8a8a;
  --close-bg: #3d3d3d;
  --display: "Funnel Display", "Helvetica Neue", Arial, sans-serif;
  --sans: "Funnel Sans", "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
body.clock-open { overflow: hidden; }

/* ---------- landing ---------- */
.landing {
  max-width: 1728px;
  margin: 0 auto;
  padding: calc(64 * var(--s)) 0 0;
  overflow-x: clip;               /* the glass canvas reaches past the ends of the title; never widen the page */
  position: relative;
}

/* Photos float, still, around the title at different sizes, all behind it.
   Positions are design px on the 1728 artboard. Video, title and statement stack above them. */
.photos { position: absolute; inset: 0; pointer-events: none; }
.photo {
  position: absolute;
  margin: 0;
  overflow: hidden;
  pointer-events: auto;
  z-index: 0;
}
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* While the mouse is over a photo, the canvas draws it through the static and the black page shows in the dot gaps. */
.photo canvas.glass { position: absolute; inset: 0; width: 100%; height: 100%; visibility: hidden; }
.photo.static canvas.glass { visibility: visible; }
.photo.static img { visibility: hidden; }
.p1 { left: calc(1010 * var(--s)); top: calc(150 * var(--s)); width: calc(460 * var(--s)); aspect-ratio: 3 / 2; }
.p2 { left: calc(1500 * var(--s)); top: calc(330 * var(--s)); width: calc(190 * var(--s)); aspect-ratio: 1; }
.p3 { left: calc(40 * var(--s));   top: calc(530 * var(--s)); width: calc(400 * var(--s)); aspect-ratio: 3 / 2; }
.p4 { left: calc(805 * var(--s));  top: calc(40 * var(--s));  width: calc(200 * var(--s)); aspect-ratio: 4 / 5; }
.video, .statement { position: relative; z-index: 1; }
.video {
  display: block;
  margin-left: calc(64 * var(--s));
  width: calc(730 * var(--s));
  aspect-ratio: 730 / 411;
  position: relative;
  background: var(--bg);
}
.video video { display: block; width: 100%; height: 100%; object-fit: cover; }
.video .play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
}
.video .play[hidden] { display: none; }
/* The title overlaps the bottom of the video by 100 design px. */
.title {
  position: relative;
  z-index: 1;
  pointer-events: none;           /* so the photos behind the letters still notice the mouse */
  width: fit-content;
  margin: calc(-100 * var(--s)) 0 0 calc(224 * var(--s));
}
.title h1 {
  margin: 0;
  font: 600 calc(160 * var(--s)) / normal var(--display);
  white-space: nowrap;
}
/* With WebGL running, the canvas draws the title and the real text stays for screen readers and search. */
.title h1.refracted { color: transparent; }
.title canvas.glass { position: absolute; top: 0; pointer-events: none; }

.statement {
  width: calc(766 * var(--s));
  margin: calc(40 * var(--s)) 0 0 calc(794 * var(--s));
  font-size: max(14px, calc(16 * var(--s)));
  line-height: normal;
}
.statement p { margin: 0 0 1.2em; }
.statement p:last-of-type { margin-bottom: 0; }
.statement .note { color: rgb(255 255 255 / 0.5); }   /* same 50% as the credit in the intro dialog */
.statement a { color: inherit; text-decoration-skip-ink: none; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 0;
  border-radius: 4px;
  background: var(--fg);
  color: var(--bg);
  font: 600 16px / normal var(--sans);
  cursor: pointer;
}
.button:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }
.statement .button { margin-top: max(24px, calc(40 * var(--s))); }

/* Lines up with the statement column, 128px below the Try it out button. */
.credit {
  max-width: 1728px;
  margin: 128px auto 0;
  padding: 0 0 max(24px, calc(48 * var(--s))) calc(794 * var(--s));
  font-size: 12px;
  opacity: 0.5;
}

/* ---------- before you begin ---------- */
.intro {
  width: min(467px, calc(100vw - 32px));
  padding: 31px;                  /* + the 1px border = Figma's 32px (its stroke sits inside the padding) */
  border: 1px solid #e6e6e6;
  border-radius: 8px;
  background: rgb(255 255 255 / 0.8);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  color: #000;
}
.intro::backdrop { background: rgb(0 0 0 / 0.75); }
.intro h2 { margin: 0 0 16px; font: 800 16px / 1.1 var(--display); }
.intro p { margin: 0; font-size: 16px; line-height: 1.4; }
.intro .note { margin-top: 16px; color: rgb(0 0 0 / 0.5); }
.intro a { color: inherit; text-decoration-skip-ink: none; }
.intro .button { width: 100%; margin-top: 24px; background: #000; color: var(--fg); }
.intro .button:focus-visible { outline-color: #000; }

/* ---------- clock ---------- */
.clock {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.clock[hidden] { display: none; }
/* The dot grid is 1530×771 on the 1728-wide artboard. */
#grid {
  width: min(88.54vw, calc((100dvh - 140px) * 1530 / 771));
  aspect-ratio: 1530 / 771;
}
.close {
  position: absolute;
  top: max(16px, calc(32 * var(--s)));
  right: max(16px, calc(33 * var(--s)));
  background: var(--close-bg);
  color: var(--fg);
}
.status {
  position: absolute;
  bottom: max(24px, calc(80 * var(--s)));
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  text-align: center;
  padding: 0 16px;
}
/* While the camera and model load (and if they fail), the view is blank with the message in the middle. */
.clock.starting #grid { visibility: hidden; }
.clock.starting .status { top: 50%; bottom: auto; transform: translateY(-50%); }
#video { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
#debug {
  position: absolute; left: 16px; bottom: 16px;
  color: #888; font: 12px/1.4 ui-monospace, Menlo, monospace;
  display: none;
}
#debug.on { display: block; }
#debug canvas { width: 200px; display: block; margin-bottom: 6px; transform: scaleX(-1); border-radius: 4px; }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  .landing { padding: 16px 16px 0; }
  .video { margin: 0; width: 100%; }
  /* Two lines, "unobserved" over "time": up to 64px, smaller where "unobserved" (~5.75em) wouldn't fit.
     Keeps the design's overlap with the video (0.625em). */
  .title { font-size: min(64px, calc((100vw - 32px) / 5.8)); margin: -0.625em 0 0; }
  .title h1 { font-size: 1em; line-height: 1; white-space: normal; }
  .statement { width: auto; margin: 28px 0 0; font-size: 15px; }
  /* Photos scatter between the title and the statement; one tucks up behind "time". */
  .landing { display: flex; flex-direction: column; }
  .video { order: 0; } .title { order: 1; } .photos { order: 2; } .statement { order: 3; }
  .photos { position: relative; inset: auto; height: 64vw; margin-top: -10vw; }
  .p1 { left: 40%; top: 30%; width: 58%; }
  .p2 { left: 2%;  top: 36%; width: 34%; }
  .p3 { left: 36%; top: 0;   width: 30%; }
  .p4 { left: 70%; top: 0;   width: 24%; }
  .credit { padding: 0 16px 24px; }
  #grid { width: calc(100vw - 32px); }
}
/* Phones held upright: the clock fills the screen, hours over minutes over seconds (drawn by clock.js). */
@media (max-width: 760px) and (orientation: portrait) {
  #grid { width: 100vw; height: 100dvh; aspect-ratio: auto; }
}
