/* Shared case-study layout and components. Project themes live in site.css. */
.case-study h1,
.case-study h2,
.case-study h3 {
    margin-top: 0;
    color: var(--text);
}

.case-study h1,
.case-study h2 {
    font-family: var(--heading-font);
    font-weight: 500;
}

.case-study h1 {
    margin-bottom: 12px;
    font-size: clamp(2rem, 4vw, 3.5rem);
    line-height: 1.12;
    letter-spacing: -0.045em;
}

.case-study h2 {
    margin-bottom: 20px;
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    line-height: 1.25;
    letter-spacing: -0.035em;
}

.case-study h3 {
    margin-bottom: 10px;
    font-size: 1.125rem;
    line-height: 1.4;
}

.case-study p {
    margin: 0 0 16px;
    color: var(--text-muted);
}

.case-study .eyebrow {
    margin-bottom: 12px;
    font-size: 0.875rem;
    color: var(--accent);
}

.case-study strong {
    color: var(--text);
}

.case-study main section {
    padding-block: var(--section-space);
    border-bottom: 1px solid var(--border-soft);
}

.case-study .case-hero {
    padding-block: var(--section-space);
    border-bottom: 1px solid var(--border);
}

.case-hero--split {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.75fr);
    align-items: start;
    gap: 48px;
}

/* Application links stay available in the sticky project header. */
.case-demo-link {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    transition:
        background-color 160ms ease,
        color 160ms ease;
}
.case-demo-link svg {
    width: 16px;
    height: 16px;
}
.case-demo-link:hover {
    background: var(--accent);
    color: var(--background);
}

.case-study .lede {
    max-width: 88ch;
    font-size: clamp(1.0625rem, 1.8vw, 1.25rem);
    line-height: 1.75;
}

.fact-card h2 {
    margin: 4px 0 0;
    color: var(--accent);
    font-family: var(--heading-font);
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.6;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 18px;
}

.stack {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
}

.pill {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-muted);
    font-family: var(--heading-font);
    font-size: 0.875rem;
}

.cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-top: 26px;
}

.card,
.fact-card,
.transformation-explanation {
    min-width: 0;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.facts {
    display: grid;
    gap: 16px;
}

.fact-row {
    display: grid;
    gap: 2px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-soft);
}

