/*
    DETAIL / CASE STUDY PAGE

    Loaded after styles.css, so it inherits the same theme tokens
    (--fg, --fg-muted, --border and so on). Nothing here hard-codes a
    colour, which means the page works with either .bg-black or
    .bg-white on the .case-study section.
*/

.case-study {
    /* The sticky navbar sits above, so the top needs a little less room */
    padding-top: 60px;
}

/*
    GAP ABOVE THE FOOTER
*/
.case-study.section {
    padding-bottom: 40px;
}

.footer-compact {
    padding-top: 56px;
}

/* --- NAV --- */
.nav-logo {
    opacity: 100;
}

/* --- HEADER --- */

.case-study-type {
    margin-bottom: 16px;
    color: var(--accent-text, var(--accent));
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.case-study h1 {
    max-width: 900px;
    font-size: clamp(42px, 7vw, 80px);
    line-height: 0.95;
    letter-spacing: -0.05em;
}

.case-study-intro {
    max-width: 700px;
    margin-top: 24px;
    color: var(--fg-muted);
    font-size: 18px;
}

.case-study-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
}

.case-study-tags span {
    padding: 7px 10px;
    border: 1px solid var(--border);
    color: var(--fg-muted);
    font-size: 12px;
}

.case-study-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 32px;
}

/* Empty when a project has no links, so don't leave a gap behind */
.case-study-actions:empty {
    margin-top: 0;
}


/* --- BODY --- */

.case-study-body {
    margin-top: 56px;
    padding-top: 48px;
    border-top: 1px solid var(--border);
}

/* --- FULL-WIDTH MEDIA --- */

.case-study-media {
    display: flex;
    flex-direction: column;
    gap: 40px;
    margin-bottom: 56px;
}

/* flex: none stops images being squashed inside the scrolling side column */
.media-item {
    flex: none;
    margin: 0;
    position: relative;

    /* each embed gets its own stacking layer */
    isolation: isolate;      
}

.media-item img {
    width: 100%;
    height: auto;
    border: 1px solid var(--border);
    background: var(--card-bg-2);
}

.media-embed {
    position: relative;
    aspect-ratio: 16 / 9;
}

.media-embed iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.media-linkedin {
    padding-bottom: 8px;
}

.media-linkedin iframe {
    display: block;
    width: 100%;
    max-width: 550px;
    margin: 0 auto;
    border: 0;
    background: #fff;
}

.media-item figcaption {
    margin-top: 8px;
    color: var(--fg-muted);
    font-size: 13px;
}


/* --- TEXT + OPTIONAL SIDE COLUMN --- */

.case-study-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 56px;
}

.case-study-columns.has-aside {
    grid-template-columns: minmax(0, 1fr) minmax(0, 380px);

    /* the side column is as tall as the text, never taller */
    align-items: stretch;   
}

.case-study-text {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* Without a side column, keep the text at a comfortable reading width */
.case-study-columns:not(.has-aside) .case-study-text {
    max-width: 760px;

}

.case-study-text section + section {
    padding-top: 40px;
    border-top: 1px solid var(--border);
}

.case-study-text h2 {
    margin-bottom: 16px;
    font-size: 24px;
}

/*
    The inner box is absolutely positioned, so it can never make the row
    taller than the text. If its content is longer, it scrolls instead.
*/
.case-study-aside {
    position: relative;
    min-height: 320px;
}

.case-study-aside-inner {

    gap: 40px;
    overscroll-behavior: contain;

    position: absolute;
    inset: 0;

    display: flex;
    flex-direction: column;

    padding-right: 6px;
    overflow-y: auto;
    scrollbar-width: thin;
}


/* --- RICH TEXT (everything written in project-data.js) --- */

.case-study-text .rich {
    color: var(--fg-muted);
    font-size: 15px;
}

.rich p + p,
.rich p + ul,
.rich ul + p,
.rich ol {
    margin-top: 1em;
}

.rich ul,
.rich ol {
    padding-left: 1.25em;
}

.rich li + li {
    margin-top: 0.4em;
}

.rich strong {
    color: var(--fg);
    font-weight: 600;
}

.rich mark {
    padding: 0 0.2em;
    background: rgba(230, 39, 60, 0.22);
    color: var(--fg);
}

.rich a {
    color: var(--accent-text, var(--accent));
    text-decoration: underline;
    text-underline-offset: 3px;
}

.rich a:hover {
    color: var(--accent-hi);
}

.rich code {
    padding: 0.1em 0.35em;
    background: var(--card-bg-2);
    font-family: var(--font-mono);
    font-size: 0.9em;
}


/* --- BACK LINK --- */

.back-nav {
    /* Spacing between the arrow and text */
    gap: 6px;
    margin-top: 48px;
}

.back-arrow {
    color: var(--fg-muted);
    transition: color 0.2s ease;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--fg-muted);
    font-size: 15px;
    transition: color 0.2s ease;
}

/* Make both the arrow and link change color together on hover */
.back-nav:hover .back-arrow,
.back-link:hover {
    color: var(--accent-text, var(--accent));
}


/* --- NOT FOUND --- */

/* Shown when the ?project= value doesn't match anything in projects */
.case-study-missing h1 {
    font-size: clamp(36px, 6vw, 60px);
}


/* --- RESPONSIVE --- */

@media (max-width: 860px) {

    .case-study-columns.has-aside {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Stacked under the text on mobile, with no inner scrolling */
    .case-study-aside {
        min-height: 0;
    }

    .case-study-aside-inner {
        position: static;
        overflow: visible;
        padding-right: 0;
    }
}

@media (max-width: 600px) {

    .case-study h1 {
        font-size: clamp(40px, 13vw, 60px);
    }

    .case-study-body {
        margin-top: 40px;
        padding-top: 32px;
    }

    .case-study-media {
        margin-bottom: 40px;
    }
}