/* Cryptex. The brass itself is drawn on the canvas by app.js; this is the
   leather mat it sits on, the controls laid over it and the parchment slip. */

.cx-mat {
  --cx-gold: #ffd47a;
  position: relative;
  height: 14rem;
  border-radius: 1rem;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(120% 85% at 50% 38%, rgb(255 196 130 / 0.13), transparent 62%),
    radial-gradient(70% 60% at 50% 110%, rgb(0 0 0 / 0.45), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.09 0 0 0 0 0.05 0 0 0 0 0.02 0 0 0 0.75 -0.12'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.012' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.25 0 0 0 0 0.14 0 0 0 0 0.07 0 0 0 0.6 -0.2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)'/%3E%3C/svg%3E"),
    linear-gradient(160deg, #47291a, #2e190f 55%, #24130b);
  box-shadow:
    inset 0 1px 0 rgb(255 225 190 / 0.09),
    inset 0 0 0 1px rgb(0 0 0 / 0.5),
    inset 0 10px 30px rgb(0 0 0 / 0.35),
    0 14px 32px -18px rgb(40 18 5 / 0.75);
  transition: height 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Stitching round the edge of the mat. */
.cx-mat::before {
  content: "";
  position: absolute;
  inset: 7px;
  z-index: 0;
  border: 1.5px dashed rgb(232 196 150 / 0.33);
  border-radius: 0.6rem;
  box-shadow: 0 1px 0 rgb(0 0 0 / 0.35), inset 0 1px 0 rgb(0 0 0 / 0.35);
  pointer-events: none;
}

.cx-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.cx-controls {
  position: absolute;
  inset: 0;
  z-index: 3;
}

/* A ring's grab area. Transparent: the canvas underneath is the ring. */
.cx-ring {
  position: absolute;
  border-radius: 0.5rem;
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  outline: 2px solid transparent;
  outline-offset: 2px;
}
.cx-ring.is-dragging { cursor: grabbing; }
.cx-ring[aria-readonly="true"] { cursor: not-allowed; }
.cx-ring:focus-visible {
  outline-color: var(--cx-gold);
  box-shadow: 0 0 0 5px rgb(0 0 0 / 0.45), 0 0 18px 2px rgb(255 200 110 / 0.35);
}

/* The small up and down arrows above and below each ring. */
.cx-turn {
  position: absolute;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0.6rem;
  background: rgb(255 220 170 / 0.05);
  color: rgb(246 222 182 / 0.82);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s, color 0.15s, transform 0.1s, opacity 0.4s;
  box-shadow: inset 0 1px 0 rgb(255 230 190 / 0.08), inset 0 -1px 0 rgb(0 0 0 / 0.35);
}
.cx-turn svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.cx-turn:hover { background: rgb(255 220 170 / 0.13); color: #fff0cf; }
.cx-turn:active { transform: translateY(1px); background: rgb(255 220 170 / 0.18); }
.cx-turn:focus-visible { outline: 2px solid var(--cx-gold); outline-offset: 1px; }
.cx-turn:disabled { cursor: default; color: rgb(246 222 182 / 0.5); background: transparent; box-shadow: none; }
.cx-turn .cx-lock { display: none; }
.cx-turn.is-locked .cx-arrow { display: none; }
.cx-turn.is-locked .cx-lock { display: block; }
.cx-mat.is-open .cx-turn { opacity: 0; pointer-events: none; }

/* The slip of parchment that comes out of the opened cryptex. */
.cx-slip {
  position: absolute;
  left: 50%;
  top: 60%;
  z-index: 1;
  width: min(84%, 24rem);
  padding: 0.9rem 1.25rem 1.05rem;
  border-radius: 3px 3px 6px 6px;
  color: #43290f;
  text-align: center;
  background:
    radial-gradient(90% 60% at 25% 20%, rgb(255 255 255 / 0.4), transparent 60%),
    radial-gradient(70% 80% at 85% 90%, rgb(140 80 20 / 0.22), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.6' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.3 0 0 0 0 0.12 0 0 0 0.35 -0.05'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)'/%3E%3C/svg%3E"),
    linear-gradient(#f6e7c4, #ead3a2);
  box-shadow: inset 0 0 24px rgb(130 75 20 / 0.35), 0 10px 22px -8px rgb(0 0 0 / 0.65);
  transform: translate(-50%, -2.5rem);
  clip-path: inset(0 0 100% 0);
  visibility: hidden;
  transition: transform 0.95s cubic-bezier(0.2, 0.85, 0.25, 1), clip-path 0.95s cubic-bezier(0.2, 0.85, 0.25, 1), visibility 0s 0.95s;
}
.cx-slip.is-out {
  transform: translate(-50%, 0);
  clip-path: inset(0 0 0 0);
  visibility: visible;
  transition-delay: 0s;
}
.cx-slip-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgb(95 58 22 / 0.75);
}
.cx-slip-words {
  margin-top: 0.35rem;
  display: grid;
  gap: 0.1rem;
  font-family: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 5vw, 1.8rem);
  font-weight: 700;
  font-style: italic;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgb(255 245 220 / 0.6);
}

.cx-icon { width: 1.15rem; height: 1.15rem; }
.cx-icon path:first-child { fill: currentColor; }
.cx-icon path { stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.cx-results {
  border-radius: 0.875rem;
  border: 1px solid var(--color-base-300);
  padding: 1rem 1.1rem 1.1rem;
  background: color-mix(in oklab, #e0a040 7%, var(--color-base-100));
}
.cx-results.is-new { animation: cx-rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes cx-rise { from { opacity: 0; transform: translateY(10px); } }

.cx-squares { font-size: 1.6rem; letter-spacing: 0.12em; line-height: 1; }

.cx-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  text-align: center;
}
.cx-stat {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-end;
  gap: 0.15rem;
  border-radius: 0.6rem;
  border: 1px solid var(--color-base-300);
  padding: 0.5rem 0.2rem;
}
.cx-stat dt { font-size: 0.7rem; line-height: 1.15; color: var(--color-muted); }
.cx-stat dd { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .cx-mat, .cx-turn, .cx-slip { transition: none; }
  .cx-results.is-new { animation: none; }
}
