/* ============================================================
   CASE STUDY BLOCK SYSTEM
   ------------------------------------------------------------
   Loaded only by project-detail.html, after home.css.
   One rule set per block type rendered by project-detail.js.
   Tokens (--bg, --ink, --line, --red, --gutter …) come from home.css.
   ============================================================ */

/* ---- canvas & widths -------------------------------------- */

.case-blocks {
    --measure-inset: 780px;
    --measure-wide: 1500px;
    display: flex;
    flex-direction: column;
    gap: clamp(14px, 1.6vw, 28px);
    padding: clamp(60px, 8vw, 130px) 0;
}

.case-block { width: 100%; margin-inline: auto; }
.case-block.is-inset { max-width: var(--measure-inset); padding-inline: var(--gutter); }
.case-block.is-wide  { max-width: var(--measure-wide);  padding-inline: var(--gutter); }
.case-block.is-full  { max-width: none; padding-inline: 0; }

/* Images butt up close; the reading blocks buy their own space back. In a flex
   column these margins add to the gap, so image-to-image stays tight while text,
   quotes and specimens keep room to breathe. */
.case-block--text,
.case-block--quote,
.case-block--palette,
.case-block--typespec {
    margin-block: clamp(40px, 5.5vw, 92px);
}
.case-block--text + .case-block--text { margin-top: calc(-1 * clamp(40px, 5.5vw, 92px) + 30px); }

/* spacer */
.case-block--spacer { height: 20px; }
.case-block--spacer.is-s { height: clamp(16px, 3vw, 40px); }
.case-block--spacer.is-m { height: clamp(40px, 6vw, 90px); }
.case-block--spacer.is-l { height: clamp(80px, 11vw, 170px); }

/* ---- reveal ----------------------------------------------- */

.case-blocks .reveal {
    opacity: 0;
    transform: translateY(26px);
    transition: opacity .85s var(--ease-out), transform .85s var(--ease-out);
    transition-delay: calc(var(--i, 0) * 40ms);
}
.case-blocks .reveal.is-in { opacity: 1; transform: none; }

/* ---- media ------------------------------------------------ */

.case-media { margin: 0; position: relative; }

.case-media__btn {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: var(--bg-2);
    cursor: zoom-in;
    overflow: hidden;
    border-radius: 2px;
    position: relative;
}
.case-block.is-full .case-media__btn { border-radius: 0; }

.case-media__btn img {
    display: block;
    width: 100%;
    height: auto;
    transition: transform 1.1s var(--ease-out), filter .5s var(--ease);
}
@media (hover: hover) {
    .case-media__btn:hover img { transform: scale(1.022); }
}

