/* Case study page */
.v2-case {
    padding: 50px var(--v2-pad) 80px;
}

.v2-case__tag {
    display: flex; gap: 14px; align-items: center; margin-bottom: 14px;
}

.v2-case__meta {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--v2-border);
    border: 1px solid var(--v2-border);
    margin-bottom: 36px;
}
.v2-case__meta > div {
    background: var(--v2-bg-card);
    padding: 20px 24px;
}
.v2-case__meta-key {
    font-family: var(--v2-f-mono); font-size: 10px; color: var(--v2-muted-deep);
    text-transform: uppercase; letter-spacing: 1px;
    display: block; margin-bottom: 8px;
}
.v2-case__meta-val { font-size: 16px; color: var(--v2-text); font-weight: 500; }

.v2-case__hero-img {
    aspect-ratio: 21/9;
    overflow: hidden;
    margin-bottom: 50px;
    background: #111;
}
.v2-case__hero-img img {
    width: 100%; height: 100%; object-fit: cover;
}

.v2-case__block {
    display: grid; grid-template-columns: 1fr 1.8fr; gap: 50px; margin-bottom: 60px;
}

.v2-case__solution-list > li {
    display: flex; gap: 18px; padding: 18px 0;
    border-bottom: 1px solid var(--v2-border);
}
.v2-case__solution-list > li:last-child { border-bottom: 0; }
.v2-case__solution-n {
    font-family: var(--v2-f-mono); font-size: 11px;
    color: var(--v2-accent); letter-spacing: 1px; width: 32px;
    text-transform: uppercase;
}
.v2-case__solution-t {
    font-size: 17px; font-weight: 500; color: var(--v2-text);
    letter-spacing: -0.3px; margin-bottom: 6px;
}
.v2-case__solution-d {
    font-size: 13px; line-height: 1.6; color: var(--v2-dim); margin: 0;
}

.v2-case__metrics {
    padding: 32px;
    background: var(--v2-bg-elev);
    border: 1px solid var(--v2-border-md);
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px;
    margin-bottom: 50px;
}
.v2-case__metric-v {
    font-family: var(--v2-f-head); font-size: 32px; font-weight: 500;
    color: var(--v2-text); letter-spacing: -1px; margin-bottom: 6px;
}

.v2-case__back {
    font-family: var(--v2-f-mono); font-size: 13px; letter-spacing: 1px;
    color: var(--v2-accent); text-transform: uppercase;
    display: inline-block; padding: 10px 0;
}

@media (max-width: 900px) {
    .v2-case__meta { grid-template-columns: repeat(2, 1fr); }
    .v2-case__block { grid-template-columns: 1fr; gap: 20px; }
    .v2-case__metrics { grid-template-columns: repeat(2, 1fr); padding: 24px; }
}

/* ── /projects listing — magazine-style alternating rows ───────────────
 * Each project gets its own full-width row. Odd rows: photo on the left;
 * even rows: photo on the right (via :nth-child(even) + flip modifier).
 * Pattern inspired by Apple Business / Linear customer-stories pages.
 */
.v2-pl-magazine {
    padding: 30px var(--v2-pad) 80px;
}
.v2-pl-row {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 60px;
    /* Align image and text to the top — text can grow as long as the admin
     * wants (user explicitly asked to show the full lead). Image stays 16:9
     * at the top of the row; extra vertical space below it is fine. */
    align-items: start;
    padding: 60px 0;
    border-top: 1px solid var(--v2-border);
}
.v2-pl-row:first-child { border-top: 0; padding-top: 30px; }
.v2-pl-row:nth-child(even) { direction: rtl; }
.v2-pl-row:nth-child(even) > * { direction: ltr; }

.v2-pl-row__media {
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    position: relative;
    background: #151515;
    border: 1px solid var(--v2-border);
}
.v2-pl-row__media img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.45s ease, filter 0.45s ease;
    filter: grayscale(0.08) contrast(1.02);
}
.v2-pl-row:hover .v2-pl-row__media img {
    transform: scale(1.04);
    filter: none;
}
.v2-pl-row__badge {
    position: absolute;
    top: 14px; left: 14px;
    font-family: var(--v2-f-mono); font-size: 10px; letter-spacing: 1px;
    color: var(--v2-bg);
    background: var(--v2-accent);
    padding: 4px 10px;
}

.v2-pl-row__body {
    display: flex; flex-direction: column;
    gap: 16px;
    min-width: 0;
}
.v2-pl-row__index {
    font-family: var(--v2-f-mono); font-size: 11px; letter-spacing: 1.5px;
    color: var(--v2-accent); text-transform: uppercase;
}
.v2-pl-row__meta {
    display: flex; align-items: center; gap: 8px;
    font-family: var(--v2-f-mono); font-size: 11px; letter-spacing: 1px;
    text-transform: uppercase;
    flex-wrap: wrap;
}
.v2-pl-row__dot { color: var(--v2-muted); }
.v2-pl-row__title {
    font-family: var(--v2-f-head);
    font-size: clamp(28px, 3.2vw, 44px);
    font-weight: 500;
    letter-spacing: -0.8px;
    line-height: 1.05;
    color: var(--v2-text);
    margin: 4px 0 4px;
}
/* Show the full lead as authored — no line-clamp. Admin controls length
 * manually; if they want a shorter summary they trim the Quill content. */
.v2-pl-row__lead {
    color: var(--v2-text-body);
    font-size: 16px;
    line-height: 1.6;
}
.v2-pl-row__lead > *:first-child { margin-top: 0; }
.v2-pl-row__lead > *:last-child  { margin-bottom: 0; }

