/* Case pages: the inner pages in /work. Loads after style.css and uses its tokens. */

.vh {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Long-form reading needs a real gutter on small phones. */
.case-page .container {
    padding-inline: clamp(1.25rem, 5vw, 3rem);
}

/* Bar */
.case-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 2rem;
    min-height: 40px;
    margin-top: clamp(1.5rem, 4vh, 2.5rem);
    padding-right: 56px;
}

.case-home {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    line-height: 1;
    letter-spacing: -0.01em;
    color: var(--text-color);
    text-decoration: none;
}

.case-home em {
    font-style: italic;
    color: var(--accent-color);
}

.case-bar-nav {
    display: flex;
    gap: 1.5rem;
}

.case-bar-nav a {
    display: inline-block;
    padding: 0.5rem 0;
    font-size: 0.9375rem;
    color: var(--text-light);
    text-decoration: none;
}

.case-bar-nav a:hover {
    color: var(--text-color);
}

@media (min-width: 1200px) {
    .case-bar {
        padding-right: 0;
    }
}

/* Header */
.case-header {
    padding-top: clamp(4rem, 12vh, 8rem);
}

.case-title {
    font-family: var(--font-heading);
    font-size: clamp(3.25rem, 9vw, 7.5rem);
    font-weight: 400;
    line-height: 0.98;
    letter-spacing: -0.025em;
    text-wrap: balance;
    color: var(--text-color);
    margin-bottom: clamp(1.5rem, 3vw, 2.25rem);
}

.case-lede {
    font-size: clamp(1.125rem, 0.6vw + 1rem, 1.375rem);
    line-height: 1.55;
    max-width: 50ch;
    color: var(--text-color);
    text-wrap: pretty;
}

.case-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 1.25rem 2rem;
    margin-top: clamp(2rem, 5vw, 3.5rem);
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.case-meta dt {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-light);
    margin-bottom: 0.25rem;
}

.case-meta dd {
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--text-color);
}

/* Sections */
.case-section {
    margin-top: clamp(4.5rem, 10vw, 8rem);
    padding-top: 1.25rem;
    border-top: 1px solid var(--rule);
}

.case-section h2 {
    font-family: var(--font-heading);
    font-size: clamp(1.875rem, 3.2vw, 2.625rem);
    font-weight: 400;
    line-height: 1.1;
    letter-spacing: -0.01em;
    text-wrap: balance;
    color: var(--text-color);
    margin-bottom: 1.25rem;
}

@media (min-width: 960px) {
    .case-section {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
        column-gap: clamp(2rem, 5vw, 4.5rem);
        align-items: start;
    }

    .case-section > * {
        grid-column: 2;
    }

    .case-section > h2 {
        grid-column: 1;
        grid-row: 1;
        margin-bottom: 0;
        padding-right: 1rem;
        position: sticky;
        top: 1.5rem;
    }

    .case-section > .case-figure {
        grid-column: 1 / -1;
    }
}

/* Body copy */
.case-body {
    max-width: 62ch;
}

.case-figure + .case-body {
    margin-top: clamp(2.5rem, 6vw, 4rem);
}

.case-body > * + * {
    margin-top: 1.1em;
}

.case-body p,
.case-body li {
    font-size: 1.0625rem;
    line-height: 1.7;
    color: var(--text-color);
    text-wrap: pretty;
}

.case-body ol,
.case-body ul {
    padding-left: 1.25rem;
}

.case-body li + li {
    margin-top: 0.5em;
}

.case-body a {
    color: var(--accent-text);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    text-decoration-color: color-mix(in srgb, var(--accent-text) 40%, transparent);
}

.case-body a:hover {
    color: var(--accent-text-hover);
    text-decoration-color: currentColor;
}

.case-body code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.875em;
    padding: 0.1em 0.35em;
    border-radius: var(--radius-sm);
    background: var(--background-elevated);
}

/* A process, read as one line of steps */
.case-body .case-steps {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    row-gap: 0.25rem;
}

.case-body .case-steps li {
    margin: 0;
    font-size: 1rem;
    line-height: 1.6;
}

.case-steps li + li::before {
    content: "›";
    content: "›" / "";
    margin: 0 0.55em;
    color: var(--text-light);
}

/* Results and other plain lists */
.case-body .case-list {
    list-style: none;
    padding: 0;
}

.case-body .case-list li {
    margin: 0;
    padding: 0.875rem 0;
    border-top: 1px solid var(--rule);
}

.case-body .case-list li:last-child {
    border-bottom: 1px solid var(--rule);
}

