/* =========================================================
   Modern Writing Lab: Christmas theme
   Everything here is scoped to html.xmas, which js/xmas.js
   sets (in season, unless Settings turned it off). Decor
   never takes taps from the page: only the footer snowman
   and the decorations (tap one for its gift tag) accept a pointer.
   ========================================================= */

/* ---------- falling snow ---------- */
.xm-snow { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 35; pointer-events: none; }

/* ---------- the drawings ----------
   Outlines stay 2px at any size (like every border on the site);
   .s marks the few strokes that have to scale with the drawing. */
.xm-art { display: block; width: 100%; height: auto; overflow: visible; }
.xm-art * { vector-effect: non-scaling-stroke; }
.xm-art .s, .xm-art .s * { vector-effect: none; }
.xm-host { position: relative; }

/* ---------- string lights under the top bar ---------- */
html.xmas .topbar { isolation: auto; }
.xm-lights { position: absolute; left: 0; right: 0; top: calc(100% - 4px); height: 46px; overflow: hidden; pointer-events: none; }
.xm-lights svg { position: absolute; left: 0; top: 0; display: block; }
.xm-lights i {
  position: absolute; top: 12px; width: 12px; height: 17px; margin-left: -6px;
  border: 2px solid #141414; border-radius: 50% 50% 50% 50% / 38% 38% 62% 62%;
  background: radial-gradient(circle at 34% 30%, rgba(255, 255, 255, .9) 0 1.6px, transparent 2.2px), var(--c);
  transform-origin: 50% -5px; transform: rotate(var(--r));
}
.xm-lights i::before { content: ""; position: absolute; left: 50%; top: -7px; width: 8px; height: 6px; margin-left: -4px; background: #146B45; border: 1.5px solid #141414; border-radius: 2px; }
.xm-lights i::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--c) 78%, transparent) 0, transparent 66%);
  opacity: .6; z-index: -1;
}
@media (max-width: 699px) {
  .xm-lights i { width: 10px; height: 14px; margin-left: -5px; top: 11px; }
  .xm-lights i::after { width: 30px; height: 30px; margin: -15px 0 0 -15px; }
}
@media (prefers-reduced-motion: no-preference) {
  .xm-lights i { animation: xm-tw 2.8s ease-in-out var(--d) infinite; }
  .xm-lights i::after { animation: xm-glow 2.8s ease-in-out var(--d) infinite; }
}
@keyframes xm-tw { 0%, 100% { opacity: 1; } 50% { opacity: .72; } }
@keyframes xm-glow { 0%, 100% { opacity: .85; } 50% { opacity: .12; } }

/* ---------- Santa hat on the wordmark, snow on the Rooms button ---------- */
html.xmas .wordmark { position: relative; }
.xm-hat { position: absolute; left: -.55em; top: calc(50% - 1.38em); width: 1.5em; height: auto; transform: rotate(-16deg); pointer-events: none; }
html.xmas .rooms-btn { position: relative; overflow: visible; }
.xm-cap { position: absolute; left: 7px; right: 7px; top: -6px; width: calc(100% - 14px); height: 11px; pointer-events: none; }

/* ---------- a decoration at every stop ----------
   .xm-d is one decoration. --s is its width, --x / --y where it sits
   from the top right corner of its section. Sizes are set per tier
   (phone, iPad upright, desktop) at the end of this file. */
.xm-d {
  --s: 56px; --x: 0px; --y: 0px;
  position: absolute; z-index: 2; top: var(--y); right: var(--x); width: var(--s);
  pointer-events: auto; cursor: pointer; -webkit-tap-highlight-color: transparent; user-select: none;
}
.xm-d .xm-j { display: block; transform-origin: 50% 90%; }
.xm-d .xm-art { filter: drop-shadow(3px 3px 0 rgba(20, 20, 20, .92)); }
.xm-stand .xm-art { transform: rotate(var(--tilt, 4deg)); }
.xm-stand:nth-of-type(even) { --tilt: -5deg; }

