html {
    scroll-behavior: smooth;
}

/* --- Case Study Layout --- */
.case-study-hero {
    padding: 80px 10% 80px;
    background-color: var(--bg-paper);
    min-height: 80vh;
    display: flex;
    flex-direction: column;
}

.go-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-pencil);
    font-family: var(--font-ui);
    font-weight: 500;
    margin-bottom: 32px;
    font-size: 1rem;
    transition: transform 0.3s var(--ease-sketch);
}

.go-back-link:hover {
    transform: translateX(-5px);
}

.hero-main-row {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 4rem;
    margin-bottom: 32px;
}

.hero-left {
    flex: 1;
}

.case-study-title {
    font-family: var(--font-sketch);
    font-size: clamp(2rem, 5vw, 3.8rem);
    font-weight: 800;
    line-height: 1.25;
    color: var(--text-pencil);
    letter-spacing: -1.5px;
}

.hero-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: left;
}

.project-number-container {
    position: relative;
    margin-bottom: 2rem;
}

.project-number {
    font-family: var(--font-sketch);
    font-size: 10rem;
    font-weight: 800;
    color: rgba(26, 26, 24, 0.05);
    /* Very light grey */
    line-height: 1;
}

.number-underline {
    position: absolute;
    bottom: 15px;
    right: 0;
    width: 80px;
    height: 4px;
    background-color: #D4FF00;
    /* Lime green */
}

.hero-summary {
    font-family: var(--font-ui);
    font-size: 1.35rem;
    line-height: 1.5;
    color: #444;
    max-width: 500px;
}

.project-meta-grid {
    display: grid;
    grid-template-columns: auto auto auto;
    justify-content: start;
    column-gap: 64px;
    row-gap: 24px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding: 24px 0;
    margin-bottom: 0;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.meta-label {
    font-family: var(--font-sketch);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: #888;
}

.meta-value {
    font-family: var(--font-ui);
    font-size: 0.875rem;
    /* 14px */
    font-weight: 500;
    color: var(--text-pencil);
}

.case-study-media-full {
    width: 100%;
    margin-top: 40px;
}

.cs-hero-img,
.cs-section-img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: none;
    border: 1.5px solid #E3D9C6;
    /* dark creme / beige stroke */
    cursor: zoom-in;
    transition: transform 0.3s ease;
}

.cs-section-img:hover {
    transform: translateY(-2px);
    box-shadow: none;
}

.case-study-content {
    padding: 100px 10%;
    max-width: 1400px;
    margin: 0 auto;
}

.cs-container {
    max-width: 900px;
}

.cs-section-title {
    font-family: var(--font-sketch);
    font-size: 2.5rem;
    /* 40px */
    font-weight: 700;
    margin-bottom: 20px;
    letter-spacing: -1px;
}

.cs-paragraph {
    font-family: var(--font-ui);
    font-size: 1.125rem;
    /* 18px */
    line-height: 1.5;
    margin-bottom: 2rem;
    /* Reduced from 2.5rem */
    color: #333;
}

/* --- Sticky Article Layout --- */
.cs-article-layout {
    display: flex;
    gap: 80px;
    padding: 50px 10% 60px;
    /* Halved top (from 100px) and reduced bottom */
    background-color: var(--bg-paper);
    max-width: 1400px;
    margin: 0 auto;
}

.cs-sidebar {
    flex: 1;
    min-width: 250px;
}

.cs-toc {
    position: sticky;
    top: 40px;
}

.cs-toc-label {
    display: block;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 700;
    color: #AAA;
    letter-spacing: 2px;
    margin-bottom: 20px;
    /* Reduced from 40px */
}

.cs-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* Reduced gap */
}

.cs-toc-list li a {
    text-decoration: none;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 500;
    color: #AAA;
    /* Lighter color for inactive */
    transition: all 0.3s ease;
}

.cs-toc-list li.active a {
    color: var(--text-pencil);
    font-weight: 700;
}

.cs-toc-list li a:hover {
    color: var(--text-pencil);
}

.cs-main-content {
    flex: 3;
    display: flex;
    flex-direction: column;
}

/* Refined Content Sections */
.cs-content-section {
    max-width: 1000px;
    scroll-margin-top: 150px;
    /* Offset for sticky header + spacing */
}

.cs-card-section {
    background-color: #FFF;
    border-radius: 16px;
    padding: 32px;
    margin: 40px 0;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.02);
}

