/* Optional images are requested only when their effect is present. */
canvas.winter-kit-canvas,
winter-kit-scene,
winter-kit-header,
winter-kit-light-string,
winter-kit-light,
winter-kit-layer,
winter-kit-piece {
  pointer-events: none !important;
  user-select: none;
}

winter-kit-scene {
  position: fixed;
  inset: 0;
  display: block;
  z-index: var(--winter-overlay-z, 9998);
}

:root {
  --winter-garland-default: min(clamp(44px, 7vw, 54px), 7vh);
}

winter-kit-header {
  position: relative;
  display: block;
  width: 100%;
  flex: none;
  grid-column: 1 / -1;
  height: calc(24px + var(--winter-top-offset, 0px));
}

winter-kit-header[data-winter-decor="garland"] {
  height: calc(var(--winter-garland-height, var(--winter-garland-default)) + var(--winter-top-offset, 0px));
}

winter-kit-header > winter-kit-layer[data-decoration="garland"] .winter-kit-top,
winter-kit-light-string {
  top: var(--winter-top-offset, 0px);
}

winter-kit-light-string {
  position: absolute;
  inset-inline: 0;
  height: 24px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: start;
  justify-items: center;
  z-index: 2;
}

winter-kit-light-string::before {
  content: "";
  position: absolute;
  top: 4px;
  width: 100%;
  border-top: 1px solid rgba(190, 200, 195, .38);
}

winter-kit-light {
  position: relative;
  display: block;
  width: 5px;
  height: 8px;
  margin-top: 6px;
  border-radius: 38% 38% 52% 52%;
  background: radial-gradient(ellipse at 43% 37%, #fff 0%, currentColor 72%);
  color: var(--lamp-start);
  box-shadow: 0 0 3px currentColor, 0 0 8px currentColor;
  box-shadow: 0 0 3px 1px currentColor, 0 0 8px 1px color-mix(in srgb, currentColor 70%, transparent);
  animation: winter-kit-light-colors 10s ease-in-out infinite;
}

winter-kit-light::before {
  content: "";
  position: absolute;
  inset: -3px 1px auto;
  height: 3px;
  border-radius: 1px 1px 0 0;
  background: #80918a;
}

@keyframes winter-kit-light-colors {
  0%, 100% { color: var(--lamp-start); opacity: .84; }
  33% { color: var(--lamp-next); opacity: 1; }
  66% { color: var(--lamp-end); opacity: .76; }
}

@media (max-width: 900px) {
  winter-kit-light:nth-child(n+17) { display: none; }
}

@media (max-width: 520px) {
  winter-kit-light:nth-child(n+11) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  winter-kit-light { animation: none; }
}

canvas.winter-kit-canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  z-index: var(--winter-snow-z, 9999);
}

.winter-kit-positioned {
  position: relative;
}

winter-kit-layer {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  border-radius: inherit;
  z-index: var(--winter-decor-z, 1);
}

winter-kit-piece {
  position: absolute;
  display: block;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.winter-kit-drift {
  bottom: 0;
  width: min(24%, 250px);
  height: auto;
  aspect-ratio: 250 / 28;
  background-image: url("images/drift-corner.webp");
}

.winter-kit-layer[data-drift="edge"] .winter-kit-drift {
  width: 100%;
  height: 26px;
  aspect-ratio: auto;
  background-image: url("images/drift.webp");
  background-repeat: repeat-x;
  background-size: clamp(230px, 35%, 400px) 100%;
}

.winter-kit-layer[data-drift="corners"] .winter-kit-drift {
  max-width: 50%;
}

.winter-kit-top {
  top: 0;
  width: min(34%, 166px);
  height: 55px;
}

.winter-kit-layer[data-decoration="branches"] .winter-kit-top {
  background-image: url("images/branches.webp");
}

.winter-kit-layer[data-decoration="trees"] .winter-kit-top {
  width: min(30%, 102px);
  height: 76px;
  background-image: url("images/trees.webp");
}

.winter-kit-layer[data-decoration="tinsel"] .winter-kit-top {
  width: min(23%, 164px);
  height: auto;
  aspect-ratio: 164 / 24;
  background-image: url("images/tinsel.webp");
}

.winter-kit-layer[data-decoration="lights"] .winter-kit-top {
  width: min(40%, 220px);
  height: auto;
  aspect-ratio: 310 / 30;
  background-image: url("images/lights.webp");
}

.winter-kit-layer[data-decoration="garland"] .winter-kit-top {
  width: 100%;
  height: var(--winter-garland-height, var(--winter-garland-default));
  max-height: 100%;
  background-image: url("images/garland.webp");
  background-size: auto 100%;
  background-position: center top;
  background-repeat: repeat-x;
}

@media (max-width: 430px) and (hover: none) {
  :root { --winter-garland-default: 26.5vw; }

  .winter-kit-layer[data-decoration="garland"] .winter-kit-top {
    background-image: url("images/garland-mobile.webp");
    background-size: 100% auto;
    background-repeat: no-repeat;
  }
}

@media (430px < width < 500px) and (hover: none) {
  :root { --winter-garland-default: calc(544px - 100vw); }
}

@media (min-width: 768px) {
  :root { --winter-garland-default: min(clamp(54px, 3.4vw, 66px), 7vh); }
}

[data-winter-layout="edge"] > winter-kit-layer:is([data-decoration="lights"], [data-decoration="tinsel"]) .winter-kit-top {
  left: 0;
  right: auto;
  width: 100%;
  height: 30px;
  aspect-ratio: auto;
  transform: none;
  background-repeat: round no-repeat;
  background-size: 310px 30px;
}

[data-winter-layout="edge"] > winter-kit-layer[data-decoration="tinsel"] .winter-kit-top {
  height: 20px;
  background-size: 210px 20px;
}

[data-winter-layout="edge"] > winter-kit-layer:is([data-decoration="lights"], [data-decoration="tinsel"]) .winter-kit-top + .winter-kit-top {
  display: none;
}

.winter-kit-left {
  left: 0;
}

.winter-kit-right {
  right: 0;
  transform: scaleX(-1);
}

@media (max-width: 767px) {
  [data-winter-layout="edge"] > winter-kit-layer[data-decoration="lights"] .winter-kit-top {
    height: 22px;
    background-size: 215px 22px;
  }

  [data-winter-layout="edge"] > winter-kit-layer[data-decoration="tinsel"] .winter-kit-top {
    height: 15px;
    background-size: 150px 15px;
  }

  .winter-kit-drift {
    width: min(44%, 216px);
    height: clamp(24px, 8vw, 38px);
  }

  .winter-kit-layer[data-drift="edge"] .winter-kit-drift {
    height: 24px;
  }

  .winter-kit-top {
    width: min(34%, 116px);
    height: 42px;
  }

  .winter-kit-layer[data-decoration="trees"] .winter-kit-top {
    width: min(32%, 78px);
    height: 56px;
  }
}
