@import url('https://fonts.googleapis.com/css2?family=Sora:wght@500;600;700;800&display=swap');

:root {
  --paper: #f4efe5;
  --ink: #23252d;
  --accent: #ff6b4b;
  --accent-deep: #e5532f;
  --teal: #2ec4b6;
  --yellow: #ffc53d;
  --shell: #fffdf8;
  --screen: #23252d;
  --eye: #fffdf8;
  --muted: #9a948a;
  --field: #faf7f0;
  --line: 2px solid var(--ink);
  --turn: .65s cubic-bezier(.5, -0.3, .25, 1.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Sora', 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
}

.scene {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 110px 24px 70px;
  overflow: clip;
  position: relative;
  background:
    radial-gradient(rgba(35, 37, 45, .07) 1.2px, transparent 1.3px) 0 0 / 24px 24px,
    var(--paper);
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

/* robot */

.robot {
  position: relative;
  z-index: 1;
  margin-bottom: -16px;
  animation: float 4s ease-in-out infinite alternate;
  perspective: 800px;
}

@keyframes float {
  from {
    transform: translateY(0);
  }

  to {
    transform: translateY(-5px);
  }
}

/* antenna */
.antenna {
  position: absolute;
  top: -32px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
}

.antenna-rod {
  width: 4px;
  height: 22px;
  background: var(--ink);
  border-radius: 2px;
}

.antenna-tip {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent);
  border: var(--line);
  order: -1;
  margin-bottom: -2px;
  position: relative;
  animation: bob 2.4s ease-in-out infinite;
}

.antenna-tip::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .85);
}

@keyframes bob {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-2.5px);
  }
}

.robot[data-mood="excited"] .antenna-tip {
  animation-duration: .4s;
  background: var(--yellow);
}

.robot[data-mood="success"] .antenna-tip {
  background: var(--teal);
}

/* head */
.head3d {
  width: 152px;
  height: 140px;
  perspective: 700px;
  transform-style: preserve-3d;
  transform:
    translateY(var(--hy, 0px)) scale(var(--hsc, 1)) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .25s ease-out;
  will-change: transform;
}

.is-hyped .head3d {
  --hy: 5px;
  --hsc: 1.04;
}

.is-pressed .head3d {
  --hy: 9px;
  --hsc: .94;
}

/* squash on click */
.head {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform var(--turn);
}

.is-turned .head {
  transform: rotateY(180deg);
}

.is-spinning .head {
  animation: victory .9s ease-in-out;
}

@keyframes victory {
  to {
    transform: rotateY(360deg);
  }
}

.ear {
  position: absolute;
  top: 48px;
  width: 16px;
  height: 40px;
  background: var(--shell);
  border: var(--line);
  border-radius: 8px;
  transform: translateZ(0);
}

.ear--l {
  left: -10px;
}

.ear--r {
  right: -10px;
}

.face {
  position: absolute;
  inset: 0;
  border-radius: 34px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--shell);
  border: var(--line);
}

.face--front {
  box-shadow: 5px 6px 0 rgba(35, 37, 45, .16);
}

.face--back {
  box-shadow: 5px 6px 0 rgba(35, 37, 45, .16);
  transform: rotateY(180deg);
  display: grid;
  place-items: center;
}

/* face */
.visor {
  position: absolute;
  inset: 22px 16px 20px;
  background: var(--screen);
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 13px;
  overflow: hidden;
}

.eyes {
  display: flex;
  gap: 28px;
  transform: translate(var(--lx, 0px), var(--ly, 0px));
  transition: transform .18s ease-out;
}

.eyes.blink .eye {
  transform: scaleY(.08);
}

.eye {
  width: 19px;
  height: 25px;
  border-radius: 9px;
  background: var(--eye);
  transition: all .22s ease;
}

/* happy eyes */
[data-mood="happy"] .eye,
[data-mood="success"] .eye {
  width: 25px;
  height: 12px;
  background: transparent;
  border: 5px solid var(--eye);
  border-bottom: none;
  border-radius: 25px 25px 0 0;
}

[data-mood="excited"] .eye {
  transform: scale(1.2);
  border-radius: 50%;
  height: 21px;
}