.cs-card-section .cs-section-title {
    font-size: 2rem;
    /* 32px */
    margin-bottom: 1.5rem;
}

.cs-card-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 40px;
    align-items: flex-start;
}

.cs-card-subtitle {
    font-family: var(--font-sketch);
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--text-pencil);
}

.cs-bullet-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.cs-bullet-list li {
    font-family: var(--font-ui);
    font-size: 1rem;
    /* 16px */
    line-height: 1.6;
    color: #444;
    position: relative;
    padding-left: 1.5rem;
}

.cs-bullet-list li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--text-pencil);
    font-weight: 700;
}

.cs-summary-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    column-gap: 80px;
    row-gap: 40px;
    align-items: flex-start;
}

.cs-summary-left {
    max-width: 350px;
}

.cs-summary-title {
    font-family: var(--font-sketch);
    font-size: 2.5rem;
    /* 40px */
    font-weight: 800;
    line-height: 1;
    margin-bottom: 20px;
}

.cs-summary-underline {
    width: 60px;
    height: 4px;
    background-color: #327F86;
    margin-bottom: 40px;
}

.cs-summary-intro {
    font-family: var(--font-ui);
    font-size: 1.125rem;
    /* 18px */
    line-height: 1.5;
    color: #444;
    /* Darker as per reference */
}

.cs-summary-full-image {
    grid-column: 1 / -1;
}

.cs-summary-right {
    display: flex;
    flex-direction: column;
    gap: 60px;
}

.cs-summary-body-text {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.cs-summary-body-text p {
    font-family: var(--font-ui);
    font-size: 1.125rem;
    /* 18px */
    line-height: 1.6;
    color: #555;
    margin-bottom: 0;
}

.cs-summary-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 48px 40px;
}

.cs-stat-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cs-stat-label {
    font-family: var(--font-ui);
    font-size: 0.95rem;
    color: #888;
    font-weight: 500;
}

.cs-stat-value {
    font-family: var(--font-sketch);
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text-pencil);
}

.cs-divider {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.15);
    width: 100%;
    margin: 24px 0;
    /* Reduced from 40px */
}

/* --- Responsive Video Container --- */
.cs-video-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    /* 16:9 Aspect Ratio */
    height: 0;
    overflow: hidden;
    border-radius: 12px;
}

.cs-video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* --- Smart Mobile Navigation --- */
#cs-mobile-nav {
    display: none;
}

@media (max-width: 1100px) {
    .go-back-link {
        display: none !important;
    }

    #cs-mobile-nav {
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        padding: 16px 5%;
        background-color: rgba(250, 248, 245, 0.85);
        /* Glassy effect */
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        z-index: 10000;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
        transition: transform 0.3s ease;
    }

    #cs-mobile-nav.nav-hidden {
        transform: translateY(-100%);
    }

    .cs-mobile-back {
        color: var(--text-pencil);
        display: flex;
        align-items: center;
        justify-content: center;
        text-decoration: none;
    }

    .cs-mobile-toc-btn {
        display: flex;
        align-items: center;
        background: none;
        border: none;
        font-family: var(--font-ui);
        font-size: 14px;
        font-weight: 600;
        color: #000;
        cursor: pointer;
        padding: 0;
        margin-left: auto;
        /* Push to right when back button is hidden */
    }

    .cs-mobile-toc-btn svg {
        width: 20px;
        height: 20px;
    }

    .toc-btn-content,
    .toc-btn-close {
        display: flex;
        align-items: center;
        gap: 6px;
    }

    /* Prevent active link from remaining bold and change color to dark grey on mobile */
    .cs-toc-list li.active a {
        font-weight: 500 !important;
        color: #666 !important;
    }

    .cs-article-layout {
        flex-direction: column;
        padding: 60px 8%;
    }

    .cs-sidebar {
        display: none;
        position: fixed;
        top: 52px;
        /* Below nav (16px + 16px padding + 20px icon = 52px) */
        left: 0;
        width: 100%;
        height: calc(100dvh - 52px);
        /* dvh handles address bar better */
        background-color: var(--bg-paper);
        z-index: 9999;
        padding: 24px 5% 80px 5%;
        /* added 80px bottom padding so it skips under scroll */
        overflow-y: auto;
        /* Allow scrolling if contents don't fit in 100vh */
        box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.03);
    }

    .cs-sidebar.active {
        display: block;
    }

    .cs-toc-label {
        color: #AAA !important;
    }

    .cs-toc-list {
        gap: 16px;
        /* Revert default gap, we'll control it with margin */
    }

    .cs-toc-list li a {
        font-size: 16px;
        /* 16px font size */
        color: #000 !important;
    }

    .cs-toc-list li {
        margin-top: 4px;
        /* 4px distance up */
        margin-bottom: 4px;
        /* 4px distance down */
    }

    .cs-outline-btn {
        width: 100%;
        /* Fill button width */
        justify-content: center;
        /* Center content inside button */
    }

    .cs-main-content {
        gap: 0;
    }

    .cs-summary-grid {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .cs-summary-left {
        max-width: 100%;
    }
}

