/* ==========================================================================
   Featured card (shared)
   The video card used on the homepage Featured Projects list AND as the hero on each
   case study page: rest color, backdrop graphic, animated screen, inner shadow.
   Loaded by index.html and the case study pages. Homepage-only parts (cutout, lift,
   hover, caption) live in styles.css.

   Figma values are unitless px on the 1200px-wide card frame; art/backdrop positions
   are turned into container-relative lengths with calc(N / var(--card-w) * 100cqw), so
   the card keeps its 1200:494 ratio and everything scales with it.
   ========================================================================== */
.project__cell {
    --card-w: 1200;
    --card-h: 494;
    /* 36px at the desktop card width (~968px), scaling down in proportion as the card
       shrinks. cqw resolves against .project__cell where it's used. Card, media AND
       cutout share this, so they always match. */
    --card-radius: min(36px, calc(36 / 968 * 100cqw));
    --card-fill: #EBF1FF;         /* media rest color */
    /* The hovered homepage card and the case study hero use this. Kept at the rest color so
       the card stays light blue throughout; it used to lift to white (#ffffff). */
    --card-fill-lifted: var(--card-fill);
    --card-inner-shadow: 0 0 12px rgba(0, 0, 0, 0.15);
    --cutout-blue: #056AE0;       /* same blue as the hero */

    /* Drop shadow on the animated screen (Figma: X 0, Y 4, blur 12, spread 0, #000 15%) */
    --art-shadow-y: 4;
    --art-shadow-blur: 12;
    --art-shadow-color: rgba(0, 0, 0, 0.15);

    --hover-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --hover-duration: 0.45s;
    --tilt-perspective: 1100px;

    position: relative;
    container-type: inline-size;
    aspect-ratio: var(--card-w) / var(--card-h);
    perspective: var(--tilt-perspective);
}

/* Media layer: rest color, backdrop, video, inner-shadow overlay */
.project__media {
    /* Art position in Figma px (opaque cards: 920x518 art at x=140, y=32) */
    --art-left: 140;
    --art-top: 32;
    --art-width: 920;
    --art-ratio: 920 / 518;
    --art-radius: 4;

    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: var(--card-radius);
    background: var(--card-fill);
    transition: background-color var(--hover-duration) var(--hover-ease);
}

/* Inner shadow sits above the video so the art can't cover it. Eases out on hover. */
.project__media::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    border-radius: inherit;
    box-shadow: inset var(--card-inner-shadow);
    pointer-events: none;
    transition: box-shadow var(--hover-duration) var(--hover-ease);
}

.project__art {
    position: absolute;
    z-index: 2;
    left: calc(var(--art-left) / var(--card-w) * 100cqw);
    top: calc(var(--art-top) / var(--card-w) * 100cqw);
    width: calc(var(--art-width) / var(--card-w) * 100cqw);
    height: auto;
    aspect-ratio: var(--art-ratio);
    border-radius: calc(var(--art-radius) / var(--card-w) * 100cqw);
    object-fit: cover;
    display: block;
    box-shadow:
        0
        calc(var(--art-shadow-y) / var(--card-w) * 100cqw)
        calc(var(--art-shadow-blur) / var(--card-w) * 100cqw)
        var(--art-shadow-color);
}

/* Backdrop graphics: SVGs exported from Figma at 1:1 on the 1200px card frame, behind
   the video (z 1 vs 2). Position and width are Figma px; tune per card here. */
/* .project__cell prefix raises specificity above the case study pages' own
   `.hero-image img` rule (full width, radius, drop shadow), which would otherwise
   stretch the backdrop and give it a shadow of its own. */
.project__cell .project__backdrop {
    position: absolute;
    z-index: 1;
    left: calc(var(--bg-left) / var(--card-w) * 100cqw);
    top: calc(var(--bg-top) / var(--card-w) * 100cqw);
    width: calc(var(--bg-width) / var(--card-w) * 100cqw);
    height: auto;
    border-radius: 0;
    box-shadow: none;
    pointer-events: none;
    user-select: none;
}

.project__backdrop--gates     { --bg-left: 171; --bg-top: 0;  --bg-width: 1029; }
.project__backdrop--ai        { --bg-left: 43;  --bg-top: 72; --bg-width: 1113; }
.project__backdrop--cultural  { --bg-left: 0;   --bg-top: 0;  --bg-width: 912; }
.project__backdrop--minigames { --bg-left: 40;  --bg-top: 50; --bg-width: 1132; }

/* Gates: transparent art, wider. Figma: 1162.5px wide, centered (x = 18.75), flush to
   the top; the video's native height overflows the card bottom. Its drop shadow is
   baked into the transparent WebM, so none here. */
.project--wide .project__media {
    --art-width: 1162.5;
    --art-left: 18.75;
    --art-top: 0;
    --art-ratio: 2326 / 1048;
    --art-radius: 0;
}

.project--wide .project__art {
    box-shadow: none;
}

/* Case study hero: same card and same corner radius as the homepage thumbnails (the
   --card-radius token above), but with the case study pages' existing drop shadow
   instead of the inner shadow. */
.project__cell--hero .project__media {
    box-shadow: 0 8px 32px rgba(0, 10, 20, 0.15);
    /* Lands in the hovered-card state: the homepage card is white (lifted) when clicked. */
    background-color: var(--card-fill-lifted);
}

.project__cell--hero .project__media::after {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .project__media,
    .project__media::after {
        transition: none;
    }
}

/* ==========================================================================
   PAGE TRANSITION: homepage card → case study (page-transition.js)
   Implied motion, not a literal flight: the clicked card presses down, the page changes,
   and the case study's hero image arrives lifted and settles straight down into place.
   Only card clicks animate (page-transition.js sets html.cs-arrive).
   Reduced motion: no settle — the page just changes.
   Tuning: the hero's start offset/scale in pt-settle, and the durations below.
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {
    /* No cross-page fade: the case study replaces the homepage directly, so the settle is
       what shows the card landing. It starts on the first frame (the card is drawn lifted
       from the very first paint, then drops) with a quick, decisive ease-out, like a card
       being set down. When a fade covered the first ~0.24s, this waited 0.1s and eased in
       gently so the travel wasn't hidden; without it, that wait read as a stall. */
    html.cs-arrive .project__cell--hero .project__media {
        animation: pt-settle 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
    }

    /* Everything below follows a beat behind, so the image clearly leads. */
    html.cs-arrive .project-container,
    html.cs-arrive .project-footer {
        animation: pt-rise 0.45s cubic-bezier(0.22, 1, 0.36, 1) 0.12s both;
    }
}

/* From a lifted pose (higher, a touch larger, a deeper shadow) down to rest. */
@keyframes pt-settle {
    from {
        transform: translateY(-14px) scale(1.01);
        box-shadow: 0 22px 44px rgba(0, 10, 20, 0.2);
    }
}

@keyframes pt-rise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
}
