/* GovThatWorks.org — V60 Housing First 3D Path to Stability Stacker */
:root {
  --hf-navy: var(--home-navy, #0F1E36);
  --hf-teal: var(--home-teal, #0D9488);
  --hf-amber: #D97706;
  --hf-red: #B42318;
  --hf-slate: #F8F9FA;
  --hf-ink: #0F1E36;
  --hf-muted: #526174;
  --hf-border: rgba(15, 30, 54, .14);
  --hf-shadow: 0 22px 64px rgba(15, 30, 54, .10);
}

.hf-stacker,
.hf-stacker * { box-sizing: border-box; }

.hf-stacker {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--hf-border);
  border-radius: 28px;
  background:
    radial-gradient(circle at 80% 0%, rgba(13,148,136,.12), transparent 34%),
    linear-gradient(145deg, #fff 0%, #f8fafc 56%, #eef3f6 100%);
  box-shadow: var(--hf-shadow);
}

.hf-stacker::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(15,30,54,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15,30,54,.025) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, transparent, #000 28%, #000 85%, transparent);
}

.hf-stacker__header {
  position: relative;
  z-index: 2;
  padding: 34px 34px 10px;
  max-width: 860px;
}

.hf-stacker__header h2 {
  margin: 0;
  color: var(--hf-navy);
  font-family: "Source Serif 4", Merriweather, Georgia, serif;
  font-size: clamp(2rem, 4vw, 3.6rem);
  font-weight: 500;
  line-height: 1.03;
  letter-spacing: -.035em;
}

.hf-stacker__header p:last-child {
  margin: 14px 0 0;
  max-width: 760px;
  color: var(--hf-muted);
  line-height: 1.7;
}

.hf-stacker__layout {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(230px, .72fr) minmax(360px, 1.25fr) minmax(250px, .82fr);
  gap: 22px;
  padding: 24px 34px 34px;
}

.hf-panel {
  border: 1px solid var(--hf-border);
  border-radius: 20px;
  background: rgba(255,255,255,.80);
  backdrop-filter: blur(12px);
}

.hf-block-bank { padding: 20px; }

.hf-block-bank h3,
.hf-narrative h3 {
  margin: 0 0 6px;
  color: var(--hf-navy);
  font-size: 1rem;
}

.hf-block-bank > p,
.hf-narrative > p {
  margin: 0;
  color: var(--hf-muted);
  font-size: .8rem;
  line-height: 1.55;
}

.hf-block-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.hf-block {
  --block-color: var(--hf-teal);
  --block-dark: #086f67;
  position: relative;
  width: 100%;
  min-height: 84px;
  padding: 15px 16px 15px 58px;
  border: 1px solid color-mix(in srgb, var(--block-color) 38%, #fff);
  border-radius: 14px;
  background: linear-gradient(145deg, #fff 0%, color-mix(in srgb, var(--block-color) 9%, #fff) 100%);
  box-shadow: 0 10px 20px rgba(15,30,54,.07), 0 4px 0 color-mix(in srgb, var(--block-dark) 34%, #fff);
  color: var(--hf-ink);
  text-align: left;
  cursor: grab;
  transform: translateY(0) rotateX(0) rotateZ(0);
  transform-origin: center bottom;
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease, border-color .2s ease;
}

.hf-block:active { cursor: grabbing; }
.hf-block:hover,
.hf-block:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 16px 28px rgba(15,30,54,.12), 0 7px 0 color-mix(in srgb, var(--block-dark) 38%, #fff);
}
.hf-block:focus-visible { outline: 3px solid rgba(13,148,136,.28); outline-offset: 3px; }

.hf-block::before {
  content: attr(data-order);
  position: absolute;
  left: 14px;
  top: 16px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--block-color);
  color: #fff;
  font-weight: 900;
  box-shadow: inset -3px -3px 0 rgba(0,0,0,.13), 0 5px 10px rgba(15,30,54,.10);
}

.hf-block strong { display: block; font-size: .91rem; line-height: 1.28; }
.hf-block small { display: block; margin-top: 5px; color: var(--hf-muted); font-size: .72rem; line-height: 1.4; }

.hf-block--enforcement { --block-color: var(--hf-red); --block-dark: #7f1d1d; }
.hf-block--treatment { --block-color: var(--hf-amber); --block-dark: #92400e; }
.hf-block--housing { --block-color: var(--hf-teal); --block-dark: #065f58; }

.hf-block.is-placed {
  opacity: .5;
  cursor: default;
  box-shadow: inset 0 0 0 2px rgba(13,148,136,.18);
  transform: none;
}
.hf-block.is-placed::after {
  content: "Placed";
  position: absolute;
  right: 10px;
  top: 10px;
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--hf-navy);
  color: #fff;
  font-size: .59rem;
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.hf-block.is-falling {
  pointer-events: none;
  animation: hf-fall-away .78s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes hf-fall-away {
  0%   { transform: translate3d(0,0,0) rotate(0deg); opacity: 1; }
  15%  { transform: translate3d(-7px,-2px,0) rotate(-4deg); }
  30%  { transform: translate3d(8px,-1px,0) rotate(5deg); }
  46%  { transform: translate3d(-9px,3px,0) rotate(-7deg); }
  62%  { transform: translate3d(10px,9px,0) rotate(9deg); opacity: 1; }
  100% { transform: translate3d(42px,190px,0) rotate(28deg) scale(.86); opacity: 0; }
}

/* 3D stage */
.hf-stage-shell {
  position: relative;
  min-height: 440px;
  overflow: hidden;
  border: 1px solid rgba(15,30,54,.12);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 48%, rgba(13,148,136,.11), transparent 29%),
    linear-gradient(180deg, #f8fafc 0%, #e9eff3 100%);
  perspective: 1050px;
}

.hf-stage-shell.is-dragover {
  box-shadow: inset 0 0 0 3px rgba(13,148,136,.24), 0 0 34px rgba(13,148,136,.14);
}

.hf-stage-caption {
  position: absolute;
  z-index: 6;
  left: 18px;
  top: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.82);
  border: 1px solid rgba(15,30,54,.12);
  color: var(--hf-muted);
  font-size: .68rem;
  font-weight: 750;
  backdrop-filter: blur(8px);
}
.hf-stage-caption::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--hf-teal);
  box-shadow: 0 0 0 5px rgba(13,148,136,.10);
}

.hf-world {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 280px;
  height: 280px;
  transform-style: preserve-3d;
  transform: translate(-50%,-50%) rotateX(60deg) rotateZ(-45deg);
  transition: transform .25s ease;
}
.hf-stage-shell:hover .hf-world {
  transform: translate(-50%,-50%) rotateX(57deg) rotateZ(-43deg) scale(1.015);
}

.hf-platform {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  border: 1px solid rgba(15,30,54,.17);
  border-radius: 18px;
  background:
    linear-gradient(rgba(15,30,54,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15,30,54,.08) 1px, transparent 1px),
    linear-gradient(145deg, #fdfefe 0%, #dfe7ec 100%);
  background-size: 35px 35px, 35px 35px, 100% 100%;
  box-shadow: 22px 26px 36px rgba(15,30,54,.20);
}
.hf-platform::before,
.hf-platform::after {
  content: "";
  position: absolute;
  background: #c6d1d9;
}
.hf-platform::before {
  top: 100%; left: 12px; width: calc(100% - 12px); height: 20px;
  transform-origin: top;
  transform: rotateX(-90deg);
  border-radius: 0 0 10px 10px;
}
.hf-platform::after {
  left: 100%; top: 12px; width: 20px; height: calc(100% - 12px);
  transform-origin: left;
  transform: rotateY(90deg);
  border-radius: 0 10px 10px 0;
  background: #b6c4cd;
}

.hf-foundation-mark {
  position: absolute;
  left: 58px;
  top: 58px;
  width: 164px;
  height: 164px;
  border: 2px dashed rgba(13,148,136,.38);
  border-radius: 18px;
  background: rgba(13,148,136,.035);
  box-shadow: inset 0 0 28px rgba(13,148,136,.04);
}

.hf-cube {
  position: absolute;
  left: 67px;
  top: 78px;
  width: 146px;
  height: 116px;
  border-radius: 13px;
  transform-style: preserve-3d;
  opacity: 0;
  transform: translateZ(-14px) scale(.82);
  transition: opacity .35s ease, transform .6s cubic-bezier(.2,.9,.25,1.15), filter .35s ease;
}
.hf-cube::before,
.hf-cube::after {
  content: "";
  position: absolute;
}
.hf-cube::before {
  left: 100%; top: 8px; width: 22px; height: calc(100% - 8px);
  transform-origin: left;
  transform: rotateY(90deg);
  border-radius: 0 6px 6px 0;
}
.hf-cube::after {
  left: 8px; top: 100%; width: calc(100% - 8px); height: 22px;
  transform-origin: top;
  transform: rotateX(-90deg);
  border-radius: 0 0 6px 6px;
}

.hf-cube--housing { background: linear-gradient(145deg, #20b6aa, var(--hf-teal)); }
.hf-cube--housing::before { background: #066a64; }
.hf-cube--housing::after { background: #08786f; }
.hf-cube--treatment { background: linear-gradient(145deg, #f4aa2a, var(--hf-amber)); }
.hf-cube--treatment::before { background: #9a4f05; }
.hf-cube--treatment::after { background: #b25e08; }

.hf-cube.is-locked-housing {
  opacity: 1;
  transform: translateZ(26px) scale(1);
  filter: drop-shadow(0 10px 9px rgba(15,30,54,.16));
}
.hf-cube.is-locked-treatment {
  opacity: 1;
  transform: translateZ(57px) scale(.92);
  filter: drop-shadow(0 12px 10px rgba(15,30,54,.16));
}

.hf-stage-label {
  position: absolute;
  z-index: 7;
  right: 18px;
  min-width: 160px;
  max-width: 205px;
  padding: 9px 11px;
  border-radius: 11px;
  background: rgba(15,30,54,.92);
  color: #fff;
  box-shadow: 0 10px 24px rgba(15,30,54,.16);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .3s ease, transform .3s ease;
  pointer-events: none;
}
.hf-stage-label strong { display: block; font-size: .73rem; }
.hf-stage-label small { display: block; margin-top: 2px; color: rgba(255,255,255,.68); font-size: .64rem; }
.hf-stage-label--housing { bottom: 72px; }
.hf-stage-label--treatment { bottom: 127px; }
.hf-stage-label.is-visible { opacity: 1; transform: translateY(0); }

.hf-drop-hint {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: calc(100% - 36px);
  text-align: center;
  color: var(--hf-muted);
  font-size: .73rem;
}

.hf-stage-shell.is-success {
  box-shadow: inset 0 0 0 2px rgba(13,148,136,.30), 0 0 42px rgba(13,148,136,.18);
  animation: hf-success-glow 1.45s ease-out 1;
}
@keyframes hf-success-glow {
  0% { box-shadow: inset 0 0 0 2px rgba(13,148,136,.12), 0 0 0 rgba(13,148,136,0); }
  45% { box-shadow: inset 0 0 0 3px rgba(13,148,136,.42), 0 0 60px rgba(13,148,136,.28); }
  100% { box-shadow: inset 0 0 0 2px rgba(13,148,136,.30), 0 0 42px rgba(13,148,136,.18); }
}

/* narrative */
.hf-narrative { padding: 20px; }
.hf-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  margin-bottom: 14px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #edf2f6;
  color: var(--hf-navy);
  font-size: .67rem;
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.hf-status-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}
.hf-status-pill.is-foundation::before { background: var(--hf-teal); }
.hf-status-pill.is-success::before { background: #22c55e; box-shadow: 0 0 0 5px rgba(34,197,94,.10); }

.hf-message {
  min-height: 104px;
  margin-top: 16px;
  padding: 16px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid var(--hf-border);
  color: var(--hf-muted);
  font-size: .82rem;
  line-height: 1.58;
}
.hf-message.is-warning { background: #fff7ed; border-color: rgba(217,119,6,.25); color: #8a4608; }
.hf-message.is-success { background: #ecfdf5; border-color: rgba(13,148,136,.26); color: #075e54; }

.hf-success-copy {
  display: none;
  margin-top: 16px;
  padding: 17px;
  border-left: 3px solid var(--hf-teal);
  border-radius: 0 12px 12px 0;
  background: rgba(13,148,136,.07);
  color: var(--hf-ink);
  font-size: .82rem;
  line-height: 1.62;
}
.hf-success-copy.is-visible { display: block; animation: hf-fade-up .45s ease-out both; }
@keyframes hf-fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.hf-reset {
  width: 100%;
  min-height: 44px;
  margin-top: 16px;
  border: 1px solid var(--hf-border);
  border-radius: 999px;
  background: #fff;
  color: var(--hf-navy);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.hf-reset:hover { background: #f4f7f9; }
.hf-reset:focus-visible { outline: 3px solid rgba(13,148,136,.28); outline-offset: 3px; }

.hf-stacker__note {
  position: relative;
  z-index: 2;
  margin: 0;
  padding: 0 34px 28px;
  color: #70808d;
  font-size: .71rem;
  line-height: 1.55;
}

@media (max-width: 980px) {
  .hf-stacker__layout { grid-template-columns: 1fr 1.35fr; }
  .hf-narrative { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .hf-stacker { border-radius: 20px; }
  .hf-stacker__header { padding: 25px 20px 6px; }
  .hf-stacker__layout { grid-template-columns: 1fr; padding: 18px 20px 24px; }
  .hf-block-bank { order: 1; }
  .hf-stage-shell { order: 2; min-height: 390px; }
  .hf-narrative { order: 3; grid-column: auto; }
  .hf-world { width: 230px; height: 230px; }
  .hf-foundation-mark { left: 47px; top: 47px; width: 136px; height: 136px; }
  .hf-cube { left: 55px; top: 65px; width: 120px; height: 96px; }
  .hf-stage-label { right: 12px; min-width: 135px; max-width: 165px; }
  .hf-stacker__note { padding: 0 20px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .hf-block,
  .hf-world,
  .hf-cube,
  .hf-stage-label { transition: none; }
  .hf-block.is-falling { animation: hf-fall-fade .16s linear both; }
  .hf-stage-shell.is-success { animation: none; }
  .hf-success-copy.is-visible { animation: none; }
  .hf-stage-shell:hover .hf-world { transform: translate(-50%,-50%) rotateX(60deg) rotateZ(-45deg); }
}
@keyframes hf-fall-fade { from { opacity: 1; } to { opacity: .18; } }
