/* The advent calendar (./advent.ts says what it is and how it moves). The night, the house and Santa's bus are
   kie's pictures; the windows on the house's blank wall and the pixel snow are the page's own. Red is the one
   colour (Sergei 2026-12-01: "make red primary color"): the house's roof, its doors, the sparks. */

@font-face {
  font-family: 'Reckless';
  src: url('./fonts/RecklessCollectionVF-TRIAL.ttf') format('truetype');
  font-weight: 100 900;
  font-display: block;
}
@font-face {
  font-family: 'Haffer';
  src: url('./fonts/Haffer-TRIAL-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: block;
}
@font-face {
  font-family: 'Haffer';
  src: url('./fonts/Haffer-TRIAL-Medium.woff2') format('woff2');
  font-weight: 500;
  font-display: block;
}

/* unfair.so's wordmark face (That That New Pixel, the static cut the product's own share cards use; bought) */
@font-face {
  font-family: 'UnfairPixel';
  src: url('./fonts/NewPixel.ttf') format('truetype');
  font-weight: 400;
  font-display: block;
}

:root {
  --red: #c8102e;
  /* the night picture's own sky at its top edge, so the sky goes on above the picture with no seam */
  --sky: #090a0f;
}

*,
::before,
::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
}
body {
  -webkit-font-smoothing: antialiased;
  color: #fff;
  background: var(--sky);
}

/* ------------------------------------------------------------------ the stage */

.advent-snow {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  image-rendering: pixelated;
}
.advent-snow[data-layer='back'] {
  z-index: 0;
}
.advent-snow[data-layer='front'] {
  z-index: 3;
}

/* the night stands at the foot of the page, the house on its snow; the sky above it is its top colour. The house's
   mound is the end of the page (Sergei 2026-12-01: "move the home to the bottom till the end of the page"). */
.scene {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: url('./img/advent/night.webp') center bottom / max(100%, 1500px) auto no-repeat;
}
/* the house's snow and the hills' run together at the foot of the page: a drift of their one colour, the colour
   make.py grades the hills to, laps over the bottom of the house's mound so it sinks in rather than sits on top */
.scene::after {
  content: '';
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  height: 40px;
  background: linear-gradient(rgba(235, 230, 228, 0), rgb(235, 230, 228) 85%);
  pointer-events: none;
}

/* The title holds still at the top of the window while the house scrolls up over it (Sergei 2026-12-01: "make a
   parallax like we show the title and the santa and house scrolls over them"); the house comes after it and above
   it, so it covers it as it goes by. Santa is no longer under the house: he rides with it (Sergei 2026-12-01: "dont
   overlay santa and house!!"). */
.hero {
  position: sticky;
  top: 0;
  z-index: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding-top: 112px;
}
.advent-title {
  margin: 0;
  font-family: 'Reckless', Georgia, serif;
  font-weight: 400;
  font-variation-settings:
    'wght' 400,
    'wdth' 85,
    'CNTR' 22;
  font-size: 96px;
  line-height: 1;
  letter-spacing: -0.03em;
  text-align: center;
}
.advent-subtitle {
  margin: 20px 0 0;
  font-family: 'Haffer', Inter, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 20px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.72);
  text-align: center;
}

/* ------------------------------------------------------------------ Santa, flying off */

/* Santa waits in clear sky between the words and the roof, touching neither, and scrolls up with the house, so the
   house never covers him. As the page scrolls he flies straight off to the right, his fire stretching (Sergei
   2026-12-01: "maybe santa will fly away?"): advent.ts writes how far, 0 to 1, as --away, reaching 1 by the time
   the scroll would bring him up to the subtitle (Sergei, of the bus crossing the words: "this also looks bad"). */