.fact-row:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.fact-label {
    color: var(--text-muted);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.fact-value {
    color: var(--text);
    font-weight: 600;
}

.card strong {
    display: block;
    margin-bottom: 8px;
}

.card p {
    margin: 0;
    font-size: 0.9375rem;
}

.closing p {
    max-width: 1100px;
    font-size: 1.125rem;
}

.closing p:last-child {
    margin-bottom: 0;
}

@media (max-width: 900px) {
    .case-hero--split {
        grid-template-columns: minmax(0, 1fr);
        gap: 24px;
    }

    .cards {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Shared grids keep screenshots aligned at each viewport size. */
.visual-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 28px;
}

@media (max-width: 900px) {
    .visual-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Real project screenshots retain their full aspect ratio inside media cards. */
.project-screenshot {
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.project-screenshot__image {
    display: grid;
    flex: 1;
    align-items: center;
    min-width: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.project-screenshot img {
    width: 100%;
    height: auto;
}

.project-screenshot figcaption {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 8px 16px;
    padding: 16px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.project-screenshot figcaption > span {
    flex: 1;
    min-width: 0;
}

.project-screenshot__expand {
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    margin: -8px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--accent);
    transition:
        background-color 160ms ease,
        border-color 160ms ease;
}

.project-screenshot__expand svg {
    width: 22px;
    height: 22px;
    stroke-width: 2;
}

.project-screenshot__expand:hover,
.project-screenshot__expand:focus-visible {
    border-color: var(--border);
    background: var(--accent-soft);
}

/* Native modal keeps focus inside the viewer and the underlying page inert. */
html.image-viewer-open {
    overflow: hidden;
}

.image-viewer {
    width: calc(100% - 48px);
    max-width: 2400px;
    max-height: calc(100dvh - 48px);
    margin: auto;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    background: var(--surface);
    box-shadow: 0 24px 100px rgba(0, 0, 0, 0.6);
}

.image-viewer::backdrop {
    background: rgba(3, 8, 12, 0.88);
    backdrop-filter: blur(5px);
}

.image-viewer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.image-viewer__header h2 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.4;
    letter-spacing: normal;
}

.image-viewer__header form {
    flex-shrink: 0;
}

.image-viewer__close {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    color: var(--accent);
    background: transparent;
    cursor: pointer;
    touch-action: manipulation;
}

.image-viewer__close:hover {
    color: var(--text);
}

.image-viewer__close svg {
    width: 22px;
    height: 22px;
}

.image-viewer__viewport {
    position: relative;
    width: 100%;
    aspect-ratio: var(--viewer-aspect-ratio, 3.4);
    min-height: min(240px, 40dvh);
    max-height: calc(100dvh - 144px);
    overflow: hidden;
    border-radius: 6px;
    touch-action: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.image-viewer__viewport.is-zoomed {
    cursor: grab;
}

.image-viewer__viewport.is-dragging {
    cursor: grabbing;
}

.image-viewer__image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

@media (max-width: 620px) {
    .image-viewer {
        width: calc(100% - 24px);
        height: 50dvh;
        max-height: calc(100dvh - 24px);
        padding: 12px;
    }
    .image-viewer[open] {
        display: flex;
        flex-direction: column;
    }
    .image-viewer__header {
        flex-shrink: 0;
        margin-bottom: 12px;
    }
    .image-viewer__viewport {
        flex: 1;
        height: auto;
        min-height: 0;
        max-height: none;
        aspect-ratio: auto;
    }
}

/* Approved case-study shell and hierarchy, shared by all project pages. */
.engineering-diagram {
    container-type: inline-size;
    min-width: 0;
    margin: 0;
    padding: clamp(18px, 2vw, 28px);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--accent-soft), transparent), var(--surface);
}

.engineering-diagram h3 {
    margin: 0 0 24px;
    font-family: var(--heading-font);
    font-size: 1.25rem;
    font-weight: 500;
}

.engineering-diagram figcaption {
    margin-top: 16px;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.65;
}

/* Keep the project identity and section links together while scrolling. */
.project-navigation {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 24px;
    color: var(--text-muted);
    font-size: 0.9375rem;
}
.project-navigation a {
    padding-block: 8px;
}
.project-navigation a:hover {
    color: var(--accent);
}
html.case-study-page {
    scroll-padding-top: calc(var(--case-header-height, 240px) + 16px);
}
.case-header__inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 24px;
    padding-block: 16px;
}
.case-header__inner > .case-demo-link {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
}
.case-header__navigation {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 24px;
}
.case-home-link {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding-inline-end: 20px;
    border-inline-end: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.875rem;
    white-space: nowrap;
}
.case-home-link svg {
    width: 18px;
    height: 18px;
}
.case-home-link:hover {
    color: var(--accent);
}
.case-header__heading {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    align-items: start;
    justify-content: space-between;
    gap: 12px 24px;
}
.case-header__heading > div {
    min-width: 0;
}
.case-header__identity {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 24px;
}
.case-study .case-header__identity h1 {
    margin-bottom: 0;
}
.case-study .case-header__inner .eyebrow {
    margin-bottom: 0;
}
.case-study .case-header__inner .project-navigation {
    min-width: 0;
    flex-wrap: nowrap;
    margin-top: 0;
    padding-block: 0;
    border-bottom: 0;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.case-header__navigation .project-navigation a {
    flex-shrink: 0;
    white-space: nowrap;
}
.case-study .project-navigation a[aria-current="location"] {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 8px;
}

/* Give wide technical visuals the full content column, with readable prose above. */
.case-study {
    font-size: 1.125rem;
    --section-space: clamp(32px, 3vw, 48px);
}
.case-study .fact-card {
    font-size: 1rem;
}
.story-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px clamp(28px, 4vw, 72px);
}
.story-columns > p {
    max-width: 76ch;
}
.case-study .case-section-title {
    margin-bottom: 12px;
    color: var(--accent);
    font-family: var(--heading-font);
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.case-study .case-section-subtitle {
    color: var(--text);
    font-size: inherit;
    font-weight: 400;
}

@media (max-width: 900px) {
    .case-study {
        font-size: 1.0625rem;
    }
    .story-columns {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
    }
}
@media (max-width: 620px) {
    .case-header__navigation {
        display: none;
    }
    .project-navigation {
        display: none;
    }
    .case-header__inner {
        gap: 12px 16px;
        padding-block: 16px;
    }
    .case-header__heading,
    .case-header__identity {
        display: contents;
    }
    .case-study .case-header__inner h1 {
        grid-column: 1 / -1;
        font-size: clamp(1.5rem, 7vw, 2rem);
    }
    .case-study .case-header__inner .eyebrow {
        grid-column: 1;
        grid-row: 2;
        font-size: 0.6875rem;
        letter-spacing: 0.08em;
    }
    .case-header__inner > .case-demo-link {
        gap: 8px;
        padding-inline: 10px;
        font-size: 0.75rem;
    }
}

/* Readable case-study copy and portfolio-native process figures. */
.case-copy {
    max-width: 88ch;
}
.case-copy > p:last-child {
    margin-bottom: 0;
}
.visual-grid--product {
    grid-template-columns: minmax(0, 1fr);
}
.case-diagram {
    margin-top: 28px;
}
.case-study .diagram-label {
    margin-bottom: 16px;
    color: var(--accent);
    font-family: var(--heading-font);
    font-size: 0.8125rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.case-study .diagram-label--next {
    margin-top: 28px;
}
.process-flow {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 28px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.process-flow li {
    position: relative;
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-raised);
}
.process-flow strong {
    display: block;
    margin-bottom: 8px;
}
.process-flow span,
.system-map__hosting div > span,
.system-map__resource div > span,
.execution-endpoint span {
    display: block;
    color: var(--text-muted);
    font-size: 1rem;
}
.process-flow li:not(:last-child)::after {
    content: "→";
    position: absolute;
    right: -24px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent);
}
.diagram-note {
    margin-top: 20px;
    padding: 16px 18px;
    border-left: 3px solid var(--accent);
    background: var(--accent-soft);
    color: var(--text-muted);
    font-size: 1rem;
}
@media (max-width: 900px) {
    .process-flow {
        grid-template-columns: minmax(0, 1fr);
    }
    .process-flow li:not(:last-child)::after {
        content: "↓";
        top: auto;
        right: auto;
        bottom: -28px;
        left: 50%;
        transform: translateX(-50%);
    }
}

/* Desktop application action: stronger proportions without a taller sticky header. */
@media (min-width: 1101px) {
    .case-header__inner > .case-demo-link {
        min-height: 48px;
        padding-inline: 18px;
        font-size: 1rem;
    }
    .case-header__inner > .case-demo-link svg {
        width: 18px;
        height: 18px;
    }
}
/* A compact route home on tablets, retaining the chapter divider. */
@media (min-width: 621px) and (max-width: 1100px) {
    .case-home-link {
        gap: 6px;
        padding-inline-end: 12px;
    }
    .case-header__navigation {
        gap: 14px;
    }
}
/* Short prose is deliberately framed on the same reading column as its heading. */
.case-study .closing {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
}
.case-study .closing > * {
    width: 100%;
    max-width: 88ch;
}
.case-study--dataflow .closing .case-copy {
    padding: 20px 24px;
    border-left: 2px solid var(--accent);
    background: var(--surface);
    border-radius: 0 8px 8px 0;
}
.case-study .closing .case-copy p {
    font-size: 1.0625rem;
}
@media (max-width: 620px) {
    .case-study--dataflow .closing .case-copy {
        padding: 16px;
    }
    .engineering-diagram {
        padding: 16px;
    }
    .engineering-diagram h3 {
        margin-bottom: 16px;
        font-size: 1.125rem;
    }
    .engineering-diagram figcaption {
        margin-top: 12px;
        font-size: 0.875rem;
    }
    .process-flow {
        gap: 22px;
    }
    .process-flow li {
        padding: 12px 14px;
    }
    .process-flow li:not(:last-child)::after {
        bottom: -23px;
    }
    .process-flow span {
        font-size: 0.9375rem;
    }
}

.case-home-icon {
    display: none;
}
@media (min-width: 621px) and (max-width: 1100px) {
    .case-home-label,
    .case-home-arrow {
        display: none;
    }
    .case-home-icon {
        display: block;
        width: 22px;
        height: 22px;
    }
}

/* Match the DFD graph: image and expand link share one visual surface. */
.project-screenshot--overlay,
.dataflow-graph {
    position: relative;
}
.project-screenshot--overlay {
    overflow: hidden;
}
.project-screenshot--overlay .project-screenshot__image,
.dataflow-graph .project-screenshot__image {
    border-radius: var(--radius);
}
.project-screenshot--overlay .project-screenshot__expand,
.dataflow-graph .project-screenshot__expand {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1;
    margin: 0;
    border: 0;
    background: transparent;
}
.project-screenshot--overlay .project-screenshot__expand:hover,
.project-screenshot--overlay .project-screenshot__expand:focus-visible,
.dataflow-graph .project-screenshot__expand:hover,
.dataflow-graph .project-screenshot__expand:focus-visible {
    border: 0;
    background: transparent;
}
.project-screenshot--overlay .project-screenshot__expand svg,
.dataflow-graph .project-screenshot__expand svg {
    transition: transform 160ms ease;
}
.project-screenshot--overlay .project-screenshot__expand:hover svg,
.project-screenshot--overlay .project-screenshot__expand:focus-visible svg,
.dataflow-graph .project-screenshot__expand:hover svg,
.dataflow-graph .project-screenshot__expand:focus-visible svg {
    transform: scale(1.15);
}
/* Shared diagram nodes and boundaries; project files define their relationships. */

.system-map__hosting,
.system-map__resource,
.ev-system__node {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.system-map__hosting svg,
.system-map__resource svg,
.ev-system__node svg {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    color: var(--text-muted);
}

.system-map__hosting strong,
.system-map__resource strong,
.system-map__module strong,
.ev-system__node strong {
    display: block;
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
}

.system-map__browser,
.ev-system__boundary {
    padding: 16px;
    border: 1px dashed var(--accent);
    border-radius: var(--radius);
    background: rgba(8, 14, 20, 0.35);
}