/* Zoom affordance */
.case-media__btn::after {
    content: "";
    position: absolute;
    inset: auto 14px 14px auto;
    width: 34px; height: 34px;
    border-radius: 50%;
    background: rgba(10,10,10,.55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23fff' stroke-width='1.7' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l4 4M7 5v4M5 7h4'/%3E%3C/svg%3E") center/16px no-repeat;
    backdrop-filter: blur(6px);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .35s var(--ease), transform .35s var(--ease);
    pointer-events: none;
}
@media (hover: hover) {
    .case-media__btn:hover::after { opacity: 1; transform: none; }
}

.case-media__caption {
    display: block;
    margin-top: 14px;
    font-family: var(--sans);
    font-size: 12.5px;
    line-height: 1.6;
    letter-spacing: .01em;
    color: var(--ink-faint);
    max-width: 620px;
}
.case-block.is-full .case-media__caption { padding-inline: var(--gutter); }
.case-media__caption--group { margin-top: 18px; }

/* ---- grids (duo / trio / quad) ---------------------------- */

.case-grid {
    display: grid;
    gap: clamp(10px, 1.4vw, 22px);
}
.case-grid--2 { grid-template-columns: repeat(2, 1fr); }
.case-grid--3 { grid-template-columns: repeat(3, 1fr); }
.case-grid--4 { grid-template-columns: repeat(4, 1fr); }

.case-media--tile .case-media__btn { height: 100%; }
.case-media--tile .case-media__btn img { height: 100%; object-fit: cover; }

@media (max-width: 900px) {
    .case-grid--3, .case-grid--4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
    .case-grid--2, .case-grid--3, .case-grid--4 { grid-template-columns: 1fr; }
}

/* ---- text block ------------------------------------------- */

.case-block--text { max-width: var(--measure-inset); padding-inline: var(--gutter); }

.case-text__eyebrow {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin-bottom: 26px;
}
.case-text__eyebrow::before {
    content: "";
    width: 26px;
    height: 1px;
    background: var(--red);
    flex: none;
}

.case-text__heading {
    font-family: var(--display);
    font-size: clamp(26px, 3.6vw, 46px);
    font-weight: 600;
    line-height: 1.08;
    letter-spacing: -0.025em;
    color: var(--ink);
    margin: 0 0 26px;
    text-wrap: balance;
}

.case-text__body {
    font-family: var(--sans);
    font-size: clamp(16px, 1.35vw, 19px);
    font-weight: 300;
    line-height: 1.72;
    color: var(--ink-mute);
    margin: 0 0 1.1em;
    max-width: 66ch;
}
.case-text__body:last-child { margin-bottom: 0; }

/* ---- pull quote ------------------------------------------- */

.case-block--quote { max-width: 1100px; padding-inline: var(--gutter); }

.case-pullquote {
    position: relative;
    margin: 0;
    padding: clamp(28px, 4vw, 52px) 0 0;
    border-top: 1px solid var(--line);
}
.case-pullquote__mark {
    position: absolute;
    top: clamp(6px, 2vw, 18px);
    left: -6px;
    font-family: var(--serif);
    font-size: clamp(80px, 11vw, 150px);
    line-height: 1;
    color: var(--red);
    opacity: .16;
    pointer-events: none;
    user-select: none;
}
.case-pullquote__text {
    position: relative;
    font-family: var(--serif);
    font-style: italic;
    font-weight: 400;
    font-size: clamp(24px, 3.6vw, 44px);
    line-height: 1.32;
    color: var(--ink);
    margin: 0;
    text-wrap: balance;
}
.case-pullquote__cite {
    display: block;
    margin-top: 24px;
    font-family: var(--sans);
    font-style: normal;
    font-size: 12px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

/* ---- palette ---------------------------------------------- */

.case-block--palette { max-width: var(--measure-wide); padding-inline: var(--gutter); }

.case-palette {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: clamp(12px, 1.6vw, 22px);
}
.case-palette__swatch { display: flex; flex-direction: column; gap: 14px; }

.case-palette__chip {
    aspect-ratio: 4 / 3;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 2px;
    cursor: copy;
    position: relative;
    transition: transform .4s var(--ease-out);
}
.case-palette__chip:hover { transform: translateY(-4px); }
.case-palette__chip::after {
    content: "Copied";
    position: absolute;
    inset: auto 0 10px 0;
    text-align: center;
    font-family: var(--sans);
    font-size: 10px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: #fff;
    text-shadow: 0 1px 6px rgba(0,0,0,.6);
    opacity: 0;
    transition: opacity .3s var(--ease);
}
.case-palette__chip.is-copied::after { opacity: 1; }

.case-palette__meta { display: flex; flex-direction: column; gap: 5px; }
.case-palette__name {
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
}
.case-palette__hex {
    font-family: var(--sans);
    font-size: 11.5px;
    letter-spacing: .09em;
    color: var(--ink-faint);
    font-variant-numeric: tabular-nums;
}
.case-palette__note {
    font-family: var(--sans);
    font-size: 10.5px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-faint);
    opacity: .75;
}

/* ---- type specimen ---------------------------------------- */

.case-block--typespec { max-width: var(--measure-wide); padding-inline: var(--gutter); }

.case-typespec {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: clamp(14px, 2vw, 28px);
}
.case-typespec__item {
    border: 1px solid var(--line);
    border-radius: 2px;
    padding: clamp(24px, 3vw, 40px);
    background: var(--bg-2);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color .4s var(--ease), background .4s var(--ease);
}
.case-typespec__item:hover { border-color: var(--line-2); }
.case-typespec__sample {
    font-family: var(--serif);
    font-size: clamp(46px, 6.5vw, 84px);
    line-height: 1;
    color: var(--ink);
    letter-spacing: -0.01em;
}
.case-typespec__family {
    font-family: var(--display);
    font-size: 17px;
    font-weight: 600;
    color: var(--ink);
    margin-top: 12px;
}
.case-typespec__meta { display: flex; flex-direction: column; gap: 4px; }
.case-typespec__role {
    font-family: var(--sans);
    font-size: 10.5px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--red);
}
.case-typespec__note {
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 300;
    line-height: 1.6;
    color: var(--ink-mute);
}

