/* Halloween, 20 October to 1 November, every year.

   Every rule here hangs off html.hw, which the small script in each page's
   head sets only in that window - the rest of the year this file matches
   nothing. The site's own rule is one typeface and two colours; for twelve
   days it is night instead: the same typeface, bone on black, and pumpkin
   for the one accent. The decorations are drawn the way the headings are
   written - in chalk - and lit by candle. */

html.hw {
  --ink:    #efe7d8;   /* bone */
  --paper:  #0d0a12;   /* night */
  --muted:  #a59ab6;   /* fog */
  --rule:   #efe7d8;
  --danger: #ff6b5e;
  --pumpkin: #ff7a1a;
  --ember:   #ffb54d;
  --chalk:   #c9bde0;
  color-scheme: dark;
  scrollbar-color: var(--pumpkin) var(--paper);
}
html.hw body { background: var(--paper); overflow-x: clip; }
html.hw ::selection { background: var(--pumpkin); color: #170a02; }
html.hw :focus-visible { outline-color: var(--pumpkin); }
html.hw p a:hover, html.hw li a:hover, html.hw .hw-cta:hover { color: var(--ember); }

/* ---------- type ---------- */

/* the headline is lit from somewhere below, and the candle gutters now and then */
html.hw h1 {
  text-shadow: 0 0 22px rgba(255, 122, 26, 0.38), 0 0 2px rgba(255, 170, 80, 0.4);
  animation: hw-gutter 9s infinite;
}
@keyframes hw-gutter {
  0%, 90%, 92.5%, 95%, 100% { opacity: 1; }
  91% { opacity: 0.55; }
  94% { opacity: 0.82; }
}
html.hw .quote { border-left-color: var(--pumpkin); }

/* candy corn instead of bullets */
html.hw .wrap ul { list-style: none; padding-left: 1.4rem; }
html.hw .wrap ul > li::before {
  content: "";
  display: inline-block;
  width: 11px;
  height: 14px;
  margin: 0 0.6rem 0 -1.4rem;
  vertical-align: -0.1em;
  background: var(--hw-corn) no-repeat center / contain;
}

/* ---------- header: wax dripping off the rule, a pumpkin by the name ---------- */

html.hw header.site { position: relative; border-bottom-color: transparent; }
html.hw header.site::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 22px;
  margin-top: -1px;
  /* each tile is drawn taller than the strip that shows it: a repeated image
     bleeds its top row into its bottom one, and this way that row is cut off */
  background: var(--hw-drip-a) repeat-x 0 0 / 160px 40px, var(--hw-drip-b) repeat-x 61px 0 / 230px 40px;
  pointer-events: none;
}

.hw-jack {
  width: 36px;
  height: 36px;
  margin: -8px 0 -8px -0.5rem;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  align-self: center;
  filter: drop-shadow(0 0 8px rgba(255, 122, 26, 0.35));
}
.hw-jack svg, .hw-banner-pk svg { display: block; width: 100%; height: 100%; overflow: visible; }
.hw-laugh { animation: hw-laugh 0.75s ease-in-out; }
@keyframes hw-laugh {
  0%, 100% { transform: rotate(0) scale(1); }
  15% { transform: rotate(-14deg) scale(1.15); }
  32% { transform: rotate(11deg) scale(1.15); }
  50% { transform: rotate(-8deg) scale(1.1); }
  70% { transform: rotate(5deg) scale(1.05); }
}

/* a candle inside every pumpkin, each burning to its own rhythm */
.hw-face {
  filter: drop-shadow(0 0 2px rgba(255, 190, 40, 0.95));
  animation: hw-candle 2.7s linear infinite;
}
@keyframes hw-candle {
  0%   { opacity: 1; }
  9%   { opacity: 0.8; }
  13%  { opacity: 0.97; }
  31%  { opacity: 0.86; }
  37%  { opacity: 1; }
  58%  { opacity: 0.74; }
  63%  { opacity: 0.95; }
  82%  { opacity: 0.85; }
  100% { opacity: 1; }
}

