:root {
  --vh: 100vh;
  --photo: url("assets/connie.jpg");
  --font-code: "JetBrains Mono", ui-monospace, Consolas, monospace;
}

@supports (height: 100dvh) {
  :root {
    --vh: 100dvh;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  background: #0d1117;
  overflow: hidden;
}

/* Photo fills the viewport exactly so nothing is cropped on landscape screens */
.stage {
  --h: var(--vh);
  --sw: 100vw;
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sw);
  height: var(--h);
  cursor: default;
}

/* Portrait screens would squash the photo, so crop to the dog instead */
@media (max-aspect-ratio: 1/1) {
  .stage {
    --sw: calc(var(--h) * 1024 / 576);
    left: calc(50vw - var(--sw) * 0.52);
  }
}

.stage.is-over-connie {
  cursor: pointer;
}

.layer {
  position: absolute;
  inset: 0;
  background: var(--photo) 0 0 / 100% 100% no-repeat;
}

/* —— Moving parts: feathered copies of the photo —— */
.plant,
.paw,
.head,
.head__bob {
  will-change: transform;
}

.plant {
  -webkit-mask-image: var(--mask);
  mask-image: var(--mask);
  animation: sway 6s ease-in-out infinite alternate;
}

.plant--window {
  --mask: radial-gradient(ellipse 7.5% 9.5% at 11.9% 26%, #000 50%, transparent 100%);
  transform-origin: 11.9% 32.5%;
}

.plant--shelf {
  --mask: radial-gradient(ellipse 5.5% 6.5% at 22.7% 11.5%, #000 50%, transparent 100%);
  transform-origin: 22.7% 15.6%;
  animation-duration: 7.5s;
  animation-delay: -2s;
}

.plant--right {
  --mask: radial-gradient(ellipse 8.5% 10% at 92.3% 33%, #000 50%, transparent 100%);
  transform-origin: 92.8% 41.7%;
  animation-duration: 6.8s;
  animation-delay: -4s;
}

.paw--left {
  --mask: radial-gradient(ellipse 6.2% 8.4% at 51.2% 67.9%, #000 45%, transparent 100%);
  -webkit-mask-image: var(--mask);
  mask-image: var(--mask);
}

.paw--right {
  --mask: radial-gradient(ellipse 2.4% 6% at 58.9% 63.5%, #000 40%, transparent 100%);
  -webkit-mask-image: var(--mask);
  mask-image: var(--mask);
}

/* Head tilts around the neck; the bob layer handles the bark */
.head,
.head__bob,
.head__photo {
  position: absolute;
  inset: 0;
}

.head {
  transform-origin: 50.5% 44%;
  transition: transform 0.8s cubic-bezier(0.45, 0, 0.25, 1);
}

.head__bob {
  transform-origin: 50.5% 44%;
}

.head__photo {
  --mask: radial-gradient(ellipse 12.5% 21% at 50.5% 29.5%, #000 62%, transparent 100%);
  -webkit-mask-image: var(--mask);
  mask-image: var(--mask);
}

/* Eyelids are patches of fur from just below each eye, with a lash line,
   squashed down over the eye from the top */
.lid {
  --lid-h: 0.0243;
  position: absolute;
  left: calc(var(--x) * 100%);
  top: calc(var(--y) * 100%);
  width: 1.7%;
  height: calc(var(--lid-h) * 100%);
  border-radius: 50%;
  background-image:
    linear-gradient(to top, rgba(28, 14, 8, 0.85), rgba(28, 14, 8, 0.25) 22%, transparent 45%),
    var(--photo);
  background-size: 100% 100%, var(--sw) var(--h);
  background-position:
    0 0,
    calc(var(--sw) * var(--x) * -1) calc(var(--h) * (var(--y) + var(--lid-h)) * -1);
  -webkit-mask-image: radial-gradient(closest-side, #000 65%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 65%, transparent 100%);
  filter: blur(calc(var(--h) * 0.0004)) brightness(0.82);
  transform: scaleY(0);
  transform-origin: top;
}

.lid--left {
  --x: 0.4635;
  --y: 0.2186;
}

.lid--right {
  --x: 0.53;
  --y: 0.2234;
}

/* —— Time of day —— */
.tint,
.night-lights,
.screen-restore {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 2s ease;
}

.tint--dusk {
  background: linear-gradient(
    180deg,
    rgba(255, 120, 40, 0.55),
    rgba(190, 80, 90, 0.45)
  );
  mix-blend-mode: soft-light;
}

.tint--night {
  background:
    radial-gradient(ellipse 14% 34% at 6% 16%, rgb(50, 60, 105), transparent),
    radial-gradient(ellipse 9% 40% at 95% 20%, rgb(50, 60, 105), transparent),
    radial-gradient(ellipse 10% 18% at 50% 8%, rgb(60, 70, 115), transparent),
    rgb(92, 106, 160);
  mix-blend-mode: multiply;
}

/* Keeps the monitor bright once the room goes dark */
.screen-restore {
  clip-path: polygon(61.3% 4.6%, 86.1% 1.4%, 86.1% 35.2%, 61.3% 34.1%);
}

.night-lights {
  background:
    radial-gradient(ellipse 5% 9% at 29.9% 29%, rgba(255, 170, 80, 0.55), transparent),
    radial-gradient(ellipse 14% 20% at 29.9% 30%, rgba(255, 140, 60, 0.16), transparent),
    radial-gradient(ellipse 26% 42% at 72% 22%, rgba(90, 140, 255, 0.22), transparent 70%),
    radial-gradient(ellipse 14% 18% at 57% 52%, rgba(170, 200, 255, 0.16), transparent 70%);
  mix-blend-mode: screen;
}

.time-dusk .tint--dusk,
.time-night .tint--night,
.time-night .screen-restore,
.time-night .night-lights {
  opacity: 1;
}

.time-night .steam {
  opacity: 0.45;
}

/* —— Screens —— */
.glow {
  position: absolute;
  left: 56.6%;
  top: 1%;
  width: 30%;
  height: 35%;
  background: radial-gradient(
    ellipse at 60% 40%,
    rgba(110, 160, 255, 0.16),
    transparent 70%
  );
  mix-blend-mode: screen;
  pointer-events: none;
  animation: flicker 4s ease-in-out infinite;
}

/* Live code on the monitor, lined up under the existing last line */
.code {
  position: absolute;
  left: 64.1%;
  top: 28.5%;
  width: 20%;
  font-family: var(--font-code);
  font-size: calc(var(--h) * 0.0068);
  line-height: calc(var(--h) * 0.0127);
  color: #d6deeb;
  white-space: pre;
  opacity: 0.85;
  filter: blur(calc(var(--h) * 0.0004));
  pointer-events: none;
}

.code__nums {
  position: absolute;
  top: 0;
  left: 0;
  color: #4b5a6e;
}

.code__lines {
  position: absolute;
  top: 0;
  left: 4.9%;
}

.code .kw {
  color: #c792ea;
}

.code .fn {
  color: #82aaff;
}

.code .str {
  color: #c3e88d;
}

.code .num {
  color: #f78c6c;
}

.code .cm {
  color: #637777;
  font-style: italic;
}

.cursor {
  display: inline-block;
  width: 0.55em;
  height: 1.1em;
  margin-left: 1px;
  vertical-align: -0.2em;
  background: #82aaff;
  animation: blink 1s steps(1) infinite;
}

.is-typing .cursor {
  animation: none;
}

/* Phone on the desk lights up with a notification now and then */
.phone {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.phone.is-lit {
  opacity: 1;
}

.phone__screen {
  position: absolute;
  inset: 0;
  clip-path: polygon(69.6% 87.7%, 75.2% 93.9%, 68.2% 100%, 62.2% 100%, 58.7% 93.9%);
  background:
    radial-gradient(ellipse 2.6% 1.6% at 67.6% 91.6%, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.5) 60%, transparent 100%),
    radial-gradient(ellipse 9% 10% at 68% 93%, rgba(200, 220, 255, 0.75), rgba(90, 130, 220, 0.45) 70%, rgba(40, 70, 160, 0.35));
  mix-blend-mode: screen;
}

.phone__spill {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 12% 12% at 67.5% 94%,
    rgba(150, 190, 255, 0.22),
    transparent 70%
  );
  mix-blend-mode: screen;
}

/* —— Ambience —— */
.steam {
  position: absolute;
  left: 27.4%;
  top: 39.5%;
  width: 6.6%;
  height: 14%;
  pointer-events: none;
  transition: opacity 2s ease;
}

.steam span {
  position: absolute;
  bottom: 0;
  left: 35%;
  width: 34%;
  height: 45%;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at center,
    rgba(255, 255, 255, 0.5),
    transparent 70%
  );
  filter: blur(calc(var(--h) * 0.006));
  opacity: 0;
  animation: steam 4.8s ease-out infinite;
}

.steam span:nth-child(2) {
  left: 15%;
  animation-delay: 1.6s;
  animation-duration: 5.4s;
}

.steam span:nth-child(3) {
  left: 52%;
  animation-delay: 3.1s;
  animation-duration: 5s;
}

.dust {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transition: opacity 2s ease;
}

.time-night .dust {
  opacity: 0;
}

/* Glasses glint */
.glint {
  position: absolute;
  left: 44.3%;
  top: 21%;
  width: 12.5%;
  height: 6.6%;
  border-radius: 45%;
  overflow: hidden;
  pointer-events: none;
  mix-blend-mode: screen;
}

.glint::after {
  content: "";
  position: absolute;
  inset: -50% auto -50% 0;
  width: 30%;
  background: linear-gradient(
    100deg,
    transparent,
    rgba(255, 255, 255, 0.55),
    transparent
  );
  transform: translateX(-150%) skewX(-18deg);
  animation: glint 7s ease-in-out 2s infinite;
}

@keyframes sway {
  from {
    transform: rotate(-1deg) skewX(0.4deg);
  }
  to {
    transform: rotate(1.1deg) skewX(-0.4deg);
  }
}

@keyframes flicker {
  0%,
  100% {
    opacity: 0.8;
  }
  40% {
    opacity: 1;
  }
  45% {
    opacity: 0.88;
  }
  70% {
    opacity: 0.95;
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes steam {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.6, 0.8);
  }
  25% {
    opacity: 0.55;
  }
  100% {
    opacity: 0;
    transform: translateY(-140%) translateX(20%) scale(1.4, 1.6);
  }
}

@keyframes glint {
  0%,
  70% {
    transform: translateX(-150%) skewX(-18deg);
  }
  85%,
  100% {
    transform: translateX(450%) skewX(-18deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .plant,
  .glow,
  .steam span,
  .glint::after,
  .cursor {
    animation: none;
  }

  .steam,
  .glint,
  .dust {
    display: none;
  }
}