/* Feature definitions */
.case-features {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: 1.75rem 2rem;
}

.case-features div {
    padding-top: 0.875rem;
    border-top: 1px solid var(--rule);
}

.case-features dt {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    line-height: 1.15;
    color: var(--text-color);
    margin-bottom: 0.375rem;
}

.case-features dd {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-light);
}

/* Figures */
.case-figure {
    margin: clamp(2.5rem, 6vw, 4.5rem) 0 0;
}

.case-hero {
    margin-top: clamp(2.5rem, 6vw, 4rem);
}

.case-zoom {
    position: relative;
    display: block;
    cursor: zoom-in;
    border-radius: var(--radius-lg);
}

.case-zoom.is-phone {
    border-radius: var(--radius-phone);
}

.case-zoom:focus-visible {
    outline-offset: 3px;
}

.case-shot,
.case-phone {
    display: block;
    width: 100%;
    height: auto;
}

.case-shot {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    background: var(--background-elevated);
}

.case-phone {
    border-radius: var(--radius-phone);
}

.case-video {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-lg);
    background: #0b1b11;
}

/* Rows: flex-grow is each image's aspect ratio, so every image in a row is the same height. */
.case-row {
    display: flex;
    align-items: flex-start;
    gap: clamp(0.75rem, 2vw, 1.5rem);
}

.case-row > * {
    flex: var(--r, 1) 1 0%;
    min-width: 0;
}

.case-stack {
    display: grid;
    gap: clamp(0.75rem, 2vw, 1.5rem);
}

.case-narrow {
    max-width: 18rem;
    margin-inline: auto;
}

.case-contain {
    max-width: 36rem;
    margin-inline: auto;
}

/* Panels give phone screens and transparent artwork a ground. */
.case-panel {
    padding: clamp(1rem, 4vw, 3rem);
    border-radius: var(--radius-lg);
    background: var(--background-elevated);
}

.case-panel > .case-row {
    max-width: 56rem;
    margin-inline: auto;
}

.case-panel--sage {
    background: #2f6945;
}

.case-panel--sage .case-zoom.is-phone,
.case-panel--sage .case-phone {
    border-radius: var(--radius-md);
}

.case-panel--ink {
    background: #0b1b11;
}

.case-panel--ink .case-zoom:focus-visible,
.case-panel--sage .case-zoom:focus-visible {
    outline-color: #e8dfd2;
}

/* Charts are HTML, not images, so their numbers stay sharp at any width. */
.case-figure.is-chart {
    margin-top: clamp(1.75rem, 4vw, 2.5rem);
}

.case-chart {
    --chart-users: #a87829;
    --chart-active: #7a5117;
    --chart-referral: #2a2520;
    --chart-industry: #8a7f72;
    --chart-industry-referral: #3d3530;
    --chart-label: #faf5ec;
    --chart-bar: clamp(2.5rem, 9cqi, 3.25rem);
    --chart-industry-bar: clamp(0.75rem, 3.5cqi, 1.375rem);
    --chart-plot: clamp(15rem, 56cqi, 19rem);
    container-type: inline-size;
    max-width: 40rem;
    padding: clamp(0.75rem, 3.5vw, 1.75rem);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--background-elevated);
    font-variant-numeric: tabular-nums;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.dark-mode .case-chart {
    --chart-users: #85602a;
    --chart-active: #c9943e;
    --chart-referral: #e8dfd2;
    --chart-industry: #7d7266;
    --chart-industry-referral: #d4c9b9;
    --chart-label: #13110f;
}

.chart-plot {
    position: relative;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    height: var(--chart-plot);
    margin-top: 1.25rem;
}

/* Gridlines, each labelled on top of its line. */
.chart-tick {
    position: absolute;
    inset-inline: 0;
    bottom: calc(var(--v) * 100%);
    padding-bottom: 0.3125rem;
    border-bottom: 1px solid var(--rule);
    font-size: 0.6875rem;
    line-height: 1;
    color: var(--text-light);
}

.chart-tick:first-child {
    border-bottom-color: var(--text-light);
}

.chart-period {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
    height: 100%;
}

.chart-bar {
    position: relative;
    flex: none;
    width: var(--chart-bar);
    height: calc(var(--h) * 100%);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: var(--chart-users);
}

.chart-bar--industry {
    width: var(--chart-industry-bar);
    background: var(--chart-industry);
}