.sky {
  --away: 0;
  position: relative;
  z-index: 1;
  width: 100%;
  margin-top: 120px;
  /* room under the bus for the hover engines' fire, 12% of the bus's width, and clear sky below it */
  padding-bottom: calc(min(1200px, 96vw) * 0.48 * 0.12 + 40px);
  overflow-x: clip;
}
.ride {
  position: relative;
  width: calc(min(1200px, 96vw) * 0.48);
  margin-left: calc(50% - min(1200px, 96vw) * 0.2);
  translate: calc(var(--away) * 120vw) 0;
  /* the stretched fire's tail is longer than the screen is wide; it fades over the last stretch */
  opacity: calc((1 - var(--away)) * 6);
  animation:
    santa-in 2.6s cubic-bezier(0.2, 0.8, 0.3, 1) both,
    santa-bob 4.5s ease-in-out 2.6s infinite;
}
/* the bus in front of its fires, so they come out from inside the engines */
.santa {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
}
/* the engine's fire, back from the nozzle's mouth at the picture's left edge; twice the mouth's height so the
   flames can flare up and down out of it, and longer the faster the bus goes */
.fire {
  position: absolute;
  right: 99%;
  top: calc((var(--middle) - var(--size)) * 100%);
  height: calc(var(--size) * 200%);
  aspect-ratio: 46 / 22;
  image-rendering: pixelated;
  transform: scaleX(calc(1 + var(--away) * 1.5));
  transform-origin: right center;
}
/* each hover engine's fire, down from its mouth: 12 by 10 cells the size of the big fire's, the middle half of the
   top row its mouth, tucked a little up inside the chrome */
.thrust {
  position: absolute;
  left: calc(var(--middle) * 100% - 7.165%);
  top: calc(var(--bottom) * 100% - 3%);
  width: 14.33%;
  aspect-ratio: 12 / 10;
  image-rendering: pixelated;
}
@keyframes santa-in {
  from {
    transform: translate(-70vw, 40px) rotate(-6deg);
  }
}
@keyframes santa-bob {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-14px) rotate(-1.5deg);
  }
}

/* ------------------------------------------------------------------ the house */

.house {
  --ratio: 0.6;
  position: relative;
  z-index: 1;
  width: min(1200px, 96vw);
  aspect-ratio: var(--ratio);
}
/* the house's shadow on the snow: an ellipse under its base, not a filter over a picture this large; inside the
   house's box, since anything below it would make the page run on past the mound */
.house::before {
  content: '';
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 0;
  height: 6%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(40, 10, 20, 0.45), rgba(40, 10, 20, 0));
}
.house-picture {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-drag: none;
}
.house-wall {
  position: absolute;
  display: grid;
  gap: 2.6% 3.4%;
  padding: 3.5% 4.5%;
}

/* ------------------------------------------------------------------ a window */

/* a door's width is its column's; it stands in the middle of its row's height (five rows of five since Sergei's
   "make 25 doors total" leave the rows taller than the doors) */
.win {
  --arch: 50% 50% 9% 9% / 36% 36% 7% 7%;
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  align-self: center;
  justify-self: center;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  perspective: 900px;
  container-type: size;
  -webkit-tap-highlight-color: transparent;
}
.win:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 4px;
  border-radius: 14px;
}

