/* Case Study Details Styles */

.narrow {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 4vw;
}

.case-study-header {
    padding: 5vh 0 1rem;
}

.case-study-header h2 {
    font-size: 2rem;
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
    line-height: 1.25;
    margin-bottom: 2rem;
    color: var(--color-text);
}

.case-study-header .summary {
    font-size: 1.15rem;
    font-weight: 400;
    color: var(--color-text);
    line-height: 1.7;
}

.case-study-hero {
    width: 100%;
    margin-bottom: 8vh;
}

.case-study-hero img {
    width: 100%;
    height: auto;
    display: block;
    background-color: #444444;
}

/* ── Hero Carousel ───────────────────────────────────────────── */
.hero-carousel {
    position: relative;
    width: 100%;
    max-width: 1440px;
    max-height: 810px;
    overflow: hidden;
    background-color: #444444;
    aspect-ratio: 16 / 9;
    margin: 0 auto;
}

.hero-carousel__track {
    position: relative;
    width: 100%;
    height: 100%;
}

.hero-carousel__slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.7s ease;
    pointer-events: none;
}

.hero-carousel__slide.is-active {
    opacity: 1;
    pointer-events: auto;
}

.hero-carousel__slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    display: block;
}

/* Arrow buttons — match dark pill style of play button */
.hero-carousel__btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #444444;
    border: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.2s ease;
    z-index: 10;
}

.hero-carousel__btn img {
    width: 24px;
    height: 24px;
    display: block;
    pointer-events: none;
}

.hero-carousel__btn--prev {
    left: 20px;
}

.hero-carousel__btn--next {
    right: 20px;
}

.hero-carousel:hover .hero-carousel__btn {
    opacity: 1;
}

.hero-carousel__btn:hover {
    opacity: 0.75;
    transform: translateY(-50%) scale(1.15);
}

.hero-carousel__btn:active {
    opacity: 0.5;
    transform: translateY(-50%) scale(0.95);
}

/* Pause button — shown on hover when slideshow is running */
.carousel-pause-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #333333;
    border: none;
    padding: 0.65rem 1.4rem;
    border-radius: 100px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-primary);
    font-size: 0.85rem;
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
    color: #ffffff;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease, background 0.15s ease;
}

/* Show pause button when carousel is hovered AND playing */
.hero-carousel.is-playing:hover .carousel-pause-btn {
    opacity: 1;
    pointer-events: auto;
}

.carousel-pause-btn:hover {
    background: #444444;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

.carousel-pause-btn:active {
    background: #111111;
}

/* Dot indicators */
.hero-carousel__dots {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 10;
}

.hero-carousel__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(68, 68, 68, 0.3);
    border: none;
    cursor: pointer;
    padding: 0;
    transition: background 0.4s ease, width 0.4s cubic-bezier(0.4, 0, 0.2, 1), border-radius 0.4s ease;
}

.hero-carousel__dot.is-active {
    background: #444444;
    width: 20px;
    border-radius: 4px;
    transform: none;
}

/* ── Floating Play Button ────────────────────────────────────── */
.carousel-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #333333;
    border: none;
    padding: 0.65rem 1.4rem;
    border-radius: 100px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-primary);
    font-size: 0.85rem;
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
    color: #ffffff;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    z-index: 20;
    transition: opacity 0.3s ease, transform 0.3s ease, background 0.15s ease, box-shadow 0.2s ease;
}

.carousel-play-btn:hover {
    background: #444444;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    transform: translate(-50%, -52%);
}

.carousel-play-btn:active {
    background: #111111;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    transform: translate(-50%, -50%);
}

.carousel-play-btn.is-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0.9);
}

/*
  Hide the play button whenever a slide other than the first is active.
  This prevents it from blocking content on slides 2, 3, 4.
  Works by detecting if any non-first slide has the is-active class.
*/
.hero-carousel__track .hero-carousel__slide:not(:first-child).is-active~.hero-carousel__btn,
.hero-carousel:has(.hero-carousel__slide:not(:first-child).is-active) .carousel-play-btn {
    opacity: 0 !important;
    pointer-events: none !important;
}