/* ---- video ------------------------------------------------ */

.case-block--video video {
    display: block;
    width: 100%;
    height: auto;
    background: var(--bg-2);
    border-radius: 2px;
}
.case-block.is-full .case-block--video video,
.case-block--video.is-full video { border-radius: 0; }

/* ---- embed (click-to-load facade) ------------------------- */

.case-embed {
    --ratio: 16 / 9;
    position: relative;
    aspect-ratio: var(--ratio);
    background: var(--bg-2);
    border-radius: 2px;
    overflow: hidden;
}
.case-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.case-embed__facade {
    position: absolute;
    inset: 0;
    width: 100%;
    border: 0;
    padding: 0;
    cursor: pointer;
    background-color: var(--bg-3);
    background-size: cover;
    background-position: center;
    display: grid;
    place-items: center;
}
.case-embed__facade::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(10,10,10,.34);
    transition: background .4s var(--ease);
}
.case-embed__facade:hover::before { background: rgba(10,10,10,.2); }

.case-embed__play {
    position: relative;
    width: clamp(60px, 7vw, 88px);
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--red);
    display: grid;
    place-items: center;
    transition: transform .45s var(--ease-out);
}
.case-embed__facade:hover .case-embed__play { transform: scale(1.08); }
.case-embed__play::after {
    content: "";
    border-style: solid;
    border-width: 9px 0 9px 15px;
    border-color: transparent transparent transparent var(--on-red, #fff);
    margin-left: 4px;
}

/* ---- before / after compare ------------------------------- */

.case-compare {
    --split: 50%;
    position: relative;
    overflow: hidden;
    border-radius: 2px;
    background: var(--bg-2);
    touch-action: pan-y;
}
.case-compare img { display: block; width: 100%; height: auto; }
.case-compare__before {
    position: absolute;
    inset: 0;
    width: var(--split);
    overflow: hidden;
}
.case-compare__before img {
    position: absolute;
    inset: 0;
    width: auto;
    height: 100%;
    max-width: none;
}
.case-compare__handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--split);
    width: 2px;
    background: #fff;
    transform: translateX(-1px);
    pointer-events: none;
    box-shadow: 0 0 0 1px rgba(0,0,0,.18);
}
.case-compare__handle::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 42px; height: 42px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%230A0A0A' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 4L2 9l4 5M12 4l4 5-4 5'/%3E%3C/svg%3E") center/18px no-repeat;
    box-shadow: 0 4px 20px rgba(0,0,0,.3);
}
.case-compare__range {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: ew-resize;
}
.case-compare__tag {
    position: absolute;
    top: 14px;
    font-family: var(--sans);
    font-size: 10px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: #fff;
    background: rgba(10,10,10,.6);
    backdrop-filter: blur(6px);
    padding: 6px 11px;
    border-radius: 2px;
    pointer-events: none;
}
.case-compare__tag--before { left: 14px; }
.case-compare__tag--after  { right: 14px; }

/* ---- reading progress ------------------------------------- */

.case-progress {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 2px;
    z-index: 220;
    pointer-events: none;
    background: transparent;
}
.case-progress span {
    display: block;
    height: 100%;
    background: var(--red);
    transform-origin: 0 50%;
    transform: scaleX(0);
}

/* ---- hero summary ----------------------------------------- */

.case-hero__summary {
    font-family: var(--sans);
    font-size: clamp(16px, 1.5vw, 20px);
    font-weight: 300;
    line-height: 1.65;
    color: var(--ink-mute);
    max-width: 62ch;
    margin: 0;
}

/* ---- unpublished state ------------------------------------ */

