/* =====================================================================
   Hero photo deck.
   Structure:  figure.hx-card  >  .hx-inner  >  .hx-front (photo) + .hx-back (details)
   - .hx-card   : position in the fan (data-pos), tilt toward the cursor
   - .hx-inner  : the 3D flip (rotateY 180°) when the top card is clicked
   - choosing a card behind (.is-pulling): it slides out from under the cards in front, then settles on top
   ===================================================================== */
.hx-deck{perspective:none}

.hx-card{
    --x:0px;--y:0px;--r:0deg;
    position:absolute;inset:0;margin:0;cursor:pointer;
    perspective:1300px;
    transform:perspective(1100px) translate(var(--x),var(--y)) rotate(var(--r)) rotateX(var(--rx,0deg)) rotateY(var(--ry,0deg));
    transform-origin:50% 100%;
    transition:transform .6s cubic-bezier(.22,1.1,.36,1),filter .45s,opacity .35s;
    will-change:transform;
}
.hx-card.is-tilting{transition:transform .12s ease-out,filter .45s}
.hx-card:focus-visible{outline:3px solid var(--brand-deep-green);outline-offset:4px;border-radius:30px}

/* the fan: each card sits a little lower, turned a little more, and darker than the one above */
/* works for any number of cards: --p is the card's place (0 = top), --n the number of cards in the deck.
   The steps shrink as the deck grows, so eight cards still fit in the same room as four. */
.hx-deck{--n:1}
.hx-card{
    --p:0;
    --sx:min(18,72 / max(var(--n) - 1,1));
    --sy:min(12,80 / max(var(--n) - 1,1));
    --sr:min(4,16 / max(var(--n) - 1,1));
    --sd:min(.1,.45 / max(var(--n) - 1,1));
    --x:calc(var(--p) * var(--sx) * -1px);
    --y:calc(var(--p) * var(--sy) * 1px);
    --r:calc(var(--p) * var(--sr) * -1deg);
    z-index:calc(20 - var(--p));
}
.hx-card:not([data-pos="0"]){filter:brightness(calc(1 - var(--p) * var(--sd)))}

/* ---- the flip ---- */
.hx-inner{position:absolute;inset:0;transform-style:preserve-3d;transition:transform .85s cubic-bezier(.3,.85,.3,1)}
.hx-card.is-flipped .hx-inner{transform:rotateY(180deg)}
.hx-face{
    position:absolute;inset:0;overflow:hidden;
    padding:9px;border-radius:30px;background:var(--brand-off-white);
    border:1px solid color-mix(in srgb,var(--brand-charcoal) 10%,transparent);
    box-shadow:0 24px 50px rgba(32,37,34,.22);
    -webkit-backface-visibility:hidden;backface-visibility:hidden;
    transition:box-shadow .45s;
}
.hx-card[data-pos="0"]:hover .hx-face{box-shadow:0 32px 64px rgba(32,37,34,.3)}
.hx-back{transform:rotateY(180deg)}

/* front: photo, dark gradient for legibility, glass caption, flip hint */
.hx-front img{display:block;width:100%;height:100%;object-fit:cover;border-radius:22px;-webkit-user-drag:none;user-select:none}
.hx-front::after{
    content:"";position:absolute;inset:9px;border-radius:22px;pointer-events:none;
    background:linear-gradient(to top,color-mix(in srgb,var(--brand-charcoal) 78%,transparent),transparent 46%);
    transition:opacity .35s ease .28s;
}
.hx-front figcaption{
    position:absolute;z-index:1;inset-inline:26px;bottom:24px;padding:12px 16px;border-radius:14px;
    background:color-mix(in srgb,var(--brand-charcoal) 55%,transparent);
    -webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);
    border:1px solid color-mix(in srgb,var(--brand-off-white) 16%,transparent);
    font-size:13.5px;line-height:1.8;color:var(--brand-off-white);
    transition:opacity .35s ease .28s;
}
.hx-flip-hint{
    position:absolute;z-index:1;top:22px;inset-inline-end:22px;display:inline-flex;align-items:center;gap:7px;
    padding:7px 13px 7px 11px;border-radius:999px;font-size:12.5px;font-weight:700;color:var(--brand-off-white);
    background:color-mix(in srgb,var(--brand-charcoal) 50%,transparent);
    -webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);
    border:1px solid color-mix(in srgb,var(--brand-off-white) 22%,transparent);
    opacity:0;transform:translateY(-4px);transition:opacity .3s,transform .3s;
}
.hx-flip-hint svg{width:15px;height:15px;fill:none;stroke:currentColor;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round}
.hx-card[data-pos="0"]:hover .hx-flip-hint,.hx-card[data-pos="0"]:focus-visible .hx-flip-hint{opacity:1;transform:none}

