/* -------------------------------------------------------------------------- */
/* Room atmosphere (lit vs dark)                                              */
/* -------------------------------------------------------------------------- */

.room {
  --text: #e8eef5;
  --muted: #9fb3c8;
  --panel-bg: rgba(0, 0, 0, 0.2);
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1.5rem 2rem;
  position: relative;
  overflow-x: hidden;
  transition: background 0.85s ease, color 0.6s ease;
}

/* Soft vignette + lamp wash */
.room::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.85s ease, background 0.85s ease;
}

/* Lights on — warm pool from the ceiling */
.room--on {
  background: linear-gradient(
    180deg,
    #5c5348 0%,
    #3d3630 18%,
    #252028 55%,
    #12141a 100%
  );
  color: #faf6f0;
  --text: #faf6f0;
  --muted: #c8c2b8;
  --panel-bg: rgba(255, 248, 235, 0.08);
}

.room--on::before {
  opacity: 1;
  /* Slightly softer wash so the ceiling bulb still reads as the light source */
  background: radial-gradient(
      ellipse 110% 65% at 50% -6%,
      rgba(255, 220, 160, 0.55) 0%,
      rgba(255, 190, 110, 0.14) 32%,
      transparent 58%
    ),
    radial-gradient(ellipse 80% 50% at 50% 100%, transparent 0%, rgba(0, 0, 0, 0.45) 100%);
}