/* hanging: a string from the section's ruled line, then the ornament */
.xm-swag { --u: 12px; --hs: 34px; top: 0; right: var(--x); width: 0; height: 0; pointer-events: none; }
.xm-hang { top: 0; }
.xm-hang .xm-j { position: relative; padding-top: var(--len); transform-origin: 50% 0; }
.xm-hang .xm-j::before { content: ""; position: absolute; left: 50%; top: 0; width: 2px; height: calc(var(--len) + 4px); margin-left: -1px; background: #141414; }
.xm-hang .xm-art { position: relative; filter: drop-shadow(2px 3px 0 rgba(20, 20, 20, .92)); }
.xm-swag .xm-hang { pointer-events: auto; }

/* arriving: stickers pop, ornaments drop, once, when the section scrolls in */
html.xm-mo .xm-stand { opacity: 0; transform: translateY(14px) scale(.5) rotate(-14deg); transition: opacity .25s, transform .7s var(--ease-spring); }
html.xm-mo .xm-stand.in { opacity: 1; transform: none; }
html.xm-mo .xm-swag .xm-hang { opacity: 0; transform: translateY(-30px); transition: opacity .25s calc(var(--k) * .12s), transform .7s var(--ease-spring) calc(var(--k) * .12s); }
html.xm-mo .xm-swag.in .xm-hang { opacity: 1; transform: none; }
@media (prefers-reduced-motion: no-preference) {
  .xm-hang .xm-j { animation: xm-sway 4.6s ease-in-out var(--d, 0s) infinite alternate; }
  .xm-d .xm-j.jingle { animation: xm-jingle 1.5s var(--ease-out); }
  .xm-stand .xm-j.jingle { animation: xm-boing .9s var(--ease-out); }
  .xm-steam { animation: xm-steam 2.6s ease-in-out infinite alternate; }
}
@keyframes xm-sway { from { transform: rotate(-3.5deg); } to { transform: rotate(3.5deg); } }
@keyframes xm-jingle { 0% { transform: rotate(0); } 15% { transform: rotate(17deg); } 35% { transform: rotate(-12deg); } 55% { transform: rotate(7deg); } 75% { transform: rotate(-3deg); } 100% { transform: rotate(0); } }
@keyframes xm-boing { 0% { transform: none; } 20% { transform: scale(1.12, .86); } 45% { transform: scale(.92, 1.1) translateY(-10px) rotate(-6deg); } 70% { transform: scale(1.04, .96) rotate(4deg); } 100% { transform: none; } }
@keyframes xm-steam { from { transform: translateY(2px); opacity: .9; } to { transform: translateY(-3px); opacity: .45; } }

/* snow piled on the top edge of a card */
.xm-cap2 { position: absolute; z-index: 2; top: -21px; width: 150px; height: 30px; pointer-events: none; }
.xm-cap2.l { left: 22px; }
.xm-cap2.r { right: 26px; transform: scaleX(-1); }
.xm-cap2 svg { display: block; width: 100%; height: 100%; overflow: visible; }
.xm-cap2:has(.sm) { width: 94px; }
/* a pile that would cover something (js/xmas.js checks) melts away */
.xm-cap2.xm-melt { visibility: hidden; }

/* ---------- the gift tag on each decoration: why it is there ----------
   Shows on hover with a mouse, or for a few seconds after a tap. */
.xm-tag {
  position: absolute; z-index: 3; right: 0; top: calc(100% + 6px); width: max-content; max-width: min(230px, 70vw);
  padding: 7px 11px 7px 20px; border: 2px solid var(--ink); border-radius: 4px 10px 10px 4px;
  background: var(--card); box-shadow: 3px 3px 0 var(--xm-green);
  font-family: var(--f-display); font-size: 13.5px; font-weight: 600; line-height: 1.3; color: var(--ink); text-align: left;
  opacity: 0; transform: translateY(-4px) rotate(-2deg); transform-origin: 100% 0; pointer-events: none;
  transition: opacity .18s, transform .25s var(--ease-spring);
}
/* the hole the string goes through */
.xm-tag::before { content: ""; position: absolute; left: 7px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border: 1.5px solid var(--ink); border-radius: 50%; background: var(--paper); }
.xm-hang .xm-tag { right: auto; left: 50%; transform: translate(-80%, -4px) rotate(2deg); }
.xm-d.say .xm-tag { opacity: 1; transform: rotate(-2deg); }
.xm-hang.say .xm-tag { transform: translate(-80%, 0) rotate(2deg); }
@media (hover: hover) and (pointer: fine) {
  .xm-d:hover .xm-tag { opacity: 1; transform: rotate(-2deg); }
  .xm-hang:hover .xm-tag { transform: translate(-80%, 0) rotate(2deg); }
}
.xm-d.say, .xm-d:hover { z-index: 6; }

/* ---------- Santa hats on the About photos ----------
   The photo itself is swapped for the edited one (js/xmas.js); this is the
   top of the hat, which sticks up above the photo's frame. */
/* it reaches 24px (of the photo's 800) down into the photo, so the hat covers the frame line */
.portrait img.xm-phat { position: absolute; left: 2px; top: 2px; width: calc(100% - 4px); height: auto; aspect-ratio: auto; object-fit: fill;
  margin-top: calc((100% - 4px) * 24 / 800); transform: translateY(-100%); border: 0; border-radius: 0; box-shadow: none; background: none; pointer-events: none; z-index: 2; }
.xm-credit { display: block; margin-top: 6px; font-family: var(--f-mono); font-size: 11.5px; font-weight: 400; line-height: 1.4; letter-spacing: 0; color: var(--ink-2); }
.xm-credit a { color: inherit; }
/* Nate's seasonal note: a card in red and green */
.xm-note { position: relative; margin: 18px 0 0; max-width: 400px; padding: 12px 14px 13px; border: 2px solid var(--ink); border-radius: 12px;
  background: #FFF6D6; color: #141414; box-shadow: 4px 4px 0 var(--xm-green); transform: rotate(-1.2deg); }
.xm-note p { margin: 0; font-size: 14.5px; line-height: 1.45; }
.xm-note .xm-note-k { font-family: var(--f-mono); font-size: 11.5px; color: var(--xm-red); }
.xm-note .xm-note-h { margin: 2px 0 5px; font-size: 17px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.xm-lists { display: grid; gap: 10px; }
.xm-lists ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 5px; }
.xm-lists li { position: relative; padding-left: 16px; font-size: 14px; line-height: 1.35; }
.xm-lists li::before { content: "•"; position: absolute; left: 3px; top: 0; font-weight: 800; }
.xm-lh { margin: 0 0 4px !important; font-family: var(--f-mono); font-size: 12.5px !important; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.xm-nice .xm-lh, .xm-nice li::before { color: var(--xm-green); }
.xm-naughty { padding-top: 9px; border-top: 1.5px dashed rgba(20, 20, 20, .25); }
.xm-naughty .xm-lh, .xm-naughty li::before { color: var(--xm-red); }
/* the photos need room above them for the hats */
html.xmas .portrait:has(.xm-phat) { margin-top: clamp(64px, 8vw, 110px); }

/* ---------- red and green highlights while the theme is up ---------- */
html.xmas { --xm-red: #D42F24; --xm-green: #17804F; }
html.xmas ::selection { background: #FFD3CE; }
/* page titles in red, section titles in green (alternating down the page) */
html.xmas :is(.hero-title, .kt-title, .lab-title, .fu-title, .ab-title, .gr-title, .ce-title, .st-title) em { color: var(--xm-red); }
html.xmas :is(.ex-title, .stop-title, .learn-title, .eol-title, .rooms-title) em { color: var(--xm-green); }
html.xmas :is(section, article):nth-of-type(even) :is(.ex-title, .stop-title) em { color: var(--xm-red); }
html.xmas .exhibit.ex-network .ex-title em { color: var(--lime); }
/* buttons: red, green on hover; exhibit labels and progress bars green */
html.xmas .btn:not(.btn-ghost):not(:disabled) { background: var(--xm-red); color: #fff; }
html.xmas .btn:not(.btn-ghost):not(:disabled):hover { background: var(--xm-green); }
html.xmas .btn-ghost:hover, html.xmas .btn-ghost[aria-pressed="true"] { background: #CFEBD9; }
html.xmas .placard-no { background: var(--xm-green); color: #fff; }
html.xmas .lm-bar i { background: #7CC995; }
html.xmas .map-col .map-room:hover, html.xmas .map-extra:hover { box-shadow: 3px 3px 0 var(--xm-red); }
html.xmas .foot { box-shadow: 0 -6px 0 var(--xm-green); }

/* ---------- the Lab directory: a wreath on the door ---------- */
.xm-wreath { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.xm-garland { position: absolute; left: 0; top: 0; display: block; overflow: visible; }
.xm-door > :not(.xm-wreath) { position: relative; z-index: 1; }
html.xmas #map .sheet-in.xm-door { padding: 72px 30px max(40px, env(safe-area-inset-bottom)); }
html.xmas #map .xm-door .sheet-close { position: absolute; top: 24px; right: 26px; }
.xm-door > .xm-door-bow { position: absolute; z-index: 3; left: 50%; top: 0; width: 84px; margin-left: -42px; }
.xm-door-bow .xm-art { width: 100%; height: auto; display: block; filter: drop-shadow(2px 2px 0 rgba(20, 20, 20, .85)); }
.xm-door-bow .xm-tag { right: auto; left: 50%; transform: translate(-50%, -4px) rotate(-2deg); transform-origin: 50% 0; }
.xm-door-bow.say .xm-tag { transform: translate(-50%, 0) rotate(-2deg); }
@media (hover: hover) and (pointer: fine) { .xm-door-bow:hover .xm-tag { transform: translate(-50%, 0) rotate(-2deg); } }
html.xmas #map .map-col .map-room { box-shadow: 3px 3px 0 var(--xm-green); }
html.xmas #map .map-extra { border-color: var(--xm-red); }
html.xmas #map .map-x-tag { color: var(--xm-red); font-weight: 600; }
@media (min-width: 900px) {
  html.xmas #map .sheet-in.xm-door { padding: 50px 50px 44px; }
  html.xmas #map .xm-door .sheet-close { top: 34px; right: 40px; }
  .xm-door > .xm-door-bow { width: 100px; margin-left: -50px; }
}

/* ---------- the footer: a snowy hill, trees, presents and a snowman ---------- */
html.xmas .foot { position: relative; margin-top: 150px; }
.xm-yard { position: absolute; left: 0; right: 0; top: 0; height: 0; }
.xm-drift { position: absolute; left: 0; top: -24px; width: 100%; height: 40px; pointer-events: none; overflow: visible; }
.xm-grove { position: absolute; left: max(var(--gutter), calc((100% - var(--max)) / 2)); bottom: 4px; display: flex; align-items: flex-end; pointer-events: none; }
.xm-t { display: block; }
.xm-t .xm-art { filter: none; }
.xm-t.t1 { width: 104px; }
.xm-t.t2 { width: 66px; margin: 0 0 -4px -18px; }
.xm-t.t3 { width: 70px; margin: 0 0 -9px 6px; }
.xm-man {
  position: absolute; right: max(var(--gutter), calc((100% - var(--max)) / 2)); bottom: -2px;
  width: 104px; height: 130px; padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.xm-man:focus-visible { outline-color: var(--blue); border-radius: 12px; }
.xm-man .sm { display: block; width: 100%; height: 100%; overflow: visible; }
.xm-man .sm-left { display: none; }
.sm-arm, .sm-hat { transform-box: fill-box; }
.sm-arm-r { transform-origin: 0% 100%; }
.sm-arm-l { transform-origin: 100% 100%; }
.sm-hat { transform-origin: 50% 100%; }
.xm-say {
  position: absolute; right: 70%; bottom: 86%; width: max-content; max-width: min(240px, 62vw);
  padding: 8px 12px; border: 2px solid var(--ink); border-radius: 14px 14px 4px 14px; background: var(--card); box-shadow: 3px 3px 0 var(--ink);
  font-family: var(--f-display); font-size: 14px; font-weight: 600; line-height: 1.3; color: var(--ink); text-align: left;
  opacity: 0; transform: translateY(6px) scale(.92); transform-origin: 100% 100%; pointer-events: none;
  transition: opacity .2s, transform .25s var(--ease-spring);
}
.xm-man.hi .xm-say { opacity: 1; transform: none; }
@media (prefers-reduced-motion: no-preference) {
  .xm-man:hover .sm-hat { transform: rotate(-8deg) translateY(-2px); }
  .sm-hat { transition: transform .3s var(--ease-spring); }
  .xm-man.hi .sm-arm-r { animation: xm-wave .9s ease-in-out 2; }
  .xm-man.hi .sm-hat { animation: xm-hop .6s var(--ease-spring); }
  .xm-man:active .sm { transform: scale(.96); }
}
@keyframes xm-wave { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-26deg); } 65% { transform: rotate(12deg); } }
@keyframes xm-hop { 0%, 100% { transform: none; } 40% { transform: translateY(-9px) rotate(-10deg); } }

/* =========================================================
   WHERE EACH DECORATION SITS
   Phone first; iPad upright and desktop each get their own
   sizes and spots below (never a scaled copy of another tier).
   ========================================================= */
/* ----- phone ----- */
.xm-stand { --s: 52px; --y: 8px; --x: var(--gutter); }
.xm-swag { --x: calc(var(--gutter) + 14px); --u: 6px; --hs: 30px; }

/* the Lab directory: a small one beside the close button */
.sheet-in > .xm-stand { --s: 46px; --y: 12px; --x: 66px; }
.nf-v > .xm-stand { --y: 0px; --x: 0px; }
.kt-hero > .xm-stand { --s: 44px; --y: 2px; }
/* the Learning Lab and Games heroes: clear of the string of lights */
.lab-hero > .xm-stand { --s: 44px; --y: 22px; }
/* sections whose label sits right under the line: tiny ornaments that stay above it */
.ab-sec > .xm-swag, .gr-sec > .xm-swag { --u: 1.5px; --hs: 24px; }

/* ----- iPad upright ----- */
@media (min-width: 700px) and (max-width: 899px) {
  .lab-hero > .xm-stand { --s: 74px; --y: 18px; }
  .xm-stand { --s: 74px; --y: 18px; --x: 28px; }
  .ab-sec > .xm-swag, .gr-sec > .xm-swag { --u: 4px; --hs: 36px; }
  .kt-hero > .xm-stand { --s: 58px; --y: -4px; }
  .sheet-in > .xm-stand { --s: 52px; }
  .xm-swag { --x: 46px; --u: 11px; --hs: 40px; }
  html.xmas .foot { margin-top: 160px; }
}
/* ----- desktop, and iPad on its side ----- */
@media (min-width: 900px) {
  .xm-stand, .kt-hero > .xm-stand, .lab-hero > .xm-stand { --s: 96px; --y: 26px; --x: var(--gutter); }
  .sheet-in > .xm-stand { --s: 56px; --y: 14px; --x: 72px; }
  .xm-swag { --x: calc(var(--gutter) + 30px); --u: 15px; --hs: 56px; }
  /* these sections start their title close under the line: shorter strings keep the ornaments off it */
  .ab-sec > .xm-swag, .gr-sec > .xm-swag { --u: 5px; --hs: 50px; }
  .eol > .xm-swag { --u: 8px; --hs: 50px; }
  html.xmas .foot { margin-top: 180px; }
  .xm-t.t1 { width: 132px; } .xm-t.t2 { width: 84px; } .xm-t.t3 { width: 88px; }
  .xm-man { width: 120px; height: 150px; }
}
@media (max-width: 699px) {
  html.xmas .foot { margin-top: 124px; }
  .xm-t.t1 { width: 78px; } .xm-t.t2 { width: 50px; } .xm-t.t3 { width: 52px; }
  .xm-man { width: 82px; height: 102px; }
  .xm-cap2 { width: 118px; height: 24px; top: -17px; }
  .xm-cap2:has(.sm) { width: 76px; }
  .xm-cap2.l { left: 16px; } .xm-cap2.r { right: 18px; }
}

/* the string of lights is long and thin: it gets more width at every tier */
.xm-stand.xm-a-lights { --s: 86px; }
@media (min-width: 700px) and (max-width: 899px) { .xm-stand.xm-a-lights { --s: 118px; } }
@media (min-width: 900px) { .xm-stand.xm-a-lights { --s: 156px; } }
