/* Christmas on SweetFox, drawn in pixel art like the rest of the site (pixel.css). Nothing here applies until xmas.js sets
   html[data-xmas] ("on" or "calm"); data-xmas-fx is "full" (snow falls, lights twinkle) or "still"
   (decorations only). Sprites are shown at whole multiples of their pixels so they stay crisp. */

/* ---------- the fox's hat ---------- */
/* Drawn over each mark on the mark's own 16 x 16 pixel grid: the hat's top-left pixel is at (3, -5). */
html[data-xmas] :is(.kn-brand, .Layout-module__jbLzUW__footerBrand) { position: relative; }
html[data-xmas] :is(.kn-brand, .kn-mbrand, .Layout-module__jbLzUW__footerBrand)::before {
  --xm-px: calc(var(--xm-fox, 24px) / 16);
  content: "";
  position: absolute;
  left: calc(var(--xm-fx, 0px) + 3 * var(--xm-px));
  top: calc(var(--xm-fy, 0px) - 5 * var(--xm-px));
  width: calc(10 * var(--xm-px));
  height: calc(10 * var(--xm-px));
  background: url(/assets/xmas/hat.svg) 0 0 / 100% 100% no-repeat;
  image-rendering: pixelated;
  pointer-events: none;
  transform-origin: 50% 90%;
}
html[data-xmas] .kn-brand { --xm-fx: 10px; --xm-fy: 10px; }
html[data-xmas] .Layout-module__jbLzUW__footerBrand { --xm-fox: 28px; }
html[data-xmas] :is(.kn-brand, .kn-mbrand, .Layout-module__jbLzUW__footerBrand):hover::before { animation: xmHat .7s ease; }
@keyframes xmHat {
  20% { transform: rotate(-14deg) translateY(-1px); }
  50% { transform: rotate(9deg); }
  75% { transform: rotate(-4deg); }
}

