/* ============================================================
   FEATURED PROJECTS — carousel + lightbox
   Scoped to body.site #featured / .featured-lightbox
   ============================================================ */

.band--featured {
    padding: clamp(4rem, 8vw, 7rem) 0 clamp(2.5rem, 5vw, 3.5rem);
}

.featured-shell {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 2rem;
}

.featured-head-ghost {
    position: absolute;
    top: -2.75rem;
    right: 0;
    font-family: var(--mono);
    font-size: clamp(3rem, 7vw, 5.5rem);
    font-weight: 500;
    letter-spacing: 0.06em;
    color: transparent;
    -webkit-text-stroke: 1px rgba(26, 24, 20, 0.3);
    user-select: none;
    pointer-events: none;
    line-height: 1;
}

.featured-head {
    position: relative;
    max-width: 46rem;
}

.band--featured .band-lead {
    margin-top: 0.25rem;
}

/* ---------- Rail ---------- */
.featured-rail-wrap {
    position: relative;
    margin-top: 2.75rem;
}

.featured-rail {
    display: flex;
    gap: 1.25rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-left: clamp(1.5rem, 4vw, 4rem);
    padding: 0.5rem clamp(1.5rem, 4vw, 4rem) 1.5rem;
    scrollbar-width: none;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.featured-rail::-webkit-scrollbar {
    display: none;
}

.featured-card {
    --card-w: clamp(280px, 31vw, 430px);
    flex: 0 0 var(--card-w);
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    text-align: left;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 10px;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    font: inherit;
    color: inherit;
    transition: border-color 0.25s, transform 0.25s, box-shadow 0.25s;
    -webkit-tap-highlight-color: transparent;
}

.featured-card:hover,
.featured-card:focus-visible {
    border-color: var(--brass);
    transform: translateY(-4px);
    box-shadow: 0 14px 34px rgba(26, 24, 20, 0.18);
    outline: none;
}

/* One-time staggered entrance (set by JS via IntersectionObserver). The crop
   marks draw in from the center — the card arrives like a drawing being
   plotted onto the bench, not just fading up. */
.featured-card {
    opacity: 0;
    transform: translateY(26px) scale(0.985);
}

@keyframes fb-crop-in {
    from { inset: 50%; opacity: 0; }
    to   { inset: 10px; opacity: 0.5; }
}

.featured-card.is-in {
    opacity: 1;
    transform: translateY(0) scale(1);
    transition:
        opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.6s cubic-bezier(0.22, 1, 0.36, 1),
        border-color 0.25s,
        box-shadow 0.25s;
}

/* Crop marks draw in on entrance, in step with the stagger */
.featured-card-media::before {
    animation: none;
}
.featured-card.is-in .featured-card-media::before {
    animation: fb-crop-in 0.5s 0.15s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* After the entrance settles, restore the snappy hover transition */
.featured-card.is-settled {
    transition: border-color 0.25s, transform 0.25s, box-shadow 0.25s;
}

@media (prefers-reduced-motion: reduce) {
    .featured-card {
        opacity: 1;
        transform: none;
    }
    .featured-card.is-in .featured-card-media::before {
        animation: none;
        inset: 10px;
        opacity: 0.5;
    }
}

.featured-card-media {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #0b0d12;
    overflow: hidden;
}

.featured-card-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.featured-card:hover .featured-card-media img {
    transform: scale(1.045);
}

.featured-card-media::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 55%, rgba(10, 11, 16, 0.55));
    pointer-events: none;
}

/* Blueprint grid on hover — workshop-drawing language in the system's own
   ink/brass, not a cyan SaaS-portfolio effect */
.featured-card-media .featured-card-grid {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.35s ease;
    background-image:
        linear-gradient(rgba(154, 74, 8, 0.22) 1px, transparent 1px),
        linear-gradient(90deg, rgba(154, 74, 8, 0.22) 1px, transparent 1px);
    background-size: 24px 24px;
}

.featured-card:hover .featured-card-grid,
.featured-card:focus-visible .featured-card-grid {
    opacity: 1;
}

