/* Holiday theme for a blog post (front matter `theme: holiday`, see THEMES in tools/blog.py).
   The page loads as a normal post. assets/js/holiday.js then adds .is-festive to <body>
   and builds the decorations: lights on the headline cells, snow, a tree made of cells,
   and a toy train on a track along the top of the post.
   Every decoration's resting state is its finished state; animations only play in. */

@property --grid-line-color { syntax: "<color>"; inherits: true; initial-value: rgba(254, 255, 238, .28); }

/* the scene above the post is 100vw wide, which is wider than the page wherever the scrollbar takes up room */
html:has(body.theme-holiday), body.theme-holiday { overflow-x: clip; }
body.theme-holiday { --hol-night: #0B3528; transition: background-color 1.6s ease, --grid-line-color 1.6s ease; }
body.theme-holiday .topbar::before { transition: background-color 1.6s ease; }
body.theme-holiday.is-festive { background-color: var(--hol-night); --grid-line-color: rgba(254, 255, 238, .1); }
body.theme-holiday.is-festive .topbar::before { background-color: var(--hol-night); }
.theme-holiday .post-crumbs { transition: color 1.6s ease; }
.theme-holiday.is-festive .post-crumbs { color: var(--c-cream); }

/* room for the bulbs under the headline and the train above the post. 40px in all
   (80px on phones), so the post panel stays on the background grid. */
.theme-holiday .post-head { transition: padding-bottom .9s var(--ease-snap); }
.theme-holiday .post-headline { position: relative; transition: margin-bottom .9s var(--ease-snap); }
.theme-holiday.is-festive .post-headline { margin-bottom: 12px; }
.theme-holiday.is-festive .post-head { padding-bottom: 68px; }
@media (min-width: 720px) { .theme-holiday.is-festive .post-head { padding-bottom: 28px; } }
.theme-holiday .post-layout { position: relative; }

/* ---- snow: square flakes, behind the content ---- */
.hol-snow { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; opacity: 0; transition: opacity 2s ease; }
.is-festive .hol-snow { opacity: 1; }

/* ---- lights and snow on the headline cells ---- */
.hol-lights { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 2; }
.hol-wire { fill: none; stroke: var(--c-jet); stroke-width: 2; stroke-linecap: round; stroke-dasharray: 1; animation: hol-draw .9s ease-out backwards; }
.hol-bulb { transform-box: fill-box; transform-origin: 50% 0; animation: hol-pop .45s var(--ease-boop) backwards; animation-delay: var(--d); }
.hol-bulb__glass { stroke: var(--c-jet); stroke-width: 1.5; }
.hol-bulb__glow { opacity: .5; }
.hol-bulb__glass, .hol-bulb__glow { animation: hol-twinkle var(--t, 2.6s) ease-in-out infinite; animation-delay: var(--td, 0s); }
.hol-bulb__glow { animation-name: hol-glow; }
.hol-cap { fill: var(--c-white); stroke: var(--c-jet); stroke-width: 2; stroke-linejoin: round; transform-box: fill-box; transform-origin: 50% 100%; animation: hol-settle 3.2s ease-out 1.4s backwards; }

/* ---- the scene on top of the post: track, train, tree ---- */
.hol-scene { position: absolute; bottom: 100%; left: 50%; width: calc(100vw - 2px); height: 0; translate: -50% 0; pointer-events: none; overflow-x: clip; }
.hol-track { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; animation: hol-lay 1.6s ease-out .9s backwards; }
.hol-track::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--c-jet); box-shadow: 0 0 0 1px rgba(254, 255, 238, .5); }
.hol-track::after { content: ""; position: absolute; left: 0; right: 0; top: 3px; bottom: 0; background: repeating-linear-gradient(90deg, var(--c-jet) 0 3px, transparent 3px 14px); filter: drop-shadow(1px 0 0 rgba(254, 255, 238, .45)); }
.hol-train { position: absolute; left: 0; bottom: 7px; width: 322px; height: 60px; overflow: visible; animation: hol-run var(--run, 24s) linear 2.6s infinite backwards; }
.hol-train__wheel { transform-box: fill-box; transform-origin: center; animation: hol-spin .7s linear infinite; }
.hol-train__puff { fill: var(--c-cream); stroke: var(--c-jet); stroke-width: 1.5; transform-box: fill-box; transform-origin: center; animation: hol-puff 1.8s ease-out infinite; animation-delay: var(--d); }
.hol-train text { font-family: var(--ff-mono); font-size: 10px; text-anchor: middle; fill: var(--c-jet); }
@media (max-width: 719px) { .hol-train { width: 215px; height: 40px; } }

