* {
  box-sizing: border-box;
}
:root {
  --depth: 5vmin;
  --on: 0;
  --size: 25vmin;
  --bg: hsl(
    calc(200 - (var(--on) * 160)),
    calc((20 + (var(--on) * 50)) * 1%),
    calc((20 + (var(--on) * 60)) * 1%)
  );
  --cord: hsl(0, 0%, calc((60 - (var(--on) * 50)) * 1%));
  --stroke: hsl(0, 0%, calc((60 - (var(--on) * 50)) * 1%));
  --shine: hsla(0, 0%, 100%, calc(0.75 - (var(--on) * 0.5)));
  --cap: hsl(0, 0%, calc((40 + (var(--on) * 30)) * 1%));
  --filament: hsl(
    45,
    calc(var(--on) * 80%),
    calc((25 + (var(--on) * 75)) * 1%)
  );
  --glow: hsla(55, 100%, 85%, calc(0.1 * var(--on)));
  --bear-eye: #2a1c12;
}
body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  overflow: hidden;
  position: relative;
}
body::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    circle at center,
    var(--glow) 0%,
    transparent 70%
  );
  opacity: calc(0.3 * var(--on));
  z-index: 1;
  pointer-events: none;
}
label {
  position: absolute;
  opacity: 0.5;
  height: 100%;
  width: 100%;
  top: 0;
  left: 0;
  z-index: 2;
}
input {
  height: 0;
  width: 0;
  position: fixed;
  left: 100%;
  transform: scale(0);
}
.toggle {
  height: var(--size);
  width: var(--size);
  transform: translate(-50%, -100%);
  z-index: 2;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate3d(-50%, -100%, calc(var(--depth) * 3));
  filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.2));
}
.toggle-scene {
  overflow: visible !important;
  width: 100%;
  position: absolute;
}
.toggle-scene__arm {
  display: none;
}
.toggle-scene__cord {
  stroke: var(--cord);
  cursor: move;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.1));
}
.toggle-scene__cord:nth-of-type(1) {
  display: none;
}
.toggle-scene__cord:nth-of-type(2),
.toggle-scene__cord:nth-of-type(3),
.toggle-scene__cord:nth-of-type(4),
.toggle-scene__cord:nth-of-type(5) {
  display: none;
}
.toggle-scene__cord-end {
  stroke: var(--cord);
  fill: var(--cord);
}
.toggle-scene__dummy-cord {
  stroke-width: 6;
  stroke: var(--cord);
}
.bulb__filament {
  stroke: var(--filament);
  stroke-width: 3;
  filter: url(#glow);
}
.bulb__shine {
  stroke: var(--shine);
}
.bulb__flash {
  stroke: #f5e0a3;
  display: none;
}
.bulb__bulb {
  stroke: var(--stroke);
  fill: hsla(
    calc(180 - (95 * var(--on))),
    80%,
    80%,
    calc(0.1 + (0.4 * var(--on)))
  );
  filter: url(#bulb-glow);
}
.bulb__cap {
  fill: var(--cap);
}
.bulb__cap-shine {
  fill: var(--shine);
}
.bulb__cap-outline {
  stroke: var(--stroke);
}
.bear {
  display: none;
}
.bear__fur {
  fill: #784421;
  filter: url(#fur-shadow);
}
.bear__pad {
  fill: #deaa87;
}
.bear__eye {
  fill: var(--bear-eye);
}
.bear__eye-highlight {
  fill: white;
  opacity: 0.8;
}
.bear__nose {
  fill: #4a2c1a;
}
.doorway {
  position: absolute;
  top: 50%;
  height: calc(var(--size) * 4);
  width: calc(var(--size) * 1.5);
  transform: translate(0, calc(var(--size) * -0.75));
  left: calc(50% + (var(--size) * 0.5));
  -webkit-clip-path: inset(0 0 0 -200%);
  clip-path: inset(0 0 0 -200%);
}
.doorway__opening {
  height: 100%;
  width: 100%;
  position: absolute;
  background: #1a1a1a;
  transform: translate3d(0, 0, calc(var(--depth) * -1));
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}
.bear {
  position: absolute;
  top: 10%;
  width: var(--size);
  filter: drop-shadow(2px 4px 3px rgba(0, 0, 0, 0.3));
}
.door {
  --panel: hsl(30, 20%, calc(12% + (var(--on) * 40%)));
  height: 100%;
  position: absolute;
  width: 100%;
  transform-origin: 100% 50%;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.4);
}
.door__panel {
  width: 30%;
  height: 35%;
  position: absolute;
  border: 1vmin var(--panel) solid;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) translate(var(--x), var(--y));
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
}
.door__panel:nth-of-type(1) {
  --x: -70%;
  --y: -70%;
}
.door__panel:nth-of-type(2) {
  --x: 70%;
  --y: -70%;
}
.door__panel:nth-of-type(3) {
  --x: -70%;
  --y: 70%;
}
.door__panel:nth-of-type(4) {
  --x: 70%;
  --y: 70%;
}
.door__handle {
  height: 4vmin;
  width: 4vmin;
  position: absolute;
  left: 10%;
  top: 50%;
  transform: translate3d(0, -50%, 1vmin);
}
.door__handle > div {
  position: absolute;
  height: 100%;
  width: 100%;
  background-color: hsl(
    45,
    70%,
    calc((var(--lightness, 20%)) + (var(--on) * 40%))
  );
  border-radius: 50%;
}
.door__handle > div:nth-of-type(1) {
  --lightness: 25%;
}
.door__handle > div:nth-of-type(2) {
  --lightness: 30%;
  transform: translate3d(0, 0, calc(var(--depth) * 1));
}
.door__side {
  position: absolute;
}
.door__side:nth-of-type(1) {
  --lightness: 20%;
  height: 100%;
  width: 100%;
  transform: translate3d(0, 0, 0);
  z-index: 3;
  background-color: hsl(
    30,
    20%,
    calc((var(--lightness, 20%)) + (var(--on) * 40%))
  );
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3);
}
.door__side:nth-of-type(2) {
  --lightness: 10%;
  height: 100%;
  width: 100%;
  transform: translate3d(0, 0, calc(var(--depth) * -1));
}
.door__side {
  background-color: hsl(
    30,
    20%,
    calc((var(--lightness, 20%)) + (var(--on) * 40%))
  );
}

