/* Fonts are served from this site (SIL Open Font License, latin subset). */
@font-face { font-family: "Gloock"; font-weight: 400; font-display: swap; src: url(fonts/gloock-400.woff2) format("woff2"); }
@font-face { font-family: "Courier Prime"; font-weight: 400; font-display: swap; src: url(fonts/courier-prime-400.woff2) format("woff2"); }
@font-face { font-family: "Courier Prime"; font-weight: 700; font-display: swap; src: url(fonts/courier-prime-700.woff2) format("woff2"); }
@font-face { font-family: "Karla"; font-weight: 200 800; font-display: swap; src: url(fonts/karla.woff2) format("woff2"); }
@font-face { font-family: "Caveat"; font-weight: 700; font-display: swap; src: url(fonts/caveat-700.woff2) format("woff2"); }

:root {
  --bg: #1e3a2b;
  --bg-deep: #132619;
  --kraft: #e6d3ae;
  --kraft-shade: #cdb68a;
  --kraft-edge: #b99f6e;
  --twine: #c9a46a;
  --red: #b8312f;
  --ink: #2b2219;
  --pen: #23408e;
  --cream: #f3e6c8;
  --gap-x: 30px;
  --bulbs: #ff6b5e, #ffd36b, #8be08f, #7fb3ff;
}
* { box-sizing: border-box; }
html { background: #132619; }
body {
  margin: 0; min-height: 100vh; color: var(--cream);
  font: 16px/1.5 Karla, system-ui, sans-serif;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(255,255,255,.07), transparent 70%),
    radial-gradient(circle at 20% 10%, rgba(255,255,255,.045) 0 1.5px, transparent 2.5px) 0 0 / 44px 44px,
    radial-gradient(circle at 70% 60%, rgba(255,255,255,.035) 0 1px, transparent 2px) 0 0 / 36px 36px,
    linear-gradient(var(--bg), var(--bg-deep));
  transition: background-color .5s;
}

