:root {
  --table: #e7e2da;
  --ink: #2b2925;
  --ink-soft: #77716a;
  --pad: clamp(16px, 3vw, 36px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--table);
  color: var(--ink);
  font: 15px/1.4 "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

/* the tabletop: flat warm linen with a faint grain */
#table {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  background-color: var(--table);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .25 0 0 0 0 .22 0 0 0 0 .18 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
}

.label {
  position: absolute;
  z-index: 0;
  user-select: none;
  -webkit-user-select: none;
}

/* the logo and byline sit on the table itself, centered, under the plates */
#mark {
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
#mark h1 { margin: 0; }
.logo {
  display: block;
  width: clamp(280px, 56vw, 760px);
  max-width: calc(100vw - 2 * var(--pad));
  height: auto;
  color: var(--ink);
}

.byline {
  margin: 1.1em 0 0;
  font-size: clamp(13px, 1.2vw, 16px);
  color: var(--ink-soft);
}
.byline a {
  pointer-events: auto; /* clickable whenever it isn't covered by a plate */
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(0, 0, 0, .18);
}
.byline a:hover { color: var(--ink); border-color: currentColor; }

/* what this is: bottom left, plates start clear of it */
.about {
  left: calc(var(--pad) + env(safe-area-inset-left));
  bottom: calc(var(--pad) + env(safe-area-inset-bottom));
  width: min(19rem, calc(100vw - 2 * var(--pad)));
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-soft);
}
.about p { margin: 0 0 .5em; text-wrap: pretty; } /* no one-word last lines */
.about p:last-child { margin-bottom: 0; }
.about .about-title { color: var(--ink); font-weight: 500; margin-bottom: .25em; }

.nojs { top: 50%; left: var(--pad); color: var(--ink-soft); }

/* controls: sound top right, always above the plates */
.tools {
  top: calc(var(--pad) + env(safe-area-inset-top));
  z-index: 99995;
  right: calc(var(--pad) + env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 10px;
}
.tool {
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-soft);
  background: none;
  border: 0;
  padding: 4px 0;
  margin: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border-bottom: 1px solid transparent;
}
.tool:hover { color: var(--ink); }
.tool:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.tool.sound { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; }
.sound .waves { display: none; }
.sound[aria-pressed="true"] .waves { display: inline; }
.sound[aria-pressed="true"] .mute { display: none; }
.sound[aria-pressed="true"] { color: var(--ink); }

/* plates */
.plate {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--d);
  height: var(--d);
  margin: calc(var(--d) / -2) 0 0 calc(var(--d) / -2);
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow:
    0 1px 2px rgba(40, 30, 20, .16),
    0 6px 14px -4px rgba(40, 30, 20, .22);
  opacity: 0;
  transition: opacity .5s ease, box-shadow .18s ease;
}

.plate.ready { opacity: 1; }

.plate img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.plate.held {
  cursor: grabbing;
  box-shadow:
    0 3px 6px rgba(40, 30, 20, .14),
    0 22px 36px -8px rgba(40, 30, 20, .32);
}

.plate:focus { outline: none; }
.plate:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* closer look */
.zoom {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  cursor: zoom-out;
  background: rgba(231, 226, 218, 0);
  transition: background .35s ease;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.zoom.open { background: rgba(231, 226, 218, .9); }

.zoom-plate {
  border-radius: 50%;
  transition: transform .42s cubic-bezier(.2, .8, .2, 1), box-shadow .42s ease;
  box-shadow: 0 6px 14px -4px rgba(40, 30, 20, .22);
  will-change: transform;
}
.zoom.open .zoom-plate {
  box-shadow:
    0 6px 12px rgba(40, 30, 20, .12),
    0 40px 80px -20px rgba(40, 30, 20, .4);
}
.zoom-plate img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

@media (prefers-reduced-motion: reduce) {
  .plate, .zoom, .zoom-plate { transition: none; }
}