.v2-pl-row__cta {
    margin-top: 8px;
    display: inline-flex; align-items: center; gap: 10px;
    font-family: var(--v2-f-mono); font-size: 13px; letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--v2-accent);
    text-decoration: none;
    width: max-content;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 122, 26, 0.35);
    transition: border-color 0.2s, gap 0.25s ease;
}
.v2-pl-row__cta:hover {
    border-bottom-color: var(--v2-accent);
    gap: 16px;
}
.v2-pl-row__arrow { font-size: 16px; transition: transform 0.25s ease; }
.v2-pl-row:hover .v2-pl-row__cta { gap: 16px; }

@media (max-width: 900px) {
    .v2-pl-row {
        grid-template-columns: 1fr;
        gap: 22px;
        padding: 40px 0;
    }
    .v2-pl-row:nth-child(even)       { direction: ltr; }
    .v2-pl-row:nth-child(even) > *   { direction: ltr; }
    .v2-pl-row__title                { font-size: 26px; }
}

/* ── Intro block — lead/meta optionally paired with a portrait photo ──
 * When `v2-case__intro--split` modifier is present (admin uploaded a
 * sideImage), the block becomes a 2-column grid: text on the left, photo
 * on the right. Without the modifier it stays full-width (legacy layout).
 */
.v2-case__intro { margin-bottom: 30px; }
.v2-case__intro--split {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 40px;
    align-items: start;
}
.v2-case__intro-text { min-width: 0; }
.v2-case__intro-photo {
    aspect-ratio: 4 / 5;
    background: #151515;
    overflow: hidden;
    border: 1px solid var(--v2-border);
    position: sticky;
    top: 20px;
}
.v2-case__intro-photo img {
    width: 100%; height: 100%;
    object-fit: cover;
    filter: grayscale(0.08) contrast(1.02);
    transition: transform 0.4s ease, filter 0.4s ease;
}
.v2-case__intro-photo:hover img {
    transform: scale(1.03);
    filter: none;
}
@media (max-width: 900px) {
    .v2-case__intro--split {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    .v2-case__intro-photo {
        position: static;
        max-width: 360px;
        margin: 0 auto;
    }
}

/* ── Project photo gallery (magazine-style collage) ────────────────────
 * Renders after the hero image. Layout switches based on data-count:
 *   1 → full-width hero
 *   2 → 50/50
 *   3 → 1 big left spanning 2 rows + 2 small stacked right
 *   4 → 2×2
 *   5 → 1 big + 2 small top row, 2 wide bottom row (magazine)
 *   6 → 3×2
 *   7+ (`many`) → masonry-like auto-fill grid
 *
 * Tile height is set EXPLICITLY via `grid-auto-rows` × row span. That's
 * the only way to stop portrait source photos from blowing the tile
 * up — `min-height: 0` on each item disables the grid default of
 * `min-height: auto`, which otherwise lets intrinsic image size win.
 */
.v2-case__gallery {
    display: grid;
    gap: 10px;
    margin: 40px 0;
}
.v2-case__gallery-item {
    display: block;
    overflow: hidden;
    background: #151515;
    border: 1px solid var(--v2-border);
    position: relative;
    cursor: zoom-in;
    min-height: 0;                    /* critical: allow grid to size it */
    min-width: 0;
}
.v2-case__gallery-item img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease, filter 0.35s ease;
    filter: grayscale(0.08) contrast(1.02);
}
.v2-case__gallery-item:hover img {
    transform: scale(1.04);
    filter: none;
}

/* Count-driven layouts */
.v2-case__gallery[data-count="1"] {
    grid-template-columns: 1fr;
    grid-auto-rows: 480px;
}
.v2-case__gallery[data-count="2"] {
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: 360px;
}
.v2-case__gallery[data-count="3"] {
    grid-template-columns: 2fr 1fr;
    grid-auto-rows: 200px;
}
.v2-case__gallery[data-count="3"] > :first-child { grid-row: span 2; }

.v2-case__gallery[data-count="4"] {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 280px;
}

.v2-case__gallery[data-count="5"] {
    grid-template-columns: repeat(6, 1fr);
    grid-auto-rows: 190px;
}
.v2-case__gallery[data-count="5"] > :nth-child(1) { grid-column: span 4; grid-row: span 2; }
.v2-case__gallery[data-count="5"] > :nth-child(2) { grid-column: span 2; }
.v2-case__gallery[data-count="5"] > :nth-child(3) { grid-column: span 2; }
.v2-case__gallery[data-count="5"] > :nth-child(4) { grid-column: span 3; }
.v2-case__gallery[data-count="5"] > :nth-child(5) { grid-column: span 3; }

.v2-case__gallery[data-count="6"] {
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 240px;
}

.v2-case__gallery[data-count="many"] {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    grid-auto-rows: 220px;
}

@media (max-width: 900px) {
    .v2-case__gallery[data-count="1"] { grid-auto-rows: 360px; }
    .v2-case__gallery[data-count="2"] { grid-auto-rows: 260px; }
}

@media (max-width: 700px) {
    .v2-case__gallery,
    .v2-case__gallery[data-count="2"],
    .v2-case__gallery[data-count="3"],
    .v2-case__gallery[data-count="4"],
    .v2-case__gallery[data-count="5"],
    .v2-case__gallery[data-count="6"],
    .v2-case__gallery[data-count="many"] {
        grid-template-columns: 1fr 1fr;
        grid-auto-rows: 180px;
    }
    .v2-case__gallery[data-count="1"] { grid-template-columns: 1fr; grid-auto-rows: 260px; }
    .v2-case__gallery[data-count="3"] > :first-child,
    .v2-case__gallery[data-count="5"] > * { grid-column: span 1 !important; grid-row: auto !important; }
}
