/* =========================================================
   Case study layout v2 (inspired by Ben Shih's case studies)
   Big title, info card, cover, impact cards, one narrow reading
   column, a floating "On this page" box and "More case studies".
   Loaded after case-study.css on every case study page.
   ========================================================= */

.csx {
    --csx-ink: var(--text-pencil, #1A1A18);
    --csx-teal: var(--color-highlight, #266268);
    --csx-teal-dark: var(--color-highlight-dark, #1B4A4F);
    --csx-muted: #5c5c56;
    --csx-line: var(--line, #D2CDC4);
    --csx-sand: #F6F1E7;
    --csx-text: 680px;
    --csx-wide: 940px;
    --csx-hero: 1040px;
}

/* ---------- Hero ---------- */
.csx-hero {
    max-width: calc(var(--csx-hero) + 48px);
    margin: 0 auto;
    padding: 40px 24px 0;
}

.csx-crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--csx-muted);
    margin-bottom: 20px;
}

.csx-crumbs a {
    color: var(--csx-teal-dark);
    text-decoration: none;
}

.csx-crumbs a:hover {
    text-decoration: underline;
}

.csx-crumbs .csx-dot {
    color: #b9b2a3;
}

.csx-title {
    font-family: var(--font-sketch);
    font-weight: 700;
    font-size: clamp(2.5rem, 5.4vw, 4.4rem);
    line-height: 1.03;
    letter-spacing: -0.02em;
    color: var(--csx-ink);
    max-width: 900px;
    margin: 0;
}

/* Longer titles: a wider column so they sit on two even lines */
.csx-title.csx-title-wide {
    max-width: 1000px;
    text-wrap: balance;
}

.csx-title .text-accent {
    color: var(--csx-teal-dark);
}

.csx-lede {
    font-family: var(--font-ui);
    font-size: 1.12rem;
    line-height: 1.65;
    color: #44443f;
    max-width: 720px;
    margin: 20px 0 0;
}

.csx-hero .ia-hero-actions {
    margin-top: 24px;
}

/* Info card: Overview, My role, Team, Timeline */
.csx-meta {
    display: grid;
    grid-template-columns: 1.9fr 1.3fr 1.2fr 1fr;
    gap: 28px;
    margin-top: 32px;
    padding: 24px 26px;
    background: #fff;
    border: 0.5px solid var(--line, #E5E1D8);
    border-radius: 10px;
    box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.1);
}

.csx-meta-label {
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--csx-ink);
    margin: 0 0 8px;
}

.csx-meta-text {
    font-family: var(--font-ui);
    font-size: 0.95rem;
    line-height: 1.55;
    color: #4a4a45;
    margin: 0;
}

/* Cover image */
.csx-cover {
    margin: 32px 0 0;
    border-radius: 12px;
    overflow: hidden;
    border: 0.5px solid var(--line, #E5E1D8);
    box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.1);
    background: #fff;
}

.csx-cover img,
.csx-cover video {
    display: block;
    width: 100%;
    height: auto;
    border: 0 !important;
    border-radius: 0 !important;
}

/* Impact overview */
.csx-impact {
    margin-top: 28px;
    padding: 20px 22px 22px;
    background: var(--csx-sand);
    border: 1px solid var(--csx-line);
    border-radius: 12px;
}

.csx-impact-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-ui);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--csx-ink);
    margin: 0 0 14px;
}

.csx-impact-title svg {
    width: 18px;
    height: 18px;
    color: var(--csx-teal);
}

.csx-impact-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.csx-impact-card {
    background: #fff;
    border: 1.2px solid var(--csx-teal);
    border-radius: 10px;
    padding: 16px 16px 18px;
}

.csx-impact-card h3 {
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 700;
    color: var(--csx-ink);
    margin: 0 0 8px;
}

.csx-impact-card p {
    font-family: var(--font-ui);
    font-size: 0.95rem;
    line-height: 1.55;
    color: #4a4a45;
    margin: 0;
}

.csx-impact-card strong {
    color: var(--csx-ink);
}

/* ---------- Reading layout ---------- */
.csx-layout {
    position: relative;
    padding: 96px 24px 24px;
}

.csx-body {
    display: block;
    max-width: var(--csx-wide);
    margin: 0 auto;
}

/* Sections: images and grids use the wide column, text stays narrow */
.csx-body > .cs-content-section {
    width: 100%;
    max-width: var(--csx-wide);
    margin: 0 auto 88px;
    padding: 0;
    scroll-margin-top: 96px;
}

