@font-face {
  font-family: Gloock;
  src: url("./fonts/gloock.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
:root {
  font-family: Georgia, "Times New Roman", serif;
  --display: Gloock, Georgia, serif;
  --pine: #133a2d;
  --red: #ab1824;
  color: #f5f9f6;
  background: #09271e;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100svh;
  display: grid;
  align-content: center;
  justify-items: center;
  grid-template-columns: minmax(0, 1fr);
  padding: clamp(12px, 2.25vmin, 28px);
  background: repeating-linear-gradient(110deg, transparent 0 8px, #13382c55 8px 9px, transparent 9px 17px);
}
h1, h2, p { margin: 0; }
button, a { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible { outline: 3px solid #ffcc5c; outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sheet, .colophon { width: min(100%, 1440px, max(820px, calc(150svh - 144px))); }
.sheet {
  padding: 4px;
  border: 1px solid #bda675;
  box-shadow: 0 12px 35px #01150f80;
  background: #133b29;
  position: relative;
}
.painting {
  position: relative;
  isolation: isolate;
  --scene: url("./art/christmas-valley-landscape.webp");
  background-color: #073626;
  background-position: center;
  background-size: 100% 100%;
  width: 100%;
  aspect-ratio: 3/2;
}
.painting, .cover {
  background-image: var(--scene);
  background-repeat: no-repeat;
}
h1 {
  position: absolute;
  container-type: inline-size;
  top: 4%;
  left: 3.5%;
  width: 45%;
  line-height: 0;
}
h1 img {
  display: block; width: 100%; height: auto;
  clip-path: polygon(0 0, 100% 0, 100% 56%, 94.5% 56%, 95.65% 66%, 95.55% 69.7%, 97% 77%, 100% 77%, 100% 100%, 0 100%);
}
/* Print the detached spark at half size, anchored to the broken tip of the bulb. */
h1::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: url("./art/wordmark.webp") center / 100% 100% no-repeat;
  clip-path: polygon(94.5% 56%, 100% 56%, 100% 77%, 97% 77%, 95.55% 69.7%, 95.65% 66%);
  transform-origin: 95.3% 68.1%;
  transform: scale(.5);
}
.year {
  position: absolute; right: 8%; top: -5%;
  color: #ffcf78; font: 400 8.8cqi/1 var(--display);
  text-shadow: 0 1px 0 #633d20, 0 2px 3px #10222a;
}
/* Register the gold ink to ADVENT and CALENDAR on the curved ribbon. */
h1::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to right, transparent 33.08%, #ffb82f 33.08% 48.4%, transparent 48.4% 57.6%, #ffb82f 57.6% 79%, transparent 79%);
  mix-blend-mode: darken;
  clip-path: polygon(33.08% 77.8%, 48.4% 74.4%, 58% 75.5%, 79% 80.6%, 79% 92%, 58% 86.8%, 48.4% 86%, 33.08% 90.1%);
}
.colophon {
  text-align: center;
  font: 500 13px/1.4 system-ui,sans-serif; color: #d1d8cd;
  padding: 0 4px;
}
.colophon a { display: inline-flex; align-items: center; min-height: 44px; text-underline-offset: 3px; }
.door {
  position: absolute;
  left: var(--x); top: var(--y); width: var(--w); height: var(--h);
  padding: 0; border: 0; background: transparent; perspective: 700px;
}
.door:focus-visible { z-index: 2; }
.cover, .inside, .stitch { position: absolute; inset: 0; display: block; }
.cover {
  transform-origin: left center;
  background-position: var(--bx) var(--by);
  background-size: var(--bw) var(--bh);
  transition: transform 180ms ease-out;
}
.stitch {
  border: 1px dashed #ffefd199;
  border-left: 1px solid #12221748;
  border-radius: 0 2px 2px 0;
  box-shadow: 1px 1px 1px #03170c88;
}
.number {
  position: absolute;
  left: 5%; bottom: 6%;
  color: #fff9de;
  font: 400 clamp(18px,1.85vw,29px)/1 var(--display);
  -webkit-text-stroke: 2.5px #2a301d;
  paint-order: stroke fill;
}
.door[data-state="ready"] .number {
  display: grid;
  place-items: center;
  width: clamp(28px,2.6vw,39px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #a51420;
  border: 1px solid #ffdb91;
  box-shadow: 0 1px 3px #10221599;
  color: white;
  font-size: clamp(20px,1.8vw,29px);
  -webkit-text-stroke: 0;
}
.door[data-state="ready"] .stitch { border-color: #ffe9bce0; border-left-color: #17342766; }
.door[data-state="ready"] .cover::after {
  content: ""; position: absolute; right: 0; top: calc(50% - 6px); width: 5px; height: 12px;
  border-radius: 8px 0 0 8px; background: #123325c9; border: 1px solid #ffdfaa; border-right: none;
}
.inside { display: none; overflow: hidden; background: white; border: 1px solid #d0b97e; }
.inside img { width: 100%; height: 100%; object-fit: contain; }
.inside-day { position: absolute; left: 1px; bottom: 0; padding: 0 3px; background: #fffffff0; color: var(--pine); font: 400 15px/1.25 var(--display); }
.door[data-state="opened"] .inside, .door.opening .inside { display: block; }
.door[data-state="opened"] .cover { visibility: hidden; }
.door.opening { z-index: 1; }
.door.opening .cover { transform: rotateY(-95deg); transition: transform 340ms ease-in; }
@media (hover: hover) {
  .door[data-state="ready"]:hover { z-index: 1; }
  .door[data-state="ready"]:hover .cover { transform: rotateY(-9deg); box-shadow: 3px 2px 5px #09291aa3; }
  .door.opening[data-state="ready"]:hover .cover { transform: rotateY(-95deg); }
  .door[data-state="opened"]:hover .inside { outline: 2px solid #ffe1a3; }
}
.load-error { padding: 10px; text-align: center; font: 15px/1.4 system-ui,sans-serif; }
.load-error button { border: 0; background: none; text-decoration: underline; }
dialog {
  border: 0; padding: 0; width: min(570px, calc(100% - 28px)); max-height: calc(100dvh - 36px);
  background: #fff; color: #182920; box-shadow: 0 16px 80px #04150dc9; overscroll-behavior: contain;
}
dialog::backdrop { background: #031b15cb; }
body:has(dialog[open]) { overflow: hidden; }
dialog[open] { animation: reveal 170ms ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(7px); } }
.page { position: relative; padding: 22px clamp(24px, 4.3vw, 42px) 26px; border-top: 4px solid var(--red); }
.close { position: absolute; z-index: 1; top: 3px; right: 3px; width: 44px; height: 44px; background: #fffffff0; border: 0; }
.close::before, .close::after { content: ""; position: absolute; top: 21px; left: 12px; width: 20px; height: 2px; background: var(--pine); transform: rotate(45deg); }
.close::after { transform: rotate(-45deg); }
#story .story-art { display: block; width: 100%; height: clamp(155px, 24svh, 245px); object-fit: contain; margin: 0 auto 16px; }
.story-heading { display: flex; align-items: flex-start; gap: 12px; }
.story-number {
  display: grid; place-items: center; flex: 0 0 auto; margin-top: 2px; width: 1.5em; aspect-ratio: 1;
  color: #9c1b20; border: 1.5px solid currentColor; border-radius: 50%;
  font: 400 clamp(19px, 2vw, 25px)/1 var(--display);
}
h2 { font: 400 clamp(28px, 3.1vw, 42px)/1.05 var(--display); letter-spacing: -.025em; text-wrap: pretty; }
.copy { margin-top: 16px; font-size: clamp(17px, 1.3vw, 19px); line-height: 1.5; }
.sources { display: flex; gap: 4px 18px; flex-wrap: wrap; margin-top: 17px; padding-top: 8px; border-top: 1px solid #c5cfc8; }
.sources a { display: inline-flex; align-items: center; min-height: 36px; font: 500 14px/1.3 system-ui,sans-serif; color: #265741; text-underline-offset: 3px; }
@media (min-width: 540px) and (max-width: 700px) and (orientation: landscape) {
  body { padding: 3px; }
  .sheet { padding: 2px; }
}
@media (max-width: 539px), (max-width: 1000px) and (orientation: portrait) {
  body { padding: 9px; }
  .sheet, .colophon { width: min(100%, max(377px, calc(53.3333svh - 36px))); }
  .sheet { padding: 3px; }
  .painting {
    --scene: url("./art/christmas-valley-portrait.webp");
    aspect-ratio: 8/15;
    background-size: 125% 100%;
    background-position: 70% center;
  }
  h1 { top: 4.3%; left: 5%; width: 90%; }
  .door { left: var(--mx); top: var(--my); width: var(--mw); height: var(--mh); }
  .cover { background-position: var(--mbx) var(--mby); background-size: var(--mbw) var(--mbh); }
  .number { font-size: clamp(17px, 3.8vw, 25px); }
  .door[data-state="ready"] .number { width: clamp(24px, 5vw, 30px); font-size: clamp(17px,3.5vw,22px); }
  .page { padding: 20px 23px 15px; }
  #story .story-art { height: clamp(125px, 21svh, 205px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