/* the lights switch, which stays visible when everything else does not */
.hw-lights {
  position: relative;
  z-index: 9995;
  font: inherit;
  font-size: 0.9rem;
  color: var(--ember);
  background: none;
  border: 0;
  padding: 0.72rem 0.6rem;
  margin: -0.72rem 0;
  cursor: pointer;
}
.hw-lights:hover { text-decoration: underline; }
html.hw-lightsout .hw-lights { text-shadow: 0 0 10px rgba(255, 170, 60, 0.8); }

/* ---------- lights out: a torch where the pointer is, dark everywhere else ---------- */

.hw-dark {
  position: fixed;
  inset: 0;
  z-index: 9990;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.7s ease, visibility 0s linear 0.7s;
  background:
    radial-gradient(circle at var(--x, 50%) var(--y, 42%), rgba(255, 196, 110, 0.10) 0, rgba(255, 196, 110, 0) 170px),
    radial-gradient(circle at var(--x, 50%) var(--y, 42%), rgba(5, 3, 8, 0) 0, rgba(5, 3, 8, 0) 90px, rgba(5, 3, 8, 0.7) 160px, rgba(5, 3, 8, 0.975) 240px);
}
html.hw-lightsout .hw-dark { opacity: 1; visibility: visible; transition: opacity 0.7s ease; }

/* ---------- the sky: stars in the margins, a moon, fog along the bottom ---------- */

