/* Light the tree: the outside of the house at night, cropped on the window. */
:root {
  --siding: #1A2442;
  --siding-line: #151D37;
  --trim: #D5DCE4;
  --snow: #CDD8E8;
  --snow-hi: #E4EBF4;
  --ink: #162039;
  --ink-soft: #3D4A6B;
  --amber: #FFC46B;
  --amber-deep: #F2A33A;
  --serif: "Young Serif", Georgia, serif;
  --sans: "Atkinson Hyperlegible", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--siding);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.scene {
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.snowfall {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 3;
}

/* ---- the wall and window ---- */
.wall {
  display: flex;
  justify-content: center;
  padding: max(28px, env(safe-area-inset-top)) 20px 0;
  background:
    repeating-linear-gradient(180deg, var(--siding) 0 21px, var(--siding-line) 21px 23px);
}

.window {
  display: block;
  width: min(88vw, 50svh, 440px);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 8px;
  filter: drop-shadow(0 10px 18px rgba(5, 9, 24, .55));
  transition: transform .18s ease;
}
.window svg { display: block; width: 100%; height: auto; }
.window:active { transform: scale(.985); }
.window:focus-visible { outline: 3px solid var(--amber); outline-offset: 6px; }
.window[aria-disabled="true"] { cursor: default; }

/* room, tree, bulbs: dark by default */
.room-warm { opacity: 0; transition: opacity .16s linear; }
.floor { fill: #0B1122; transition: fill .16s linear; }
.boughs { fill: #10261C; transition: fill .16s linear; }
.boughs-shade { fill: #000; opacity: .22; }
.trunk { fill: #2A1D14; }
.stand { fill: #3A1B18; transition: fill .16s linear; }
.garland { fill: none; stroke: #2E3A33; stroke-width: 1.2; opacity: .7; }
.bulbs circle { opacity: .38; transition: opacity .16s linear; }
.star { fill: #6B6248; transition: fill .16s linear; }
.reflection { opacity: 1; transition: opacity .3s; }

/* lit: the one orchestrated moment. The glow blooms slowly; switching off is instant, like a real switch. */
.is-on .room-warm { opacity: .92; transition: opacity .9s cubic-bezier(.2, .7, .2, 1) .12s; }
.is-on .floor { fill: #4A2414; transition: fill .9s ease .12s; }
.is-on .boughs { fill: #1F5A3A; transition: fill .6s ease; }
.is-on .stand { fill: #8E2D25; transition: fill .6s ease; }
.is-on .garland { stroke: #E8C77A; opacity: .55; }
.is-on .bulbs circle { opacity: 1; filter: url(#bulbGlow); transition: opacity .25s ease; }
.is-on .star { fill: #FFD873; filter: url(#starGlow); transition: fill .4s ease .3s; }
.is-on .reflection { opacity: .25; }

@media (prefers-reduced-motion: no-preference) {
  .is-on .bulbs circle.tw { animation: twinkle var(--tw, 3.4s) ease-in-out var(--td, 0s) infinite; }
}
@keyframes twinkle {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}

/* ---- the yard: snow, light spill, and the controls ---- */
.yard {
  position: relative;
  margin-top: -6px;
  padding: 34px 24px max(32px, env(safe-area-inset-bottom));
  background:
    radial-gradient(120% 60% at 50% 0%, var(--snow-hi) 0%, var(--snow) 55%, #B9C7DB 100%);
  border-radius: 46% 54% 0 0 / 22px 26px 0 0;
  overflow: hidden;
}
.spill {
  position: absolute;
  left: 50%; top: 0;
  width: min(120vw, 640px);
  height: 100%;
  transform: translateX(-50%);
  background: radial-gradient(60% 55% at 50% 0%, rgba(255, 196, 107, .55), rgba(255, 196, 107, 0) 70%);
  opacity: 0;
  transition: opacity .16s linear;
  pointer-events: none;
}
.is-on .spill { opacity: 1; transition: opacity 1.1s ease .25s; }

.panel {
  position: relative;
  z-index: 4;
  max-width: 30rem;
  margin: 0 auto;
  text-align: center;
}

.status {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.1rem, 9vw, 3.3rem);
  line-height: 1.05;
  letter-spacing: -.01em;
  margin: 0 0 .45rem;
}
.meta {
  margin: 0 0 1.4rem;
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--ink-soft);
  min-height: 1.5em;
}

.flip {
  appearance: none;
  display: block;
  width: 100%;
  max-width: 20rem;
  margin: 0 auto;
  padding: 1.05rem 1.25rem;
  border: 2px solid var(--ink);
  border-radius: 14px;
  font: 700 1.12rem/1.2 var(--sans);
  color: var(--ink);
  background: var(--amber);
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease, background-color .2s;
}
.flip.to-off { background: var(--ink); color: var(--snow-hi); box-shadow: 0 4px 0 #0A1022; }
.flip:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.flip:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }
.flip:disabled { cursor: default; background: #C3CCD9; color: #4A5672; border-color: #8C98AE; box-shadow: none; transform: none; }
.flip.busy { opacity: .8; }

.note {
  min-height: 1.5em;
  margin: 1rem 0 0;
  font-size: 1rem;
  line-height: 1.5;
}
.note.bad { color: #8A1F1A; }


@media (min-height: 860px) {
  .wall { padding-top: 56px; }
}
@media (prefers-reduced-motion: reduce) {
  .snowfall { display: none; }
  * { transition-duration: .01ms !important; animation: none !important; }
}
