/* The London Ledger: Christmas layer (Version 3)
   Linked only while build.py has CHRISTMAS = True. Delete nothing to switch off: set the flag to False and rebuild.
   Rules: decoration only (pseudo-elements or aria-hidden nodes), never blocks clicks, animates opacity/transform only,
   positioned absolutely so nothing shifts layout. Sprig sizes were solved against the real button and wordmark boxes
   at 901–1920px so they never touch them (see PLAN.md, Version 3). */

/* ---------- stacking: content above the decoration ---------- */
.masthead{position:relative;overflow:hidden}
.masthead>.wrap,.footer>.wrap,.letter>.wrap,.edit>.wrap{position:relative;z-index:2}
.catnav{position:relative;z-index:7}
.footer,.letter{position:relative;overflow:hidden}

/* ---------- masthead corner sprigs (desktop only; phones get the nav light string) ----------
   Width scales with the side margin: 1.7 x (margin + gutter), 100-240px. Left: rotated -12deg from its top-left corner.
   Right: the exact mirror (translateX + opposite rotation + flip), so one image serves both corners. */
@media (min-width:901px){
  .masthead{--ms:clamp(100px, calc((max(0px, (100vw - 1320px) / 2) + var(--gut)) * 1.7), 240px)}
  .masthead::before,.masthead::after{content:"";position:absolute;z-index:1;top:calc(var(--ms) * -.04);width:var(--ms);height:calc(var(--ms) / 2);
    background:url(/assets/img/xmas/sprig-corner-640.webp) 0 0/100% 100% no-repeat;
    background-image:image-set(url(/assets/img/xmas/sprig-corner-420.webp) 1x,url(/assets/img/xmas/sprig-corner-640.webp) 2x);
    transform-origin:0 0;pointer-events:none}
  .masthead::before{left:calc(var(--ms) * -.1);transform:rotate(-12deg)}
  .masthead::after{right:calc(var(--ms) * -.1);transform:translateX(var(--ms)) rotate(12deg) scaleX(-1)}
}
@media (min-width:901px) and (max-width:1023px){ .masthead{--ms:88px} }

/* ---------- footer: corner greenery (the light string runs between them) ---------- */
.footer::before,.footer::after{content:"";position:absolute;z-index:3;top:0;width:var(--fs);height:calc(var(--fs) / 2);
  background:url(/assets/img/xmas/sprig-corner-640.webp) 0 0/100% 100% no-repeat;
  background-image:image-set(url(/assets/img/xmas/sprig-corner-420.webp) 1x,url(/assets/img/xmas/sprig-corner-640.webp) 2x);
  transform-origin:0 0;pointer-events:none}
.footer::before{--fs:clamp(130px, calc((max(0px, (100vw - 1320px) / 2) + var(--gut)) * 1.8), 220px);left:calc(var(--fs) * -.1);transform:rotate(-4deg)}
.footer::after{--fs:clamp(170px, calc((max(0px, (100vw - 1320px) / 2) + var(--gut)) * 2.4), 290px);right:calc(var(--fs) * -.1);transform:translateX(var(--fs)) rotate(5deg) scaleX(-1)}

/* ---------- newsletter band: one holly sprig, top right ---------- */
.letter::after{content:"";position:absolute;z-index:1;top:clamp(8px,2.2vw,26px);right:calc(max(0px, (100vw - 1320px) / 2) + var(--gut));
  width:clamp(84px,10vw,140px);aspect-ratio:300/176;background:url(/assets/img/xmas/holly-300.webp) center/contain no-repeat;transform:rotate(7deg);pointer-events:none}