/* cards behind show only their photo (caption and hint appear when they arrive on top) */
.hx-card:not([data-pos="0"]) .hx-front::after,
.hx-card:not([data-pos="0"]) .hx-front figcaption,
.hx-card:not([data-pos="0"]) .hx-flip-hint{opacity:0;transition-delay:0s}

/* back: the details */
.hx-back{
    display:flex;flex-direction:column;gap:13px;padding:30px 30px 26px;
    background:
        radial-gradient(70% 60% at 100% 0%,color-mix(in srgb,var(--brand-light-green) 22%,transparent),transparent 70%),
        linear-gradient(165deg,var(--brand-off-white),var(--brand-soft-green));
}
.hx-back::before{ /* the brand device, quiet, in the bottom corner */
    content:"";position:absolute;pointer-events:none;left:-30px;bottom:-14px;width:78%;aspect-ratio:556/240;
    background:url("brand-device.png") no-repeat center/contain;opacity:.16;
}
.hx-back>*{position:relative;z-index:1}
.hx-back-eyebrow{
    display:inline-flex;align-items:center;gap:8px;align-self:flex-start;
    font-size:12px;font-weight:700;letter-spacing:.04em;color:var(--brand-deep-green);
}
.hx-back-eyebrow::before{content:"";width:14px;height:14px;background:var(--leaf) center/contain no-repeat}
.hx-back h3{margin:0;font-size:clamp(19px,2vw,23px);line-height:1.5;font-weight:700;color:var(--brand-charcoal);text-wrap:balance}
.hx-back-meta{display:flex;flex-wrap:wrap;gap:8px}
.hx-back-meta span{
    padding:5px 13px;border-radius:999px;font-size:12.5px;color:var(--brand-deep-green);
    background:color-mix(in srgb,var(--brand-deep-green) 9%,var(--brand-off-white));
    border:1px solid color-mix(in srgb,var(--brand-deep-green) 16%,transparent);
}
.hx-back p{
    margin:0;font-size:14px;line-height:1.95;font-weight:300;color:color-mix(in srgb,var(--brand-charcoal) 80%,var(--brand-off-white));
    display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;line-clamp:3;overflow:hidden;
}
.hx-back-cta{
    align-self:flex-start;display:inline-flex;align-items:center;gap:9px;min-height:44px;padding:0 22px;border-radius:999px;
    background:var(--brand-deep-green);color:var(--brand-off-white);font-size:14px;font-weight:700;text-decoration:none;
    transition:background-color .2s,transform .2s;
}
.hx-back-cta svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round;transition:translate .25s}
.hx-back-cta:hover{background:color-mix(in srgb,var(--brand-deep-green) 82%,var(--brand-charcoal));transform:translateY(-2px)}
.hx-back-cta:hover svg{translate:-4px 0}
.hx-back-cta:focus-visible{outline:3px solid var(--brand-light-green);outline-offset:3px}

/* while the top card shows its details, the fan gathers neatly behind it (this also frees the left side) */
.hx-visual.is-flipped .hx-card{
    --x:calc(var(--p) * min(5,32 / max(var(--n) - 1,1)) * -1px);
    --y:calc(var(--p) * min(7,44 / max(var(--n) - 1,1)) * 1px);
    --r:calc(var(--p) * min(1,6 / max(var(--n) - 1,1)) * -1deg);
}