.carousel-play-btn .play-icon {
    font-size: 0.75rem;
    line-height: 1;
}

.case-study-content {
    margin-bottom: 10vh;
}

.case-study-content p {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--color-text);
    margin-bottom: 2rem;
    font-weight: 400;
}

.case-study-content h3 {
    font-size: 1.35rem;
    font-weight: 400;
    margin: 3rem 0 1rem;
    color: var(--color-text);
}

.content-image {
    margin: 4rem 0;
    width: 100%;
}

.content-image img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    background-color: var(--color-bg);
}

.content-image figcaption {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--color-text-light);
    text-align: center;
}

.case-study-content ul {
    margin-bottom: 2rem;
    padding-left: 1.5rem;
}

.case-study-content li {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--color-text);
    font-weight: 400;
    margin-bottom: 0.5rem;
}

.case-study-pagination {
    border-top: 1px solid #999999;
    padding-top: 4vh;
}

.back-link {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    display: inline-block;
    background-color: var(--color-bg);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    color: var(--color-text-light);
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 100;
    opacity: 0.9;
}

.back-link:hover {
    color: var(--color-text);
    transform: translateX(-4px);
    opacity: 1;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

/* ── Case Study Body: 4-column grid layout ────────────────────── */
.cs-body {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6vh 0;
    padding: 0 var(--spacing-layout);
    max-width: 1440px;
    margin: 0 auto 12vh;
}

@media (min-width: 860px) {
    .cs-body {
        grid-template-columns: 1fr 3fr;
        gap: 0 5vw;
        align-items: start;
    }
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.cs-sidebar {
    padding-top: 0.25rem;
}

@media (min-width: 860px) {
    .cs-sidebar {
        position: sticky;
        top: 7rem;
    }
}

/* Metadata block */
.cs-meta {
    margin-bottom: 3.5rem;
}

.cs-meta-row {
    margin-bottom: 1.5rem;
}

.cs-meta-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-light);
    opacity: 0.55;
    margin-bottom: 0.35rem;
}

.cs-meta-value {
    font-size: 0.9rem;
    color: var(--color-text);
    line-height: 1.55;
}

.cs-meta-value ul {
    padding: 0;
    margin: 0;
    list-style: none;
}

.cs-meta-value li {
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--color-text);
    margin-bottom: 0;
}

/* Section anchor nav */
.cs-nav {
    border-top: 1px solid #999999;
    padding-top: 1.75rem;
    display: flex;
    flex-direction: column;
}

.cs-nav__link {
    display: block;
    font-size: 0.85rem;
    color: var(--color-text-light);
    text-decoration: none;
    padding: 0.4rem 0;
    opacity: 0.6;
    transition: opacity 0.25s ease, color 0.25s ease;
    line-height: 1.4;
}

.cs-nav__link:hover,
.cs-nav__link.is-active {
    opacity: 1;
    color: var(--color-text);
}

/* ── Content area ─────────────────────────────────────────────── */
.cs-content {
    min-width: 0;
    /* prevent grid blowout */
}

.cs-section {
    padding-top: 5vh;
    margin-top: -5vh;
    /* offset for sticky header scroll */
    margin-bottom: 6vh;
}

.cs-section:first-child {
    padding-top: 0;
    margin-top: 0;
}

.cs-section h3 {
    font-size: 1.25rem;
    font-weight: 400;
    margin-bottom: 1.5rem;
    color: var(--color-text);
}

.cs-section p {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--color-text);
    margin-bottom: 1.5rem;
    font-weight: 400;
}

.cs-section ul {
    padding-left: 1.25rem;
    margin-bottom: 1.5rem;
}

.cs-section li {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--color-text);
    margin-bottom: 0.4rem;
}

.cs-image {
    margin: 2.5rem 0;
    width: 100%;
}

.cs-image img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
    background-color: #f5f5f5;
}

