@font-face {
  font-family: Wall Paint;
  src: url("assets/wall-paint.woff") format("woff");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { color: #e4ccb0; background: #130e0b; font-family: system-ui, sans-serif; }
.scene {
  --spot-x: 50%;
  --spot-y: 61%;
  --swing: 0deg;
  --voltage: 1;
  --bulb-width: clamp(40px, min(7svh, 12vw), 64px);
  --letter-gap: clamp(10px, 1.75svh, 18px);
  --pool-width: clamp(292px, 37vw, 720px);
  --pool-height: clamp(264px, 62svh, 700px);
  --tsoi-size: clamp(76px, 10vw, 114px);
  --tsoi-left: calc(max(10px, env(safe-area-inset-left)) + 16px);
  --tsoi-top: calc(max(10px, env(safe-area-inset-top)) + 16px);
  position: relative;
  min-width: 250px;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  isolation: isolate;
  background: #30231c;
}
.wall, .wall-light, .shadow, #moths { position: absolute; inset: 0; pointer-events: none; }
.wall {
  z-index: 0;
  background: #553e30 url("assets/wall.webp") center / cover no-repeat;
  filter: saturate(.74) brightness(.72);
}
@media (max-aspect-ratio: 4/5) {
  .wall { background-image: url("assets/wall-mobile.webp"); }
}
.wall-light {
  z-index: 1;
  background: radial-gradient(ellipse var(--pool-width) var(--pool-height) at var(--spot-x) var(--spot-y),
    #eaa15e72, #bd773b42 31%, #5a2d1019 56%, transparent 77%);
  mix-blend-mode: screen;
  opacity: calc(.86 * var(--voltage));
}
.shadow {
  z-index: 2;
  background:
    radial-gradient(ellipse var(--pool-width) var(--pool-height) at var(--spot-x) var(--spot-y),
      #b7792d10 12%, #32180a20 37%, #0b070559 61%, #0a0705a9 92%, #080605d8 137%),
    linear-gradient(180deg, #100c0b38, transparent 45%, transparent 68%, #100b0893);
}
.inscription {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  width: max-content;
  max-width: 94%;
  margin: 0;
  transform: translate(-50%, -50%) rotate(-2.4deg) scaleX(1.07);
  color: #f0ede5;
  font-family: Wall Paint, "Arial Narrow", "Arial Black", sans-serif;
  font-size: clamp(38px, 11vw, 145px);
  font-weight: 700;
  line-height: .89;
  letter-spacing: -.026em;
  text-align: center;
  text-transform: uppercase;
  user-select: text;
}
.inscription > .plain { display: block; }
.inscription > .plain:first-child { font-size: .74em; letter-spacing: .075em; }
.inscription > .plain-middle { font-size: .54em; }
.inscription:not(.painted) > .plain + .plain { margin-top: var(--letter-gap); }
@supports (background-clip: text) {
  .inscription {
    color: transparent;
    background:
      radial-gradient(ellipse at 18% 25%, #532f2270 0 13%, transparent 24%) 0 0 / 6px 9px,
      radial-gradient(ellipse at 68% 44%, #6b412d86 0 12%, transparent 25%) 1px 4px / 9px 6px,
      radial-gradient(ellipse at 80% 71%, #865738a3 0 10%, transparent 25%) 1px 2px / 5px 7px,
      linear-gradient(167deg, #efeee9 10%, #fbf9f4 28%, #dedbd3 76%, #d0ccc3 100%);
    background-clip: text;
  }
}
.pendant {
  position: absolute;
  z-index: 4;
  top: -9px;
  left: 50%;
  width: var(--bulb-width);
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateX(-50%) rotate(var(--swing));
  transform-origin: 50% 0;
  pointer-events: none;
}
.cord {
  display: block;
  flex: none;
  width: clamp(2.4px, .32vw, 4px);
  height: var(--cord-length, 31svh);
  background:
    linear-gradient(90deg, #1e130dcf, transparent 57%, #1a100dd4),
    repeating-linear-gradient(-40deg, #332015 0 .7px, #916344 1.5px, #503023 2.2px, #432a1d 3.2px);
  box-shadow: 1px 0 3px #080503ab;
}
.pendant img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: auto;
  margin-top: -1px;
  filter: drop-shadow(0 3px 5px #0d0806ab) brightness(calc(1.1 * var(--voltage)));
}
.pendant::after {
  content: "";
  position: absolute;
  bottom: -39px;
  left: 50%;
  width: 212px;
  height: 159px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, #ffad4057, #e27c2440 18%, #cd622015 45%, transparent 70%);
  opacity: calc(.78 * var(--voltage));
  pointer-events: none;
}
#moths { z-index: 5; display: block; width: 100%; height: 100%; }
.tsoi-badge {
  position: absolute;
  inset: var(--tsoi-top) auto auto var(--tsoi-left);
  z-index: 6;
  width: var(--tsoi-size);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.tsoi-badge:focus-visible { outline: 2px solid #ffe292; outline-offset: 3px; }
.tsoi-logo {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: 49.2% 41%;
  animation: tsoi-spin 10s linear infinite paused;
}
.tsoi-badge[aria-pressed="true"]:not([data-buffering]) .tsoi-logo {
  filter: drop-shadow(0 0 5px #fdd4038c);
  animation-play-state: running;
}
@keyframes tsoi-spin {
  to { transform: rotate(1turn); }
}
@media (prefers-reduced-motion: reduce) {
  .tsoi-logo { animation: none; }
}
.scene-controls {
  position: absolute;
  right: max(13px, env(safe-area-inset-right));
  bottom: max(13px, env(safe-area-inset-bottom));
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
}
.motion-control, .sound-control {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid #c9a88b65;
  border-radius: 50%;
  background: #1e130cb0;
  color: #d8bea1;
  cursor: pointer;
}
.motion-control[hidden], .sound-control[hidden] { display: none; }
.sound-control { position: relative; }
.sound-control::before, .sound-control::after, .sound-wave { position: absolute; }
.sound-control::before, .sound-control::after { content: ""; }
.sound-control::before {
  top: 13px;
  left: 10px;
  width: 14px;
  height: 16px;
  background: currentColor;
  clip-path: polygon(0 35%, 34% 35%, 100% 3%, 100% 97%, 34% 65%, 0 65%);
}
.sound-control::after {
  top: 20px;
  left: 12px;
  width: 21px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  box-shadow: 0 0 0 1px #241910;
  transform: rotate(-45deg);
}
.sound-wave { display: none; }
.sound-control[aria-pressed="true"]::after, .sound-control[aria-pressed="true"] .sound-wave {
  display: block;
  border-right: 2px solid currentColor;
  border-radius: 50%;
}
.sound-control[aria-pressed="true"]::after {
  top: 13px;
  left: 25px;
  width: 8px;
  height: 16px;
  background: transparent;
  box-shadow: none;
  transform: none;
}
.sound-wave { top: 16px; left: 23px; width: 6px; height: 10px; }
.motion-control::before {
  content: "";
  width: 9px;
  height: 13px;
  border-inline: 2px solid currentColor;
}
.motion-control[aria-pressed="true"]::before {
  width: 0;
  height: 0;
  border: 0;
  border-left: 9px solid currentColor;
  border-block: 6px solid transparent;
  transform: translateX(1px);
}
.motion-control:hover, .sound-control:hover { background: #332219; }
.motion-control:focus-visible, .sound-control:focus-visible { outline: 2px solid #e4bf91; outline-offset: 4px; }

@media (max-width: 520px) {
  .scene { --pool-width: max(260px, 81vw); --pool-height: 57svh; }
  .inscription { font-size: clamp(35px, 12.5vw, 65px); }
  .scene-controls { right: 12px; bottom: 12px; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .inscription { top: 50%; font-size: min(9vw, 14svh); }
}

.paint-lines { display: none; }
.inscription.painted {
  width: min(79vw, 715px, 97svh);
  background: none;
}
.inscription.painted .paint-lines {
  display: grid;
  justify-items: center;
  row-gap: var(--letter-gap);
}
.paint-line {
  position: relative;
  overflow: hidden;
}
/* The three crops share one scan and preserve the painted edges and drips. */
.paint-line-upper { width: 52.5424%; aspect-ratio: 620 / 293; }
.paint-line-middle { width: 9%; aspect-ratio: 183 / 234; }
.paint-line-lower { width: 100%; aspect-ratio: 1180 / 323; }
.paint-line img {
  position: absolute;
  display: block;
  width: 100%;
  height: auto;
  opacity: .92;
}
.paint-line-upper img { top: 0; left: -27.4194%; width: 190.3226%; }
.paint-line-middle img { top: -25.2137%; left: -442.0765%; width: 644.8087%; }
.paint-line-lower img { bottom: 0; }
.inscription.painted > .plain {
  position: absolute;
  margin: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@media (max-width: 520px) {
  .inscription.painted { width: min(89vw, 88svh); }
}
@media (max-height: 500px) and (orientation: landscape) {
  .scene { --bulb-width: clamp(25px, 9svh, 42px); }
  .inscription.painted { width: min(65vw, 84svh); }
}
@media (max-height: 300px) and (orientation: landscape) {
  .inscription.painted { width: min(65vw, 75svh); }
}

.wall-scratch {
  position: absolute;
  z-index: 2;
  height: auto;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.textured-paint {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  mask-image: radial-gradient(ellipse var(--pool-width) var(--pool-height)
    at calc(var(--spot-x) - var(--paint-x, 0px)) calc(var(--spot-y) - var(--paint-y, 0px)),
    #000 24%, #000e 73%, #000d 100%);
}
.textured-paint, .inscription {
  filter: brightness(calc(.88 + .17 * var(--voltage))) drop-shadow(0 1px 1px #21150edf);
}
.inscription.has-paint-texture .paint-line img { opacity: 0; }