/* the room behind the door: a dark recess in the wall that lights up warm once the door is open */
.win-hole {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: var(--arch);
  background: radial-gradient(120% 90% at 50% 90%, #5a0a18 0%, #22030a 70%);
  box-shadow:
    inset 0 8px 16px rgba(0, 0, 0, 0.75),
    inset 0 -2px 0 rgba(255, 255, 255, 0.35),
    0 0 0 3px rgba(255, 255, 255, 0.85),
    0 3px 0 3px rgba(180, 160, 150, 0.6);
}
.win-hole::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(90% 75% at 50% 75%, #fff1c9 0%, #ffc560 45%, rgba(255, 150, 40, 0) 100%);
  opacity: 0;
  transition: opacity 600ms ease-out 150ms;
}
.win[data-open] .win-hole::before {
  opacity: 0.95;
}

/* the door, hung on its left edge: it peeks open under the pointer, jiggles, then swings past and settles */
.win-door {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transform-origin: left center;
  background: center / 100% 100% no-repeat;
  transition:
    transform 900ms cubic-bezier(0.28, 1.5, 0.45, 1),
    filter 900ms ease-out;
  filter: drop-shadow(0 4px 4px rgba(40, 0, 10, 0.4));
}
.win-door[data-face='red'] {
  background-image: url('./img/advent/door-red.webp');
  color: #fff;
}
.win-door[data-face='white'] {
  background-image: url('./img/advent/door-white.webp');
  color: var(--red);
}
.win:not([data-open]):hover .win-door {
  transform: rotateY(-14deg);
  transition-duration: 250ms;
}
.win[data-opening] .win-door {
  animation: win-stuck 220ms ease-in-out;
}
.win[data-open] .win-door {
  transform: rotateY(-104deg);
  filter: drop-shadow(0 4px 4px rgba(40, 0, 10, 0.4)) brightness(0.72);
}
/* the back of an open door is plain glaze, not its number read backwards: the number goes as the door turns
   edge-on (the door's shadow flattens it, so the number cannot simply face away) */
.win[data-open] .win-number {
  opacity: 0;
  transition: opacity 0s 160ms;
}
.win-number {
  font-family: 'Reckless', Georgia, serif;
  font-variation-settings:
    'wght' 500,
    'wdth' 85,
    'CNTR' 22;
  font-size: 40cqh;
  line-height: 1;
  letter-spacing: -0.04em;
  transform: translate(-7%, -4%);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}

@keyframes win-stuck {
  0%,
  100% {
    transform: rotateY(0);
  }
  30% {
    transform: rotateY(-9deg);
  }
  60% {
    transform: rotateY(-3deg);
  }
  80% {
    transform: rotateY(-7deg);
  }
}

/* ------------------------------------------------------------------ the card a door opens */

/* the page stays put under the card */
html:has(.reveal:not([hidden])) {
  overflow: hidden;
}
.reveal {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  cursor: pointer;
  background: radial-gradient(60% 60% at 50% 45%, rgba(90, 8, 24, 0.55), rgba(8, 4, 10, 0.9));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: reveal-in 420ms ease-out both;
}
.reveal[hidden] {
  display: none;
}
.reveal[data-state='out'] {
  animation: reveal-out 420ms ease-in both;
}
/* warm rays turning slowly behind the figurine while it is out */
.reveal-rays {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 130vmax;
  height: 130vmax;
  margin: -65vmax 0 0 -65vmax;
  background: repeating-conic-gradient(rgba(255, 190, 90, 0.14) 0deg 7deg, rgba(255, 190, 90, 0) 7deg 20deg);
  -webkit-mask-image: radial-gradient(closest-side, #000 8%, transparent 62%);
  mask-image: radial-gradient(closest-side, #000 8%, transparent 62%);
  animation: rays-turn 40s linear infinite;
  pointer-events: none;
}
/* the greeting over every card */
.reveal-greeting {
  position: relative;
  margin: 0 0 4px;
  font-family: 'Reckless', Georgia, serif;
  font-variation-settings:
    'wght' 400,
    'wdth' 85,
    'CNTR' 22;
  font-size: 36px;
  line-height: 1;
  letter-spacing: -0.02em;
  animation: words-in 500ms cubic-bezier(0.2, 0.8, 0.3, 1) 300ms both;
}
/* the place the figurine flies to; the figurine itself is drawn over it (.reveal-gift) */
.reveal-spot {
  position: relative;
  width: min(50vmin, 400px);
  aspect-ratio: 1;
}
.reveal-gift {
  position: fixed;
  z-index: 5;
  object-fit: contain;
  cursor: pointer;
  filter: drop-shadow(0 26px 30px rgba(0, 0, 0, 0.45));
}
.reveal-gift.is-home {
  animation: gift-float 3.6s ease-in-out infinite;
}
.reveal-words {
  position: relative;
  max-width: 460px;
  text-align: center;
  font-family: 'Haffer', Inter, -apple-system, BlinkMacSystemFont, sans-serif;
}
.reveal-words > * {
  animation: words-in 500ms cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
.reveal-date {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  color: #ffd36e;
  animation-delay: 380ms !important;
}
.reveal-title {
  margin: 10px 0 0;
  font-family: 'Reckless', Georgia, serif;
  font-weight: 400;
  font-variation-settings:
    'wght' 400,
    'wdth' 85,
    'CNTR' 22;
  font-size: 44px;
  line-height: 1;
  letter-spacing: -0.03em;
  animation-delay: 460ms !important;
}
.reveal-line {
  margin: 12px 0 0;
  font-size: 18px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.82);
  animation-delay: 540ms !important;
}
/* the card's two keys: keep the prediction as a picture, or post it on X */
.reveal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
  cursor: default;
  animation-delay: 620ms !important;
}
.reveal-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  font: 500 15px/1 'Haffer', Inter, -apple-system, BlinkMacSystemFont, sans-serif;
  color: #fff;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  transition:
    background 150ms,
    transform 100ms;
}
.reveal-button:hover {
  background: rgba(255, 255, 255, 0.18);
}
.reveal-button:active {
  transform: scale(0.96);
}
.reveal-button:disabled {
  opacity: 0.6;
  cursor: progress;
}
.reveal-button:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}
.reveal-button[data-action='share'] {
  border-color: var(--red);
  background: var(--red);
}
.reveal-button[data-action='share']:hover {
  background: #e0193a;
}
.reveal-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.reveal-button .x-logo {
  fill: currentColor;
  stroke: none;
}
.reveal[data-state='out'] .reveal-words > * {
  animation: none;
}
@keyframes reveal-in {
  from {
    opacity: 0;
  }
}
@keyframes reveal-out {
  to {
    opacity: 0;
  }
}
@keyframes rays-turn {
  to {
    transform: rotate(1turn);
  }
}
@keyframes gift-float {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-10px) rotate(-2deg);
  }
}
@keyframes words-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