.cs-image figcaption {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--color-text-light);
    opacity: 0.6;
    text-align: left;
}

/* ═══════════════════════════════════════════════════════════════
   TAP-TO-ENLARGE LIGHTBOX
═══════════════════════════════════════════════════════════════ */
.carousel-lightbox {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.93);
    z-index: 9000;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    align-items: flex-start;
    justify-content: center;
}
.carousel-lightbox.is-open { display: flex; }
.carousel-lightbox img {
    width: 100%;
    height: auto;
    display: block;
    cursor: zoom-out;
    touch-action: pinch-zoom;
    user-select: none;
    -webkit-user-select: none;
}

/* ── Section nav scroll arrows ──────────────────────────────── */
.cs-page-nav-wrapper {
    position: sticky;
    top: var(--header-h, 70px);
    z-index: 900;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
}

.cs-page-nav__scroll-btn {
    display: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 44px;
    width: 36px;
    background: rgba(255, 255, 255, 0.6);
    border: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    z-index: 5;
    color: var(--color-text);
    padding: 0;
    transition: opacity 0.25s ease;
}

.cs-page-nav__scroll-btn--left  { left: 0; }
.cs-page-nav__scroll-btn--right { right: 0; }

.cs-page-nav__scroll-btn.is-faded {
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 767px) {
    .cs-page-nav__scroll-btn { display: flex; }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE OPTIMISATIONS  (≤ 767px)
═══════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {

    /* 1 — Hero title: responsive clamp, no overflow */
    .case-study-header h2 {
        font-size: clamp(1.3rem, 5.5vw, 2rem);
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .case-study-header .summary {
        font-size: 1rem;
    }

    .case-study-header {
        padding-top: 5vh;
        padding-bottom: 3vh;
    }

    /* 3 — Carousel: full viewport width, no container horizontal padding */
    .case-study-hero {
        padding-left: 0;
        padding-right: 0;
        margin-bottom: 0;
    }

    /* 3 — Hide desktop carousel controls on mobile */
    .hero-carousel__btn,
    .carousel-play-btn,
    .carousel-pause-btn,
    .hero-carousel__dots {
        display: none !important;
    }

    /* ── Thumbnail strip ──────────────────────────────────────── */
    .cs-thumb-strip {
        position: relative;
        padding: 0.5rem 0 0.75rem;
    }

    .cs-thumb-hint {
        display: block;
        font-size: 0.75rem;
        color: var(--color-text-light);
        text-align: center;
        margin-bottom: 0.4rem;
        letter-spacing: 0.04em;
    }

    .cs-thumb-strip__inner {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 16px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 0 1.25rem;
        align-items: flex-start;
    }

    .cs-thumb-strip__inner::-webkit-scrollbar { display: none; }

    .cs-thumb {
        display: block;
        flex: 0 0 auto;
        width: 90px !important;
        min-width: 90px;
        max-width: 90px;
        height: 60px !important;
        min-height: 60px;
        max-height: 60px;
        object-fit: cover;
        border-radius: 4px;
        cursor: zoom-in;
        opacity: 0.65;
        border: 2px solid transparent;
        transition: opacity 0.2s, border-color 0.2s;
    }

    .cs-thumb.is-active {
        opacity: 1;
        border-color: var(--color-text);
    }

    /* ── Mobile lightbox ──────────────────────────────────────── */
    .cs-mobile-lb {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(255, 255, 255, 0.95);
        z-index: 9000;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding-top: 3.5rem; /* clearance for close button */
    }

    .cs-mobile-lb.is-open { display: flex; }

    .cs-mobile-lb__close {
        position: absolute;
        top: 1rem;
        right: 1rem;
        width: 44px;
        height: 44px;
        background: rgba(0, 0, 0, 0.08);
        border: none;
        border-radius: 50%;
        color: var(--color-text);
        font-size: 1.25rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1;
    }

    .cs-mobile-lb__img {
        width: 100%;
        height: auto;
        max-height: calc(100vh - 180px); /* reserve space for thumb row */
        object-fit: contain;
        touch-action: pinch-zoom;
        user-select: none;
        -webkit-user-select: none;
        display: block;
        flex-shrink: 0;
    }

    /* Thumbnail row inside lightbox */
    .cs-mobile-lb__thumbs {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 16px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 1rem 1.25rem 0.5rem;
        align-items: flex-start;
        width: 100%;
        box-sizing: border-box;
    }

    .cs-mobile-lb__thumbs::-webkit-scrollbar { display: none; }

    .cs-mobile-lb__thumb {
        display: block;
        flex: 0 0 auto;
        width: 90px !important;
        min-width: 90px;
        max-width: 90px;
        height: 60px !important;
        min-height: 60px;
        max-height: 60px;
        object-fit: cover;
        border-radius: 4px;
        cursor: pointer;
        opacity: 0.5;
        border: 2px solid transparent;
        transition: opacity 0.2s, border-color 0.2s;
    }

    .cs-mobile-lb__thumb.is-active {
        opacity: 1;
        border-color: var(--color-text);
    }

    /* 10 — 20px horizontal padding on all content containers */
    .narrow {
        padding: 0 1.25rem;
    }

    /* Explicit section padding so nothing touches screen edges */
    .cs-challenge-card {
        padding: 1.25rem;
    }

    /* 7 — Process images: full bleed, break out of .narrow padding */
    .cs-content-full .cs-image,
    .cs-section .cs-image {
        margin-left: -1.25rem;
        margin-right: -1.25rem;
    }
    .cs-content-full .cs-image img,
    .cs-section .cs-image img {
        border-radius: 0;
    }

    /* 9 — Captions: minimum 14px */
    .cs-image figcaption,
    .content-image figcaption {
        font-size: 0.875rem;
        padding: 0 0.25rem;
    }

    /* 9 — Section headings: responsive, no overflow */
    .cs-section h3 {
        font-size: clamp(1rem, 4.5vw, 1.25rem);
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .case-study-content h3 {
        overflow-wrap: break-word;
        word-break: break-word;
    }

    /* 9 — Body text minimum 16px */
    .cs-section p,
    .cs-section li,
    .case-study-content p,
    .case-study-content li {
        font-size: 1rem;
        overflow-wrap: break-word;
    }

    /* 11 — Images never overflow viewport */
    .cs-image img,
    .content-image img,
    .hero-carousel__slide img {
        max-width: 100%;
    }

    /* Back link: comfortable position on mobile */
    .back-link {
        bottom: 2rem;
        left: 1rem;
        font-size: 0.875rem;
        padding: 0.6rem 1rem;
    }
}

/* ═══════════════════════════════════════════════════════════════
   APPROACH STAGE LIGHTBOX (all viewports)
═══════════════════════════════════════════════════════════════ */
.cs-approach-lb {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.97);
    z-index: 9000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 3.5rem;
}

.cs-approach-lb.is-open { display: flex; }

.cs-approach-lb__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.08);
    border: none;
    border-radius: 50%;
    color: var(--color-text);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.cs-approach-lb__img {
    width: 100%;
    max-width: 1200px;
    height: auto;
    max-height: calc(100vh - 200px);
    object-fit: contain;
    touch-action: pinch-zoom;
    user-select: none;
    -webkit-user-select: none;
    display: block;
    flex-shrink: 0;
    padding: 0 1.5rem;
    box-sizing: border-box;
    cursor: zoom-out;
}

.cs-approach-lb__thumbs {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 1rem 1.25rem 0.5rem;
    align-items: flex-start;
    width: 100%;
    max-width: 1200px;
    box-sizing: border-box;
    justify-content: center;
}

.cs-approach-lb__thumbs::-webkit-scrollbar { display: none; }

.cs-approach-lb__thumb {
    display: block;
    flex: 0 0 auto;
    width: 90px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.45;
    border: 2px solid transparent;
    transition: opacity 0.2s, border-color 0.2s;
}

.cs-approach-lb__thumb.is-active {
    opacity: 1;
    border-color: var(--color-text);
}