/* Enhanced decorative elements with animations */
.floor {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 20%;
  background: linear-gradient(to top, #2c1b0e, #4a3120);
  z-index: -1;
  box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.floor::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  animation: floorShine 8s infinite linear;
}

.wall {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 80%;
  background: linear-gradient(to bottom, #3a2a1d, #2c1e12);
  z-index: -2;
  overflow: hidden;
}

.wall::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    circle at 30% 50%,
    rgba(255, 255, 255, 0.03) 0%,
    transparent 40%
  );
  animation: wallPulse 15s infinite alternate;
}

.wall::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(
      circle at 25% 30%,
      rgba(120, 80, 60, 0.1) 2px,
      transparent 2px
    ),
    radial-gradient(
      circle at 75% 70%,
      rgba(120, 80, 60, 0.1) 2px,
      transparent 2px
    ),
    radial-gradient(
      circle at 40% 20%,
      rgba(120, 80, 60, 0.1) 1px,
      transparent 1px
    ),
    radial-gradient(
      circle at 60% 80%,
      rgba(120, 80, 60, 0.1) 1px,
      transparent 1px
    );
  background-size: 200px 200px, 300px 300px, 150px 150px, 250px 250px;
  animation: wallTexture 30s infinite linear;
  z-index: -1;
}

.particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.particle {
  position: absolute;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  opacity: 0;
  animation: floatParticle 15s infinite linear;
}

@keyframes floatParticle {
  0% {
    transform: translateY(100vh) translateX(0);
    opacity: 0;
  }
  10% {
    opacity: 0.5;
  }
  90% {
    opacity: 0.3;
  }
  100% {
    transform: translateY(-100px) translateX(20px);
    opacity: 0;
  }
}

@keyframes floorShine {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

@keyframes wallPulse {
  0% {
    opacity: 0.3;
    background-position: 30% 50%;
  }
  50% {
    opacity: 0.5;
    background-position: 40% 60%;
  }
  100% {
    opacity: 0.3;
    background-position: 35% 55%;
  }
}

@keyframes wallTexture {
  0% {
    background-position: 0 0, 0 0, 0 0, 0 0;
  }
  100% {
    background-position: 200px 200px, 300px 300px, 150px 150px, 250px 250px;
  }
}

/* Subtle ambient animation */
@keyframes ambientPulse {
  0%,
  100% {
    transform: translate3d(-50%, -100%, calc(var(--depth) * 3)) scale(1);
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.2));
  }
  50% {
    transform: translate3d(-50%, -100%, calc(var(--depth) * 3)) scale(1.02);
    filter: drop-shadow(0 8px 15px rgba(0, 0, 0, 0.25));
  }
}

.toggle {
  animation: ambientPulse 8s infinite ease-in-out;
}