/* ---------- two section rules on the front page get a sprig resting on the line ---------- */
.sec-head:has(#best-h),.sec-head:has(#trips-h){position:relative}
.sec-head:has(#best-h)::before,.sec-head:has(#trips-h)::before{content:"";position:absolute;bottom:calc(100% - 1px);pointer-events:none}
.sec-head:has(#best-h)::before{right:-6px;width:clamp(86px,8vw,124px);aspect-ratio:360/166;background:url(/assets/img/xmas/sprig-bow-360.webp) center bottom/contain no-repeat;transform:rotate(-2deg);transform-origin:50% 100%}
.sec-head:has(#trips-h)::before{left:-8px;width:clamp(62px,5.6vw,84px);aspect-ratio:300/176;background:url(/assets/img/xmas/holly-300.webp) center bottom/contain no-repeat;transform:rotate(4deg);transform-origin:50% 100%}

/* ---------- fairy-light strings (built by christmas.js) ---------- */
.xm-lights{--xm-wire:#3a342a;--xm-sock:#4d4233;--xm-off:rgba(120,100,70,.3);--bw:7px;--bh:10px;
  position:absolute;left:0;right:0;height:28px;z-index:1;pointer-events:none;overflow-x:clip;opacity:0;transition:opacity 1.4s var(--ease)}
.xm-lights.is-lit{opacity:1}
.xm-lights--below{top:100%}
.xm-lights--top{top:0}
.xm-lights--dark{--xm-wire:#806a43;--xm-sock:#8c754a;--xm-off:rgba(255,236,200,.13)}
.xm-lights--compact{--bw:5px;--bh:8px;height:18px}
.xm-lights--edit,.xm-lights--footer{--bw:8px;--bh:11px;height:34px}
.xm-lights--edit{z-index:3}
.xm-wire{position:absolute;left:0;top:0;display:block;overflow:visible}
.xm-wire__a,.xm-wire__b{fill:none;stroke:var(--xm-wire);stroke-width:1;stroke-linecap:round}
/* twisted pair: one dark strand, one brass strand, so the wire reads on paper and on dark photographs */
.xm-wire__b{stroke:var(--xm-wire-2,#a58652);opacity:.75}
.xm-wire__clip{fill:var(--xm-sock)}
.xm-bulb{position:absolute;width:var(--bw);height:calc(var(--bh) + 3px);margin-left:calc(var(--bw) / -2);transform:rotate(var(--r,0deg));transform-origin:50% 0}
.xm-bulb::before{content:"";position:absolute;left:50%;top:0;width:4px;height:4px;margin-left:-2px;border-radius:1px 1px .5px .5px;background:var(--xm-sock)}
.xm-bulb::after,.xm-bulb b{content:"";position:absolute;left:0;top:3px;width:var(--bw);height:var(--bh);border-radius:50% 50% 50% 50%/42% 42% 58% 58%}
.xm-bulb::after{background:var(--xm-off)}
.xm-bulb b{display:block;z-index:1;background:radial-gradient(circle at 42% 34%,#fffdf6 0 20%,#ffefc9 46%,#f5cd82 100%);
  box-shadow:0 0 3px 1px rgba(255,226,160,.85),0 0 10px 3px rgba(255,204,120,.4),0 0 22px 7px rgba(255,190,100,.14);
  animation:xm-breathe var(--t,4s) ease-in-out var(--d,0s) infinite}
.xm-bulb.is-gold b{background:radial-gradient(circle at 42% 34%,#fff6dc 0 16%,#f2c86a 50%,#b8862e 100%);
  box-shadow:0 0 3px 1px rgba(242,190,90,.85),0 0 10px 3px rgba(226,168,70,.4),0 0 22px 7px rgba(210,150,60,.14)}
.xm-bulb.is-wink b{animation-name:xm-wink}
@keyframes xm-breathe{0%,100%{opacity:1}50%{opacity:.5}}
@keyframes xm-wink{0%,56%,100%{opacity:1}60%{opacity:.14}64%{opacity:.85}67%{opacity:.2}74%{opacity:1}}
.xm-lights.is-off .xm-bulb b{animation-play-state:paused}
/* the compact bar's string travels with the bar; hide it while the bar is tucked away */
.compact:not(.is-on) .xm-lights{opacity:0;transition-duration:.2s}
.compact:not(.is-on) .xm-bulb b{animation-play-state:paused}

/* ---------- glass baubles (hang from the Christmas section's string) ---------- */
.xm-bauble{position:absolute;top:1px;width:var(--bw);margin-left:calc(var(--bw) / -2)}
.xm-bauble__lean,.xm-bauble__sway{display:block;transform-origin:50% 0}
.xm-bauble__sway{animation:xm-sway var(--sd,6s) ease-in-out var(--sdel,0s) infinite alternate}
.xm-bauble__thread{display:block;width:1px;height:var(--len);margin:0 auto;background:linear-gradient(#9c7a42,#d2b06c)}
.xm-bauble img{display:block;width:100%;height:auto;margin-top:-1px;filter:drop-shadow(0 7px 9px rgba(0,0,0,.35))}
@keyframes xm-sway{from{transform:rotate(calc(var(--amp,2deg) * -1))}to{transform:rotate(var(--amp,2deg))}}

/* ---------- snow (canvas, Christmas section only) ---------- */
.xm-snow{position:absolute;inset:0;width:100%;height:100%;z-index:0;pointer-events:none;opacity:0;transition:opacity 2s var(--ease)}
.xm-snow.is-on{opacity:1}

/* ---------- phones ---------- */
@media (max-width:600px){
  .footer::before{--fs:100px}
  .footer::after{--fs:122px}
  .letter::after{width:80px;top:8px}
}

/* ---------- reduced motion (and ?still): lights stay lit, nothing sways, no snow ---------- */
.xm-still .xm-bulb b,.xm-still .xm-bauble__sway{animation:none!important;opacity:1}
.xm-still .xm-lights{transition:none}
@media (prefers-reduced-motion:reduce){
  .xm-bulb b,.xm-bauble__sway{animation:none!important;opacity:1}
  .xm-snow{display:none}
}
