/* ==========================================================================
   Methodist Church Shahpur — CHRISTMAS HERO (index.html only, 1–31 December)
   Three painted Nativity scenes that crossfade into each other as you scroll (each slowly zooming towards its star),
   each with its own line of text and slowly turning star rays.
   Which hero shows is decided by the small script in <head> of index.html
   (html[data-hero="christmas"] in December, "sunrise" the rest of the year).
   Preview any time: index.html?hero=christmas  /  index.html?hero=sunrise
   ========================================================================== */

/* only one hero is ever shown */
html[data-hero="christmas"] #hero{display:none}
html:not([data-hero="christmas"]) #xmas{display:none}

#xmas{height:420vh;padding:0;background:#03040f}
.xstick{position:sticky;top:0;height:100vh;overflow:hidden}
.xstick::after{content:"";position:absolute;left:0;right:0;bottom:0;height:10vh;z-index:4;pointer-events:none;background:linear-gradient(transparent,rgba(3,4,14,.75))}   /* soft fade into the Welcome section */
.xtrack{position:relative;height:100%}
.xs{position:absolute;inset:0;margin:0;overflow:hidden;will-change:opacity;   /* scenes are stacked; js/christmas.js fades each one in over the last */
  /* where the text sits: --ty is a height inside the PAINTING (0 = top, 1 = bottom), set per scene in index.html so the line always lands
     in the sky between the star and the stable/camels, however the screen crops the picture. The painting's height on screen is max(56.28vw,100vh). */
  --ly:max(calc(env(safe-area-inset-top,0px) + 118px),calc(50vh + (var(--ty,.34) - .5) * max(56.28vw,100vh)))}

/* the painting always covers the screen; the frame keeps the image's shape so the rays can sit exactly on its star */
.xframe{position:absolute;left:50%;top:50%;width:max(100vw,177.69vh);aspect-ratio:1672/941;transform:translate(calc(-50% + var(--ox,0%)),-50%) scale(var(--z,1));transform-origin:var(--sx) var(--sy);will-change:transform}
.xframe img{position:absolute;inset:0;width:100%;height:100%;display:block}
.xs::after{content:"";position:absolute;inset:0;z-index:1;pointer-events:none;background:radial-gradient(ellipse 75% 18% at 50% var(--ly),rgba(3,4,15,.42),transparent 72%)}   /* gentle shade behind the text */

/* star rays: the same idea as the sunrise rays — thin gold beams turning slowly clockwise */
.xrays{position:absolute;left:var(--sx);top:var(--sy);width:58%;aspect-ratio:1;transform:translate(-50%,-50%);pointer-events:none;mix-blend-mode:screen}
.xrays::before{content:"";position:absolute;inset:0;border-radius:50%;background:repeating-conic-gradient(from 0deg,rgba(255,232,170,.22) 0 2.5deg,transparent 2.5deg 12deg);-webkit-mask:radial-gradient(circle,#000 0,rgba(0,0,0,.55) 16%,transparent 58%);mask:radial-gradient(circle,#000 0,rgba(0,0,0,.55) 16%,transparent 58%);animation:xraySpin 120s linear infinite;animation-play-state:paused}
.xrays::after{content:"";position:absolute;left:50%;top:50%;width:16%;aspect-ratio:1;transform:translate(-50%,-50%);border-radius:50%;background:radial-gradient(circle,rgba(255,246,214,.75),rgba(255,215,128,.25) 35%,transparent 70%);animation:xglow 3.4s ease-in-out infinite}
#xmas.spin .xrays::before{animation-play-state:running}
/* star flare: each time a scene arrives its star swells and brightens, then settles (js/christmas.js adds .flare) */
.xs.flare .xrays{animation:xflare 1.9s cubic-bezier(.2,.7,.2,1)}
@keyframes xflare{0%{transform:translate(-50%,-50%) scale(.8);filter:brightness(1)}28%{transform:translate(-50%,-50%) scale(1.4);filter:brightness(2.4)}100%{transform:translate(-50%,-50%) scale(1);filter:brightness(1)}}
@keyframes xraySpin{to{transform:rotate(360deg)}}
@keyframes xglow{50%{opacity:.6;transform:translate(-50%,-50%) scale(.85)}}

/* the line of text on each scene (same lettering as the sunrise verse) */
.xline{position:absolute;z-index:3;left:50%;top:var(--ly);width:92vw;margin:0;transform:translate(-50%,-50%);text-align:center;pointer-events:none;
  font-family:var(--serif);font-weight:500;font-size:clamp(2rem,min(5.6vw,8.5vh),4.8rem);line-height:1.1;letter-spacing:.01em;color:#f5f0e6;text-wrap:balance;
  text-shadow:0 2px 16px rgba(0,0,0,.75),0 4px 30px rgba(0,0,0,.6);will-change:opacity,transform,filter}
.xs:nth-child(3) .xline{font-size:clamp(1.75rem,min(5.1vw,7.8vh),4.4rem)}   /* the longest line, and the least sky above the stable */
/* gold words: a thin dark outline (drawn behind the letters) so they stand out even over the bright star light */
.xline .gold{color:#f6c945;font-weight:700;font-style:italic;-webkit-text-stroke:2px rgba(28,16,0,.9);paint-order:stroke fill;
  text-shadow:0 0 3px rgba(0,0,0,.85),0 0 22px rgba(246,201,69,.5),0 4px 30px rgba(0,0,0,.6)}
.xw{display:inline-block;will-change:opacity,transform,filter}   /* one word (js/christmas.js builds the words up one by one) */

/* twinkling stars in the sky (added by js/christmas.js) and golden sparkles rising from the light (canvas) */
.xstars{z-index:1;pointer-events:none}
.xsparks{position:absolute;inset:0;width:100%;height:100%;z-index:2;pointer-events:none}

/* which scene you are on */
.xdots{position:absolute;z-index:5;left:50%;bottom:calc(3vh + 54px);transform:translateX(-50%);display:flex;gap:10px}
.xdots i{width:7px;height:7px;border-radius:50%;background:rgba(245,240,230,.35);transition:background .4s,transform .4s}
.xdots i.on{background:#e8b960;transform:scale(1.35);box-shadow:0 0 10px rgba(232,185,96,.8)}

/* very short screens (phones held sideways): little sky shows, so the text may come closer under the smaller phone header */
@media(max-height:500px){
  .xs{--ly:max(calc(env(safe-area-inset-top,0px) + 108px),calc(50vh + (var(--ty,.34) - .5) * max(56.28vw,100vh)))}
  .xline{font-size:max(1.3rem,7vh)}
  .xs:nth-child(3) .xline{font-size:max(1.2rem,6vh)}
}

@media(max-aspect-ratio:1/1){
  .xs:nth-child(3) .xframe{--ox:-4%}   /* phones see only the middle of the painting: nudge scene 3 so baby Jesus in the manger stays in view */
}

/* reduced motion: the three scenes simply stack one under another, nothing fades, zooms or turns */
@media(prefers-reduced-motion:reduce){
  #xmas{height:auto}
  .xstick{position:relative;height:auto}
  .xs{position:relative;height:100vh;opacity:1!important}
  .xdots,.xstick .hint{display:none}
  .xrays::before,.xrays::after,.xs.flare .xrays{animation:none}
  .xsparks{display:none}
  .xline{opacity:1!important;filter:none!important}
}