/* corner crop marks — echoes the plate-frame system */
.featured-card-media::before {
    content: "";
    position: absolute;
    inset: 10px;
    z-index: 2;
    pointer-events: none;
    background:
        linear-gradient(#fff, #fff) top left / 14px 1px no-repeat,
        linear-gradient(#fff, #fff) top left / 1px 14px no-repeat,
        linear-gradient(#fff, #fff) top right / 14px 1px no-repeat,
        linear-gradient(#fff, #fff) top right / 1px 14px no-repeat,
        linear-gradient(#fff, #fff) bottom left / 14px 1px no-repeat,
        linear-gradient(#fff, #fff) bottom left / 1px 14px no-repeat,
        linear-gradient(#fff, #fff) bottom right / 14px 1px no-repeat,
        linear-gradient(#fff, #fff) bottom right / 1px 14px no-repeat;
    opacity: 0.5;
}

.featured-card-num {
    position: absolute;
    top: 0.65rem;
    left: 0.8rem;
    z-index: 3;
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    color: #f3efe6;
    mix-blend-mode: difference;
}

.featured-card-view {
    position: absolute;
    bottom: 0.65rem;
    right: 0.8rem;
    z-index: 3;
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #f3efe6;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.25s, transform 0.25s;
}

.featured-card:hover .featured-card-view,
.featured-card:focus-visible .featured-card-view {
    opacity: 0.9;
    transform: translateY(0);
}

.featured-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1rem 1.15rem 1.15rem;
    flex: 1;
}

.featured-card-cat {
    font-family: var(--mono);
    font-size: 0.6rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--brass);
}

.featured-card-title {
    font-size: 1.02rem;
    font-weight: 650;
    letter-spacing: -0.015em;
    line-height: 1.25;
    color: var(--ink);
}

.featured-card-blurb {
    font-size: 0.82rem;
    color: var(--paper-dim);
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.featured-card-foot {
    margin-top: auto;
    padding-top: 0.7rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.featured-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.85rem;
    font-family: var(--mono);
    font-size: 0.58rem;
    letter-spacing: 0.04em;
    color: var(--paper-mute);
}

.featured-card-tags span::before {
    content: "·";
    margin-right: 0.85rem;
    opacity: 0;
}

.featured-card-tags span + span::before {
    opacity: 0.5;
}

.featured-card-status {
    font-family: var(--mono);
    font-size: 0.58rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--emerald);
    white-space: nowrap;
}

.featured-card-status.status--dev {
    color: var(--brass);
}

.featured-card-status::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    margin-right: 0.45rem;
    vertical-align: 1px;
}

/* AI-generated badge */
.featured-card-ai {
    position: absolute;
    top: 0.65rem;
    right: 0.8rem;
    z-index: 3;
    font-family: var(--mono);
    font-size: 0.55rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #f3efe6;
    background: rgba(10, 11, 16, 0.72);
    border: 1px solid rgba(243, 239, 230, 0.3);
    padding: 0.2rem 0.45rem;
    border-radius: 3px;
}

/* ---------- Arrows (foot row) ---------- */
.featured-arrow {
    flex-shrink: 0;
    width: 2.75rem;
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--paper);
    border: 1px solid var(--rule-strong);
    border-radius: 6px;
    color: var(--ink);
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, opacity 0.2s;
}

.featured-arrow svg {
    width: 1.1rem;
    height: 1.1rem;
}

.featured-arrow:hover:not(:disabled) {
    border-color: var(--brass);
    color: var(--brass);
}

.featured-arrow:disabled {
    opacity: 0.35;
    cursor: default;
}

/* ---------- Dots + counter ---------- */
.featured-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 0.5rem;
    padding-bottom: 1rem;
}

.featured-foot .featured-arrow:first-child {
    order: -1;
}

.featured-dots {
    display: flex;
    gap: 0.45rem;
}

.featured-dot {
    width: 22px;
    height: 3px;
    border: none;
    border-radius: 2px;
    background: var(--rule-strong);
    cursor: pointer;
    transition: background 0.25s, width 0.25s;
    /* 44px hit target (WCAG 2.2) without changing the 3px visual */
    position: relative;
}

.featured-dot::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 44px;
    transform: translateY(-50%);
}

.featured-dot:hover {
    background: var(--paper-dim);
}

.featured-dot.is-active {
    background: var(--brass);
    width: 34px;
}

.featured-counter {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    color: var(--paper-mute);
}

/* ============================================================
   LIGHTBOX
   ============================================================ */
.featured-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(0.75rem, 3vw, 2.5rem);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.featured-lightbox[hidden] {
    display: flex;
}

.featured-lightbox.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.featured-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 18, 14, 0.9);
    backdrop-filter: blur(6px);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.featured-lightbox.active .featured-lightbox-backdrop {
    opacity: 1;
}

.featured-lightbox-shell {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.9fr);
    width: min(1180px, 100%);
    max-height: min(88vh, 780px);
    background: var(--paper);
    border: 1px solid var(--rule-strong);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.55);
    opacity: 0;
    transform: scale(0.94) translateY(18px);
    transition: opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1), transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
}