@media (max-width: 600px) {
    .cs-article-layout {
        padding: 40px 5%;
    }

    .cs-summary-stats-grid {
        grid-template-columns: 1fr;
    }

    .cs-stat-value {
        font-size: 3rem;
    }
}

@media (max-width: 1100px) {
    .hero-main-row {
        flex-direction: column;
        gap: 3rem;
    }

    .hero-right {
        align-items: flex-start;
        text-align: left;
    }

    .project-number {
        font-size: 8rem;
    }

    .project-meta-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 3rem;
    }
}

@media (max-width: 600px) {
    .case-study-hero {
        padding: 64px 5% 8px;
    }

    .case-study-title {
        font-size: 40px;
        line-height: 1.2;
        letter-spacing: -1.5px;
    }

    .project-meta-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .cs-section-title,
    .cs-summary-title,
    .cs-card-section .cs-section-title {
        font-size: 28px;
        margin-bottom: 12px;
    }

    .cs-paragraph,
    .cs-summary-intro,
    .cs-bullet-list li,
    .cs-main-content p {
        font-size: 16px;
    }

    .cs-card-grid,
    .cs-summary-grid {
        grid-template-columns: 1fr;
    }

    #validation-rollout.cs-summary-grid {
        gap: 24px;
    }

    #validation-rollout .cs-summary-underline {
        margin-bottom: 0px;
    }

    #validation-rollout .cs-summary-right {
        gap: 24px;
    }

    #validation-rollout .cs-summary-right p {
        margin-top: 0px !important;
    }

    #future-goals.cs-summary-grid {
        gap: 24px;
        margin-bottom: 24px;
    }

    #future-goals .cs-summary-underline {
        margin-bottom: 0px;
    }

    #future-goals .cs-summary-intro {
        margin-bottom: 0px;
    }

    #lessons-learned ul.cs-paragraph {
        margin-bottom: 0px;
    }

    #lessons-learned {
        padding: 24px !important;
    }

    #wrap-up {
        padding-top: 0px !important;
    }

    #wrap-up .cs-paragraph {
        font-size: 16px !important;
    }

    .cs-primary-btn {
        font-size: 16px !important;
        padding: 12px 24px !important;
    }

    .cs-primary-btn .cs-desktop-text {
        display: none !important;
    }

    .cs-primary-btn .cs-mobile-text {
        display: inline !important;
    }

    .cs-wrap-btn-container {
        margin: 24px 0 !important;
    }

    #validation.cs-card-section {
        padding: 24px !important;
        margin-bottom: 0px !important;
    }
}

/* Image Modal Styles */
.cs-image-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(250, 248, 245, 0.95);
    /* matching paper background with opacity */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cs-image-modal.show {
    opacity: 1;
}

.cs-modal-content {
    margin: auto;
    display: block;
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 40px 120px rgba(0, 0, 0, 0.08);
    /* Smoother, softer shadow */
    border: 1px solid #E3D9C6;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: zoom-out;
    /* Show that clicking closes the modal */
}

.cs-image-modal.show .cs-modal-content {
    transform: scale(1);
}

.cs-close-modal {
    position: absolute;
    top: 30px;
    right: 40px;
    color: var(--text-pencil);
    font-size: 40px;
    font-weight: 300;
    cursor: pointer;
    transition: opacity 0.2s;
    line-height: 1;
    z-index: 10000;
}

.cs-close-modal:hover {
    opacity: 0.6;
}

.cs-outline-btn:hover {
    background-color: var(--color-highlight);
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(50, 127, 134, 0.2);
}

.cs-primary-btn:hover {
    background-color: #26636a;
    /* Slightly darker teal */
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(50, 127, 134, 0.4);
}