.csx-body > .cs-content-section:last-child {
    margin-bottom: 40px;
}

.csx-body > .cs-content-section > :is(h2, h3, h4, p, ul, ol, blockquote, .cs-summary-left, .cs-summary-right, .cs-summary-body-text),
.csx-body .cs-summary-grid > :is(.cs-summary-left, .cs-summary-right, h2, p, ul, ol) {
    max-width: var(--csx-text);
    margin-left: auto;
    margin-right: auto;
}

/* Sections built from wide text rows (Softworker's Key Design Decisions):
   the heading spans the same width so it lines up with the rows below */
.csx-body > .cs-content-section:has(> .sw-decision) > .cs-section-title {
    max-width: var(--csx-wide);
}

/* Old two column blocks become one reading column */
.csx-body .cs-summary-grid {
    display: block;
}

.csx-body .cs-summary-left,
.csx-body .cs-summary-right {
    display: block;
    max-width: var(--csx-text);
}

.csx-body .cs-summary-right {
    margin-top: 16px;
}

.csx-body .cs-summary-body-text {
    gap: 16px;
}

.csx-body .cs-summary-underline,
.csx-body .cs-divider,
.csx-layout > .cs-divider {
    display: none;
}

/* Headings */
.csx-body .cs-section-title,
.csx-body .cs-summary-title,
.csx-body .cs-card-section .cs-section-title {
    font-family: var(--font-sketch);
    font-size: clamp(1.8rem, 3vw, 2.25rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.01em;
    color: var(--csx-ink);
    margin-top: 0;
    margin-bottom: 16px;
}

.csx-body .cs-card-subtitle,
.csx-body > .cs-content-section > h3 {
    font-size: 1.35rem;
    line-height: 1.3;
    margin-bottom: 12px;
}

/* Body text */
.csx-body .cs-paragraph,
.csx-body .cs-summary-intro,
.csx-body .cs-summary-body-text p,
.csx-body > .cs-content-section > p {
    font-family: var(--font-ui);
    font-size: 1.06rem;
    line-height: 1.75;
    color: #33332f;
    margin-bottom: 1.1rem;
}

.csx-body .cs-summary-intro {
    font-size: 1.12rem;
    color: var(--csx-ink);
}

.csx-body .cs-bullet-list {
    gap: 0.8rem;
    margin-bottom: 1.2rem;
}

.csx-body .cs-bullet-list li {
    font-size: 1.02rem;
    line-height: 1.7;
    color: #3a3a36;
}

/* Figures: a soft card with the caption under the image */
.csx-body .cs-summary-full-image {
    max-width: var(--csx-wide);
    margin: 32px auto;
    padding: 10px;
    background: #fff;
    border: 1px solid var(--csx-line);
    border-radius: 14px;
}

.csx-body .cs-summary-full-image .cs-section-img,
.csx-body .cs-summary-full-image img,
.csx-body .cs-summary-full-image video {
    display: block;
    width: 100%;
    border: 0;
    border-radius: 8px;
}

.csx-body .cs-summary-full-image > p,
.csx-body .cs-summary-full-image figcaption,
.csx-body .abdm-caption {
    font-family: var(--font-ui);
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--csx-muted);
    text-align: center;
    margin: 10px auto 2px;
    max-width: var(--csx-text);
}

.csx-body .cs-section-img {
    border-color: var(--csx-line);
}

/* Images that sit straight in the text column get the same frame, with even space on every side */
.csx-body .cs-summary-left > .cs-section-img,
.csx-body .cs-summary-right > .cs-section-img,
.csx-body .cs-content-section > .cs-section-img {
    display: block;
    width: 100%;
    height: auto;
    box-sizing: border-box;
    padding: 10px;
    background: #fff;
    border: 1px solid var(--csx-line);
    border-radius: 14px;
}

/* Cards inside the story */
.csx-body .cs-card-section {
    max-width: var(--csx-wide);
    margin: 32px auto;
    padding: 28px;
    background: var(--csx-sand);
    border: 1px solid var(--csx-line);
    border-radius: 14px;
    box-shadow: none;
}

.csx-body .cs-card-section .cs-card-grid {
    gap: 28px;
}

.csx-body .abdm-stat {
    border: 1px solid var(--csx-line);
}

/* Side note in the right margin on wide screens (use class csx-note) */
.csx-note {
    font-family: var(--font-ui);
    font-size: 0.85rem;
    line-height: 1.5;
    color: #7a2f25;
    background: #FFF1EE;
    border: 1px solid #F2C6BE;
    border-radius: 8px;
    padding: 10px 12px;
    max-width: var(--csx-text);
    margin: 12px auto;
}

