/**
 * Case study reading column.
 *
 * Every block in the article used to set its own inline padding: plain sections at 0,
 * panels and the TL;DR at 52px. Text zig-zagged between two left edges down the page,
 * and the new lede added a third. This puts all of them on one column and one gutter,
 * then steps the type down from the lede title so headings stop competing with it.
 *
 * Loaded after case-study-lede.css, and only on pages using the new lede.
 */

.case-study-container {
    --cs-gutter: clamp(1.25rem, 3vw, 2rem);
    --cs-heading-color: var(--color-text);
    /* Panels pad themselves from this variable, so pointing it at the shared gutter
       aligns their text with the plain sections instead of overriding padding. */
    --case-study-panel-pad-inline: var(--cs-gutter);
}

/* One column. The gutter is identical everywhere, so one left edge runs down the page. */
.case-study-container > .cs-lede,
.case-study-container > .case-study-section,
.case-study-container > .case-study-tldr,
.case-study-container > .case-study-hero,
.case-study-container > .case-study-back,
.case-study-container > .case-study-disclaimer {
    box-sizing: border-box;
    width: 100%;
    max-width: none;
    margin-inline: 0;
    padding-inline: var(--cs-gutter);
}

/* The nav is fixed, so the article needs to start below it rather than under it. */
.case-study-container {
    padding-top: calc(var(--layout-nav-height, 80px) + clamp(0.75rem, 2vh, 1.5rem));
}

.case-study-container > .case-study-back {
    margin-bottom: clamp(1rem, 3vh, 2rem);
}

.cs-lede {
    padding-top: 0;
}

/*
 * Fact strip. Four items that used to sit permanently expanded and cost most of a
 * screen. Collapsed they read as a single line each; the detail opens on hover,
 * focus, or tap. main.css force-expands these inside the container, so this undoes it.
 */
.case-study-container .case-study-hero {
    margin-bottom: clamp(1.75rem, 4vh, 2.75rem);
    padding-bottom: clamp(1.75rem, 4vh, 2.75rem);
}

.case-study-container .case-study-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: 0.5rem;
}

.case-study-container .meta-item {
    min-height: 0;
    padding: 0.7rem 0.85rem;
    gap: 0.5rem;
    cursor: default;
}

.case-study-container .meta-index {
    font-size: 0.65rem;
    opacity: 0.55;
}

.case-study-container .meta-label {
    font-family: var(--font-sans);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--color-text-light);
}

.case-study-container .meta-value {
    font-family: var(--font-sans);
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.3;
    color: var(--color-text);
}

.case-study-container .meta-detail {
    max-height: 0;
    margin-top: 0;
    opacity: 0;
    overflow: hidden;
}

.case-study-container .meta-item:hover .meta-detail,
.case-study-container .meta-item:focus-visible .meta-detail,
.case-study-container .meta-item:focus-within .meta-detail {
    max-height: 8rem;
    margin-top: 0.4rem;
    opacity: 1;
}

/*
 * TL;DR: a scan block, not a section. Column flow rather than grid, so each term stays
 * above its own definition. A grid put every dt in one column and every dd in another.
 */
.case-study-container .case-study-tldr dl {
    display: block;
    columns: 2;
    column-gap: 2rem;
}

.case-study-container .case-study-tldr dt {
    break-after: avoid;
    margin-bottom: 0.2rem;
}

.case-study-container .case-study-tldr dd {
    break-before: avoid;
    break-inside: avoid;
    margin: 0 0 1rem;
}

@media (max-width: 640px) {
    .case-study-container .case-study-tldr dl {
        columns: 1;
    }
}


/*
 * Section kicker. Was Playfair 24px uppercase, heavy enough to read as a heading and
 * fight the real one under it. Now it matches the lede kicker and behaves like a label.
 */
.case-study-container .case-study-section-title {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--color-text-light);
    margin-bottom: 0.65rem;
}

/* The heading the reader actually navigates by. One clear step below the lede title. */
.case-study-container .case-study-section-heading {
    font-family: var(--font-serif);
    font-size: clamp(1.5rem, 2.8vw, 2.05rem);
    font-weight: 700;
    line-height: 1.16;
    letter-spacing: -0.012em;
    color: var(--cs-heading-color);
    margin-top: 0;
    margin-bottom: 1.1rem;
    text-wrap: balance;
}

.case-study-container .case-study-text {
    font-family: var(--font-sans);
    font-size: 1.0625rem;
    font-weight: 400;
    line-height: 1.75;
    color: var(--color-text-light);
    max-width: 38rem;
    text-wrap: pretty;
}

.case-study-container .case-study-text + .case-study-text {
    margin-top: 1.1rem;
}