/* eyes closed when the button is pressed */
[data-mood="pressed"] .eye {
  width: 24px;
  height: 12px;
  background: transparent;
  border: 5px solid var(--eye);
  border-top: none;
  border-radius: 0 0 24px 24px;
}

.cheek {
  position: absolute;
  top: 59%;
  width: 15px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transition: opacity .3s ease;
}

.cheek--l {
  left: 15px;
}

.cheek--r {
  right: 15px;
}

[data-mood="happy"] .cheek,
[data-mood="excited"] .cheek,
[data-mood="pressed"] .cheek,
[data-mood="success"] .cheek {
  opacity: .9;
}

.mouth {
  width: 15px;
  height: 5px;
  border-radius: 4px;
  background: var(--eye);
  transition: all .25s ease;
}

[data-mood="watching"] .mouth {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

[data-mood="happy"] .mouth {
  width: 30px;
  height: 12px;
  border-radius: 0 0 16px 16px;
}

[data-mood="excited"] .mouth {
  width: 22px;
  height: 16px;
  border-radius: 0 0 13px 13px;
}

[data-mood="pressed"] .mouth {
  width: 27px;
  height: 15px;
  border-radius: 0 0 14px 14px;
}

[data-mood="success"] .mouth {
  width: 38px;
  height: 17px;
  border-radius: 0 0 20px 20px;
}

/* back of the head + password meter */
.panel {
  width: 116px;
  padding: 12px 10px 10px;
  background: var(--screen);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.panel-lights {
  display: flex;
  gap: 6px;
}

.panel-lights i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: bob 1.8s ease-in-out infinite;
}

.panel-lights i:nth-child(2) {
  animation-delay: .3s;
  background: var(--yellow);
}

.panel-lights i:nth-child(3) {
  animation-delay: .6s;
  background: var(--teal);
}

.meter {
  display: flex;
  gap: 5px;
}

.meter i {
  width: 15px;
  height: 20px;
  border-radius: 4px;
  background: #3b3e49;
  transition: background .25s ease;
}

.meter[data-lvl="1"] i.on {
  background: #ff5c4d;
}

.meter[data-lvl="2"] i.on {
  background: #ff9f43;
}

.meter[data-lvl="3"] i.on {
  background: var(--yellow);
}

.meter[data-lvl="4"] i.on {
  background: var(--teal);
}

.panel-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.5px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--paper);
  white-space: nowrap;
}

/* speech bubble */
.bubble {
  position: absolute;
  bottom: calc(100% + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--shell);
  border: var(--line);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  padding: 9px 14px;
  border-radius: 12px;
  width: max-content;
  max-width: 250px;
  text-align: center;
  box-shadow: 3px 3px 0 rgba(35, 37, 45, .9);
  z-index: 3;
}

.bubble::after {
  content: '';
  position: absolute;
  top: calc(100% - 5px);
  left: 50%;
  width: 10px;
  height: 10px;
  background: var(--shell);
  border-right: var(--line);
  border-bottom: var(--line);
  transform: translateX(-50%) rotate(45deg);
}

.bubble.pop {
  animation: pop .3s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes pop {
  from {
    transform: translateX(-50%) scale(.8);
  }

  to {
    transform: translateX(-50%) scale(1);
  }
}

/* form card */

.card {
  position: relative;
  z-index: 2;
  width: min(344px, calc(100vw - 48px));
  background: linear-gradient(165deg, #fffefb 0%, #fdfaf3 45%, #f7f1e4 100%);
  border: var(--line);
  border-radius: 20px;
  padding: 36px 28px 40px;
  box-shadow: 8px 9px 0 rgba(35, 37, 45, .9);
}

.hand {
  position: absolute;
  top: -16px;
  width: 44px;
  height: 32px;
  background:
    linear-gradient(90deg, transparent 31%, rgba(35, 37, 45, .9) 32%, rgba(35, 37, 45, .9) 36%, transparent 37%, transparent 63%, rgba(35, 37, 45, .9) 64%, rgba(35, 37, 45, .9) 68%, transparent 69%) 0 12px / 100% calc(100% - 12px) no-repeat,
    var(--shell);
  border: var(--line);
  border-radius: 9px 9px 14px 14px;
  z-index: 3;
  transition: transform .25s ease;
}

.hand--l {
  left: 36px;
}

.hand--r {
  right: 36px;
}

.is-hyped~.card .hand {
  transform: translateY(-3px) scaleY(1.08);
}

.foot {
  position: absolute;
  bottom: -26px;
  width: 54px;
  height: 34px;
  background: var(--shell);
  border: var(--line);
  border-radius: 9px 9px 14px 14px;
  box-shadow: inset 0 -9px 0 rgba(35, 37, 45, .12);
  z-index: -1;
}

.foot--l {
  left: 62px;
}

.foot--r {
  right: 62px;
}

.title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.2px;
  text-align: center;
  margin-bottom: 24px;
}

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 14px;
  margin-bottom: 14px;
  background: var(--field);
  border: 2px solid rgba(35, 37, 45, .22);
  border-radius: 12px;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
  cursor: text;
}