/* ---------- On this page (floating box) ---------- */
.csx-toc {
    position: fixed;
    top: 96px;
    left: 24px;
    width: 212px;
    max-height: calc(100vh - 128px);
    overflow-y: auto;
    padding: 14px 12px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--csx-line);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(26, 26, 24, 0.06);
    font-family: var(--font-ui);
    z-index: 50;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.csx-toc.is-visible {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.csx-toc-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--csx-muted);
    margin: 0 0 10px 8px;
}

.csx-toc ol {
    list-style: none;
    margin: 0;
    padding: 0;
}

.csx-toc-group > a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 7px;
    font-size: 0.86rem;
    font-weight: 600;
    color: #3d3d39;
    text-decoration: none;
}

.csx-toc-group > a::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: transparent;
    flex: none;
}

.csx-toc-group > a:hover {
    background: #F4EFE6;
}

.csx-toc-group.is-active > a {
    background: #E6F1F1;
    color: var(--csx-teal-dark);
}

.csx-toc-group.is-active > a::before {
    background: var(--csx-teal);
}

.csx-toc-sub {
    display: none;
    margin: 2px 0 6px 14px !important;
    padding-left: 10px !important;
    border-left: 1px solid var(--csx-line);
}

.csx-toc-group.is-active .csx-toc-sub {
    display: block;
}

.csx-toc-sub a {
    display: block;
    padding: 4px 6px;
    font-size: 0.78rem;
    line-height: 1.35;
    color: #6b6b64;
    text-decoration: none;
    border-radius: 5px;
}

.csx-toc-sub a:hover {
    color: var(--csx-ink);
}

.csx-toc-sub a.is-current {
    color: var(--csx-teal-dark);
    font-weight: 700;
}

.csx-toc a:focus-visible {
    outline: 2px solid var(--csx-teal);
    outline-offset: 1px;
}

.csx-toc-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 12px 4px 2px;
    padding: 9px 10px;
    border: 0.5px solid var(--line, #E5E1D8);
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--csx-ink);
    text-decoration: none;
    background: #fff;
}

.csx-toc-cta:hover {
    background: var(--csx-ink);
    color: #fff;
}

/* Phone and tablet: the box opens from a button */
.csx-toc-btn {
    display: none;
}

@media (max-width: 1279px) {
    .csx-toc {
        top: auto;
        bottom: 84px;
        left: 16px;
        right: 16px;
        width: auto;
        max-height: 60vh;
        box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.1);
        border-color: rgba(26, 26, 24, 0.5);
        opacity: 0;
        transform: translateY(12px);
        pointer-events: none;
    }

    .csx-toc.is-visible {
        opacity: 0;
        transform: translateY(12px);
        pointer-events: none;
    }

    .csx-toc.is-open {
        background: #fff;
        opacity: 1 !important;
        transform: none !important;
        pointer-events: auto !important;
    }

    .csx-toc-sub {
        display: block;
    }

    .csx-toc-btn {
        position: fixed;
        right: 16px;
        bottom: 20px;
        z-index: 60;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        height: 46px;
        padding: 0 18px;
        border-radius: 999px;
        border: 1px solid var(--csx-ink);
        background: var(--csx-ink);
        color: #fff;
        font-family: var(--font-ui);
        font-size: 0.9rem;
        font-weight: 700;
        box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.1);
        cursor: pointer;
        opacity: 0;
        transform: translateY(10px);
        pointer-events: none;
        transition: opacity 0.3s ease, transform 0.3s ease;
    }

    .csx-toc-btn.is-visible {
        opacity: 1;
        transform: none;
        pointer-events: auto;
    }

    .csx-toc-btn svg {
        width: 16px;
        height: 16px;
    }
}

/* Keep wide images clear of the floating box */
@media (min-width: 1280px) and (max-width: 1480px) {
    .csx-body,
    .csx-body > .cs-content-section,
    .csx-body .cs-summary-full-image,
    .csx-body .cs-card-section {
        max-width: min(var(--csx-wide), calc(100vw - 540px));
    }
}

/* ---------- Further reading ---------- */
.csx-read-card {
    display: grid;
    gap: 6px;
    max-width: var(--csx-text);
    margin: 20px auto 0;
    padding: 20px 22px;
    background: #fff;
    border: 0.5px solid var(--line, #E5E1D8);
    border-radius: 12px;
    box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.1);
    text-decoration: none;
    color: var(--csx-ink);
    font-family: var(--font-ui);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.csx-read-card:hover {
    transform: translate(-2px, -2px);
    box-shadow: 7px 7px 0 rgba(0, 0, 0, 0.15);
}

.csx-read-meta {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--csx-muted);
}

