/* The solving cube: a pale panel on a white page with a black puzzle cube in it, six sticker colours, and the words
   and the pill under it. The cube's light and shade are worked out by script.js; the colours are these. */
:root {
  --page: #ffffff;          /* the page */
  --panel: #f2f2ef;         /* the panel */
  --ink: #17171a;           /* the words */
  --muted: #6d6d73;         /* the quieter words */
  --plastic: #141417;       /* the cube's black plastic */
  --top: #f3f1ea;           /* the stickers of the top face */
  --bottom: #f5c330;        /* the bottom face */
  --front: #17a05a;         /* the front face */
  --back: #2b5fe0;          /* the back face */
  --right: #e23d2e;         /* the right face */
  --left: #f4831f;          /* the left face */
  --shadow: #16161a;        /* the cube's shadow on the panel */
  --ok: #17884b;            /* the tick and the words when it is done */
  --button: #17171a;        /* the button */
  --button-ink: #ffffff;    /* its words */
  --focus: #2b5fe0;         /* the keyboard's focus ring */
}

* {
  box-sizing: border-box;
}

/* a tap is a click at once: no wait for a double tap, no zoom */
html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Instrument Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

/* ---------------------------------------------------------------- the panel */
.opt {
  position: relative;
  width: min(380px, 100%);
  padding: 8px 20px 18px;
  border-radius: 24px;
  background: var(--panel);
  color: var(--ink);
}

/* the cube's place: the perspective is here, the cube floats in the middle of it */
.opt__scene {
  position: relative;
  height: 212px;
  perspective: 900px;
  perspective-origin: 50% 38%;
}

.opt__lift {
  position: absolute;
  left: 50%;
  top: 47%;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
}

.cube {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
}

/* the soft shadow on the panel, under the cube; it shrinks and fades when the cube hops */
.opt__shadow {
  position: absolute;
  left: 50%;
  top: 86%;
  width: 150px;
  height: 26px;
  margin: -13px 0 0 -75px;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--shadow) 34%, transparent), color-mix(in srgb, var(--shadow) 12%, transparent) 62%, transparent);
  filter: blur(3px);
}

/* ---------------------------------------------------------------- the small cubes */
.cubie {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
}

/* a side of a small cube: black plastic with round corners; the outer sides carry a sticker */
.face {
  position: absolute;
  left: calc(var(--s) * -0.5);
  top: calc(var(--s) * -0.5);
  width: var(--s);
  height: var(--s);
  border-radius: calc(var(--s) * 0.13);
  background: var(--plastic);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.sticker {
  position: absolute;
  inset: 7%;
  border-radius: calc(var(--s) * 0.12);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 46%, rgba(0, 0, 0, 0.08)),
    var(--c);
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.18);
}

.sticker[data-c='u'] { --c: var(--top); }
.sticker[data-c='d'] { --c: var(--bottom); }
.sticker[data-c='f'] { --c: var(--front); }
.sticker[data-c='b'] { --c: var(--back); }
.sticker[data-c='r'] { --c: var(--right); }
.sticker[data-c='l'] { --c: var(--left); }

/* the glint where the lamp is reflected, and the flash when every face is closed */
.gloss {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(120% 90% at 28% 18%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.25) 42%, rgba(255, 255, 255, 0) 70%);
  opacity: 0;
}

.sticker::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #ffffff;
  opacity: calc(var(--glow, 0) * 0.42);
}

/* the shade of a side turned away from the lamp, over the sticker and the plastic */
.shade {
  position: absolute;
  inset: -0.5px;
  border-radius: inherit;
  background: #000000;
  opacity: 0;
}

/* ---------------------------------------------------------------- the words */
.opt__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.opt__words {
  min-width: 0;
}

.opt__title {
  margin: 0;
  font-size: 16px;
  font-weight: 620;
  font-stretch: 94%;
  line-height: 1.25;
  letter-spacing: -0.012em;
  white-space: nowrap;
}

.opt__meta {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 450;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
}

.opt__swap {
  display: inline-block;
}

.opt__swap .is-ok {
  color: var(--ok);
}

.opt__figure {
  position: relative;
  flex: none;
  min-width: 52px;
  height: 20px;
  margin: 0;
  font-size: 16px;
  font-weight: 620;
  line-height: 20px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.opt__pct {
  display: inline-block;
}

.opt__pct.is-quiet {
  color: var(--muted);
  font-weight: 480;
}

.opt__tick {
  position: absolute;
  right: -2px;
  top: -2px;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--ok);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  visibility: hidden;
}

.opt__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

/* the file being worked on, in a monospace, with what it saved */
.opt__file {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.opt__file .opt__swap {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.opt__file b {
  color: var(--ink);
  font-weight: 520;
}

.opt__file .is-ok {
  color: var(--ok);
}

/* ---------------------------------------------------------------- the button */
/* its words widen on the width axis under the pointer, its pill swells with a bounce and squashes when pressed */
.opt__btn {
  position: relative;
  isolation: isolate;
  flex: none;
  height: 36px;
  padding: 0 17px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--button-ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 36px;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  transition: color 0.25s ease;
}

.opt__btn::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--button);
  transition: transform 0.45s cubic-bezier(0.34, 1.7, 0.64, 1), background-color 0.25s ease, box-shadow 0.25s ease;
}

.opt__label {
  display: inline-block;
  font-stretch: 86%;
  transition: font-stretch 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* while it works the button only pauses it: it steps back */
.opt__btn.is-quiet {
  color: var(--ink);
}

.opt__btn.is-quiet::before {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ink) 16%, transparent);
}

@media (hover: hover) and (pointer: fine) {
  .opt__btn:hover .opt__label {
    font-stretch: 100%;
  }

  .opt__btn:hover::before {
    transform: scale(1.05, 1.08);
  }

  .opt__btn.is-quiet:hover::before {
    background: color-mix(in srgb, var(--ink) 6%, transparent);
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .opt__label,
  .opt__btn::before {
    transition: none;
  }

  @media (hover: hover) {
    .opt__btn:hover::before {
      transform: none;
    }
  }
}