.field:focus-within {
  border-color: var(--ink);
  box-shadow: 3px 3px 0 var(--accent);
  transform: translate(-1px, -1px);
}

.field-icon {
  width: 19px;
  height: 19px;
  fill: var(--muted);
  flex: none;
  transition: fill .18s ease;
}

.field:focus-within .field-icon {
  fill: var(--ink);
}

.field input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
}

.field input::placeholder {
  color: var(--muted);
  font-weight: 500;
}

.peek {
  border: none;
  background: none;
  padding: 4px;
  cursor: pointer;
  border-radius: 8px;
  display: grid;
  place-items: center;
}

.peek svg {
  width: 20px;
  height: 20px;
  fill: var(--muted);
  transition: fill .18s ease;
}

.peek:hover svg,
.peek[aria-pressed="true"] svg {
  fill: var(--ink);
}

.peek:focus-visible {
  outline: 2px solid var(--ink);
}

/* login button */
.btn {
  position: relative;
  width: 100%;
  height: 54px;
  margin-top: 10px;
  border: var(--line);
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 4px 5px 0 rgba(35, 37, 45, .9);
  transition: transform .18s cubic-bezier(.34, 1.56, .64, 1), box-shadow .18s ease, background .25s ease;
}

.btn:hover,
.btn:focus-visible {
  transform: translate(-2px, -2px);
  background: var(--accent-deep);
  box-shadow: 7px 8px 0 rgba(35, 37, 45, .9);
}

.btn:active {
  transform: translate(3px, 4px);
  box-shadow: 0 0 0 rgba(35, 37, 45, .9);
}

.btn:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.btn-bolt {
  display: inline-block;
  opacity: 0;
  transform: translateX(-10px) scale(.4) rotate(-30deg);
  transition: all .3s cubic-bezier(.34, 1.56, .64, 1);
}

.btn:hover .btn-bolt,
.btn:focus-visible .btn-bolt {
  opacity: 1;
  transform: none;
  animation: bolt-jitter .4s ease-in-out infinite;
}

@keyframes bolt-jitter {

  0%,
  100% {
    transform: rotate(-7deg) scale(1);
  }

  50% {
    transform: rotate(7deg) scale(1.2);
  }
}

.btn.is-success {
  background: var(--teal);
}

/* error shake */
.card.shake {
  animation: shake .4s ease;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-7px);
  }

  50% {
    transform: translateX(6px);
  }

  75% {
    transform: translateX(-3px);
  }
}

/* confetti (from js) */
.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  top: 0;
  left: 0;
  border-radius: 2px;
  pointer-events: none;
  z-index: 10;
}

/* responsive + reduced motion */

@media (max-width: 560px) {
  .scene {
    padding-top: 96px;
  }

  .bubble {
    max-width: 210px;
    font-size: 12.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .robot {
    animation: none;
  }

  .antenna-tip,
  .panel-lights i {
    animation: none;
  }

  .head {
    transition-duration: .01s;
  }

  .btn:hover .btn-bolt {
    animation: none;
  }

  .is-spinning .head {
    animation: none;
  }

  .bubble.pop {
    animation: none;
  }

  .eyes {
    transition: none;
  }
}