/* ------------------------------------------------------------------ the music key */

/* a round glass key at the top right: the speaker with its waves while the music plays, crossed out while not */
.music {
  position: fixed;
  z-index: 6;
  top: 20px;
  right: 20px;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  transition:
    background 150ms,
    transform 100ms;
}
.music:hover {
  background: rgba(255, 255, 255, 0.18);
}
.music:active {
  transform: scale(0.94);
}
.music:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}
.music svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.music[aria-pressed='true'] .music-off,
.music[aria-pressed='false'] .music-waves {
  display: none;
}

/* ------------------------------------------------------------------ a phone */

@media (max-width: 700px) {
  /* the first screen is the title, the bus and the roof, as on a desk, with sky enough between the words and the bus
     for the page to scroll and the bus to fly off before it reaches them */
  .hero {
    padding-top: 80px;
  }
  .advent-title {
    font-size: min(46px, 11vw);
  }
  .advent-subtitle {
    margin-top: 10px;
    font-size: 16px;
  }
  .sky {
    margin-top: 22svh;
    padding-bottom: calc(96vw * 0.56 * 0.12 + 24px);
  }
  .ride {
    width: calc(96vw * 0.56);
    margin-left: calc(50% - 96vw * 0.12);
  }
  .reveal-title {
    font-size: 32px;
  }
  .reveal-greeting {
    font-size: 26px;
  }
  .reveal-line {
    font-size: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .win-door,
  .win-hole::before {
    transition: none;
  }
  .win[data-opening] .win-door,
  .ride,
  .reveal,
  .reveal[data-state='out'],
  .reveal-rays,
  .reveal-gift.is-home,
  .reveal-words > * {
    animation: none;
  }
}