.hol-tree { position: absolute; bottom: calc(100% + 7px); right: 12px; overflow: visible; pointer-events: none; }
@media (min-width: 720px) { .hol-tree { right: 40px; } }
.hol-tree__cell, .hol-tree__gift { transform-box: fill-box; transform-origin: center; animation: hol-pop .4s var(--ease-boop) backwards; animation-delay: var(--d); }
.hol-tree__cell { stroke: var(--c-jet); stroke-width: 1.5; }
.hol-tree__gift rect { stroke: var(--c-jet); stroke-width: 1.5; }
.hol-tree__orn { animation: hol-pop .4s var(--ease-boop) backwards, hol-twinkle var(--t, 2.4s) ease-in-out infinite; animation-delay: var(--d), var(--td); }
.hol-tree__star { fill: var(--c-yellow); stroke: var(--c-jet); stroke-width: 1.5; stroke-linejoin: round; transform-box: fill-box; transform-origin: center; animation: hol-star .7s var(--ease-boop) backwards, hol-shine 3s ease-in-out infinite; animation-delay: var(--d), calc(var(--d) + .7s); }
/* re-planted after a resize: no second build-up */
.hol-tree--set * { animation: none; }

@keyframes hol-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes hol-pop { from { opacity: 0; scale: .2; } }
@keyframes hol-twinkle { 0%, 100% { filter: none; } 50% { filter: brightness(.82); } }
@keyframes hol-glow { 0%, 100% { opacity: .5; } 50% { opacity: .12; } }
@keyframes hol-settle { from { scale: 1 0; opacity: 0; } 20% { opacity: 1; } }
@keyframes hol-lay { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes hol-run { from { translate: -340px 0; } to { translate: calc(100vw + 24px) 0; } }
@keyframes hol-spin { to { rotate: 360deg; } }
@keyframes hol-puff { from { opacity: 0; translate: 0 0; scale: .4; } 15% { opacity: 1; } to { opacity: 0; translate: -26px -22px; scale: 1.5; } }
@keyframes hol-star { from { opacity: 0; scale: 0; rotate: -90deg; } }
@keyframes hol-shine { 0%, 100% { scale: 1; } 50% { scale: 1.14; } }

/* no motion: the finished scene, standing still, with the train parked by the tree */
@media (prefers-reduced-motion: reduce) {
  body.theme-holiday, body.theme-holiday *, body.theme-holiday *::before, body.theme-holiday *::after { animation: none !important; transition: none !important; }
  .hol-train { translate: max(16px, calc(50vw - 320px)) 0; }
  .hol-train__puff { display: none; }
}

/* ---- section headings: each one is a wrapped present lying across the post, with a ribbon,
   a bow, snow settled on top and the heading on a gift tag. The papers take turns
   (data-paper, set by holiday.js; red until then). */
.theme-holiday .post-body { counter-reset: hol-sec; }
.theme-holiday .post-body h2 { --paper: var(--c-red); --ribbon: var(--c-yellow); --rx: 30px; --bow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 46'%3E%3Cg fill='%23FFC501' stroke='%230E0E0E' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M33 24 19 44l9-3 3 4 8-19Z'/%3E%3Cpath d='M39 24l14 20-9-3-3 4-8-19Z'/%3E%3Cpath d='M36 22C28 5 8 1 4 10c-4 10 16 16 32 12Z'/%3E%3Cpath d='M36 22C44 5 64 1 68 10c4 10-16 16-32 12Z'/%3E%3Crect x='29' y='14' width='14' height='14' rx='4'/%3E%3C/g%3E%3C/svg%3E");
  counter-increment: hol-sec; position: relative; display: flex; flex-direction: column; align-items: flex-start;
  margin: 96px 0 30px; padding: 20px 18px 22px 62px; border: 1.5px solid var(--c-jet); border-radius: 12px;
  box-shadow: 8px 8px 0 rgba(14, 14, 14, .14); rotate: -.4deg; font-size: clamp(25px, 3.4vw, 36px); line-height: 1.08;
  background:
    linear-gradient(90deg, transparent calc(var(--rx) - 13px), var(--c-jet) calc(var(--rx) - 13px) calc(var(--rx) - 11px), var(--ribbon) calc(var(--rx) - 11px) calc(var(--rx) + 11px), var(--c-jet) calc(var(--rx) + 11px) calc(var(--rx) + 13px), transparent calc(var(--rx) + 13px)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .22) 0 10px, transparent 10px 20px),
    var(--paper); }