.csx-read-title {
    font-family: var(--font-sketch);
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1.2;
}

.csx-read-desc {
    font-size: 0.95rem;
    line-height: 1.55;
    color: #4a4a45;
}

.csx-read-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--csx-teal-dark);
}

/* ---------- More case studies ---------- */
.csx-more {
    max-width: calc(var(--csx-text) + 120px);
    margin: 24px auto 96px;
    padding: 28px 24px 28px;
    background: var(--csx-sand);
    border: 1px solid var(--csx-line);
    border-radius: 16px;
}

.csx-more-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.csx-more-title {
    font-family: var(--font-sketch);
    font-size: 2rem;
    font-weight: 700;
    color: var(--csx-ink);
    margin: 0;
}

.csx-shuffle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid var(--csx-ink);
    background: var(--csx-ink);
    color: #fff;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
}

.csx-shuffle svg {
    width: 15px;
    height: 15px;
}

.csx-shuffle:hover {
    background: #33332f;
}

.csx-more-stage {
    position: relative;
    padding-top: 14px;
}

/* Two paper sheets behind the card, like a stack */
.csx-more-stage::before,
.csx-more-stage::after {
    content: "";
    position: absolute;
    left: 24px;
    right: 24px;
    top: 0;
    height: 30px;
    border: 1px solid var(--csx-line);
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
    background: #fff;
}

.csx-more-stage::after {
    left: 12px;
    right: 12px;
    top: 7px;
}

.csx-more-card {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    align-items: center;
    gap: 22px;
    padding: 14px;
    background: #fff;
    border: 0.5px solid var(--line, #E5E1D8);
    border-radius: 12px;
    box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.1);
    color: var(--csx-ink);
    text-decoration: none;
}

.csx-more-card[hidden] {
    display: none;
}

.csx-more-card img {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--csx-line);
    display: block;
}

.csx-more-tag {
    display: inline-block;
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--csx-teal-dark);
    margin-bottom: 6px;
}

.csx-more-name {
    font-family: var(--font-sketch);
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.15;
    margin: 0 0 8px;
}

.csx-more-desc {
    font-family: var(--font-ui);
    font-size: 0.92rem;
    line-height: 1.55;
    color: #4a4a45;
    margin: 0 0 14px;
}

.csx-more-go {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    border-radius: 8px;
    background: var(--csx-teal);
    color: #fff;
    font-family: var(--font-ui);
    font-size: 0.86rem;
    font-weight: 700;
}

.csx-more-card:hover .csx-more-go {
    background: var(--csx-teal-dark);
}

/* Keep arrow icons small and the button on one line */
.csx-read-cta svg,
.csx-more-go svg {
    width: 14px;
    height: 14px;
    flex: none;
}

.csx-more-go,
.csx-read-cta {
    white-space: nowrap;
    align-self: flex-start;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .csx-meta {
        grid-template-columns: 1fr 1fr;
        gap: 22px;
    }

    .csx-meta-overview {
        grid-column: 1 / -1;
    }

    .csx-impact-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .csx-hero {
        padding: 24px 16px 0;
    }

    .csx-title {
        font-size: 2.3rem;
        line-height: 1.08;
    }

    .csx-lede {
        font-size: 1rem;
    }

    .csx-meta {
        grid-template-columns: 1fr;
        padding: 20px;
        box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.1);
    }

    .csx-cover {
        box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.1);
    }

    .csx-layout {
        padding: 64px 16px 16px;
    }

    .csx-body > .cs-content-section {
        margin-bottom: 64px;
    }

    .csx-body .cs-paragraph,
    .csx-body .cs-summary-intro,
    .csx-body .cs-summary-body-text p,
    .csx-body .cs-bullet-list li,
    .csx-body > .cs-content-section > p {
        font-size: 1rem;
    }

    .csx-body .cs-summary-full-image {
        padding: 6px;
        margin: 24px auto;
    }

    .csx-body .cs-card-section {
        padding: 20px;
    }

    .csx-more {
        margin: 16px 16px 72px;
        padding: 20px 16px;
    }

    .csx-more-title {
        font-size: 1.6rem;
    }

    .csx-more-card {
        grid-template-columns: 1fr;
        gap: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .csx-toc,
    .csx-toc-btn,
    .csx-read-card {
        transition: none;
    }
}
