/* Clocks + melting snowman (js/keepsakes.js).
   First part: used in the room AND in the corners. Second part: only the corners of the calendar. */

.ks-clock, .ks-snowman { font-variant-numeric: lining-nums tabular-nums; }   /* otherwise the 1 looks like an I */
.ks-clock p { margin: 0; }
.ks-drawn { display: block; width: 100%; height: auto; border-radius: 50%; }
/* a clock from a picture: shadow, picture and hands lie exactly on top of each other */
.ks-picture { position: relative; width: 100%; aspect-ratio: 606 / 1200; }
.ks-picture > * { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.ks-picture > .ks-shadow {          /* 24 px of blur around 202 x 400, moved down a little */
  left: -11.88%;
  top: -3.5%;
  width: 123.76%;
  height: 112%;
  max-width: none;
  opacity: .5;
}

.ks-snowman {
  position: relative;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.ks-snowman:focus { outline: none; }
.ks-snowman:focus-visible { outline: 2px solid #ffc67a; outline-offset: 2px; border-radius: 8px; }
/* All sizes are parts of the button, which is as big as the picture of him (966 x 1562).
   The sign stands half next to him, so it sticks out on the left. */
.ks-snowman { aspect-ratio: 966 / 1562; }
.ks-man, .ks-sign, .ks-ground { position: absolute; display: block; }
.ks-man { left: 0; top: 0; width: 100%; height: 100%; transform-origin: 50% 98%; }
.ks-sign { left: -50%; bottom: 0; width: 80%; aspect-ratio: 1034 / 950; transform-origin: 50% 100%; }
.ks-board, .ks-sign svg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.ks-sign.is-plain::before { content: ""; position: absolute; inset: 7% 1% 20%; border-radius: 4px; background: #a58763; }
.ks-words { fill: #33200f; transform-box: fill-box; transform-origin: 50% 50%; }
/* soft shadows on the ground: under him and under the post of the sign */
.ks-ground {
  left: -32%;
  bottom: -2%;
  width: 132%;
  height: 9%;
  background:
    radial-gradient(closest-side, rgba(28, 17, 22, .6), rgba(28, 17, 22, 0)) 100% 50% / 74% 100% no-repeat,
    radial-gradient(closest-side, rgba(28, 17, 22, .6), rgba(28, 17, 22, 0)) 0 80% / 34% 60% no-repeat;
}

.ks-bubble {
  position: absolute;
  right: 3%;
  bottom: calc(var(--head, 100%) + 8px);   /* --head = height of his hat, set by keepsakes.js */
  box-sizing: border-box;
  width: max-content;
  max-width: 146%;               /* never further left than the sign */
  padding: 9px 15px 10px;
  border-radius: 16px 16px 4px 16px;
  background: #fffaf0;
  color: #3a2c25;
  box-shadow: 0 8px 22px rgba(30, 20, 15, .35);
  font: 600 18px/1.15 "Cormorant Garamond", Georgia, serif;
  text-wrap: balance;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px) scale(.92);
  transform-origin: 100% 100%;
  transition: opacity .25s ease, transform .3s cubic-bezier(.3, 1.4, .5, 1);
}
.ks-bubble.is-visible { opacity: 1; transform: none; }

/* ───────────── Calendar: the corners of the screen ───────────── */
/* its own layer above the picture, below the falling snow; only the snowman can be tapped */
#keepsakes {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  transition: opacity .6s ease, visibility 0s;
}
#keepsakes[hidden] { display: none; }
/* out of the way while a door is open, during the events and the title */
#app.is-zooming #keepsakes,
#ev-catch.is-active ~ #keepsakes,
#keepsakes.is-waiting {
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility 0s .25s;
}

/* top left: two clocks on chains. The left one hangs lower. With a notch (safe area) the chains
   are longer, the clocks start below it. */
#keepsakes .ks-clock {
  --top: max(30px * var(--ks), var(--safe-top) + 4px + 20px * var(--ks));
  position: absolute;
  top: 0;
  left: calc(5px * var(--ks));
  width: calc(57px * var(--ks));
  padding-top: var(--top);
  text-align: center;
  color: #fff6e6;
  text-shadow: 0 1px 2px rgba(25, 14, 22, .9), 0 0 8px rgba(25, 14, 22, .75);
}
#keepsakes .ks-clock + .ks-clock {
  --top: max(10px * var(--ks), var(--safe-top) + 4px);
  left: calc(66px * var(--ks));
}
#keepsakes .ks-clock::before {     /* the chain */
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 3px;
  height: calc(var(--top) + 2px);
  margin-left: -1.5px;
  background: radial-gradient(ellipse 1.5px 2.4px at 50% 50%, var(--metal, #e8c98a) 55%, #4a3a30 80%, rgba(74, 58, 48, 0) 100%) 50% 100% / 3px 5px repeat-y;
}
#keepsakes .ks-drawn { position: relative; box-shadow: 0 4px 10px rgba(20, 12, 18, .5); }
#keepsakes .ks-city {
  margin: calc(3px * var(--ks)) -10px 0;
  font: 600 12.5px/1.1 var(--font-display);
  letter-spacing: .03em;
}
#keepsakes .ks-time {
  margin: 0 -10px;
  font: 600 14.5px/1.1 var(--font-display);
  font-variant-numeric: lining-nums tabular-nums;   /* `font:` above resets it */
  white-space: nowrap;
}

/* bottom right: the snowman with his sign, on the frozen lake */
#keepsakes .ks-snowman {
  position: absolute;
  right: 0;
  bottom: calc(var(--safe-bottom) * .3 + 2px);
  height: calc(170px * var(--ks));
  pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
  .ks-bubble { transition: opacity .25s ease; transform: none; }
}
