/* Page coordinates (CSS px): no container, the field sits on the ground. Content 32..508; 8 cells x 48 = 384, toggle 64 at the right. */
.pw {
  --cream: #f9ecd4;
  --ink: #2a120b;
  --brick: #c14e2c;
  width: 540px;
  height: 540px;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  background: var(--brick);
  color: var(--cream);
  font-family: "Recursive Variable", sans-serif;
  font-variation-settings: "MONO" 0, "CASL" 0;
}

.pw * { box-sizing: border-box; }

.pw-field {
  display: block;
  width: 476px;
}

.pw-label {
  display: block;
  font-size: 34px;
  font-weight: 500;
  line-height: 40px;
  letter-spacing: -0.01em;
}

.pw-box {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 133px;
  margin-top: 5px;
  border-bottom: 5px solid var(--cream);
}

.pw-entry {
  position: relative;
  width: 384px;
  height: 104px;
  /* Cells centre their glyphs; pulling the row left puts the first character's ink on the label's edge. */
  margin-left: -7px;
}

.pw-control,
.pw-cells {
  position: absolute;
  inset: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}

.pw-control {
  outline: none;
  color: transparent;
  caret-color: transparent;
  font-size: 40px;
}

.pw-cells {
  display: flex;
  pointer-events: none;
  font-size: 78px;
  font-weight: 350;
  line-height: 104px;
  font-variation-settings: "MONO" 1, "CASL" 0;
}

.pw-cell {
  position: relative;
  width: 48px;
  height: 104px;
  animation: pw-in 180ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

@keyframes pw-in {
  from {
    opacity: 0;
    scale: 0.4;
  }
}

/* Hidden: the dot shows. Shown: the dot folds flat and the glyph unfolds, one cell after another. */
.pw-dot {
  position: absolute;
  left: 8px;
  top: 38px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--cream);
  transition: scale 110ms cubic-bezier(0.5, 0, 0.9, 0.4) calc(var(--i) * 26ms + 200ms);
}

.pw-glyph {
  position: absolute;
  inset: 0;
  text-align: center;
  scale: 1 0;
  opacity: 0;
  transition:
    scale 100ms cubic-bezier(0.5, 0, 0.9, 0.4) calc(var(--i) * 26ms),
    opacity 60ms linear calc(var(--i) * 26ms + 40ms);
}

.pw-box[data-visible] .pw-dot {
  scale: 1 0;
  transition-delay: calc(var(--i) * 26ms);
}

.pw-box[data-visible] .pw-glyph {
  scale: 1;
  opacity: 1;
  transition:
    scale 200ms cubic-bezier(0.15, 0.8, 0.25, 1) calc(var(--i) * 26ms + 100ms),
    opacity 60ms linear calc(var(--i) * 26ms + 100ms);
}

.pw-caret {
  position: absolute;
  left: calc(var(--n) * 48px + 4px);
  top: 16px;
  width: 4px;
  height: 72px;
  background: var(--cream);
  opacity: 0;
  transition: left 100ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

.pw-box:has(.pw-control:focus) .pw-caret { opacity: 1; }

.pw-toggle {
  flex: none;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  border-radius: 0;
  outline: none;
  background: transparent;
  color: var(--cream);
  transition: background-color 140ms ease, color 140ms ease, scale 120ms ease;
}

.pw-toggle:active {
  background: #f9ecd438;
  scale: 0.88;
  transition: scale 120ms ease;
}

/* The press lands at once; the lid and the characters follow. */
.pw-toggle[data-visible] {
  background: var(--cream);
  color: var(--ink);
  transition: scale 120ms ease;
}

.pw-toggle svg {
  width: 46px;
  height: 46px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: square;
}

.pw-lid {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transform: scaleY(-1);
  transition: transform 260ms cubic-bezier(0.15, 0.8, 0.25, 1);
}

.pw-pupil {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  fill: currentColor;
  stroke: none;
  transform: scale(0);
  transition: transform 220ms cubic-bezier(0.15, 0.8, 0.25, 1);
}

.pw-lash { transition: opacity 120ms linear; }

.pw-toggle[data-visible] .pw-lid { transform: scaleY(1); }
.pw-toggle[data-visible] .pw-pupil { transform: scale(1); transition-delay: 80ms; }
.pw-toggle[data-visible] .pw-lash { opacity: 0; }

.pw-hint {
  display: block;
  margin: 16px 0 0;
  color: var(--ink);
  font-size: 23px;
  font-weight: 450;
  line-height: 30px;
}