.case-empty {
    padding: clamp(90px, 14vw, 190px) var(--gutter);
    max-width: 760px;
    margin-inline: auto;
    text-align: center;
}
.case-empty__title {
    font-family: var(--display);
    font-size: clamp(26px, 4vw, 44px);
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.1;
    color: var(--ink);
    margin: 0 0 20px;
}
.case-empty__body {
    font-family: var(--sans);
    font-size: 17px;
    font-weight: 300;
    line-height: 1.7;
    color: var(--ink-mute);
    margin: 0 0 36px;
}
.case-empty__actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.case-empty__link {
    font-family: var(--sans);
    font-size: 13px;
    letter-spacing: .04em;
    color: var(--ink);
    text-decoration: none;
    border: 1px solid var(--line-2);
    padding: 14px 26px;
    border-radius: 999px;
    transition: border-color .35s var(--ease), color .35s var(--ease), background .35s var(--ease);
}
.case-empty__link:hover { border-color: var(--red); color: var(--red); }
.case-empty__link--accent { background: var(--red); border-color: var(--red); color: var(--on-red, #fff); }
.case-empty__link--accent:hover { background: transparent; color: var(--red); }

/* ---- lightbox --------------------------------------------- */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: grid;
    place-items: center;
    padding: clamp(20px, 5vw, 70px);
    background: rgba(6,6,6,.94);
    backdrop-filter: blur(14px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .45s var(--ease), visibility .45s;
}
.lightbox.is-open { opacity: 1; visibility: visible; }

.lightbox__stage {
    margin: 0;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.lightbox__stage img {
    max-width: 100%;
    max-height: 82vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 2px;
    transform: scale(.97);
    transition: transform .5s var(--ease-out);
}
.lightbox.is-open .lightbox__stage img { transform: none; }

.lightbox__caption {
    font-family: var(--sans);
    font-size: 13px;
    line-height: 1.6;
    color: rgba(255,255,255,.6);
    text-align: center;
    max-width: 62ch;
}

.lightbox__close,
.lightbox__nav {
    position: absolute;
    border: 1px solid rgba(255,255,255,.18);
    background: rgba(255,255,255,.06);
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    display: grid;
    place-items: center;
    transition: background .3s var(--ease), border-color .3s var(--ease), transform .3s var(--ease);
}
.lightbox__close:hover,
.lightbox__nav:hover { background: var(--red); border-color: var(--red); }

.lightbox__close {
    top: clamp(16px, 3vw, 34px);
    right: clamp(16px, 3vw, 34px);
    width: 46px; height: 46px;
    font-size: 26px;
    line-height: 1;
}
.lightbox__nav {
    top: 50%;
    transform: translateY(-50%);
    width: 52px; height: 52px;
    font-size: 28px;
    line-height: 1;
}
.lightbox__nav:hover { transform: translateY(-50%) scale(1.06); }
.lightbox__nav--prev { left: clamp(12px, 2.5vw, 34px); }
.lightbox__nav--next { right: clamp(12px, 2.5vw, 34px); }

.lightbox__counter {
    position: absolute;
    bottom: clamp(16px, 3vw, 34px);
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--sans);
    font-size: 11.5px;
    letter-spacing: .16em;
    color: rgba(255,255,255,.45);
    font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
    .lightbox__nav { width: 42px; height: 42px; font-size: 22px; }
    .lightbox__stage img { max-height: 72vh; }
}

/* ---- reduced motion --------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .case-blocks .reveal { opacity: 1; transform: none; transition: none; }
    .case-media__btn img,
    .case-palette__chip,
    .case-embed__play,
    .lightbox__stage img { transition: none !important; transform: none !important; }
}

/* ---- no flash of placeholder text before the project data lands ---- */
#caseMain.is-loading-case .case-hero { opacity: 0; }
#caseMain .case-hero { opacity: 1; transition: opacity .4s var(--ease-out); }

/* ---- project information + credits, at the foot of the case ----
   Two columns: the written account of the project on the left, the
   people who made it on the right. Rendered by renderAbout() from the
   `info` and `credits` fields in projects.json. */

.case-about {
    max-width: var(--measure-wide);
    margin-inline: auto;
    padding-inline: var(--gutter);
}
.case-about[hidden] { display: none; }

.case-about__grid {
    display: grid;
    grid-template-columns: minmax(0, 1.9fr) minmax(200px, 0.7fr);
    gap: clamp(40px, 6vw, 110px);
    align-items: start;
    border-top: 1px solid var(--line);
    padding-top: clamp(36px, 4vw, 64px);
}

.case-about__label {
    font-family: var(--sans);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 0 0 30px;
}

.case-about__p {
    font-family: var(--sans);
    font-size: clamp(15px, 1.15vw, 17px);
    font-weight: 300;
    line-height: 1.75;
    color: var(--ink-mute);
    max-width: 82ch;
    margin: 0 0 1.2em;
}
.case-about__p:last-child { margin-bottom: 0; }

.case-credits {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 24px;
}
.case-credit { display: flex; flex-direction: column; gap: 6px; }
.case-credit__role {
    font-family: var(--sans);
    font-size: 14px;
    color: var(--ink-mute);
}
.case-credit__name {
    font-family: var(--sans);
    font-size: 14px;
    color: var(--ink);
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-thickness: 1px;
    transition: color .3s var(--ease-out);
}
a.case-credit__name:hover { color: var(--red); }

/* ============================================================
   MOBILE LAYER — case study
   ============================================================ */

@media (max-width: 900px) {
    /* The stats row was a rigid 4-column grid at every width, so on a
       phone each cell got roughly 80px. */
    .case-stats { grid-template-columns: repeat(2, 1fr); gap: 28px 20px; }
    .case-about__grid { grid-template-columns: 1fr; gap: 48px; }
}

@media (max-width: 700px) {
    .case-hero {
        min-height: auto;
        padding-top: 104px;
        padding-bottom: 44px;
        gap: 24px;
    }
    .case-hero__title { font-size: clamp(38px, 12.5vw, 56px); }
    .case-hero__summary { font-size: 15.5px; }

    .case-blocks {
        gap: clamp(10px, 2.4vw, 18px);
        padding: clamp(40px, 10vw, 70px) 0;
    }

    /* Wide blocks lose their inner max-width and just use the gutter. */
    .case-block.is-wide,
    .case-block.is-inset { max-width: none; }

    .case-text__heading { font-size: clamp(24px, 7.5vw, 32px); }
    .case-text__body    { font-size: 15.5px; line-height: 1.68; }
    .case-text__eyebrow { margin-bottom: 18px; }

    .case-pullquote__text { font-size: clamp(21px, 6.8vw, 30px); }
    .case-pullquote__mark { font-size: clamp(64px, 20vw, 96px); left: -2px; }

    /* Two swatches per row reads better than three cramped ones. */
    .case-palette { grid-template-columns: repeat(2, 1fr); gap: 14px; }
    .case-typespec { grid-template-columns: 1fr; }
    .case-typespec__item { padding: 22px; }
    .case-typespec__sample { font-size: clamp(40px, 13vw, 60px); }

    .case-services__grid { gap: 8px; }
    .case-next__title { font-size: clamp(30px, 9vw, 44px); }

    /* Captions on full-bleed blocks need the gutter back. */
    .case-block.is-full .case-media__caption { padding-inline: var(--gutter); }

    /* Zoom affordance is meaningless without hover; tapping still opens it. */
    .case-media__btn::after { display: none; }

    /* Compare slider: the handle needs to be thumb-sized. */
    .case-compare__handle::after { width: 48px; height: 48px; }
    .case-compare__tag { font-size: 9px; padding: 5px 8px; top: 10px; }
}

@media (max-width: 430px) {
    .case-stats { grid-template-columns: 1fr; gap: 24px; text-align: left; }
    .case-palette { grid-template-columns: 1fr 1fr; }
}

/* Lightbox on phones: full-width image, controls out of the way. */
@media (max-width: 700px) {
    .lightbox { padding: 56px 12px 72px; }
    .lightbox__stage img { max-height: 68vh; }
    .lightbox__nav { top: auto; bottom: 14px; transform: none; width: 46px; height: 46px; }
    .lightbox__nav:hover { transform: none; }
    .lightbox__nav--prev { left: 50%; margin-left: -58px; }
    .lightbox__nav--next { right: 50%; margin-right: -58px; }
    .lightbox__counter { bottom: 26px; left: 50%; }
    .lightbox__close { top: 12px; right: 12px; width: 42px; height: 42px; }
    .lightbox__caption { font-size: 12px; }
}

/* Back chip sits in the hero's top padding, clear of the fixed nav. */
@media (max-width: 700px) {
    .case__back { top: 62px; font-size: 11.5px; padding: 8px 13px; }
    .case-hero { padding-top: 116px; }
}