.featured-lightbox.active .featured-lightbox-shell {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.featured-lightbox-media {
    position: relative;
    margin: 0;
    background: #0b0d12;
    min-height: 320px;
    align-self: stretch;
    overflow: hidden;
}

.featured-lightbox-media img {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Hands-Free CAD: hero content is the LEFT compile-timeline panel, not a
   centered photo. Centered cover amputates it (and on mobile deletes it).
   Anchor left so the timeline always survives the crop; the expendable
   right tool rail takes the trim instead. Card-scoped — the other seven
   are centered imagery that needs the default center anchor. */
.featured-lightbox-media.is-left img {
    object-position: left center;
}

/* UI screenshots (Bayline): show the whole image, no cover crop; the figure
   takes the screenshot's paper colour so the letterbox has no dark strip */
.featured-lightbox-media.is-contain {
    background: #f6f3ee;
}
.featured-lightbox-media.is-contain img {
    object-fit: contain;
    background: #f6f3ee;
}
/* Per-card letterbox (lb.bg in featured.js, e.g. dark CubeFactory screenshot) */
.featured-lightbox-media.is-contain.has-bg,
.featured-lightbox-media.is-contain.has-bg img {
    background: var(--lb-bg);
}

.featured-lightbox-media-label {
    position: absolute;
    left: 0;
    bottom: 0;
    margin: 0;
    padding: 0.5rem 0.9rem;
    background: rgba(10, 11, 16, 0.78);
    color: #cfc9bc;
    font-family: var(--mono);
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.featured-lightbox-close {
    position: absolute;
    top: 0.6rem;
    right: 0.7rem;
    z-index: 3;
    width: 2.6rem;
    height: 2.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(243, 239, 230, 0.92);
    border: 1px solid var(--rule-strong);
    border-radius: 6px;
    color: var(--ink);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.featured-lightbox-close:hover {
    color: var(--brass);
    border-color: var(--brass);
}

.featured-lightbox-info {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    padding: clamp(1.4rem, 3vw, 2.2rem);
    overflow-y: auto;
}

.featured-lightbox-kicker {
    margin: 0;
    font-family: var(--mono);
    font-size: 0.66rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--brass);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.featured-lightbox-kicker::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--rule);
}

.featured-lightbox-info h3 {
    margin: 0;
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.15;
    color: var(--ink);
    text-wrap: balance;
}

.featured-lightbox-body {
    margin: 0;
    color: #3d3a34;
    font-size: 0.95rem;
    line-height: 1.7;
}

.featured-lightbox-tags {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0;
    margin: 0;
}

.featured-lightbox-tags li {
    font-family: var(--mono);
    font-size: 0.6rem;
    letter-spacing: 0.06em;
    color: var(--paper-dim);
    border: 1px solid var(--rule);
    border-radius: 999px;
    padding: 0.28rem 0.65rem;
    background: var(--steel);
}

.featured-lightbox-status {
    margin: 0;
    font-family: var(--mono);
    font-size: 0.66rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--emerald);
}

.featured-lightbox-status.status--dev {
    color: var(--brass);
}

.featured-lightbox-status::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    margin-right: 0.5rem;
    vertical-align: 1px;
}

.featured-lightbox-cta {
    margin: 0.25rem 0 0;
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--brass);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.75rem;
    width: fit-content;
    border-bottom: 1px solid rgba(154, 74, 8, 0.35);
    padding: 0.35rem 0;
    transition: border-color 0.2s, gap 0.2s;
}

.featured-lightbox-cta:hover {
    border-color: var(--brass);
    gap: 0.8rem;
}

.featured-lightbox-cta::after {
    content: "→";
}

.featured-lightbox-nav {
    margin-top: auto;
    padding-top: 1.1rem;
    border-top: 1px solid var(--rule);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    position: sticky;
    bottom: 0;
    background: var(--paper);
}

.featured-lightbox-nav button {
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--paper-dim);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem 0.2rem;
    transition: color 0.2s;
}

.featured-lightbox-nav button:hover {
    color: var(--brass);
}

.featured-lightbox-count {
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    color: var(--paper-mute);
}