/* ---- picking a card from behind ---- */
/* step 1: the chosen card slides out from under the cards in front of it (its z-index is still its own) */
.hx-card.is-pulling{
    transform:perspective(1100px) translate(calc(var(--x) - 74px),calc(var(--y) - 30px)) rotate(calc(var(--r) - 3deg));
    filter:brightness(1);
    transition:transform .32s cubic-bezier(.3,.7,.3,1),filter .32s;
}
.hx-card.is-pulling .hx-front::after,.hx-card.is-pulling .hx-front figcaption{opacity:0}
/* a quiet cue on the cards behind: they step forward a little */
.hx-card:not([data-pos="0"]){transition:transform .6s cubic-bezier(.22,1.1,.36,1),translate .3s ease,filter .45s,opacity .35s}
.hx-card:not([data-pos="0"]):hover{translate:-12px -10px;filter:brightness(1.04)}

@media (max-width:980px){
    .hx-card{--sx:min(10,64 / max(var(--n) - 1,1));--sy:min(8,48 / max(var(--n) - 1,1))}
}
@media (max-width:560px){
    .hx-back-meta span{font-size:11.5px;padding:4px 10px}
    .hx-back-cta{min-height:40px;padding:0 18px;font-size:13px}
    .hx-flip-hint{opacity:1;transform:none;top:16px;inset-inline-end:16px}
    .hx-card:not([data-pos="0"]) .hx-flip-hint{opacity:0}
}
/* touch devices have no hover: keep the hint visible on the top card */
@media (hover:none){.hx-card[data-pos="0"] .hx-flip-hint{opacity:1;transform:none}}

@media (prefers-reduced-motion:reduce){
    .hx-inner{transition-duration:.01ms}
}
@media print{.hx-back{display:none}}


/* =====================================================================
   Card back – the whole face is used: head (eyebrow + client), title, tags, summary,
   three headline figures, scope list, and a footer row with the button.
   ===================================================================== */
.hx-back{gap:12px;padding:28px 30px 24px}
.hx-back-head{display:flex;align-items:center;justify-content:space-between;gap:10px}
.hx-back-badge{
    padding:4px 13px;border-radius:999px;font-size:12px;font-weight:700;color:var(--brand-charcoal);
    background:color-mix(in srgb,var(--brand-light-green) 45%,var(--brand-off-white));
}
.hx-back h3{font-size:clamp(18px,1.9vw,22px)}

.hx-back-metrics{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-top:2px}
.hx-back-metrics>div{
    display:flex;flex-direction:column;gap:2px;padding:12px 14px;border-radius:16px;
    background:color-mix(in srgb,var(--brand-off-white) 80%,transparent);
    border:1px solid color-mix(in srgb,var(--brand-deep-green) 14%,transparent);
}
.hx-back-metrics strong{font-size:clamp(20px,2.1vw,25px);line-height:1.15;font-weight:700;color:var(--brand-deep-green);text-align:start}
.hx-back-metrics span{font-size:12.5px;line-height:1.4;color:var(--brand-grey)}

.hx-back-scope{list-style:none;margin:2px 0 0;padding:0;display:grid;gap:8px}
.hx-back-scope li{
    position:relative;padding-inline-start:22px;font-size:13.5px;line-height:1.65;color:color-mix(in srgb,var(--brand-charcoal) 84%,var(--brand-off-white));
    display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;overflow:hidden;
}
.hx-back-scope li::before{
    content:"";position:absolute;inset-inline-start:0;top:6px;width:12px;height:12px;background:var(--leaf) center/contain no-repeat;
}

