/* HotWax - Layer Stack (3D, self-guided). Colours and sizes arrive as --hw-* variables from the module fields.
   --s is the side of one slab before it is tilted; tilted, a slab is --w wide and --vh tall on screen. */
.hw-stack { --s: var(--hw-s, 300px); --gap: var(--hw-gap, 170px); --w: calc(var(--s) * 1.4143); --vh: calc(var(--s) * .7495);
  /* --open: how far the slabs above the active one lift to uncover it; --top leaves room for that lift */
  --open: max(0px, calc(var(--vh) - var(--gap) + 16px)); --top: calc(var(--open) + 24px);
  background: var(--hw-bg, #14110F); color: var(--hw-text, #CFC7C1); font-family: var(--hw-font-b, Montserrat, Arial, sans-serif); overflow-x: clip; --hw-vh: 1vh; }
@supports (height: 1svh) { .hw-stack { --hw-vh: 1svh; } }
.hw-stack *, .hw-stack *::before, .hw-stack *::after { box-sizing: border-box; }
.hw-stack__inner { max-width: var(--hw-max, 1240px); margin: 0 auto; padding: var(--hw-pt, 96px) 72px var(--hw-pb, 96px); }

/* ---------- Heading ---------- */
.hw-stack__eyebrow { display: flex; align-items: baseline; gap: 16px; margin: 0 0 14px;
  font-size: var(--hw-eb-size, 11px); font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--hw-accent, #E74000); }
.hw-stack__num { font: 400 1.36em/1 var(--hw-font-h, "Playfair Display", Georgia, serif); letter-spacing: 0; }
.hw-stack .hw-stack__title { margin: 0 0 12px; color: var(--hw-title, #fff);
  font: 700 var(--hw-h-size, 38px)/1.22 var(--hw-font-h, "Playfair Display", Georgia, serif); }
.hw-stack__intro { max-width: 64ch; margin: 0 0 28px; font-size: var(--hw-intro-size, 15.5px); line-height: 1.6; color: var(--hw-muted, #A8A09A); }

/* ---------- Layout: stack | legend, caption underneath ---------- */
.hw-stack__body { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 60px; align-items: start; }
.hw-stack__caption { grid-column: 1 / -1; }
.hw-stack--stage-right .hw-stack__body { grid-template-columns: minmax(0, 1fr) auto; }
@media (min-width: 961px) {
  .hw-stack--stage-right .hw-stack__legend { order: 1; }
  .hw-stack--stage-right .hw-stack__stage { order: 2; }
  .hw-stack--stage-right .hw-stack__caption { order: 3; }
}

/* tone of a layer: neutral, accent or outline */
.hw-stack__slab, .hw-stack__row { --b-bg: var(--hw-n-bg); --b-bd: var(--hw-n-bd); --b-bg-on: var(--hw-n-bg-on); --b-bd-on: var(--hw-n-bd-on);
  --b-text: var(--hw-n-text); --b-line: solid; }
.hw-stack__slab--accent, .hw-stack__row--accent { --b-bg: var(--hw-a-bg); --b-bd: var(--hw-a-bd); --b-bg-on: var(--hw-a-bg-on);
  --b-bd-on: var(--hw-a-bd-on); --b-text: var(--hw-a-text); }
.hw-stack__slab--outline, .hw-stack__row--outline { --b-bg: transparent; --b-bd: var(--hw-o-bd); --b-bg-on: var(--hw-o-bg-on);
  --b-bd-on: var(--hw-accent); --b-text: var(--hw-o-text); --b-line: dashed; }

/* ---------- The 3D stack ---------- */
.hw-stack__stage { position: relative; width: calc(var(--w) + 40px);
  height: calc(var(--top) + 24px + var(--vh) + (var(--hw-layers, 4) - 1) * var(--gap) + var(--hw-thick, 12px)); }
/* a slab is a flat box on screen; the plate inside it is the tilted square. Stacked drop-shadows give it thickness. */
.hw-stack__slab { --side: #0b0908; --side: color-mix(in srgb, var(--b-bd) 62%, #000); --t: calc(var(--hw-thick, 12px) / 3); --br: 1;
  position: absolute; left: 50%; top: calc(var(--top) + var(--i, 0) * var(--gap)); z-index: calc(var(--hw-layers, 4) - var(--i, 0));
  width: var(--w); height: var(--vh); margin-left: calc(var(--w) / -2); pointer-events: none;
  filter: drop-shadow(0 var(--t) 0 var(--side)) drop-shadow(0 var(--t) 0 var(--side)) drop-shadow(0 var(--t) 0 var(--side))
          drop-shadow(0 26px 22px var(--hw-shadow, rgba(0,0,0,.45))) brightness(var(--br));
  transition: transform .5s cubic-bezier(.2,.8,.2,1), filter .35s ease, opacity .5s ease; }
.hw-stack__slab--outline { filter: brightness(var(--br)); }
.hw-stack__plate { position: absolute; left: 50%; top: 50%; width: var(--s); height: var(--s);
  margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2);
  transform: rotateX(58deg) rotateZ(-45deg); transform-style: preserve-3d;
  display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 8px; padding: 12px;
  background: var(--b-bg); background: color-mix(in srgb, var(--b-bg) 55%, var(--hw-bg, #14110F));
  border: 1px var(--b-line) var(--b-bd); }
.hw-stack__slab--outline .hw-stack__plate { background: transparent; }
.hw-stack__tile { display: flex; align-items: center; justify-content: center; min-width: 0; padding: 4px; pointer-events: auto; cursor: default;
  background: var(--b-bg); border: 1px var(--b-line) var(--b-bd); color: var(--b-text);
  font: 600 var(--hw-tile-size, 13px)/1.25 var(--hw-font-b, Montserrat, Arial, sans-serif); letter-spacing: .04em; text-align: center;
  transition: transform .4s cubic-bezier(.2,.8,.2,1), background .3s ease, border-color .3s ease, box-shadow .3s ease, color .3s ease; }
.hw-stack__tile > span { overflow-wrap: anywhere; }

/* spotlight: the active slab rises, its tile lifts off the surface, the other slabs step back */
.hw-stack.has-active .hw-stack__slab { --br: var(--hw-dim, .75); }
.hw-stack.has-active .hw-stack__slab.is-on { --br: 1; }
/* the slabs above the active one lift out of the way, so nothing covers it */
.hw-stack.has-active .hw-stack__slab.is-above { transform: translateY(calc(var(--open) * -1)); }
.hw-stack__tile.is-active, .hw-stack__slab.is-lit .hw-stack__tile { background: var(--b-bg-on); border-color: var(--b-bd-on); border-style: solid; color: var(--hw-on-text, #fff); }
.hw-stack__tile.is-active { transform: translateZ(var(--hw-lift, 20px)); box-shadow: 0 0 0 1px var(--b-bd-on), 0 0 28px var(--b-bd-on); }

/* rails: two dashed lines down the left and right corners of the slabs, flowing upward */
.hw-stack__rail { position: absolute; z-index: 0; top: calc(var(--top) + var(--vh) / 2); width: 1px;
  height: calc((var(--hw-layers, 4) - 1) * var(--gap)); overflow: hidden; opacity: .55; }
/* the dashes are painted once on a strip one dash-pair taller than the rail, and the strip slides up by a transform.
   Animating background-position instead repainted both rails on every frame, forever. */
.hw-stack__rail::before { content: ""; position: absolute; left: 0; top: 0; width: 100%; height: calc(100% + 10px);
  background: repeating-linear-gradient(to bottom, var(--hw-rail, #E74000) 0 5px, transparent 5px 10px); background-size: 1px 10px;
  animation: hw-stack-flow 1.1s linear infinite; }
.hw-stack__rail--a { left: calc(50% - var(--w) / 2); }
.hw-stack__rail--b { left: calc(50% + var(--w) / 2); }
@keyframes hw-stack-flow { from { transform: translateY(0); } to { transform: translateY(-10px); } }

/* ---------- Legend: one row per slab, lined up with it and wired to its corner ---------- */
.hw-stack__legend { margin: 0; padding: calc(var(--top) + var(--vh) / 2 - 8px) 0 0; list-style: none; }
.hw-stack__row { position: relative; height: var(--gap); margin: 0; padding: 0; list-style: none; }
.hw-stack__row::before { content: ""; position: absolute; top: 7px; right: calc(100% + 10px); width: 66px; height: 1px;
  background: repeating-linear-gradient(to right, var(--hw-label, #7A736D) 0 4px, transparent 4px 8px); transition: background .3s ease; }
.hw-stack__row.is-on::before { background: var(--hw-accent, #E74000); }
.hw-stack--stage-right .hw-stack__row::before { right: auto; left: calc(100% + 10px); }
.hw-stack--stage-right .hw-stack__row { text-align: right; }
.hw-stack--stage-right .hw-stack__chips { justify-content: flex-end; }
.hw-stack__label { margin: 0 0 12px; font-size: var(--hw-label-size, 10.5px); font-weight: 700; line-height: 16px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--hw-label, #7A736D); transition: color .3s ease; }
.hw-stack__row--accent .hw-stack__label, .hw-stack__row.is-on .hw-stack__label { color: var(--hw-accent, #E74000); }
.hw-stack__chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.hw-stack__chips > li { margin: 0; list-style: none; }
.hw-stack__chips > li::before { content: none; }
.hw-stack__chip { padding: 6px 11px; border: 1px var(--b-line) var(--b-bd); background: var(--b-bg); color: var(--hw-text, #CFC7C1);
  font-size: var(--hw-name-size, 12px); line-height: 1.35; outline: 0; cursor: default;
  transition: background .3s ease, border-color .3s ease, color .3s ease, opacity .3s ease; }
.hw-stack__row--outline .hw-stack__chip { border-radius: 20px; }
.hw-stack__note { margin-left: 8px; font-size: 11px; color: var(--hw-muted, #A8A09A); }
.hw-stack.has-active .hw-stack__row:not(.is-on) .hw-stack__chip { opacity: .55; }
.hw-stack__chip.is-active, .hw-stack__row.is-lit .hw-stack__chip { background: var(--b-bg-on); border-color: var(--b-bd-on); border-style: solid; color: var(--hw-on-text, #fff); }
.hw-stack__chip.is-active .hw-stack__note { color: var(--hw-on-text, #fff); }
.hw-stack__chip:focus-visible { outline: 2px solid var(--hw-accent, #E74000); outline-offset: 2px; }
.hw-stack__link { position: absolute; left: 0; bottom: 14px; margin: 0; padding-left: 18px;
  font-size: 9.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--hw-label, #7A736D); }
.hw-stack__link::before { content: ""; position: absolute; left: 4px; top: -4px; bottom: -4px; width: 1px;
  background: repeating-linear-gradient(to bottom, var(--hw-accent, #E74000) 0 4px, transparent 4px 8px); }
.hw-stack--stage-right .hw-stack__link { left: auto; right: 0; padding: 0 18px 0 0; }
.hw-stack--stage-right .hw-stack__link::before { left: auto; right: 4px; }
.hw-stack__sr { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Caption strip ---------- */
.hw-stack__caption { margin-top: 26px; }
.hw-stack__meter { display: flex; align-items: center; gap: 16px; }
.hw-stack__segs { flex: 1; display: flex; gap: 6px; }
.hw-stack__seg { flex: 1; height: 2px; background: var(--hw-track, #2E2926); overflow: hidden; }
.hw-stack__seg > i { display: block; height: 100%; background: var(--hw-accent, #E74000); transform: scaleX(0); transform-origin: left center; }
.hw-stack__count { flex: none; min-width: 56px; text-align: right; font-size: 10.5px; font-weight: 600; letter-spacing: .12em;
  color: var(--hw-label, #7A736D); font-variant-numeric: tabular-nums; }
/* every entry sits in the same cell, so the strip is as tall as the longest one and never jumps */
.hw-stack__items { display: grid; padding-top: 22px; }
.hw-stack__item { grid-area: 1 / 1; display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); column-gap: 48px; align-items: start;
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity .14s ease, transform 0s linear .14s, visibility 0s linear .14s; }
/* the old text leaves first, then the new one comes in, so the two never overlap */
.hw-stack__item.is-on { opacity: 1; visibility: visible; transform: none;
  transition: opacity .35s ease .14s, transform .35s ease .14s, visibility 0s linear .14s; }
.hw-stack__kind { margin: 0 0 8px; font-size: 10px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--hw-accent, #E74000); }
.hw-stack__item-title { margin: 0; font: 400 var(--hw-cap-title, 26px)/1.25 var(--hw-font-h, "Playfair Display", Georgia, serif); color: var(--hw-title, #fff); }
.hw-stack__detail { max-width: 62ch; margin: 0; padding-top: 4px; font-size: var(--hw-cap-text, 15px); line-height: 1.6; color: var(--hw-muted, #A8A09A); }

/* ---------- Build-in: the slabs drop into place, bottom one first (only once the script is running) ---------- */
.hw-stack--build.is-armed .hw-stack__slab { opacity: 0; transform: translateY(-70px); }
.hw-stack--build.is-armed .hw-stack__rail, .hw-stack--build.is-armed .hw-stack__row, .hw-stack--build.is-armed .hw-stack__caption { opacity: 0; }
.hw-stack--build.is-armed.is-in .hw-stack__slab { opacity: 1; transform: none;
  transition-delay: calc((var(--hw-layers, 4) - 1 - var(--i, 0)) * var(--hw-build-step, 180ms)); }
.hw-stack--build.is-armed.is-in .hw-stack__rail { opacity: .55; transition: opacity .6s ease calc(var(--hw-layers, 4) * var(--hw-build-step, 180ms)); }
.hw-stack--build.is-armed.is-in .hw-stack__row, .hw-stack--build.is-armed.is-in .hw-stack__caption { opacity: 1;
  transition: opacity .6s ease calc(var(--hw-layers, 4) * var(--hw-build-step, 180ms)); }

/* ---------- Show / hide switches ---------- */
.hw-stack--no-open { --open: 0px; }
.hw-stack--no-wires .hw-stack__row::before { display: none; }
.hw-stack--no-caption .hw-stack__caption { display: none; }
/* hidden parts stay in the page for screen readers */
.hw-stack--no-names .hw-stack__chips,
.hw-stack--no-legend .hw-stack__legend { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.hw-stack--no-legend .hw-stack__body { grid-template-columns: minmax(0, 1fr); }
.hw-stack--no-legend .hw-stack__stage { margin: 0 auto; }
.hw-stack--no-names .hw-stack__label { margin-bottom: 0; }
@media (min-width: 961px) { .hw-stack--hide-d { display: none; } }

/* ---------- Scroll mode: the stack pins to the screen and scrolling moves the spotlight ----------
   The script adds .is-scroll and sets --hw-run (how much page to scroll through). The slabs shrink, if they
   have to, so the stack and the caption always fit on one screen. --cap-h is the room kept for the caption. */
.hw-stack.is-scroll { --cap-h: 190px;
  --s: min(var(--hw-s, 300px), calc((100 * var(--hw-vh) - var(--hw-pin-top, 16px) - var(--cap-h) - 84px) / (0.94 + 0.5667 * (var(--hw-layers, 4) - 1))));
  --gap: calc(var(--s) * .5667); }
.hw-stack.is-scroll .hw-stack__track::after { content: ""; display: block; height: var(--hw-run, 300vh); }
.hw-stack.is-scroll .hw-stack__body { position: sticky; top: var(--hw-pin-top, 16px); }
.hw-stack.is-scroll .hw-stack__caption { margin-top: 8px; }

/* ---------- Tablet / phone: stack, then caption, then the names ---------- */
@media (max-width: 960px) {
  .hw-stack { --s: var(--hw-s-m, 200px); --gap: var(--hw-gap-m, 112px); }
  /* phones: keep the three hard shadows that give a slab its thickness, drop the wide soft one - a 22px blurred
     drop-shadow per slab, re-drawn whenever a slab moves or dims, is the heaviest paint in this module */
  .hw-stack__slab:not(.hw-stack__slab--outline) {
    filter: drop-shadow(0 var(--t) 0 var(--side)) drop-shadow(0 var(--t) 0 var(--side)) drop-shadow(0 var(--t) 0 var(--side)) brightness(var(--br)); }
  .hw-stack--hide-m { display: none; }
  .hw-stack.is-scroll { --cap-h: 215px;
    --s: min(var(--hw-s-m, 200px), calc((100 * var(--hw-vh) - var(--hw-pin-top, 16px) - var(--cap-h) - 84px) / (0.94 + 0.5667 * (var(--hw-layers, 4) - 1))));
    --gap: calc(var(--s) * .5667); }
  /* name list off on mobile: it stays in the page for screen readers */
  .hw-stack--no-legend-m .hw-stack__legend { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
  .hw-stack__inner { padding: var(--hw-pt-m, 64px) 24px var(--hw-pb-m, 64px); }
  .hw-stack .hw-stack__title { font-size: var(--hw-h-size-m, 30px); }
  .hw-stack__body, .hw-stack--stage-right .hw-stack__body { grid-template-columns: minmax(0, 1fr); }
  .hw-stack__stage, .hw-stack--stage-right .hw-stack__stage { order: 1; margin: 0 auto; }
  .hw-stack__caption { order: 2; margin-top: 10px; }
  .hw-stack__legend { order: 3; padding-top: 26px; }
  .hw-stack__row, .hw-stack--stage-right .hw-stack__row { height: auto; margin-bottom: 20px; text-align: left; }
  .hw-stack--stage-right .hw-stack__chips { justify-content: flex-start; }
  .hw-stack__row::before { display: none; }
  .hw-stack__label { margin-bottom: 8px; }
  .hw-stack__link { display: none; }
  .hw-stack__tile { font-size: var(--hw-tile-size-m, 10.5px); letter-spacing: .02em; }
  /* pinned on a small screen the slabs can get small: the tile text shrinks with them so short names stay on one line */
  .hw-stack.is-scroll .hw-stack__tile { padding: 1px; letter-spacing: 0; font-size: min(var(--hw-tile-size-m, 10.5px), calc(var(--s) * .066)); }
  .hw-stack.is-scroll .hw-stack__plate { gap: 4px; padding: 6px; }
  .hw-stack__plate { gap: 5px; padding: 8px; }
  .hw-stack__tile.is-active { transform: translateZ(calc(var(--hw-lift, 20px) * .7)); }
  .hw-stack__items { padding-top: 16px; }
  .hw-stack__item { grid-template-columns: minmax(0, 1fr); row-gap: 6px; }
  .hw-stack__item-title { font-size: var(--hw-cap-title-m, 20px); }
  .hw-stack__detail { font-size: var(--hw-cap-text-m, 13.5px); line-height: 1.5; }
}
@media (max-width: 480px) { .hw-stack__inner { padding-left: 16px; padding-right: 16px; } }
@media (prefers-reduced-motion: reduce) {
  .hw-stack__slab, .hw-stack__tile, .hw-stack__chip, .hw-stack__item, .hw-stack__label { transition: none; }
  .hw-stack__rail::before { animation: none; }
}
@media (forced-colors: active) {
  .hw-stack__tile, .hw-stack__chip { border: 1px solid CanvasText; }
  .hw-stack__tile.is-active, .hw-stack__chip.is-active { outline: 2px solid Highlight; }
}
@media print {
  .hw-stack__caption { display: none; }
  .hw-stack.has-active .hw-stack__slab { --br: 1; }
}
