/* The document deliberately keeps the visual language of an almost unstyled HTML file. */

:root {
  color-scheme: light;
}

html {
  background: #fff;
}

body {
  max-width: 960px;
  margin: 8px;
  color: #000;
  background: #fff;
  font-family: serif;
  font-size: 16px;
  line-height: 1.55;
}

main {
  max-width: 860px;
}

h1,
h2 {
  font-size: inherit;
}

.work-metadata {
  white-space: pre-wrap;
  font-family: monospace;
  font-size: 0.875rem;
}

.mechanism {
  --key-angle: 0deg;
  max-width: 720px;
}

.mechanism-photo {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid;
  overflow: hidden;
  box-sizing: border-box;
  background: #d8c8aa;
  perspective: 1100px;
  perspective-origin: 40.6% 48.4%;
  touch-action: none;
  user-select: none;
}

.lock-photo {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.lock-core-plane,
.lock-ring-plane {
  position: absolute;
  left: 40.65%;
  top: 48.3%;
  display: block;
  width: 24.2%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%) rotateY(-43deg);
  transform-style: preserve-3d;
  pointer-events: none;
}

.lock-core-plane {
  z-index: 1;
}

.lock-ring-plane {
  z-index: 2;
  width: 25.4%;
}

.lock-plug,
.lock-ring {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.lock-plug {
  transform: rotate(var(--key-angle));
  transform-origin: 50% 50%;
}

.key {
  position: absolute;
  z-index: 3;
  top: 34.8%;
  left: -7%;
  display: block;
  width: 54%;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  line-height: 0;
  cursor: pointer;
  transform-origin: 88.2% 50%;
  transform-style: preserve-3d;
  transform: translate3d(-34%, 6%, 55px) rotateY(-43deg) rotateX(0deg);
  transition: transform 700ms cubic-bezier(.2, .72, .18, 1);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.key.is-inserted {
  transform: translate3d(0, 0, 18px) rotateY(-43deg) rotateX(var(--key-angle));
  transition: transform 150ms linear;
}

.key.is-inserting {
  transform: translate3d(0, 0, 18px) rotateY(-43deg) rotateX(0deg);
}

.key.is-winding {
  transition: none;
}

.key.is-returning {
  transition: none;
}

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

.key:focus-visible {
  filter: drop-shadow(0 0 3px #00e);
}

.key.is-winding img,
.key.is-returning img {
  filter: drop-shadow(0 3px 3px rgb(31 22 8 / 0.22));
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.plain-controls {
  margin-block: 1em;
}

.plain-controls button + button {
  margin-left: 0.35em;
}

.statement {
  min-height: 14em;
  max-width: 48em;
  white-space: pre-wrap;
}

figure {
  margin: 1em 0;
}

figure img {
  display: block;
  width: min(100%, 720px);
  height: auto;
}

figcaption {
  font-size: 0.875rem;
}

details figure {
  margin-top: 1.5em;
}

details > summary {
  width: fit-content;
  color: #0000ee;
  cursor: pointer;
  text-decoration: underline;
  list-style: none;
}

details > summary::-webkit-details-marker {
  display: none;
}

details > summary::before {
  content: "▶";
  display: inline-block;
  margin-right: 0.45em;
  color: #0000ee;
  font-size: 0.72em;
  text-decoration: none;
}

details[open] > summary::before {
  content: "▼";
}

@media (max-width: 600px) {
  body {
    font-size: 15px;
  }

  .mechanism-photo {
    perspective: 600px;
  }

  .statement {
    min-height: 20em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .key {
    transition-duration: 1ms;
  }

}