.hx-back-foot{margin-top:auto;display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.hx-back-hint{font-size:12px;color:var(--brand-grey)}

/* smaller faces keep the essentials: tablet drops the scope list, phone also drops the figures */
@media (max-width:980px){
    .hx-back{padding:20px 22px 18px;gap:9px}
    .hx-back-scope{display:none}
    .hx-back p{-webkit-line-clamp:3;line-clamp:3}
}
@media (max-width:560px){
    .hx-back{padding:16px 18px 14px;gap:7px}
    .hx-back h3{font-size:16px;line-height:1.45}
    .hx-back-metrics{display:none}
    .hx-back p{-webkit-line-clamp:2;line-clamp:2;font-size:13px;line-height:1.7}
    .hx-back-hint{display:none}
}

/* =====================================================================
   Credential cards "sink" while a card shows its details (desktop: they float over the deck).
   Like something slipping under water: it recedes behind the deck, shrinks, dims and softens, a ripple
   spreads from it, and then it drifts slowly. Flipping back lifts it to the surface again.
   ===================================================================== */
@media (min-width:981px){
    .hx-chip--cred{
        filter:blur(0);
        transition:opacity .9s ease,translate 1.1s cubic-bezier(.3,.7,.25,1),scale 1.1s cubic-bezier(.3,.7,.25,1),filter .9s ease,z-index 0s;
    }
    /* the ripple rings (idle until the card sinks or surfaces) */
    .hx-chip--cred::before,.hx-chip--cred::after{
        content:"";position:absolute;inset:-4px;border-radius:24px;pointer-events:none;opacity:0;
        border:1.5px solid color-mix(in srgb,var(--brand-green) 55%,transparent);
    }

    .hx-visual.is-flipped .hx-chip--cred{
        z-index:0;                 /* behind the cards */
        pointer-events:none;
        opacity:.66;
        scale:.84;
        filter:blur(2px) saturate(.9);
    }
    /* each card leaves through the nearest free edge, so none of them ends up under the fan or over the text:
       the two on the text side slide out to the right, the two on the left slide out to the left (measured by hero.js) */
    .hx-visual.is-flipped .hx-chip-1{translate:clamp(44px,4.5vw,66px) 6px}
    .hx-visual.is-flipped .hx-chip-3{translate:clamp(44px,4.5vw,66px) -10px}
    .hx-visual.is-flipped .hx-chip-2,
    .hx-visual.is-flipped .hx-chip-4{translate:var(--sx,-60px) var(--sy,0px)} /* x set by hero.js from the real geometry; y stays */
}

@media (min-width:981px) and (prefers-reduced-motion:no-preference){
    /* two rings, one after the other, spread outward as the card goes under */
    .hx-visual.is-flipped .hx-chip--cred::before{animation:hxRipple 1.7s ease-out .05s 1 both}
    .hx-visual.is-flipped .hx-chip--cred::after{animation:hxRipple 1.7s ease-out .5s 1 both}
    /* under water it no longer bobs like a float: it sways slowly instead */
    .hx-visual.is-flipped .hx-chip--cred{animation:hxSway 7s ease-in-out 1.2s infinite}
    .hx-visual.is-flipped .hx-chip-2{animation-delay:2s}
    .hx-visual.is-flipped .hx-chip-3{animation-delay:2.8s}
    .hx-visual.is-flipped .hx-chip-4{animation-delay:3.6s}
}
@keyframes hxRipple{
    0%{opacity:.75;transform:scale(.96)}
    100%{opacity:0;transform:scale(1.5)}
}
@keyframes hxSway{
    0%,100%{transform:translate(0,0) rotate(0)}
    50%{transform:translate(0,6px) rotate(.8deg)}
}

/* ---- slider with no project switched on: a quiet brand card keeps the composition ---- */
.hx-empty{
    position:relative;display:grid;place-items:center;aspect-ratio:5/5.5;width:min(100%,520px);margin-inline:auto;
    border-radius:30px;background:var(--brand-off-white);
    border:1px solid color-mix(in srgb,var(--brand-charcoal) 10%,transparent);
    box-shadow:0 24px 50px rgba(32,37,34,.18);overflow:hidden;
}
.hx-empty::before{
    content:"";position:absolute;inset:auto auto -10% -10%;width:78%;aspect-ratio:556/240;pointer-events:none;
    background:url("brand-device.png") no-repeat center/contain;opacity:.22;
}
.hx-empty img{position:relative;display:block;width:min(46%,210px);height:auto}
@media (max-width:980px){.hx-empty{aspect-ratio:5/4;width:min(100%,560px)}.hx-empty img{width:min(34%,150px)}}

/* a project without a picture: the plain brand background (deep green, light accent, the white logo) */
.hx-plain{
    position:relative;width:100%;height:100%;border-radius:22px;overflow:hidden;
    display:grid;place-items:center;
    background:radial-gradient(120% 90% at 85% 10%,var(--brand-green) 0,transparent 55%),linear-gradient(160deg,var(--brand-deep-green),color-mix(in srgb,var(--brand-deep-green) 55%,var(--brand-charcoal)));
}
.hx-plain img{width:min(46%,170px);height:auto;opacity:.95}