/* ---------- Top 10: candy-cane numbers ---------- */
html[data-xmas] .MediaCard-module__ksxplG__flagRank {
  background: repeating-linear-gradient(135deg, #fff 0 3px, #ff4b4b 3px 6px) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* ---------- the Christmas row on Home ---------- */
html:not([data-xmas]) [data-slot="xmas"] { display: none; }
/* a pixel tree by the heading: the sprite is 7 x 9, shown at 2x */
html[data-xmas] [data-krow="xmas"] .MediaRow-module__cgKaXa__heading::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 18px;
  margin-right: 10px;
  vertical-align: -1px;
  background: url(/assets/xmas/tree-s.svg) 0 0 / 14px 18px no-repeat;
  image-rendering: pixelated;
}
/* pixel snow on each card's top edge (two ends and a middle that repeats, each sprite pixel at 2x) */
html[data-xmas] [data-krow="xmas"] .MediaCard-module__ksxplG__artBox::after {
  content: "";
  position: absolute;
  z-index: 3;
  left: -4px;
  right: -4px;
  top: -8px;
  height: 24px;
  padding: 0 14px;
  box-sizing: border-box;
  background:
    url(/assets/xmas/cap-l.svg) left top / 14px 24px no-repeat border-box,
    url(/assets/xmas/cap-r.svg) right top / 14px 24px no-repeat border-box,
    url(/assets/xmas/cap-m.svg) left top / 120px 24px repeat-x content-box;
  image-rendering: pixelated;
  pointer-events: none;
}

/* ---------- falling snow ---------- */
#xm-snow {
  position: fixed;
  z-index: 101;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- falling snow on phones and tablets ---------- */
/* one small element per flake (xmas.js), moved by these animations: the browser runs them off the main thread */
#xm-fall { position: fixed; z-index: 101; left: 0; top: 0; width: 100%; height: 100%; overflow: hidden; pointer-events: none; contain: strict; }
.xm-f { position: absolute; top: 0; background: #fff; image-rendering: pixelated; will-change: transform; animation: xmDrop0 20s linear infinite; }
.xm-f1 { animation-name: xmDrop1; }
.xm-f2 { animation-name: xmDrop2; }
@keyframes xmDrop0 { 0% { transform: translate3d(0, -16px, 0); } 25% { transform: translate3d(12px, 26vh, 0); } 50% { transform: translate3d(-4px, 52vh, 0); } 75% { transform: translate3d(10px, 78vh, 0); } 100% { transform: translate3d(0, 104vh, 0); } }
@keyframes xmDrop1 { 0% { transform: translate3d(0, -16px, 0); } 25% { transform: translate3d(-10px, 26vh, 0); } 50% { transform: translate3d(6px, 52vh, 0); } 75% { transform: translate3d(-12px, 78vh, 0); } 100% { transform: translate3d(-2px, 104vh, 0); } }
@keyframes xmDrop2 { 0% { transform: translate3d(0, -16px, 0); } 33% { transform: translate3d(7px, 35vh, 0); } 66% { transform: translate3d(-8px, 70vh, 0); } 100% { transform: translate3d(3px, 104vh, 0); } }
/* no snow globe where there is no pointer to sweep with */
@media (pointer: coarse) { #xm-card .xm-shake, #xm-card .xm-tip { display: none; } }

/* ---------- snow lying on the menu (header bar, phone dock) ---------- */
/* placed by xmas.js along the bar's top edge; it sits beside the bar, not in it, because the bar is cut to its pixel shape */
.xm-drift { position: absolute; z-index: 2; height: 40px; pointer-events: none; transition: opacity .25s ease; }
.xm-drift.is-fixed { position: fixed; z-index: 101; }
.kn-shell.is-search ~ .xm-drift { opacity: 0; }

/* ---------- the string of lights ---------- */
#xm-lights {
  position: fixed;
  z-index: 99;
  left: 0;
  right: 0;
  top: 0;
  height: 0;
  pointer-events: none;
  transition: transform .45s cubic-bezier(.22, 1, .36, 1), opacity .3s ease;
}
#kn.is-away ~ #xm-lights { transform: translateY(-110px); opacity: 0; }
/* the wire and its bulbs, clipped to the page's width so a glow at the edge never widens the page */
.xm-rig { position: absolute; left: 0; right: 0; top: 0; height: 110px; overflow: hidden; pointer-events: none; }
#xm-lights svg { position: absolute; left: 0; top: 0; overflow: visible; }
#xm-lights .xm-wire { fill: #15231a; }
/* a bulb is a 5 x 9 pixel sprite at 2x, hung by the middle of its socket */
.xm-bulb {
  --c: #ffc233;
  --d: 3.6s;
  --dl: 0s;
  position: absolute;
  left: -5px;
  top: 0;
  width: 10px;
  height: 18px;
  color: var(--c);
  transform-origin: 50% 0;
}
.xm-bulb svg { position: relative; display: block; animation: xmGlass var(--d) ease-in-out var(--dl) infinite; }
.xm-bulb::before { /* its glow */
  content: "";
  position: absolute;
  left: -31px;
  top: -25px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--c) 0, transparent 62%);
  background: radial-gradient(circle, color-mix(in srgb, var(--c) 58%, transparent) 0, color-mix(in srgb, var(--c) 20%, transparent) 32%, transparent 66%);
  animation: xmHalo var(--d) ease-in-out var(--dl) infinite;
}
/* lit most of the time, with one dip each round */
@keyframes xmGlass { 0%, 52%, 100% { opacity: 1; } 76% { opacity: .42; } }
@keyframes xmHalo { 0%, 52%, 100% { opacity: .95; transform: scale(1); } 76% { opacity: .07; transform: scale(.58); } }
html[data-xmas-fx="still"] .xm-bulb svg, html.k-on-watch .xm-bulb svg { animation: none; }
html[data-xmas-fx="still"] .xm-bulb::before, html.k-on-watch .xm-bulb::before { animation: none; opacity: .6; }
html[data-lite="1"] .xm-bulb::before { left: -19px; top: -13px; width: 48px; height: 48px; }

/* the ornament that opens the theme's card */
#xm-orn {
  position: absolute;
  left: 0;
  top: 0;
  width: 34px;
  height: 58px;
  margin: 0 0 0 -17px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  transform-origin: 50% 0;
  animation: xmSwing 4.6s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
}
#xm-orn::before { content: ""; position: absolute; left: 50%; top: 0; width: 2px; height: 20px; margin-left: -1px; background: #15231a; }
#xm-orn::after { content: ""; position: absolute; left: 50%; top: 18px; width: 22px; height: 26px; margin-left: -11px; background: url(/assets/xmas/bauble.svg) 0 0 / 22px 26px no-repeat; image-rendering: pixelated; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .5)); transition: transform .2s ease; }
#xm-orn:hover { animation-duration: 1.5s; }
#xm-orn:hover::after, #xm-orn[aria-expanded="true"]::after { transform: scale(1.12); }
#xm-orn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; border-radius: 12px; }
@keyframes xmSwing { 0%, 100% { transform: rotate(5deg); } 50% { transform: rotate(-5deg); } }
html[data-xmas-fx="still"] #xm-orn { animation: none; }