.theme-holiday .post-body h2[data-paper="1"] { --paper: var(--c-green); --ribbon: var(--c-pink); --bow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 46'%3E%3Cg fill='%23FECDE0' stroke='%230E0E0E' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M33 24 19 44l9-3 3 4 8-19Z'/%3E%3Cpath d='M39 24l14 20-9-3-3 4-8-19Z'/%3E%3Cpath d='M36 22C28 5 8 1 4 10c-4 10 16 16 32 12Z'/%3E%3Cpath d='M36 22C44 5 64 1 68 10c4 10-16 16-32 12Z'/%3E%3Crect x='29' y='14' width='14' height='14' rx='4'/%3E%3C/g%3E%3C/svg%3E"); rotate: .4deg; }
.theme-holiday .post-body h2[data-paper="2"] { --paper: var(--c-cyan); --ribbon: var(--c-yellow); --bow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 46'%3E%3Cg fill='%23FFC501' stroke='%230E0E0E' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M33 24 19 44l9-3 3 4 8-19Z'/%3E%3Cpath d='M39 24l14 20-9-3-3 4-8-19Z'/%3E%3Cpath d='M36 22C28 5 8 1 4 10c-4 10 16 16 32 12Z'/%3E%3Cpath d='M36 22C44 5 64 1 68 10c4 10-16 16-32 12Z'/%3E%3Crect x='29' y='14' width='14' height='14' rx='4'/%3E%3C/g%3E%3C/svg%3E"); }
/* the tag: a small numbered cell stacked on the heading cell, sharing one border */
.theme-holiday .post-body h2::before { content: "Gifts \00B7  " counter(hol-sec, decimal-leading-zero); position: relative; z-index: 1; margin-bottom: -3px; padding: 6px 10px 7px;
  background: var(--c-yellow); border: 3px solid var(--c-jet); font-family: var(--ff-mono); font-size: 12px; font-weight: 400; letter-spacing: .08em; line-height: 1; text-transform: uppercase; }
.theme-holiday .post-body h2 .h2__t { display: block; padding: 8px 14px 11px; background: var(--c-white); border: 3px solid var(--c-jet); }
/* the bow on the ribbon, and snow along the top edge */
.theme-holiday .post-body h2::after { content: ""; position: absolute; left: 0; right: 0; top: -38px; height: 64px; pointer-events: none;
  background: var(--bow) calc(var(--rx) - 47px) 0 / 94px 60px no-repeat,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 140 18' preserveAspectRatio='none'%3E%3Cpath d='M2 17C1 8 14 4 28 7 44 0 70 1 84 7c18-5 52-1 54 10Z' fill='%23fff' stroke='%230E0E0E' stroke-width='2' stroke-linejoin='round' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E") right 22px top 22px / min(38%, 190px) 18px no-repeat,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 140 18' preserveAspectRatio='none'%3E%3Cpath d='M2 17C1 8 14 4 28 7 44 0 70 1 84 7c18-5 52-1 54 10Z' fill='%23fff' stroke='%230E0E0E' stroke-width='2' stroke-linejoin='round' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E") right calc(min(38%, 190px) + 52px) top 28px / 54px 12px no-repeat; }
@media (min-width: 720px) {
  .theme-holiday .post-body h2 { --rx: 46px; padding: 26px 28px 28px 92px; margin-top: 112px; }
}

/* ---- gift cards (:::gifts) ---- */
.gifts { list-style: none; margin: 28px 0 40px !important; padding: 0 !important; max-width: none !important; display: grid; gap: 28px 24px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.post-body .gifts .gift { margin: 0; display: flex; flex-direction: column; background: var(--c-white); border: 1.5px solid var(--c-jet); border-radius: 12px; overflow: hidden; box-shadow: 8px 8px 0 rgba(14, 14, 14, .12); rotate: -.4deg; }
.post-body .gifts .gift:nth-child(even) { rotate: .4deg; }
.gift__img { aspect-ratio: 4 / 3; border-bottom: 1.5px solid var(--c-jet); background: var(--c-olive); }
.gift__img img { width: 100%; height: 100%; object-fit: cover; }
/* no photo yet: wrapping paper with a ribbon */
.gift__img--wrap { --paper: var(--c-red); --ribbon: var(--c-yellow);
  background:
    linear-gradient(90deg, transparent calc(50% - 15px), var(--c-jet) calc(50% - 15px) calc(50% - 13px), var(--ribbon) calc(50% - 13px) calc(50% + 13px), var(--c-jet) calc(50% + 13px) calc(50% + 15px), transparent calc(50% + 15px)),
    linear-gradient(0deg, transparent calc(50% - 15px), var(--c-jet) calc(50% - 15px) calc(50% - 13px), var(--ribbon) calc(50% - 13px) calc(50% + 13px), var(--c-jet) calc(50% + 13px) calc(50% + 15px), transparent calc(50% + 15px)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .22) 0 10px, transparent 10px 20px),
    var(--paper); }
.gift:nth-child(3n + 2) .gift__img--wrap { --paper: var(--c-green); --ribbon: var(--c-white); }
.gift:nth-child(3n) .gift__img--wrap { --paper: var(--c-cyan); --ribbon: var(--c-pink); }
.gift__body { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; flex: 1; padding: 16px 18px 20px; }
.post-body .gift p, .post-body .gift h3 { margin: 0; max-width: none; }
.post-body .gift .gift__for { font-family: var(--ff-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; line-height: 1.4; opacity: .7; }
.post-body .gift .gift__name { font-size: 22px; font-weight: 500; letter-spacing: -0.025em; line-height: 1.15; }
.post-body .gift .gift__price { padding: 4px 8px 5px; background: var(--c-yellow); border: 2px solid var(--c-jet); font-family: var(--ff-mono); font-size: 12px; letter-spacing: .06em; line-height: 1; rotate: -1deg; }
.post-body .gift .gift__blurb { font-size: 16px; line-height: 1.5; }
.post-body .gift .gift__links { margin-top: auto; padding-top: 6px; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.post-body .gift .gift__link {font-weight: 500; text-decoration: underline; text-decoration-color: var(--c-green); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.post-body .gift .gift__link:hover { background: var(--c-cyan); }
