/*
  oddie.net: the family fridge door, in HTML and CSS only.

  The door fills the viewport. Everything stuck to it sits on a .stage that
  keeps a fixed aspect ratio (16:10 landscape, 10:16 portrait) and is scaled
  to fit, so positions are in container-width units (cqw). Each stuck-on item
  is drawn in em, with --u (one em) set per layout to scale it.
*/

:root {
  --enamel: #e6ecef;
  --chrome-dark: #8f989f;
  --chrome-light: #f4f7f8;
  --paper: #fffef9;
  --ink: #2a3a8c;
  --rule: #b9cfe6;
  --magnet: "Fredoka", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  --hand: "Caveat", "Segoe Print", "Comic Sans MS", cursive;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .7), transparent 40%, rgba(0, 0, 0, .05)),
    var(--enamel);
  overflow: hidden;
}

.door {
  position: relative;
  height: 100%;
  min-height: 100svh;
  display: grid;
  place-items: center;
}

.handle {
  position: absolute;
  left: 2.5vmin;
  top: 18%;
  width: 2vmin;
  height: 60%;
  border-radius: 1vmin;
  background: linear-gradient(90deg, var(--chrome-dark), var(--chrome-light) 45%, #aeb6bc);
  box-shadow: .4vmin .6vmin 1vmin rgba(0, 0, 0, .18);
}

.stage {
  position: relative;
  container-type: inline-size;
  width: min(100vw, 160svh);
  aspect-ratio: 16 / 10;
  --u: 1cqw;
}

.stage > * { position: absolute; margin: 0; }

/* Magnets: one line, always. */

.mags {
  left: 9cqw;
  top: 5cqw;
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 0 .5cqw;
  white-space: nowrap;
  font-size: 11.5cqw;
  font-weight: normal;
}

.m {
  display: inline-block;
  font-family: var(--magnet);
  font-weight: 700;
  line-height: .95;
  color: var(--c);
  transform: rotate(var(--r, 0deg));
  text-shadow:
    0 .035em 0 color-mix(in srgb, var(--c) 60%, #000),
    .02em .1em .08em rgba(0, 0, 0, .22);
  transition: transform .3s cubic-bezier(.3, 1.6, .5, 1);
  cursor: grab;
  user-select: none;
}

.m:hover, .m:active { transform: rotate(0deg) translateY(-.08em) scale(1.06); }

.m.sm { font-size: .62em; }

/* Things stuck to the door */

.paper { background: var(--paper); box-shadow: .3em .8em 1.4em rgba(0, 0, 0, .16); }

.pin::before {
  content: "";
  position: absolute;
  top: -1.2em;
  left: 50%;
  width: 2.8em;
  height: 2.8em;
  margin-left: -1.4em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, color-mix(in srgb, var(--pc, #e4372f) 55%, #fff), var(--pc, #e4372f));
  box-shadow: 0 .4em .6em rgba(0, 0, 0, .25);
}

.drawing {
  font-size: var(--u);
  right: 5cqw;
  top: 5cqw;
  width: 23em;
  height: 20em;
  transform: rotate(-3deg);
  --pc: #2fa84f;
}

.drawing .sun {
  position: absolute;
  left: 2.5em;
  top: 2.5em;
  width: 4em;
  height: 4em;
  border-radius: 50%;
  background: #ffb21e;
  box-shadow: 0 0 0 .8em rgba(255, 178, 30, .35);
}

.drawing .grass {
  position: absolute;
  left: 1em;
  right: 1em;
  bottom: 1.5em;
  height: 3em;
  border-radius: .4em;
  background: repeating-linear-gradient(80deg, #4cb050 0 .5em, #6cc96a .5em 1em);
}

.drawing .home {
  position: absolute;
  left: 6.5em;
  bottom: 4.2em;
  width: 7em;
  height: 5.5em;
  background: repeating-linear-gradient(-30deg, #e4372f 0 .35em, #f26a5f .35em .7em);
}

.drawing .home::before {
  content: "";
  position: absolute;
  left: -1em;
  right: -1em;
  bottom: 100%;
  height: 4em;
  background: repeating-linear-gradient(40deg, #7b4bc4 0 .35em, #9a74d6 .35em .7em);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.drawing .home::after {
  content: "";
  position: absolute;
  left: 2.6em;
  bottom: 0;
  width: 1.8em;
  height: 2.8em;
  background: #6b3f1f;
}

.drawing .sig {
  position: absolute;
  right: 1.5em;
  top: 1.6em;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 2.6em;
  color: #1f6fd1;
  transform: rotate(-4deg);
}

.polaroid {
  font-size: var(--u);
  right: 11cqw;
  top: 31cqw;
  width: 17em;
  padding: 1em 1em 4em;
  background: #fbfbf8;
  transform: rotate(6deg);
  box-shadow: .3em .8em 1.4em rgba(0, 0, 0, .2);
  --pc: #1f6fd1;
}

.polaroid .photo {
  height: 13em;
  background: linear-gradient(#8fcdf2, #d5eef8 50%, #3c8fc0 50%, #2b6f9e 70%, #e8d29c 70%);
}

.polaroid span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: .6em;
  text-align: center;
  font-family: var(--hand);
  font-size: 2.3em;
  color: #333;
}

.note {
  font-size: var(--u);
  left: 14cqw;
  top: 34cqw;
  width: 22em;
  height: 22em;
  transform: rotate(-4deg);
  padding: 3em 1.8em 0 2.2em;
  background: repeating-linear-gradient(transparent 0 2.9em, var(--rule) 2.9em 3.05em), var(--paper);
  box-shadow: .3em .8em 1.4em rgba(0, 0, 0, .15);
  --pc: #f2b31f;
}

.note p, .ticket p { margin: 0; font-family: var(--hand); font-size: 2.6em; }

/* One line of text per ruled line (3.05em of the note). */
.note p { line-height: calc(3.05em / 2.6); color: var(--ink); }

.ticket {
  font-size: var(--u);
  left: 42cqw;
  top: 40cqw;
  width: 14em;
  height: 18em;
  padding: 2em 1.4em;
  background: #f6e05e;
  transform: rotate(3deg);
  box-shadow: .3em .8em 1.4em rgba(0, 0, 0, .14);
}

.ticket p { line-height: 1.1; color: #4a3b00; }

/* Portrait: magnets across the top, everything else stacked beneath. */

@media (orientation: portrait) {
  .stage {
    width: min(100vw, 55.5svh);
    aspect-ratio: 10 / 18;
  }

  .handle { top: 30%; height: 45%; }

  .mags { left: 9cqw; top: 10cqw; font-size: 19cqw; }

  .drawing { --u: 1.7cqw; left: 9cqw; right: auto; top: 46cqw; }
  .polaroid { --u: 1.6cqw; left: auto; right: 7cqw; top: 58cqw; }
  .note { --u: 1.55cqw; left: 11cqw; top: 110cqw; }
  .ticket { --u: 1.7cqw; left: auto; right: 12cqw; top: 120cqw; }
}

@media (prefers-reduced-motion: reduce) {
  .m { transition: none; }
}