#xm-card {
  position: absolute;
  left: 0;
  top: 0;
  width: min(284px, calc(100vw - 24px));
  padding: 16px;
  border-radius: 20px;
  background: rgba(22, 23, 28, .78);
  border: 1px solid rgba(255, 255, 255, .1);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .08);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  backdrop-filter: blur(24px) saturate(1.6);
  color: #fff;
  font: 500 13px/1.45 var(--font-body, system-ui, sans-serif);
  pointer-events: auto;
  transform-origin: var(--ox, 50%) 0;
  transition: opacity .18s ease, transform .22s cubic-bezier(.22, 1, .36, 1), visibility 0s;
}
#xm-card[hidden] { display: block; visibility: hidden; opacity: 0; transform: translateY(-6px) scale(.94); pointer-events: none; transition: opacity .15s ease, transform .15s ease, visibility 0s linear .15s; }
html[data-lite="1"] #xm-card { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(18, 19, 23, .97); }
.xm-card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.xm-card-top img { width: 33px; height: 42px; flex: none; image-rendering: pixelated; }
.xm-card-top b { display: block; font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
.xm-card-top span { color: rgba(255, 255, 255, .62); }
.xm-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.xm-modes button, .xm-shake {
  appearance: none;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, .07);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .07);
  color: #fff;
  font: inherit;
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
}
.xm-modes button { padding: 8px 4px 7px; text-align: center; }
.xm-modes b { display: block; font-size: 13px; font-weight: 700; }
.xm-modes small { display: block; font-size: 11px; color: rgba(255, 255, 255, .55); }
.xm-modes button:hover, .xm-shake:hover { background: rgba(255, 255, 255, .13); }
.xm-modes button[aria-checked="true"] { background: #fff; color: #0b0c10; }
.xm-modes button[aria-checked="true"] small { color: rgba(11, 12, 16, .62); }
.xm-shake { display: block; width: 100%; margin-top: 8px; padding: 10px; font-weight: 700; }
.xm-shake[disabled] { opacity: .45; cursor: default; }
.xm-tip { margin: 12px 2px 0; font-size: 12px; color: rgba(255, 255, 255, .5); }
html[data-xmas-fx="still"] .xm-shake, html[data-xmas-fx="still"] .xm-tip, html.k-on-watch .xm-shake, html.k-on-watch .xm-tip { display: none; }
@media (hover: none) { .xm-tip { display: none; } }

/* ---------- where the theme steps back ---------- */
/* the watch page: nothing falls or blinks beside the film */
html.k-on-watch :is(#xm-snow, #xm-fall) { display: none; }
html.k-on-watch #xm-lights { opacity: .6; }
/* the player filling a phone's screen */
html.kw-pin :is(#xm-lights, #xm-snow, #xm-fall, .xm-drift) { display: none !important; }
@media (orientation: landscape) and (max-height: 640px) {
  html.k-on-watch :is(#xm-lights, .xm-drift) { display: none !important; }
}

/* ---------- phones: the header scrolls away with the page, so the lights do too ---------- */
@media (max-width: 768px) {
  #xm-lights { position: absolute; z-index: 49; }
  .xm-bulb::before { left: -23px; top: -17px; width: 56px; height: 56px; }
  html.k-on-title #xm-lights { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .xm-bulb svg, .xm-bulb::before, #xm-orn { animation: none !important; }
  #xm-fall { display: none; }
  html[data-xmas] :is(.kn-brand, .kn-mbrand, .Layout-module__jbLzUW__footerBrand):hover::before { animation: none; }
}

/* ---------- progress bars: a candy cane ---------- */
/* the fill is the Top 10 numbers' red and white, stepping one pixel a row (candy.svg, 4 x 3 pixels at 2x) */
html[data-xmas] .kino-progress { height: 6px; background: rgba(10, 16, 28, .62); }
html[data-xmas] .kino-progress i,
html[data-xmas] .kt-resume b { background: url(/assets/xmas/candy.svg) 0 0 / 8px 6px repeat-x; image-rendering: pixelated; border-radius: 0; }
html[data-xmas] .kt-resume i { height: 6px; border-radius: 0; }
@keyframes xmCane { to { background-position: 8px 0; } }

/* ---------- a Christmas card picked up ---------- */
/* Rested on, a card in the Christmas row comes alive: pixel snow falls inside its picture (two layers, the nearer
   one faster), a string of lights runs round it and chases clockwise, the snow on its top edge gives a shake, the
   candy cane on its progress bar turns, and it glows a little warmer. All of it only while the pointer is there. */
@media (hover: hover) and (pointer: fine) {
  /* the lights: a 6 px ring round the picture, wire and bulbs from two tiles (along and down) */
  html[data-xmas] [data-krow="xmas"] .MediaCard-module__ksxplG__artBox::before {
    content: "";
    position: absolute;
    z-index: 2;
    inset: -6px;
    padding: 6px 0;
    background:
      url(/assets/xmas/lights-h.svg) 0 0 / 48px 6px repeat-x border-box,
      url(/assets/xmas/lights-h.svg) 0 100% / 48px 6px repeat-x border-box,
      url(/assets/xmas/lights-v.svg) 0 0 / 6px 48px repeat-y content-box,
      url(/assets/xmas/lights-v.svg) 100% 0 / 6px 48px repeat-y content-box;
    image-rendering: pixelated;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s steps(2);
  }
  html[data-xmas] [data-krow="xmas"] .MediaCard-module__ksxplG__card:hover .MediaCard-module__ksxplG__artBox::before { opacity: 1; }
  /* the snow inside the picture: each layer is one tile taller than the picture and slides down by one tile */
  html[data-xmas] [data-krow="xmas"] .MediaCard-module__ksxplG__imageWrap::before,
  html[data-xmas] [data-krow="xmas"] .MediaCard-module__ksxplG__imageWrap.kimg-in::after {
    content: "";
    position: absolute;
    z-index: 2;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    image-rendering: pixelated;
    opacity: 0;
    transition: opacity .3s steps(3);
  }
  html[data-xmas] [data-krow="xmas"] .MediaCard-module__ksxplG__imageWrap::before { top: -64px; background: url(/assets/xmas/snow-far.svg) 0 0 / 64px 64px repeat; }
  html[data-xmas] [data-krow="xmas"] .MediaCard-module__ksxplG__imageWrap.kimg-in::after { top: -96px; background: url(/assets/xmas/snow-near.svg) 0 0 / 96px 96px repeat; transform: none; }
  html[data-xmas] [data-krow="xmas"] .MediaCard-module__ksxplG__card:hover .MediaCard-module__ksxplG__imageWrap::before { opacity: .85; }
  html[data-xmas] [data-krow="xmas"] .MediaCard-module__ksxplG__card:hover .MediaCard-module__ksxplG__imageWrap.kimg-in::after { opacity: 1; }
  html[data-xmas] [data-krow="xmas"] .MediaCard-module__ksxplG__card:hover .MediaCard-module__ksxplG__imageWrap { box-shadow: 0 22px 40px -18px rgba(0, 0, 0, .85), 0 0 34px -8px rgba(255, 196, 92, .6); }
  /* the moving parts, only with the Christmas effects on Full */
  html[data-xmas][data-xmas-fx="full"] [data-krow="xmas"] .MediaCard-module__ksxplG__card:hover .MediaCard-module__ksxplG__artBox::before { animation: xmChase .6s steps(4) infinite; }
  html[data-xmas][data-xmas-fx="full"] [data-krow="xmas"] .MediaCard-module__ksxplG__card:hover .MediaCard-module__ksxplG__imageWrap::before { animation: xmFallFar 3.2s steps(32) infinite; }
  html[data-xmas][data-xmas-fx="full"] [data-krow="xmas"] .MediaCard-module__ksxplG__card:hover .MediaCard-module__ksxplG__imageWrap.kimg-in::after { animation: xmFallNear 2.4s steps(24) infinite; }
  html[data-xmas][data-xmas-fx="full"] [data-krow="xmas"] .MediaCard-module__ksxplG__card:hover .MediaCard-module__ksxplG__artBox::after { animation: xmCapShake .5s steps(1); }
  html[data-xmas][data-xmas-fx="full"] .MediaCard-module__ksxplG__card:hover .kino-progress i { animation: xmCane .5s steps(4) infinite; }
}
@keyframes xmChase { to { background-position: 48px 0, -48px 100%, 0 -48px, 100% 48px; } }
@keyframes xmFallFar { to { transform: translateY(64px); } }
@keyframes xmFallNear { to { transform: translateY(96px); } }
@keyframes xmCapShake {
  0% { transform: translate(0, -4px); }
  20% { transform: translate(-2px, 0); }
  40% { transform: translate(2px, -2px); }
  60% { transform: translate(-2px, 0); }
  80% { transform: translate(0, -2px); }
  100% { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  html[data-xmas] [data-krow="xmas"] :is(.MediaCard-module__ksxplG__artBox::before, .MediaCard-module__ksxplG__artBox::after, .MediaCard-module__ksxplG__imageWrap::before, .MediaCard-module__ksxplG__imageWrap::after), html[data-xmas] .kino-progress i { animation: none !important; }
}