/*
 * The bullet is an absolutely positioned ::before at left:0, not a list marker, so the
 * li padding is the only thing holding its space. Shrinking that padding drops the dot
 * on top of the first letter.
 */
.case-study-container .case-study-list {
    padding-left: 0;
    margin-left: 0;
    list-style: none;
}

.case-study-container .case-study-list li {
    position: relative;
    margin-left: 0;
    padding-left: 1.5rem;
    font-family: var(--font-sans);
    font-size: 1.0625rem;
    line-height: 1.7;
    color: var(--color-text-light);
}

.case-study-container .case-study-list li + li {
    margin-top: 0.6rem;
}

/* Sized and baseline-aligned to the text rather than dropped in at 1.5rem. */
.case-study-container .case-study-list li::before {
    content: '\2022';
    position: absolute;
    left: 0.15rem;
    top: 0;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--color-accent);
}

/* Ordered lists keep their numbers instead of inheriting the dot. */
.case-study-container ol.case-study-list {
    counter-reset: cs-step;
}

.case-study-container ol.case-study-list li::before {
    counter-increment: cs-step;
    content: counter(cs-step);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 600;
    top: 0.2em;
}

/* Lead-in terms in a list are labels, so they stay in the sans face, not bold serif. */
.case-study-container .case-study-list li strong {
    font-weight: 600;
    color: var(--color-text);
}

/* TL;DR reads as a summary card, so its terms stay small and its text matches body copy. */
.case-study-container .case-study-tldr h2 {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--color-text-light);
    margin-bottom: 1.25rem;
}

.case-study-container .case-study-tldr dt {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-accent);
}

.case-study-container .case-study-tldr dd {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--color-text-light);
}

@media (max-width: 600px) {
    .case-study-container .case-study-text {
        font-size: 1rem;
    }
}

/* Shared visual evidence sequence. These frames stay explicit placeholders until
   a real artifact is available, so the page never presents invented work as proof. */
.case-study-visual-plan-intro {
    margin-bottom: 1.35rem;
}

.case-study-visual-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: clamp(0.85rem, 2vw, 1.25rem);
}

.case-study-visual-item {
    grid-column: span 4;
    display: grid;
    align-content: start;
    min-width: 0;
    margin: 0;
}

.case-study-visual-item:nth-child(2) {
    transform: translateY(clamp(0.75rem, 2vw, 1.5rem));
}

.case-study-visual-media {
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border: 1px solid var(--color-border);
    background: #e8e8e8;
}

.case-study-visual-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.fintech-synthesis {
    padding: clamp(0.65rem, 1.5vw, 1.15rem);
    border: 1px solid var(--color-border);
    background: var(--color-surface-muted);
}

.fintech-synthesis svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    font-family: var(--font-sans);
}

.fintech-synthesis__step rect {
    fill: color-mix(in srgb, var(--color-surface) 94%, var(--color-accent));
    stroke: color-mix(in srgb, var(--color-border) 82%, var(--color-accent));
    stroke-width: 1.5;
}

.fintech-synthesis__accent {
    fill: none;
    stroke: var(--color-accent);
    stroke-width: 4;
    stroke-linecap: round;
}