.hw-sky {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(120% 70% at 88% -10%, rgba(92, 56, 132, 0.24), rgba(92, 56, 132, 0) 62%),
    radial-gradient(90% 55% at 6% 108%, rgba(255, 110, 20, 0.07), rgba(255, 110, 20, 0) 70%);
}
.hw-star { position: absolute; border-radius: 50%; background: #f6efff; box-shadow: 0 0 3px rgba(246, 239, 255, 0.6); }
.hw-tw { animation: hw-twinkle 4.6s ease-in-out infinite; }
@keyframes hw-twinkle { 0%, 100% { opacity: 0.9; } 50% { opacity: 0.12; } }

.hw-moon {
  display: none;
  position: absolute;
  top: 84px;
  right: calc((100vw - 46rem) / 4 - 78px);
  width: 156px;
  height: 156px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 33% 30%, rgba(120, 100, 60, 0.13) 0 8%, transparent 9.5%),
    radial-gradient(circle at 63% 57%, rgba(120, 100, 60, 0.14) 0 12%, transparent 13.5%),
    radial-gradient(circle at 40% 71%, rgba(120, 100, 60, 0.10) 0 6%, transparent 7.5%),
    radial-gradient(circle at 72% 30%, rgba(120, 100, 60, 0.09) 0 4.5%, transparent 6%),
    radial-gradient(circle at 24% 52%, rgba(120, 100, 60, 0.08) 0 3.5%, transparent 5%),
    radial-gradient(circle at 38% 34%, #fffbea 0, #f5e8c2 52%, #d6c18a 100%);
  box-shadow: 0 0 46px 10px rgba(255, 236, 190, 0.17), 0 0 150px 46px rgba(255, 220, 160, 0.07);
}
.hw-moon.show { display: block; }
/* thin cloud drifting across it - nearly invisible against the night, dark against the moon */
.hw-cloud {
  position: absolute;
  top: 34%;
  left: 0;
  width: 190px;
  height: 26px;
  border-radius: 50%;
  background: rgba(70, 58, 92, 0.55);
  filter: blur(7px);
  animation: hw-cloud 46s linear infinite;
}
.hw-cloud2 { top: 66%; width: 140px; height: 18px; animation-duration: 63s; animation-delay: -30s; opacity: 0.8; }
@keyframes hw-cloud { from { transform: translateX(-260px); } to { transform: translateX(240px); } }

.hw-fog { position: absolute; left: 0; right: 0; bottom: 0; height: 36vh; }
.hw-fog i {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 200%;
  background:
    radial-gradient(ellipse 30% 46% at 25% 80%, rgba(186, 170, 220, 0.12), rgba(186, 170, 220, 0) 72%) repeat-x 0 0 / 50% 100%,
    radial-gradient(ellipse 26% 40% at 72% 92%, rgba(186, 170, 220, 0.10), rgba(186, 170, 220, 0) 72%) repeat-x 0 0 / 50% 100%;
  animation: hw-fog 80s linear infinite;
}
.hw-fog i + i { top: 14%; animation-duration: 125s; animation-direction: reverse; opacity: 0.75; }
@keyframes hw-fog { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ---------- cobwebs in the top corners, spiders on threads ---------- */

.hw-top {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 560px;
  overflow: hidden;
  pointer-events: none;
  z-index: 70;
}
.hw-web { position: absolute; top: 0; line-height: 0; }
.hw-web-l { left: 0; }
.hw-web-r { right: 0; transform: scaleX(-1); }
.hw-web path { fill: none; stroke: rgba(226, 216, 246, 0.36); stroke-width: 1; stroke-linecap: round; }

.hw-spider { position: absolute; top: 0; width: 0; transform-origin: 0 0; animation: hw-swing 6s ease-in-out infinite alternate; }
.hw-hang { animation: hw-bob 7s ease-in-out infinite alternate; }
.hw-climb { transition: transform 3.8s cubic-bezier(0.35, 0.1, 0.3, 1); }
.hw-spider.up .hw-climb { transform: translateY(var(--up)); transition: transform 0.55s cubic-bezier(0.55, 0, 0.9, 0.6); }
.hw-thread {
  position: absolute;
  left: -0.5px;
  width: 1px;
  background: linear-gradient(rgba(226, 216, 246, 0.12), rgba(226, 216, 246, 0.55));
}
.hw-spider-body { position: absolute; left: 0; transform: translateX(-50%); pointer-events: auto; cursor: pointer; line-height: 0; }
.hw-spider-body svg { display: block; width: 100%; height: auto; overflow: visible; }
.hw-legs { transform-box: view-box; transform-origin: 22px 24px; animation: hw-legs 1.7s ease-in-out infinite alternate; }
.hw-legs path { fill: none; stroke: var(--chalk); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.hw-sb { fill: #1a1323; stroke: var(--chalk); stroke-width: 1.1; }
.hw-se { fill: #ff4a3a; filter: drop-shadow(0 0 1.5px #ff4a3a); }
@keyframes hw-legs { from { transform: scaleX(1) scaleY(1); } to { transform: scaleX(0.9) scaleY(1.04); } }
@keyframes hw-swing { from { transform: rotate(-2.5deg); } to { transform: rotate(2.5deg); } }
@keyframes hw-bob { from { transform: translateY(0); } to { transform: translateY(24px); } }

/* ---------- bats ---------- */

.hw-bat { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; will-change: transform; line-height: 0; }
.hw-bat svg { display: block; width: 100%; height: auto; overflow: visible; }
.hw-bat path { fill: #191221; stroke: #a48dcc; stroke-width: 1.3; stroke-linejoin: round; }
.hw-bat .hw-be { fill: #ffb347; }
.hw-wl, .hw-wr { transform-box: view-box; animation: hw-flap-l 0.19s ease-in-out infinite alternate; }
.hw-wl { transform-origin: 46px 21px; }
.hw-wr { transform-origin: 54px 21px; animation-name: hw-flap-r; }
@keyframes hw-flap-l { from { transform: rotate(26deg) scaleY(0.9); } to { transform: rotate(-24deg) scaleY(0.72); } }
@keyframes hw-flap-r { from { transform: rotate(-26deg) scaleY(0.9); } to { transform: rotate(24deg) scaleY(0.72); } }

/* ---------- eyes in the dark, and a ghost that will not let you near ---------- */

.hw-eyes { position: fixed; z-index: 9996; pointer-events: none; opacity: 0; transition: opacity 1.1s ease; line-height: 0; }
.hw-eyes.on { opacity: 1; }
.hw-eyes svg { display: block; width: 100%; height: auto; overflow: visible; animation: hw-blink 3.6s infinite; }
.hw-eyes path { fill: #ffd23f; filter: drop-shadow(0 0 4px rgba(255, 186, 40, 0.9)); }
.hw-pupils { transition: transform 0.3s ease-out; }
.hw-pupils ellipse { fill: #140904; }
@keyframes hw-blink { 0%, 40%, 47%, 100% { transform: scaleY(1); } 43.5% { transform: scaleY(0.06); } }

.hw-ghost {
  position: fixed;
  z-index: 50;
  width: 52px;
  pointer-events: none;
  opacity: 0;
  transition: left 7s ease-in-out, top 7s ease-in-out, opacity 1s ease, transform 1s ease;
  line-height: 0;
}
.hw-ghost.on { opacity: 0.8; }
.hw-ghost.shy { opacity: 0 !important; transform: scale(0.6) translateY(-14px); transition: opacity 0.22s, transform 0.3s, left 0s 0.3s, top 0s 0.3s; }
.hw-ghost svg, .hw-riser svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 0 10px rgba(205, 185, 255, 0.5));
}
.hw-ghost svg { animation: hw-float 3.3s ease-in-out infinite alternate; }
.hw-gb { fill: #f1ecfb; }
.hw-ghost ellipse, .hw-riser ellipse { fill: #1b1426; }
@keyframes hw-float { from { transform: translateY(-5px) rotate(-3deg); } to { transform: translateY(6px) rotate(3deg); } }

/* ---------- the front page ---------- */

.hw-banner {
  display: flex;
  align-items: center;
  gap: 1.3rem;
  border: 2px solid var(--pumpkin);
  padding: 1.15rem 1.4rem;
  margin: -0.4rem 0 2.4rem;
  background: radial-gradient(120% 150% at 0% 50%, rgba(255, 122, 26, 0.17), rgba(255, 122, 26, 0) 62%);
  box-shadow: 0 0 34px rgba(255, 122, 26, 0.14), inset 0 0 26px rgba(255, 122, 26, 0.07);
}
.hw-banner-pk {
  flex: none;
  width: 88px;
  height: 88px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  filter: drop-shadow(0 0 14px rgba(255, 122, 26, 0.4));
}
.hw-banner p { margin: 0; }
.hw-kicker {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ember);
}
.hw-banner .hw-title {
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(2rem, 6.5vw, 2.7rem);
  line-height: 1;
  margin: 0.2rem 0 0.4rem;
  color: var(--pumpkin);
  text-shadow: 0 0 20px rgba(255, 122, 26, 0.5);
}
.hw-banner .hw-count { margin-bottom: 0.45rem; }
.hw-cta { display: inline-block; padding: 0.35rem 0; font-weight: 700; color: var(--ember); text-underline-offset: 3px; }
@media (max-width: 520px) {
  .hw-banner { gap: 0.9rem; padding: 1rem; align-items: flex-start; }
  .hw-banner-pk { width: 58px; height: 58px; margin-top: 0.3rem; }
}

/* game cards: pumpkin when you hover, and something leans out from behind it */
html.hw .game { position: relative; transition: background-color 0.2s, color 0.2s, box-shadow 0.3s, border-color 0.2s; }
html.hw .game:hover, html.hw .game:focus-visible {
  background: var(--pumpkin);
  border-color: var(--pumpkin);
  color: #160a02;
  box-shadow: 0 0 30px rgba(255, 122, 26, 0.45);
}
html.hw .game:hover .game-note, html.hw .game:focus-visible .game-note { color: #3a1a05; }
html.hw .game::after {
  content: "";
  position: absolute;
  z-index: -1;
  right: 0;
  top: 50%;
  width: 40px;
  height: 48px;
  margin-top: -24px;
  background: var(--hw-peek) no-repeat center / contain;
  filter: drop-shadow(0 0 8px rgba(205, 185, 255, 0.5));
  opacity: 0;
  transform: translateX(-20%) rotate(0);
  transform-origin: 0 100%;
  transition: opacity 0.15s, transform 0.45s cubic-bezier(0.2, 1.5, 0.4, 1);
  pointer-events: none;
}
html.hw .game:hover::after, html.hw .game:focus-visible::after { opacity: 1; transform: translateX(80%) rotate(14deg); }
html.hw .game:nth-of-type(2n)::after { right: auto; left: 0; transform-origin: 100% 100%; transform: translateX(20%); }
html.hw .game:nth-of-type(2n):hover::after, html.hw .game:nth-of-type(2n):focus-visible::after { transform: translateX(-80%) rotate(-14deg); }

/* this year's pick glows on its own */
html.hw .hw-pick { border-color: var(--pumpkin); animation: hw-breathe 4.5s ease-in-out infinite; }
@keyframes hw-breathe {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 122, 26, 0.12); }
  50% { box-shadow: 0 0 30px rgba(255, 122, 26, 0.32); }
}
html.hw .hw-tag { color: var(--pumpkin); border-color: var(--pumpkin); }
html.hw .game:hover .hw-tag, html.hw .game:focus-visible .hw-tag { color: #160a02; border-color: #160a02; }

html.hw .play:hover, html.hw .play:focus-visible { background: var(--pumpkin); border-color: var(--pumpkin); color: #160a02; }

/* ---------- a graveyard above the footer ---------- */

.hw-graveyard {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.3rem;
  margin: 3.5rem 0 0;
  line-height: 0;
}
html.hw footer.site { margin-top: 0; }
.hw-graveyard svg { display: block; width: 100%; height: auto; overflow: visible; }
.hw-treebox { flex: none; width: 150px; }
.hw-stone { position: relative; flex: none; width: clamp(80px, 15vw, 106px); }
.hw-graveyard .hw-mini { flex: none; width: 30px; height: 30px; margin-bottom: -1px; filter: drop-shadow(0 0 8px rgba(255, 122, 26, 0.5)); }
.hw-st { fill: #1f1829; stroke: var(--chalk); stroke-width: 2; stroke-linejoin: round; }
.hw-line { fill: none; stroke: var(--chalk); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.hw-graveyard text { font-family: var(--hand); fill: #e2d8f0; text-anchor: middle; }
.hw-e1 { font-size: 18px; font-weight: 700; }
.hw-e2 { font-size: 11.5px; letter-spacing: 0.04em; }
.hw-e3 { font-size: 10px; fill: #b7abc9 !important; }
.hw-gmoon { fill: #f6ecc8; filter: drop-shadow(0 0 12px rgba(255, 236, 190, 0.5)); }
.hw-mound { fill: #1f1829; stroke: var(--chalk); stroke-width: 1.4; }
.hw-tree path { fill: none; stroke: var(--chalk); stroke-linecap: round; stroke-linejoin: round; }
.hw-hangbat path:first-child { fill: none; stroke: var(--chalk); stroke-width: 1; }
.hw-hangbat ellipse, .hw-hangbat path + path { fill: #191221; stroke: #a48dcc; stroke-width: 1; }

/* now and then something comes up out of the save file's grave */
.hw-riser {
  position: absolute;
  left: 50%;
  bottom: 52%;
  width: 34px;
  margin-left: -17px;
  opacity: 0;
  pointer-events: none;
  animation: hw-rise 15s ease-in-out infinite;
  animation-delay: 4s;
}
@keyframes hw-rise {
  0%, 70% { opacity: 0; transform: translateY(26px) scale(0.5); }
  80% { opacity: 0.85; transform: translateY(-8px) scale(0.9); }
  90% { opacity: 0.6; transform: translateY(-34px) scale(1) rotate(6deg); }
  97%, 100% { opacity: 0; transform: translateY(-56px) scale(1.05) rotate(-4deg); }
}

@media (max-width: 560px) {
  .hw-treebox, .hw-cross { display: none; }
}

/* ---------- for anyone who asked for less motion: the look, none of the movement ---------- */

@media (prefers-reduced-motion: reduce) {
  html.hw *, html.hw *::before, html.hw *::after { animation: none !important; transition: none !important; }
  .hw-riser { display: none; }
}
