@font-face {
  font-family: "Cygnito Mono";
  src: url("assets/cygnito-mono.woff2") format("woff2");
  font-display: swap;
}

/* grid-v2b's stage, plus the glass ball. */
:root {
  --bg: #e3e3e3;
  --ball: 200px;       /* set from ball.js */
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

.stage {
  position: fixed;
  inset: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.stage.is-dragging { cursor: grabbing; }

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 500ms ease;
}
.stage.is-ready canvas { opacity: 1; }

/* ---- The ball ------------------------------------------------------------- */

.ball {
  position: fixed;
  /* v4a: rides on the page — starts in from the corner, then moves as the
     page is dragged (ball.js sets --pan-x/--pan-y, kept on screen). v2c,
     after Figma, hung it ~0.34 R off the left and ~0.28 R off the bottom. */
  /* Until ball.js takes over it waits above the screen, ready to drop in. */
  --pan-y: -100vh;
  left: calc(32px + var(--pan-x, 0px));
  bottom: calc(32px - var(--pan-y, 0px));
  width: var(--ball);
  height: var(--ball);
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
  z-index: 10;
}
.ball.is-dragging { cursor: grabbing; }

.ball:focus-visible { outline: 2px solid rgb(0 0 0 / 0.4); outline-offset: 4px; }

/* Glass: frosted fallback first; Chromium also understands the SVG lens and
   replaces it with real refraction (other browsers drop that declaration). */
.ball-glass {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backdrop-filter: blur(1.5px) saturate(1.15);
  -webkit-backdrop-filter: blur(1.5px) saturate(1.15);
}
.ball-glass.has-lens { backdrop-filter: url(#lens); }
/* v5a: frosted plastic — what's behind blurred right out, a touch brighter. */
.ball-glass.is-frosted {
  backdrop-filter: blur(var(--frost-blur, 14px)) saturate(1.05) brightness(1.06);
  -webkit-backdrop-filter: blur(var(--frost-blur, 14px)) saturate(1.05) brightness(1.06);
}

.ball-canvas {
  /* The Figma ball is turned 5.63° (its shading and the logo with it). */
  transform: rotate(5.63deg);
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

/* Direction hints: four small chevrons that appear on hover. */
.ball-hint {
  position: absolute;
  width: 8px;
  height: 8px;
  border-top: 1.5px solid rgb(0 0 0 / 0.5);
  border-left: 1.5px solid rgb(0 0 0 / 0.5);
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
}
.ball:hover .ball-hint, .ball:focus-visible .ball-hint { opacity: 1; }
.ball.is-dragging .ball-hint { opacity: 0; }
.ball-hint--up    { top: -14px;  left: 50%; transform: translateX(-50%) rotate(45deg); }
.ball-hint--down  { bottom: -14px; left: 50%; transform: translateX(-50%) rotate(225deg); }
.ball-hint--left  { left: -14px; top: 50%; transform: translateY(-50%) rotate(-45deg); }
.ball-hint--right { right: -14px; top: 50%; transform: translateY(-50%) rotate(135deg); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}



/* Sub-page tags curved round the ball (tags.js). */
.ball-tags {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 11;
  overflow: visible;
  text-transform: uppercase;
}

/* The 8-ball face is clickable (shake it). */
.ball.is-lucky:not(.is-dragging) { cursor: pointer; }

/* v4a: the ball's shadow on the page (placed by ball.js). */
.ball-shadow {
  position: fixed;
  left: 0;
  top: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9;
  background: radial-gradient(closest-side, rgb(0 0 0 / 0.38), rgb(0 0 0 / 0.18) 62%, transparent);
  filter: blur(12px);
}

/* Ball UI hidden (the panel's "show ball UI", off by default here). */
.no-ball-ui .ball, .no-ball-ui .ball-shadow, .no-ball-ui .ball-tags { display: none; }

/* sphere-ui_v5b: a clicked work's info card (work.js) — screen UI, top left,
   sliding in from the left like a menu. */
.work-card {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 12;
  transform: translateX(calc(-100% - 40px));
  transition: transform 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
  filter: drop-shadow(0 10px 24px rgb(0 0 0 / 0.18));
}
.work-card.is-on { transform: none; }
.work-card canvas { display: block; height: auto; }

/* sphere-ui_v5b: the works as outlines down the right (work.js; Figma
   "Object outlines / filled", node 839:9838) — 46px boxes, 24px apart. */
.work-rail {
  position: fixed;
  top: 50%;
  right: 8px;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-height: calc(100vh - 96px);
  /* Room either side for an outline grown on hover (the scroll clips it). */
  padding: 24px 22px;
  overflow-y: auto;
  scrollbar-width: none;
  /* The row fades out at its ends when there's more to scroll to. */
  -webkit-mask-image: linear-gradient(transparent, #000 48px, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(transparent, #000 48px, #000 calc(100% - 48px), transparent);
  overscroll-behavior: contain;
  transform: translate(calc(100% + 40px), -50%);
  transition: transform 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.work-rail::-webkit-scrollbar { display: none; }
.work-rail.is-on { transform: translate(0, -50%); }
.work-rail button {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transition: transform 220ms cubic-bezier(0.3, 1.5, 0.5, 1);   /* a little overshoot */
}
.work-rail button:hover { transform: scale(1.45); }
.work-rail button:focus-visible { outline: 2px solid rgb(0 0 0 / 0.4); outline-offset: 4px; }
.work-rail canvas { grid-area: 1 / 1; display: block; }
.work-rail canvas.is-on { opacity: 0; transition: opacity 200ms ease; }
.work-rail button.is-current canvas.is-on { opacity: 1; }

/* v5a: the filter tags round the ball are hidden for now (tags.js still runs). */
.ball-tags { display: none; }

/* v5a: a face that isn't the current page — click the ball to go there. */
.ball.is-go:not(.is-dragging) { cursor: pointer; }

/* ---- The top menu (menu.js; Figma "sec menu", node 855:10429) ----------------
   Layout from Figma; material from the ball: frosted white plastic — the page
   behind blurred and lifted, a milky body lighter at the top and shaded at
   the bottom (a rounded edge), a moulded orange-peel texture, a crisp light
   top edge and a soft drop shadow. */
.menu {
  --frost: rgb(250 250 251 / 0.5);
  position: fixed;
  top: 30px;
  left: 50%;
  translate: -50% 0;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 22px;
  height: 44px;
  box-sizing: border-box;
  padding: 0 18px 0 20px;
  border-radius: 999px;
  font: 12px/1 "Cygnito Mono", ui-monospace, monospace;
  text-transform: uppercase;
  color: #010103;
  white-space: nowrap;
  isolation: isolate;
  backdrop-filter: blur(11px) saturate(1.05) brightness(1.06);
  -webkit-backdrop-filter: blur(11px) saturate(1.05) brightness(1.06);
  /* A capsule, not a flat panel: lit from above, its body is brightest a
     little below the top edge, falls off through the middle and turns away
     darker underneath (a cylinder's shading), with the ends rounding off too. */
  background:
    linear-gradient(
      rgb(255 255 255 / 0.5) 0%,
      rgb(255 255 255 / 0.62) 14%,
      rgb(255 255 255 / 0.22) 38%,
      rgb(255 255 255 / 0) 56%,
      rgb(110 115 124 / 0.07) 72%,
      rgb(110 115 124 / 0.2) 90%,
      rgb(110 115 124 / 0.3) 100%),
    var(--frost);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.95),                  /* the lit top edge */
    inset 0 -1px 0 rgb(0 0 0 / 0.08),
    inset 0 -7px 10px -6px rgb(70 74 82 / 0.18),             /* the underside */
    inset 9px 0 12px -9px rgb(70 74 82 / 0.16),              /* the ends rounding off */
    inset -9px 0 12px -9px rgb(70 74 82 / 0.16),
    6px 14px 26px rgb(0 0 0 / 0.13),
    0 2px 3px rgb(0 0 0 / 0.08);
}
/* The light streak along the top of the capsule. */
.menu::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: 20px;
  right: 20px;
  top: 4px;
  height: 9px;
  border-radius: 999px;
  pointer-events: none;
  background: linear-gradient(90deg, rgb(255 255 255 / 0), rgb(255 255 255 / 0.85) 18%, rgb(255 255 255 / 0.85) 82%, rgb(255 255 255 / 0));
  filter: blur(2.5px);
  opacity: 0.8;
}
/* The moulded texture: fine bumps lit from the top left (an SVG lighting
   filter on noise), laid over the plastic. */
.menu::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.38;
  mix-blend-mode: soft-light;
  background-size: 160px 160px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='p' x='0' y='0'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='2' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'/%3E%3CfeGaussianBlur stdDeviation='0.45'/%3E%3CfeDiffuseLighting surfaceScale='2.2' lighting-color='%23fff' diffuseConstant='1.1'%3E%3CfeDistantLight azimuth='225' elevation='38'/%3E%3C/feDiffuseLighting%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)'/%3E%3C/svg%3E");
}
.menu a { color: inherit; }
.menu-logo { display: grid; flex: none; }
.menu-logo img { grid-area: 1 / 1; display: block; }
.menu-logo img:first-child { margin-left: 26.21px; }
.menu-divider { flex: none; width: 1px; height: 16px; background: rgb(0 0 0 / 0.072); }
.menu-switch { display: flex; align-items: center; gap: 12px; }
.menu-label { cursor: pointer; opacity: 0.4; transition: opacity 200ms ease; }
.menu-label.is-on { opacity: 1; cursor: default; }
/* The switch: a track pressed into the plastic, a small frosted ball for the knob. */
.menu-toggle {
  position: relative;
  width: 36px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: rgb(0 0 0 / 0.06);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.14), inset 0 -1px 0 rgb(255 255 255 / 0.7);
  cursor: pointer;
}
.menu-toggle:focus-visible { outline: 2px solid rgb(0 0 0 / 0.4); outline-offset: 3px; }
.menu-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgb(255 255 255 / 0.95), rgb(255 255 255 / 0) 42%),
    radial-gradient(circle at 50% 55%, #f6f6f7 0%, #e6e7e9 62%, #c9cbcf 100%);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.22), 0 2px 5px rgb(0 0 0 / 0.1), inset 0 -1px 1px rgb(0 0 0 / 0.08);
  transition: translate 260ms cubic-bezier(0.3, 1.4, 0.5, 1);
}
.menu-toggle[aria-checked="true"] .menu-knob { translate: 16px 0; }
.menu-time {
  flex: none;
  padding: 4px;
  border-radius: 2px;
  background: #000;
  color: #fff;
}
.menu-social { display: block; flex: none; width: 16px; height: 16px; margin-left: 2px; }
.menu-social img { display: block; }
.menu-colon { transition: opacity 120ms ease; }
.menu-colon.is-off { opacity: 0; }

/* ---- The corner nav (nav.js) ------------------------------------------------
   Beads of frosted plastic (the ball's material), tilted out of the bottom
   right corner; turned about the Moments lobe, which sits in the corner. */
.cornav {
  position: fixed;
  right: 34px;
  bottom: 34px;
  z-index: 12;
  width: var(--w);
  height: var(--h);
  transform-origin: var(--ox) var(--oy);
  rotate: var(--tilt);
  transition: opacity 300ms ease, translate 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.cornav.is-away { opacity: 0; translate: 40px 40px; pointer-events: none; }
.cornav-shadow {
  position: absolute;
  inset: 0;
  overflow: visible;
  translate: 4px 10px;
  filter: blur(11px);
  opacity: 0.2;
}
.cornav-body {
  position: absolute;
  inset: 0;
  backdrop-filter: blur(11px) saturate(1.05) brightness(1.06);
  -webkit-backdrop-filter: blur(11px) saturate(1.05) brightness(1.06);
  /* Lit from the top: brighter along the top of the beads, turning away
     underneath (the piece is tilted, so the light is tilted back). */
  background:
    linear-gradient(calc(180deg - var(--tilt)),
      rgb(255 255 255 / 0.55) 0%, rgb(255 255 255 / 0.6) 16%, rgb(255 255 255 / 0.2) 42%,
      rgb(255 255 255 / 0) 58%, rgb(110 115 124 / 0.1) 76%, rgb(110 115 124 / 0.28) 100%),
    rgb(250 250 251 / 0.5);
}
/* The moulded texture, as on the top bar. */
.cornav-body::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.38;
  mix-blend-mode: soft-light;
  background-size: 160px 160px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='p' x='0' y='0'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='2' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'/%3E%3CfeGaussianBlur stdDeviation='0.45'/%3E%3CfeDiffuseLighting surfaceScale='2.2' lighting-color='%23fff' diffuseConstant='1.1'%3E%3CfeDistantLight azimuth='225' elevation='38'/%3E%3C/feDiffuseLighting%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)'/%3E%3C/svg%3E");
}
/* Edges: a soft shade just inside the outline, and a crisp light line. */
.cornav-edge { position: absolute; inset: 0; overflow: visible; }
.cornav-edge path { fill: none; }
.cornav-edge-lo { stroke: rgb(70 74 82 / 0.16); stroke-width: 9; filter: blur(3px); }
.cornav-edge-hi { stroke: rgb(255 255 255 / 0.9); stroke-width: 2; }
/* The buttons: frosted domes set into each bead, upright text. */
.cornav-btn {
  position: absolute;
  width: 62px;
  height: 62px;
  margin: -31px 0 0 -31px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: rgb(1 1 3 / 0.6);
  font: 10px/1 "Cygnito Mono", ui-monospace, monospace;
  text-transform: uppercase;
  background:
    radial-gradient(circle at 38% 30%, rgb(255 255 255 / 0.95), rgb(255 255 255 / 0) 55%),
    radial-gradient(circle at 50% 60%, rgb(250 250 251 / 0.85), rgb(228 229 232 / 0.85) 70%, rgb(205 207 212 / 0.9));
  box-shadow:
    0 2px 3px rgb(0 0 0 / 0.16),
    0 5px 10px rgb(0 0 0 / 0.1),
    inset 0 -2px 3px rgb(0 0 0 / 0.08),
    inset 0 1px 1px rgb(255 255 255 / 0.9);
  transition: box-shadow 160ms ease, translate 160ms ease, color 160ms ease;
}
.cornav-btn span { display: block; rotate: calc(-1 * var(--tilt)); }   /* upright on screen */
.cornav-btn:hover { color: #010103; }
.cornav-btn:active, .cornav-btn.is-on {
  translate: 0 1px;
  color: #010103;
  box-shadow:
    0 0 1px rgb(0 0 0 / 0.2),
    inset 0 2px 5px rgb(0 0 0 / 0.16),
    inset 0 -1px 1px rgb(255 255 255 / 0.7);
}
.cornav-btn:focus-visible { outline: 2px solid rgb(0 0 0 / 0.4); outline-offset: 3px; }

/* U: all the page's UI hidden (main.js). */
.no-ui :is(.menu, .cornav, .ball, .ball-shadow, .ball-tags, .work-card, .work-rail) {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 250ms ease;
}