.fintech-synthesis__line,
.fintech-synthesis__arrow {
    fill: none;
    stroke: var(--color-accent);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.fintech-synthesis__index {
    fill: var(--color-accent);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.12em;
}

.fintech-synthesis__title {
    fill: var(--color-text);
    font-family: var(--font-serif);
    font-size: 22px;
    font-weight: 600;
}

.fintech-synthesis__copy {
    fill: var(--color-text-light);
    font-size: 15px;
}

.fintech-synthesis__review {
    fill: color-mix(in srgb, var(--color-accent) 12%, var(--color-surface));
    stroke: color-mix(in srgb, var(--color-accent) 55%, var(--color-border));
    stroke-width: 2;
}

.fintech-synthesis__review-text {
    fill: var(--color-text);
    font-size: 16px;
    font-weight: 600;
}

.psqr-contribution-module,
.psqr-closing-module {
    padding-block: clamp(1.35rem, 3vw, 2rem);
}

.psqr-role-tools-grid,
.psqr-closing-module > div {
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    gap: clamp(1.25rem, 4vw, 3rem);
    margin-top: 1.15rem;
}

.psqr-role-tools-grid > div + div,
.psqr-closing-module article + article {
    padding-left: clamp(1.25rem, 4vw, 3rem);
    border-left: 1px solid var(--color-border);
}

.psqr-role-tools-grid h4,
.psqr-closing-module h4 {
    margin: 0 0 0.65rem;
    color: var(--color-text);
    font-family: var(--font-serif);
    font-size: clamp(1.2rem, 2vw, 1.55rem);
}

.psqr-role-tools-grid p,
.psqr-closing-module p {
    margin: 0;
    color: var(--color-text-light);
    font: 400 0.94rem/1.65 var(--font-sans);
}

.psqr-closing-module p + p {
    margin-top: 0.75rem;
}

.psqr-role-tools-grid .case-study-tools {
    margin-top: 0;
}

.psqr-decision-map {
    margin: clamp(1.5rem, 4vw, 2.5rem) 0 0;
    padding: clamp(1rem, 2.5vw, 1.75rem);
    border: 1px solid var(--color-border);
    background: color-mix(in srgb, var(--color-surface-muted) 94%, var(--color-accent));
}

.psqr-decision-map > figcaption {
    margin-bottom: 1.15rem;
    color: var(--color-text);
    font-family: var(--font-serif);
    font-size: clamp(1.35rem, 2.5vw, 2rem);
    font-weight: 600;
}

.psqr-decision-map ol {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: clamp(0.75rem, 2vw, 1.25rem);
    margin: 0;
    padding: 0;
    list-style: none;
}

.psqr-decision-map li {
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 11rem;
    flex-direction: column;
    padding: 1rem;
    border: 1px solid color-mix(in srgb, var(--color-border) 76%, var(--color-accent));
    border-top: 3px solid var(--color-accent);
    background: var(--color-surface);
}

.psqr-decision-map li:not(:last-child)::after {
    position: absolute;
    z-index: 1;
    top: 50%;
    right: calc(clamp(0.75rem, 2vw, 1.25rem) * -0.72);
    color: var(--color-accent);
    content: '→';
    font: 700 1.3rem/1 var(--font-sans);
    transform: translateY(-50%);
}

.psqr-decision-map li > span {
    margin-bottom: 1.1rem;
    color: var(--color-accent);
    font: 700 0.72rem/1 var(--font-sans);
    letter-spacing: 0.14em;
}

.psqr-decision-map strong {
    color: var(--color-text);
    font-family: var(--font-serif);
    font-size: 1.1rem;
    line-height: 1.2;
}

.psqr-decision-map small {
    margin-top: 0.65rem;
    color: var(--color-text-light);
    font: 400 0.78rem/1.5 var(--font-sans);
}

.psqr-decision-map > p {
    margin: 1rem 0 0;
    padding: 0.8rem 1rem;
    border: 1px solid color-mix(in srgb, var(--color-accent) 58%, var(--color-border));
    border-radius: 999px;
    color: var(--color-text);
    font: 600 0.8rem/1.4 var(--font-sans);
    text-align: center;
}

.psqr-closing-module {
    background: color-mix(in srgb, var(--color-surface-muted) 88%, transparent);
}

.concierge-prototype-gallery {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(0.75rem, 2vw, 1.25rem);
    margin-top: var(--spacing-lg);
}

.concierge-prototype-gallery figure {
    min-width: 0;
    margin: 0;
}

.concierge-prototype-gallery__viewport {
    height: clamp(24rem, 52vw, 38rem);
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: var(--color-surface-muted);
    scrollbar-width: thin;
    scrollbar-color: var(--color-accent) transparent;
}

.concierge-prototype-gallery__viewport:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 3px;
}

.concierge-prototype-gallery img {
    display: block;
    width: 100%;
    height: auto;
}

.concierge-prototype-gallery figcaption {
    margin-top: 0.65rem;
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-light);
}

@media (max-width: 640px) {
    .fintech-synthesis {
        overflow-x: auto;
    }

    .fintech-synthesis svg {
        width: 760px;
        max-width: none;
    }

    .psqr-role-tools-grid,
    .psqr-closing-module > div,
    .psqr-decision-map ol {
        grid-template-columns: 1fr;
    }

    .psqr-role-tools-grid > div + div,
    .psqr-closing-module article + article {
        padding-top: 1.25rem;
        padding-left: 0;
        border-top: 1px solid var(--color-border);
        border-left: 0;
    }

    .psqr-decision-map li {
        min-height: 0;
    }

    .psqr-decision-map li:not(:last-child)::after {
        top: auto;
        right: 50%;
        bottom: -1.1rem;
        transform: translateX(50%) rotate(90deg);
    }

    .psqr-decision-map > p {
        border-radius: 1rem;
    }

    .concierge-prototype-gallery {
        grid-template-columns: 1fr;
    }

    .concierge-prototype-gallery__viewport {
        height: min(70vh, 38rem);
    }
}