/* body scroll lock */
.featured-lock {
    overflow: hidden !important;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    /* vh is the large viewport. On a phone that includes space behind the
       browser bar, so an 88vh shell plus this overlay's padding sits a
       little past the visible screen. dvh tracks the visible height. */
    .featured-lightbox {
        padding-top: max(0.75rem, env(safe-area-inset-top, 0px));
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
    }

    @supports (height: 100dvh) {
        .featured-lightbox {
            bottom: auto;
            height: 100dvh;
            max-height: 100dvh;
        }
    }

    .featured-lightbox-shell {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(220px, 42vh) minmax(0, 1fr);
        grid-template-rows: minmax(220px, 42dvh) minmax(0, 1fr);
        max-height: min(88vh, 780px);
        max-height: min(88dvh, calc(100dvh - 2.5rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)), 780px);
        overflow-y: auto;
    }

    .featured-lightbox-media {
        min-height: 220px;
        max-height: 42vh;
        max-height: 42dvh;
    }

    .featured-lightbox-media img {
        max-height: 42vh;
        max-height: 42dvh;
    }
}

@media (max-width: 640px) {
    /* Phones: a shorter picture and a shell that stays inside the visible
       screen, so the title and the previous/next row clear the browser bar. */
    .featured-lightbox {
        padding-top: max(0.65rem, env(safe-area-inset-top, 0px));
        padding-bottom: max(0.85rem, env(safe-area-inset-bottom, 0px));
    }

    .featured-lightbox-shell {
        grid-template-rows: minmax(140px, 28vh) minmax(0, 1fr);
        grid-template-rows: minmax(132px, 26dvh) minmax(0, 1fr);
        max-height: min(76vh, calc(100vh - 3.5rem));
        max-height: min(76dvh, calc(100dvh - 3.5rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
    }
    .featured-lightbox-media {
        min-height: 132px;
        max-height: 28vh;
        max-height: 26dvh;
    }
    .featured-lightbox-media img {
        max-height: 28vh;
        max-height: 26dvh;
    }
    .featured-shell {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding-top: 0.75rem;
    }

    /* Keep the ghost clear of the nav's bottom rule on phones */
    .featured-head-ghost {
        top: -1.5rem;
        font-size: clamp(2.25rem, 11vw, 3rem);
    }

    .featured-card {
        --card-w: clamp(250px, 78vw, 340px);
    }

    .featured-arrow {
        display: none;
    }

    .featured-foot {
        justify-content: center;
    }
}

/* 9 dots + counter do not fit on a 320px screen: let the counter drop below the dots */
@media (max-width: 359px) {
    .featured-foot {
        flex-wrap: wrap;
        row-gap: 0.6rem;
    }
}

/* A phone on its side is short. The stacked picture otherwise keeps the
   220px minimum and the shell sits against the screen edge. */
@media (max-width: 900px) and (max-height: 520px) {
    .featured-lightbox-shell {
        grid-template-rows: minmax(112px, 36vh) minmax(0, 1fr);
        grid-template-rows: minmax(112px, 36dvh) minmax(0, 1fr);
        max-height: min(78vh, calc(100vh - 1.25rem));
        max-height: min(78dvh, calc(100dvh - 1.25rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
    }

    .featured-lightbox-media {
        min-height: 112px;
        max-height: 36vh;
        max-height: 36dvh;
    }

    .featured-lightbox-media img {
        max-height: 36vh;
        max-height: 36dvh;
    }
}

@media (prefers-reduced-motion: reduce) {
    .featured-rail {
        scroll-behavior: auto;
    }

    .featured-card,
    .featured-card-media img,
    .featured-lightbox,
    .featured-lightbox-backdrop,
    .featured-lightbox-shell {
        transition: none;
    }

    .featured-lightbox-shell {
        transform: none;
    }
}

/* Bayline card: demo link button (shown only on that card) */
.featured-lightbox-demo {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    width: fit-content;
    max-width: 100%;
    min-height: 2.75rem;
    margin: 0.5rem 0 0.25rem;
    padding: 0.55rem 1.1rem;
    background: var(--brass);
    border: 1px solid var(--brass);
    border-radius: 4px;
    color: #fff;
    font-family: var(--mono);
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s;
}
.featured-lightbox-demo[hidden] { display: none; }
.featured-lightbox-demo::after { content: "↗"; }
.featured-lightbox-demo:hover { background: #7d3b06; border-color: #7d3b06; }