/* ---------- Kraft paper, used by every tag ---------- */
.kraft {
  background:
    radial-gradient(circle at 30% 20%, rgba(120, 85, 40, .10) 0 1px, transparent 1.6px) 0 0 / 7px 9px,
    radial-gradient(circle at 70% 80%, rgba(255, 255, 255, .25) 0 .8px, transparent 1.4px) 0 0 / 11px 7px,
    linear-gradient(170deg, #ecdbb8, var(--kraft) 40%, #dcc79c);
  color: var(--ink);
}
.eyelet {
  position: absolute; left: 50%; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 0 0 3px #c7b07a, 0 0 0 4px #8d7748, inset 0 1px 2px rgba(0,0,0,.5);
}

/* ---------- Header: one big gift tag ---------- */
header { max-width: 1120px; margin: 0 auto; padding: 0 16px; position: relative; }
.hero { position: relative; display: flex; justify-content: center; padding-top: 70px; }
.hero::before { /* the string the big tag hangs from */
  content: ""; position: absolute; top: 0; left: 50%; width: 2px; height: 86px; background: var(--twine);
}
.bigtag {
  position: relative; width: min(560px, 100%); padding: 46px 28px 26px;
  clip-path: polygon(18% 0, 82% 0, 100% 14%, 100% 100%, 0 100%, 0 14%);
  transform: rotate(-1.5deg); transform-origin: 50% -70px;
  animation: settle 1.8s cubic-bezier(.3, 1.6, .5, 1) both;
}
.bigtag .eyelet { top: 16px; }
@keyframes settle { from { transform: rotate(5deg); } to { transform: rotate(-1.5deg); } }
.fromto { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 6px 0 14px; font: 1rem "Courier Prime", monospace; }
.fromto dt { color: #7a6748; }
.fromto dd { margin: 0; font: 700 1.5rem/1.1 Caveat, cursive; color: var(--pen); border-bottom: 1.5px dashed var(--kraft-edge); }
h1 { font: 400 clamp(2.1rem, 7vw, 3.3rem)/1.02 Gloock, Georgia, serif; margin: 0 0 8px; letter-spacing: -.01em; }
.countdown { margin: 0; font: 700 1rem "Courier Prime", monospace; }
.countdown b { color: var(--red); font-size: 1.25rem; }

/* ---------- Tabs and budget filter ---------- */
.controls { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; justify-content: center; margin: 34px 0 6px; }
.budget { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  border: 1.5px solid rgba(243, 230, 200, .35); background: transparent; color: var(--cream);
  border-radius: 999px; padding: 6px 13px; font: 600 .9rem Karla, sans-serif; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--cream); color: var(--ink); border-color: var(--cream); }
.chip:focus-visible, .shop-link:focus-visible { outline: 3px solid #ffd36b; outline-offset: 3px; }

/* ---------- Garlands of tags ---------- */
main { max-width: 1120px; margin: 0 auto; padding: 30px 16px 40px; overflow: hidden; }
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 64px var(--gap-x);
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
}
.tag { position: relative; padding-top: 46px; }
/* Each tag carries its stretch of the garland, so every row reads as one line of twine. */
.tag::before {
  content: ""; position: absolute; top: 8px; height: 2px;
  left: calc(var(--gap-x) / -2 - 1px); right: calc(var(--gap-x) / -2 - 1px);
  background: var(--twine);
  border-radius: 50%;
}
.bulb {
  position: absolute; top: 9px; width: 9px; height: 13px; border-radius: 45% 45% 50% 50%;
  background: var(--c); box-shadow: 0 0 10px 2px var(--c);
  animation: twinkle var(--t) ease-in-out infinite alternate; animation-delay: var(--d);
  transition: transform .15s ease-out, filter .15s ease-out, opacity .3s;
}
/* Lights switching on one by one when the page opens. */
.bulb.off { animation: none; opacity: .15; box-shadow: none; }
/* A wave of light running along a garland. */
.bulb.flash { transform: scale(1.35); filter: brightness(1.6) saturate(1.3); }
.bulb::before { content: ""; position: absolute; left: 2px; top: -3px; width: 5px; height: 4px; background: #444; border-radius: 1px; }
@keyframes twinkle { from { opacity: .35; box-shadow: 0 0 3px 0 var(--c); } to { opacity: 1; box-shadow: 0 0 12px 3px var(--c); } }

.hang { /* string from the garland to the tag + the tag, swinging as one (driven by motion.js) */
  position: relative; transform-origin: 50% -38px; transform: rotate(var(--tilt));
  will-change: transform;
}
.hang::before {
  content: ""; position: absolute; left: 50%; top: -38px; width: 2px; height: 56px; margin-left: -1px;
  background: var(--twine);
}
.card {
  position: relative; padding: 40px 18px 18px;
  clip-path: polygon(22% 0, 78% 0, 100% 11%, 100% 100%, 0 100%, 0 11%);
  box-shadow: inset 0 -7px 0 var(--kraft-shade);
}
.card .eyelet { top: 12px; }
.photo {
  position: relative; aspect-ratio: 4 / 3; display: grid; place-items: center;
  background: #fff; padding: 10px; margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(60, 40, 10, .25), inset 0 0 0 1px rgba(0,0,0,.06);
}
.photo img { position: absolute; inset: 10px; width: calc(100% - 20px); height: calc(100% - 20px); object-fit: contain; }
.photo.missing::after { content: "🎁"; font-size: 54px; }
.sticker {
  position: absolute; right: -8px; bottom: -14px; min-width: 70px; height: 70px; padding: 0 6px; border-radius: 50%;
  display: grid; place-items: center; text-align: center; background: #fff8e8; color: var(--red);
  border: 2px solid var(--red); font: 700 1rem/1 "Courier Prime", monospace; transform: rotate(-10deg);
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.name {
  font: 700 1.02rem/1.35 "Courier Prime", monospace; margin: 0 0 4px; padding-right: 30px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.when { font-size: .78rem; color: #7a6748; margin: 0; }
.note { margin: 10px 0 0; font: 700 1.35rem/1.15 Caveat, cursive; color: var(--pen); transform: rotate(-1.5deg); }
.seal {
  position: absolute; right: -14px; top: 46px; width: 66px; height: 66px; z-index: 2;
  border-radius: 47% 53% 50% 48%;
  background: radial-gradient(circle at 35% 30%, #db5048, #a3241f 65%, #7d1916);
  color: #fde9d6; display: grid; place-items: center; text-align: center;
  font: 700 .62rem/1.05 Karla, sans-serif; transform: rotate(12deg);
  box-shadow: 0 3px 0 #5e1210, 0 6px 10px rgba(0,0,0,.3);
}
.seal b { display: block; font-size: 1.15rem; }
.shop-link {
  display: block; margin-top: 16px; text-align: center; text-decoration: none;
  font: 700 .95rem "Courier Prime", monospace; color: var(--kraft); background: var(--ink);
  padding: 12px; border-radius: 3px; transition: background .2s;
}
.shop-link:hover { background: var(--red); }
.empty { grid-column: 1 / -1; text-align: center; padding: 50px 0 20px; font: 700 1.6rem Caveat, cursive; }

footer { text-align: center; padding: 10px 16px 40px; font: 700 1.35rem Caveat, cursive; color: #cdbd98; }
footer small { display: block; margin-top: 8px; font: .8rem Karla, sans-serif; opacity: .6; }

@media (max-width: 520px) {
  .bigtag { padding: 44px 20px 22px; }
  .grid { gap: 58px var(--gap-x); }
  .photo { aspect-ratio: 16 / 10; }
}
@media (prefers-reduced-motion: reduce) {
  .bigtag, .bulb { animation: none; }
  .bulb { transition: none; }
}
.status { grid-column: 1 / -1; text-align: center; padding: 40px 0; font: 700 1.4rem Caveat, cursive; }
.countdown:empty { display: none; }

/* A sewn-in clothing label with the size, on clothes and shoes. */
.size-label {
  position: absolute; left: -6px; top: 14px; z-index: 1;
  padding: 7px 12px 7px 14px; background: #fbfaf6; color: var(--red);
  font: 700 .95rem/1 "Courier Prime", monospace;
  border-radius: 2px; transform: rotate(-6deg);
  box-shadow: 0 2px 4px rgba(0,0,0,.22);
  /* Stitching just inside the edge. */
  outline: 1.5px dashed rgba(184, 49, 47, .55); outline-offset: -4px;
}
.size-label::before { /* the fold where it is sewn in */
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  background: linear-gradient(90deg, rgba(0,0,0,.12), transparent);
}

/* Falling snow and the heaps on the tags (drawn by motion.js). It sits between the background
   and the page, so flakes fall behind the tags; the heaps lie on top of their upper edge. */
#snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
header, main, footer { position: relative; z-index: 1; }