/* Lights off — deep night */
.room--off {
  background: linear-gradient(180deg, #060708 0%, #0a0c10 35%, #050608 100%);
  color: #7a8494;
  --text: #9aa4b2;
  --muted: #5c6570;
  --panel-bg: rgba(0, 0, 0, 0.35);
}

.room--off::before {
  opacity: 1;
  background: radial-gradient(
      ellipse 90% 45% at 50% 0%,
      rgba(15, 22, 35, 0.5) 0%,
      transparent 45%
    ),
    radial-gradient(ellipse 100% 80% at 50% 100%, rgba(0, 0, 0, 0.65) 0%, #000 100%);
}

/* Unknown / loading */
.room--unknown {
  background: linear-gradient(180deg, #1e2836 0%, #141820 50%, #0e1118 100%);
  color: #c5cbd6;
  --text: #e8eef5;
  --muted: #8a96a8;
  --panel-bg: rgba(0, 0, 0, 0.22);
}

.room--unknown::before {
  opacity: 0.85;
  background: radial-gradient(
      ellipse 100% 55% at 50% -5%,
      rgba(200, 170, 90, 0.12) 0%,
      transparent 45%
    ),
    radial-gradient(ellipse 90% 60% at 50% 100%, rgba(0, 0, 0, 0.35) 0%, transparent 70%);
}

/* -------------------------------------------------------------------------- */
/* Ceiling light fixture                                                       */
/* -------------------------------------------------------------------------- */

.light-area {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 24rem;
  display: flex;
  justify-content: center;
  padding-top: 1.25rem;
  min-height: 9rem;
}

.light-fixture {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  isolation: isolate;
}

.light-fixture__cord {
  width: 3px;
  height: 2.25rem;
  background: linear-gradient(90deg, #2a2a2a, #4a4a4a, #2a2a2a);
  border-radius: 2px;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

.light-fixture__shade {
  position: relative;
  width: 5.5rem;
  height: 3rem;
  background: linear-gradient(180deg, #6b6560 0%, #4a4540 45%, #35302c 100%);
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
  border: 3px solid #2c2825;
  border-top: none;
  box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.4);
  margin-top: -1px;
}

.light-fixture__bulb {
  position: absolute;
  left: 50%;
  bottom: 0.35rem;
  transform: translateX(-50%);
  width: 2.75rem;
  height: 1.5rem;
  border-radius: 50%;
  background: radial-gradient(
    circle at 50% 35%,
    rgba(255, 255, 255, 0.35) 0%,
    rgba(180, 175, 165, 0.25) 40%,
    rgba(80, 75, 70, 0.5) 100%
  );
  transition: background 0.6s ease, box-shadow 0.6s ease;
}

.light-fixture__filament {
  position: absolute;
  left: 50%;
  bottom: 0.85rem;
  transform: translateX(-50%);
  width: 0.35rem;
  height: 0.6rem;
  border-radius: 1px;
  background: #3a3835;
  opacity: 0.4;
  transition: background 0.5s ease, opacity 0.5s ease, box-shadow 0.5s ease;
}

/* Light on — strong glow so it reads even when the room is bright */
.light-fixture--on .light-fixture__bulb {
  background: radial-gradient(
    circle at 50% 28%,
    #ffffff 0%,
    #fff8d0 18%,
    #ffe090 40%,
    #e8a030 78%,
    #a86820 100%
  );
  box-shadow: 0 0 14px 6px rgba(255, 235, 160, 1),
    0 0 32px 14px rgba(255, 210, 90, 0.95), 0 0 56px 22px rgba(255, 180, 50, 0.55),
    0 0 90px 36px rgba(255, 160, 40, 0.25);
  filter: brightness(1.08) saturate(1.15);
}

.light-fixture--on .light-fixture__filament {
  background: linear-gradient(180deg, #ffffff, #ffdd66);
  opacity: 1;
  box-shadow: 0 0 8px 2px #ffaa22, 0 0 14px #ff8800;
}

.light-fixture--on .light-fixture__shade {
  border-color: #5a5045;
  filter: brightness(1.08);
  box-shadow: inset 0 -4px 14px rgba(255, 220, 140, 0.25), 0 8px 20px rgba(0, 0, 0, 0.35),
    0 0 24px rgba(255, 200, 80, 0.35);
}

/* Light off */
.light-fixture--off .light-fixture__bulb {
  background: radial-gradient(
    circle at 50% 40%,
    #2a2830 0%,
    #1a1820 70%,
    #0e0e12 100%
  );
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
}

.light-fixture--off .light-fixture__filament {
  background: #1a1a1e;
  opacity: 0.25;
  box-shadow: none;
}

.light-fixture--off .light-fixture__shade {
  filter: brightness(0.65);
}

/* Dim / unknown */
.light-fixture--unknown .light-fixture__bulb {
  background: radial-gradient(
    circle at 50% 35%,
    rgba(200, 170, 100, 0.35) 0%,
    rgba(100, 90, 75, 0.35) 60%,
    rgba(40, 38, 42, 0.6) 100%
  );
  box-shadow: 0 0 12px 2px rgba(200, 160, 80, 0.2);
}

.light-fixture--unknown .light-fixture__filament {
  opacity: 0.5;
  background: #6a5c48;
}

/* Cone of light on the “floor” (page) */
.light-fixture__pool {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 50%;
  transform: translateX(-50%);
  width: min(100vw, 28rem);
  height: 10rem;
  pointer-events: none;
  transition: opacity 0.85s ease;
}

.light-fixture--on .light-fixture__pool {
  opacity: 1;
  background: radial-gradient(
    ellipse 55% 80% at 50% 0%,
    rgba(255, 220, 150, 0.18) 0%,
    rgba(255, 200, 120, 0.06) 45%,
    transparent 75%
  );
}

.light-fixture--off .light-fixture__pool,
.light-fixture--unknown .light-fixture__pool {
  opacity: 0;
}

/* -------------------------------------------------------------------------- */
/* Panel & switch (existing)                                                   */
/* -------------------------------------------------------------------------- */

* {
  box-sizing: border-box;
}

.panel {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 28rem;
  width: 100%;
}

h1 {
  margin: 0 0 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 1.65rem;
  color: var(--text);
}

.switch-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

:root {
  --on: #3ddc84;
  --off: #e85d5d;
  --unknown: #c9b458;
  --plate: #f4e8d5;
  --track: #c4b8a5;
}

.switch {
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.35));
  transition: transform 0.15s ease;
}

.switch:hover {
  transform: scale(1.02);
}

.switch__plate {
  position: relative;
  width: 200px;
  height: 120px;
  background: linear-gradient(145deg, #fff8ec 0%, var(--plate) 100%);
  border-radius: 18px;
  border: 4px solid #8b7355;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.65),
    inset 0 -3px 8px rgba(0, 0, 0, 0.08);
}

.switch__screw {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ddd, #777);
  border: 1px solid #555;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.5);
}

.switch__screw--tl {
  top: 8px;
  left: 10px;
}
.switch__screw--tr {
  top: 8px;
  right: 10px;
}
.switch__screw--bl {
  bottom: 8px;
  left: 10px;
}
.switch__screw--br {
  bottom: 8px;
  right: 10px;
}

.switch__track {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 120px;
  height: 44px;
  background: linear-gradient(180deg, #b5a896, var(--track));
  border-radius: 22px;
  border: 3px solid #7a6c5a;
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.25);
}

.switch__knob {
  position: absolute;
  top: 3px;
  width: 52px;
  height: 38px;
  border-radius: 19px;
  background: linear-gradient(180deg, #faf6ef 0%, #d8cfc0 100%);
  border: 2px solid #6a5c4e;
  box-shadow: 0 4px 0 #5a4d42, 0 6px 10px rgba(0, 0, 0, 0.25);
  transition: left 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  left: 4px;
}

/* Labels: ON is on the left, OFF on the right — knob sits by the matching label */
.switch--on .switch__knob {
  left: 4px;
}

.switch--off .switch__knob {
  left: 64px;
}

.switch--unknown .switch__knob {
  left: 34px;
}

.switch__label {
  position: absolute;
  bottom: 14px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #5c4f42;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.switch__label--on {
  left: 28px;
}

.switch__label--off {
  right: 24px;
}

.switch--on .switch__plate {
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.65),
    inset 0 -3px 8px rgba(0, 0, 0, 0.08), 0 0 24px rgba(61, 220, 132, 0.45);
}

.switch--off .switch__plate {
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.65),
    inset 0 -3px 8px rgba(0, 0, 0, 0.08), 0 0 20px rgba(232, 93, 93, 0.35);
}

.switch--unknown .switch__plate {
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.65),
    inset 0 -3px 8px rgba(0, 0, 0, 0.08), 0 0 18px rgba(201, 180, 88, 0.35);
}

.meta {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  text-align: left;
  background: var(--panel-bg);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  min-height: 3rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.6s ease, border-color 0.6s ease;
}

.meta strong {
  color: var(--text);
}

.meta .row {
  margin: 0.25rem 0;
}

.meta .err {
  color: #f0a0a0;
}
