/* ==========================================================================
   Word Pile module — Services & Skills
   ========================================================================== */

/* Futura LT ExtraBold.
   Targeted by its full/PostScript name: the file reports weight 700, so asking for
   "Futura LT" at 800 silently lands on a narrower style. local() uses the installed
   desktop font; for production, add your licensed webfont after the local() sources:
     url('fonts/futura-lt-extrabold.woff2') format('woff2')
   A private family name keeps other "Futura LT" weights on the site untouched. */
@font-face {
  font-family: 'WP Futura ExtraBold';
  src: local('Futura LT Extra Bold'), local('FuturaLT-ExtraBold');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

.wp {
  --wp-bg: #181918;
  --wp-cream: #fefaef;
  --wp-accent: var(--accent, #ff3400);
  /* Jost 900 is the closest free fallback in weight and width */
  --wp-font: 'WP Futura ExtraBold', 'Jost', 'Century Gothic', system-ui, sans-serif;
  /* Sizes scale with the 1920 × 1130 design frame */

  /* How far down the module the copy sits, measured from its top edge in
     viewport units. One number, read twice: by --wp-title-anchor below (where
     the eyebrow, title and shake button hang) and by --wp-height (the module
     is that same distance plus the room under the copy). They have to move
     together — raising the copy without shortening the module leaves a hole
     at the bottom, shortening the module without raising the copy buries the
     title under the pile. */
  --wp-copy-line: 38vh;

  /* The copy line plus the room the pile needs under it. That second term is
     deliberately a little short of a settled pile's height: the top of the
     pile reaches the shake button and the foot of the title and laps over
     them, the way a pile of things would. */
  --wp-height: calc(var(--wp-copy-line) + 32rem);
  --wp-floor: clamp(0.75rem, 1.04vw, 1.5rem);
  --wp-wall: clamp(0.75rem, 1.04vw, 1.5rem);
  --wp-pill-size: max(1.096875rem, 1.4625vw); /* 28.1px @ 1920 */
  --wp-title-size: max(2.5rem, 6.25vw); /* 120px @ 1920 */
  /* Centre line of the title block. The eyebrow above and the shake button
     below hang off it, so moving the heading means moving only this. */
  /* The copy line again, plus whatever js/main.js is holding. It grows that
     hold by exactly what the page scrolls, which keeps the copy still on the
     screen for a stretch, then eases it back to zero so the copy rides up to
     its own place again. The eyebrow and the shake button hang off this
     anchor too, so the three move as one block. */
  --wp-copy-hold: 0px;
  --wp-title-anchor: calc(var(--wp-copy-line) + var(--wp-copy-hold));
  --wp-stroke: max(1px, 0.078vw); /* 1.5px @ 1920 */
  --wp-smiley-size: max(6rem, 8.85vw); /* 170px @ 1920 */
  --wp-star-size: max(4.5rem, 8.28vw); /* 159px @ 1920 */

  position: relative;
  isolation: isolate;
  overflow: clip;
  /* No field of its own: the page's background runs behind this section like
     every other, so the dark-to-orange change is one global colour rather than
     a module repainting its own box. (--wp-bg is still the dark the filled
     pills and the shake button's hover state draw their text in.) */
  background: transparent;
  color: var(--wp-cream);
  font-family: var(--wp-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.wp *,
.wp *::before,
.wp *::after {
  box-sizing: border-box;
}

/* ---- UI overlay ---------------------------------------------------------- */

.wp__ui {
  position: absolute;
  inset: 0 0 auto;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(0.9rem, 3vh, 1.4rem) var(--wp-wall);
  pointer-events: none;
}

.wp__cue {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: rgba(254, 250, 239, 0.5);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.wp__cue strong {
  color: var(--wp-cream);
  font-weight: 800;
}

.wp__dot {
  width: 0.45rem;
  height: 0.45rem;
  flex: none;
  border-radius: 50%;
  background: var(--wp-accent);
  animation: wp-pulse 2.4s ease-in-out infinite;
}

@keyframes wp-pulse {
  50% {
    transform: scale(0.6);
    opacity: 0.6;
  }
}

.wp__shake {
  pointer-events: auto;
  padding: 0.8em 1.45em 0.72em;
  border: 1.5px solid var(--wp-cream);
  border-radius: 999px;
  background: transparent;
  color: var(--wp-cream);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
    background 0.25s ease,
    color 0.25s ease;
}

.wp__shake:hover,
.wp__shake:focus-visible {
  background: var(--wp-cream);
  color: var(--wp-bg);
  transform: translateY(-2px);
}

.wp__shake:focus-visible {
  outline: 2px solid var(--wp-accent);
  outline-offset: 3px;
}

.wp__shake:active {
  transform: translateY(1px);
}

/* ---- Stage --------------------------------------------------------------- */

.wp__stage {
  position: relative;
  height: var(--wp-height);
  min-height: 40rem;
  /* left/right padding doubles as the physics side walls */
  padding: clamp(3.6rem, 11vh, 5rem) var(--wp-wall) calc(var(--wp-floor) + 1rem);
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 0.75rem 1rem;
  overflow: clip;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y; /* page can still scroll on touch; pills opt out below */
}

/* Eyebrow: parked above the title the way the shake button is parked below
   it — off the same anchor, so the three move together. The title's box is
   .9em either side of 44.8% (two lines at line-height .9). */
.wp__eyebrow {
  position: absolute;
  top: calc(var(--wp-title-anchor) - 0.9 * var(--wp-title-size) - 0.9rem);
  left: var(--wp-wall);
  right: var(--wp-wall);
  z-index: 0;
  margin: 0;
  transform: translateY(-100%);
  color: var(--wp-cream);
  font-family: "Instrument Sans", system-ui, sans-serif;
  font-size: clamp(11px, 0.95vw, 15px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.14em;
  text-align: center;
  text-transform: uppercase;
  opacity: 0.62;
  pointer-events: none;
}

.wp__title {
  position: absolute;
  top: var(--wp-title-anchor);
  left: var(--wp-wall);
  right: var(--wp-wall);
  z-index: 0;
  margin: 0;
  transform: translateY(-50%);
  color: var(--wp-accent);
  font-family: var(--wp-font);
  font-size: var(--wp-title-size);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: -0.04em;
  text-align: center;
  text-transform: uppercase;
  text-wrap: balance;
  pointer-events: none;
}

/* Invisible physics floor */
.wp__floor {
  position: absolute;
  inset: auto 0 0;
  height: var(--wp-floor);
  pointer-events: none;
}

/* ---- Pills --------------------------------------------------------------- */

.wp-chip {
  --wp-flash: rgba(254, 250, 239, 0.28);

  appearance: none;
  position: relative;
  display: inline-block;
  margin: 0;
  /* No overflow clipping: the label flips in 3D when a pill rights itself */
  /* Measured from the reference @ 22px: 61px single-line / ~84px two-line, 40px sides */
  padding: 0.818em 1.828em;
  border: var(--wp-stroke) solid var(--wp-cream);
  border-radius: 999px;
  background: transparent;
  color: var(--wp-cream);
  font-family: var(--wp-font);
  font-size: var(--wp-pill-size);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: grab;
  touch-action: none;
  -webkit-user-drag: none;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}

.wp-chip[data-tone='fill'] {
  --wp-flash: rgba(255, 52, 0, 0.22);
  background: var(--wp-cream);
  color: var(--wp-bg);
  text-align: center;
}

/* The third tone: solid dark with cream type. Reads as a hole in the pile on
   the orange field, and keeps its weight on the dark one too. */
.wp-chip[data-tone='ink'] {
  --wp-flash: rgba(254, 250, 239, 0.22);
  border-color: var(--wp-bg);
  background: var(--wp-bg);
  color: var(--wp-cream);
  text-align: center;
}

.wp[data-state='live'] .wp-chip,
.wp[data-state='live'] .wp-smiley,
.wp[data-state='live'] .wp-star {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
}

.wp[data-grabbing] .wp-chip,
.wp[data-grabbing] .wp-smiley,
.wp[data-grabbing] .wp-star {
  cursor: grabbing;
}

/* ---- Smiley sprite (12 frames, 6 × 2 sheet; JS sets background-position) -- */

.wp-smiley {
  appearance: none;
  position: relative;
  display: inline-block;
  width: var(--wp-smiley-size);
  height: var(--wp-smiley-size);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  /* Bump ?v= whenever the sprite file changes, so browsers don't keep a stale copy */
  background: url('../assets/smiley-sprite.webp?v=1') 0 0 / 600% 200% no-repeat;
  cursor: grab;
  touch-action: none;
  -webkit-user-drag: none;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}

.wp-smiley:focus-visible {
  outline: 2px solid var(--wp-accent);
  outline-offset: 4px;
}

/* ---- Star (tap to leap and spin) ----------------------------------------- */

.wp-star {
  appearance: none;
  position: relative;
  display: block;
  width: var(--wp-star-size);
  height: var(--wp-star-size);
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: grab;
  touch-action: none;
  -webkit-user-drag: none;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}

/* The mark itself, on a layer of its own. The artwork is a 3D render in the
   accent, which is the colour of the field it sits on, so it is painted
   through as a flat dark silhouette instead. Its own slow turn lives here
   rather than on the button, whose transform the physics writes every frame.
   Bump ?v= whenever the artwork changes, so browsers don't keep a stale copy */
.wp-star::before {
  content: '';
  position: absolute;
  inset: 0;
  background-color: var(--dark, #151515);
  -webkit-mask: url('../assets/star.webp?v=1') center / contain no-repeat;
  mask: url('../assets/star.webp?v=1') center / contain no-repeat;
  animation: wp-star-turn 26s linear infinite;
}

@keyframes wp-star-turn {
  to {
    transform: rotate(360deg);
  }
}

.wp-star:focus-visible {
  outline: 2px solid var(--wp-cream);
  outline-offset: 4px;
}

.wp-chip__label {
  position: relative;
  z-index: 1;
  display: block;
  pointer-events: none;
}

.wp-chip__flash {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background: var(--wp-flash);
  opacity: 0;
  pointer-events: none;
}

.wp-chip:focus-visible {
  outline: 2px solid var(--wp-accent);
  outline-offset: 4px;
}

/* Impact ring (created by JS) */
.wp-shock {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 0;
  width: 8rem;
  height: 8rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 52, 0, 0.35) 0%, rgba(255, 52, 0, 0.12) 45%, transparent 68%);
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
}

/* ---- Small screens ------------------------------------------------------- */

@media (max-width: 640px) {
  .wp {
    /* The frame ratio would be too short for a phone-sized pile */
    --wp-height: max(34rem, 100svh);
    --wp-pill-size: 1.096875rem;
    --wp-title-size: 11.5vw;
    /* The pile stands taller on narrow screens: lift the title clear of it */
    --wp-title-anchor: 22%;
  }

  .wp__cue > span:not(.wp__dot) {
    display: none;
  }


  .wp-shock {
    width: 5.5rem;
    height: 5.5rem;
  }
}

/* ---- Reduced motion: static layout --------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .wp__shake,
  .wp__cue {
    display: none;
  }

  .wp-star::before {
    animation: none;
  }

  .wp__dot {
    animation: none;
  }

  .wp-chip {
    cursor: default;
  }
}