/* Shares rise from the baseline inside their bar, each with a hairline of ground above it. */
.chart-share {
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    height: calc(var(--s) * 100%);
    background: var(--chart-active);
    box-shadow: 0 -2px 0 var(--background-elevated);
}

.chart-share--referral {
    background: var(--chart-referral);
}

.chart-bar--industry .chart-share {
    min-height: 2px;
    background: var(--chart-industry-referral);
    box-shadow: none;
}

.chart-value {
    position: absolute;
    inset-inline: 0;
    bottom: calc(var(--y) * 100%);
    transform: translateY(50%);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    color: var(--chart-label);
}

.chart-names {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    margin-top: 0.625rem;
    font-size: 0.75rem;
    line-height: 1.3;
    text-align: center;
    color: var(--text-light);
}

.chart-legend {
    display: grid;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--rule);
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--text-color);
}

.chart-key {
    display: grid;
    gap: 0.375rem 1rem;
}

.chart-key-name {
    font-weight: 600;
}

.chart-key ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem 1.125rem;
    list-style: none;
    padding: 0;
}

.chart-key li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-swatch {
    flex: none;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--chart-users);
}

.chart-swatch--active {
    background: var(--chart-active);
}

.chart-swatch--referral {
    background: var(--chart-referral);
}

.chart-key--industry .chart-swatch--active {
    background: var(--chart-industry);
}

.chart-key--industry .chart-swatch--referral {
    background: var(--chart-industry-referral);
}

@container (min-width: 30rem) {
    .chart-key {
        grid-template-columns: 8.5rem minmax(0, 1fr);
    }
}

@media (min-width: 960px) {
    .case-section > .case-figure.is-chart {
        grid-column: 2;
    }
}

@media (forced-colors: active) {
    .case-chart {
        forced-color-adjust: none;
    }
}

@media (max-width: 600px) {
    .case-row--stack {
        flex-direction: column;
        align-items: stretch;
    }

    .case-row--stack > * {
        flex: none;
        width: 100%;
    }

    .case-row--stack > .is-phone {
        width: min(64%, 18rem);
        align-self: center;
    }

    .case-row--strip {
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scroll-snap-type: x mandatory;
        margin: -0.375rem;
        padding: 0.375rem 0.375rem 0.875rem;
    }

    .case-row--strip > * {
        flex: 0 0 min(68%, 17rem);
        scroll-snap-align: center;
    }
}

/* Previous and next */
.case-nav {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem 2rem;
    margin-top: clamp(5rem, 12vw, 9rem);
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.case-nav a {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem 0;
    color: var(--text-color);
    text-decoration: none;
}

.case-nav a[rel="next"] {
    grid-column: 2;
    align-items: flex-end;
    text-align: right;
}

.case-nav-label {
    font-size: 0.8125rem;
    color: var(--text-light);
}

.case-nav-title {
    font-family: var(--font-heading);
    font-size: clamp(1.5rem, 3.4vw, 2.5rem);
    line-height: 1.1;
    letter-spacing: -0.01em;
    text-wrap: balance;
}

.case-nav a:hover .case-nav-title {
    color: var(--accent-text);
}

.case-nav + .footer {
    margin-top: clamp(3rem, 8vw, 5rem);
}

/* Lightbox */
html.is-zoomed {
    overflow: hidden;
    scrollbar-gutter: stable;
}

.zoom {
    margin: 0;
    padding: 0;
    border: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    overflow: auto;
    background: transparent;
    color: #e8dfd2;
}

.zoom[open] {
    display: flex;
    padding: 4.5rem 1rem 1.5rem;
}

.zoom::backdrop {
    background: rgb(12 10 9 / 0.92);
}

.zoom-figure {
    margin: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.zoom-img {
    display: block;
    width: min(100%, calc((100vh - 6.5rem) * var(--r, 1.6)));
    width: min(100%, calc((100dvh - 6.5rem) * var(--r, 1.6)));
    height: auto;
    aspect-ratio: var(--r, 1.6);
    border-radius: var(--radius-md);
    background: #1c1916;
    cursor: zoom-out;
}

.zoom-close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    border: 1px solid rgb(232 223 210 / 0.3);
    background: rgb(19 17 15 / 0.6);
    color: #e8dfd2;
    cursor: pointer;
}

.zoom-close:hover {
    background: rgb(232 223 210 / 0.14);
}

.zoom-close:focus-visible {
    outline: 2px solid #e8dfd2;
    outline-offset: 2px;
}

@media print {
    .case-bar-nav,
    .case-nav {
        display: none;
    }

    .case-section > h2 {
        position: static;
    }
}