.case-study-visual-canvas {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    aspect-ratio: 4 / 3;
    padding: 0.85rem;
    overflow: hidden;
    border: 1px dashed color-mix(in srgb, var(--color-text-light) 52%, transparent);
    background:
        linear-gradient(90deg, transparent 49.5%, color-mix(in srgb, var(--color-border) 65%, transparent) 50%, transparent 50.5%),
        linear-gradient(transparent 49.5%, color-mix(in srgb, var(--color-border) 65%, transparent) 50%, transparent 50.5%),
        var(--color-surface-muted);
    background-size: 2rem 2rem;
}

.case-study-visual-canvas::after {
    content: '';
    position: absolute;
    right: 0.85rem;
    bottom: 0.85rem;
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid color-mix(in srgb, var(--color-accent) 60%, transparent);
    border-radius: 50%;
}

.case-study-visual-index,
.case-study-visual-status {
    position: relative;
    z-index: 1;
    font-family: var(--font-sans);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.case-study-visual-index {
    color: var(--color-accent);
}

.case-study-visual-status {
    color: var(--color-text-light);
}

.case-study-visual-caption {
    display: grid;
    gap: 0.35rem;
    padding-top: 0.85rem;
}

.case-study-visual-title,
.case-study-visual-detail {
    display: block;
}

.case-study-visual-title {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    line-height: 1.25;
    color: var(--color-text);
}

.case-study-visual-detail {
    font-family: var(--font-sans);
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--color-text-light);
}

@media (max-width: 760px) {
    .case-study-visual-grid {
        grid-template-columns: 1fr;
    }

    .case-study-visual-item {
        grid-column: 1;
        grid-template-columns: minmax(8rem, 0.8fr) minmax(0, 1fr);
        gap: 1rem;
        align-items: start;
    }

    .case-study-visual-item:nth-child(2) {
        transform: none;
    }

    .case-study-visual-caption {
        padding-top: 0;
    }
}

@media (max-width: 430px) {
    .case-study-visual-item {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

/* ---------------------------------------------------------------------------
 * Article graphics. Drawn for this case study rather than pulled from an icon
 * set: the subject is abstract, so the figures carry the explanation.
 * All of them use currentColor and the theme tokens so light mode works.
 * ------------------------------------------------------------------------- */

.cs-opening-lead {
    font-size: clamp(1.15rem, 2vw, 1.375rem);
    line-height: 1.6;
    color: var(--color-text);
    max-width: 36rem;
}

/* Scale strip: the three numbers that frame the problem. */
.cs-scale {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: 1px;
    margin: clamp(1.75rem, 4vh, 2.5rem) 0 0;
    background: var(--color-border);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    overflow: hidden;
}

.cs-scale-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 1.1rem 1.15rem;
    background: var(--color-bg);
}

.cs-scale-figure {
    font-family: var(--font-serif);
    font-size: clamp(1.6rem, 3.2vw, 2.25rem);
    font-weight: 700;
    line-height: 1;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}

.cs-scale-label {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--color-text-light);
}

/* Method diagram: four stages, drawn so the shapes show what each stage does. */
.cs-diagram {
    margin: clamp(1.5rem, 3.5vh, 2.25rem) 0;
}

.cs-diagram svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.cs-diagram-caption {
    margin: 0.85rem 0 0;
    font-family: var(--font-sans);
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--color-text-light);
}

.cs-dg-dot { fill: var(--color-text-light); opacity: 0.45; }
.cs-dg-dot-live { fill: var(--color-accent); opacity: 1; }
.cs-dg-dot-dead { fill: var(--color-text-light); opacity: 0.16; }
.cs-dg-hull { fill: none; stroke: var(--color-accent); stroke-opacity: 0.5; stroke-width: 1.25; }
.cs-dg-frame { fill: none; stroke: var(--color-border); stroke-width: 1; }
.cs-dg-arrow { fill: none; stroke: var(--color-text-light); stroke-width: 1.1; opacity: 0.5; }
.cs-dg-num {
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    fill: var(--color-text-light);
    text-transform: uppercase;
}
.cs-dg-title {
    font-family: var(--font-sans);
    font-size: 12.5px;
    font-weight: 600;
    fill: var(--color-text);
}
.cs-dg-note {
    font-family: var(--font-sans);
    font-size: 11px;
    fill: var(--color-text-light);
}

@media (max-width: 560px) {
    .cs-scale-figure { font-size: 1.5rem; }
}

/* Grab-and-drag affordance for scrollable prototype viewports. */
.concierge-prototype-gallery__viewport.is-drag-scrollable {
    cursor: grab;
}

.concierge-prototype-gallery__viewport.is-drag-scrolling {
    cursor: grabbing;
    user-select: none;
    scroll-behavior: auto;
}

.concierge-prototype-gallery__viewport.is-drag-scrolling img {
    pointer-events: none;
}
