:root
{
    --bg: #f0ede6;
    --text: #171717;
    --hover: #070707;
    --muted: #575757;
    --faded: #979797;
    --primary: #00b0cd;
    --secondary: #80c0cc;

    --yellow: #ECAF21;
    --yellow-body: #E29900;
    --red: #eb452b;
    --red-body: #de342a;
    --blue: #0070C0;
    --black: #272727;
    --bg1: #E5DAD2;
    --green: #03A653;

    --darkcyan: #008694;

    --lightblue: #e6f3fe;
    --lightcyan: #e2ffff;
    /*--line: rgba(23, 23, 23, 0.12);*/
    --line: #272727;
    --light: #dfdfdf;
    --white: #f7f7f7;
    --surface: rgba(255, 255, 255, 0.28);

    --font-sans: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --font-serif: "Source Serif", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;

    --column-width: min(72rem, calc(100% - 3rem));
    --content-width: min(48rem, calc(100% - 3rem));
    --article-grid: 1fr;
    --article-gap: 2rem;
    --article-top: 0;
}

* {
    box-sizing: border-box;
}

html {
    font-size: 14px;
    background: var(--bg);
}

a {
    color: inherit;
    font-weight: 500;
    text-decoration: underline;
    text-decoration-thickness: 0.1rem;
    text-underline-offset: 0.2rem;

    &:hover {
        color: var(--hover);
        text-decoration: underline;
        text-decoration-thickness: 1.5px;
        text-underline-offset: 0.2rem;
    }

    &[in] {
        text-decoration-style: dotted;
    }
}

h1 {
    font-size: clamp(2.25rem, 9dvw, 4rem);
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.05;
    margin: 0 0 1rem;
}

h2 {
    font-size: clamp(1.75rem, 2.25dvw, 2.375rem);
    font-weight: 800;
    line-height: 1.1;
    margin: 0 0 1.5rem;
    padding-top: 2rem;
    text-shadow: 0 1px 0 #fff;
}

h3 {
    color: var(--text);
    font-size: clamp(1.33rem, 3vw, 1.625rem);
    font-weight: 800;
    line-height: 1.3;
    margin-top: 2rem;
    margin-bottom: 1rem;
    text-shadow: 0 1px 0 #fff;

    #impact & {
        font-size: 1.1rem;
    }
}

h4 {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 0;
    text-shadow: 0 1px 0 #fff;
}

body {
    margin: 0 auto;
    padding: 0;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    display: grid;
    font-family: var(--font-sans);
    grid-template-rows: 5rem 1fr auto;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    width: 100dvw;

    /* site header and footer defaults */
    > header,
    > footer {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
    }

    /* site header */
    > header {
        border-bottom: 1px solid var(--black);
        padding: 0 1.5rem;
        position: relative;

        .title {
            align-items: center;
            display: flex;
            gap: 0.75rem;
            height: 100%;
            align-items: stretch;
        }

        .logo,
        .page {
            align-items: center;
            display: flex;
            font-size: 1.5rem;
            gap: 0.5rem;;
            text-decoration: none;

            &:hover {
                text-decoration: underline;
            }
        }

        .logo {
            font-weight: 700;
            letter-spacing: -0.04rem
        }

        .page {
            font-weight: 800;
        }

        .logo:has(+ .page) {
            font-weight: 500;
            letter-spacing: 0;
        }

        /* right menu */
        menu {
            align-items: center;
            display: none;
            gap: 1rem;
            font-size: 1rem;
            list-style: none;

            a:hover {
                color: #000;
                text-decoration-thickness: 2.5px;
            }
        }

        /* line detail */
        &::before,
        &::after {
            content: '';
            display: block;
            width: calc(100% + 1.5rem);
            height: 1px;
            background: var(--black);
            position: absolute;
            bottom: -5px;
            left: -1.5rem;
        }
        &::after {
            bottom: -9px;
        }
    }

    /* site footer */
    > footer {
        background: var(--black);
        color: var(--white);
        display: flex;
        flex-direction: column;
        font-size: 0.875rem;
        gap: 2rem;
        line-height: 1.4;
        padding: 2rem 1.5rem;
        justify-content: center;

        section {
            display: grid;
            grid-template-columns: var(--article-grid);
            gap: var(--article-gap);
            justify-content: center;
        }

        #footnotes ul {
            grid-column-start: 2;
            list-style: none;
            margin: 0 0 0 -1.5rem;
            padding: 0;

            li {
                display: grid;
                grid-template-columns: 1.5rem auto;

                span.symbol {
                    font-size: 1.25rem;
                    margin-top: -3px;
                }
            }
        }

        #end {
            padding-bottom: 2rem;

            .text {
                grid-column-start: 2;
            }
        }

        big {
            color: var(--white);
            font-size: 1.5rem;
            font-weight: bold;
        }
    }
}

/*
 * <main> is case study wrapper and includes:
 *   1. <header> is the initial full screen pane
 *   2. <nav> is for the TOC
 *   3. <article> holds the actual case study
 */
main {
    display: grid;
    grid-template-columns: auto;
    grid-template-rows: ;
    justify-items: center;

    /* layout handling for the top sections */
    > header {
        align-content: start;
        display: grid;
        grid-auto-rows: auto 12rem;
        justify-items: center;
        height: calc(100lvh - 5rem);
        max-height: calc(100lvh - 5rem);
        max-width: 100lvw;
        width: 100lvw;

        hgroup,
        aside {
            display: flex;
            width: var(--column-width);
        }

        /* top hero */
        hgroup {
            align-content: end;
            display: grid;
            padding: 3rem 0 0;

            .lede {
                margin: 1rem 0 0;
                font-size: 1.6rem;
                font-weight: 400;
                line-height: 1.5;

                strong {
                    color: var(--blue);
                    font-weight: 800;
                }

                + .lede {
                    margin-top: 1.5rem;
                }

                a {
                    text-decoration-thickness: 0.15rem;

                    &:hover {
                        text-decoration-thickness: 0.2rem;
                    }
                }
            }
        }

        /* stats */
        aside {
            align-items: flex-start;
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
            justify-content: flex-start;
            padding-top: 3rem;

            figure {
                display: grid;
                grid-template-columns: 2.25rem auto;
                grid-template-rows: 1.5rem auto;
                margin: 0;
                --icon: var(--yellow);

                span.icon {
                    width: 1.5rem;
                    height: 1.5rem;
                    color: var(--icon);
                }

                label {
                    color: var(--text);
                    font-size: .95rem;
                    text-transform: uppercase;
                    font-weight: 600;
                }

                figcaption {
                    color: var(--muted);
                    font-size: 1rem;
                    line-height: 1.4;
                    grid-column-start: 2;

                    span {
                        display: inline;
                    }
                }

                &:nth-child(2) {
                    --icon: var(--black);
                }
                &:nth-child(3) {
                    --icon: var(--red);
                }
                &:nth-child(4) {
                    --icon: var(--green);
                }
                &:nth-child(5) {
                    --icon: var(--blue);
                }
            }
        }
    }

    /* case study content */
    > article {
        background: var(--white);
        border-top: 0.5rem solid var(--black);
        display: grid;
        gap: var(--article-gap);
        grid-template-columns: var(--article-grid);
        justify-content: center;
        padding: var(--article-top) 1.5rem 3rem;
        width: 100%;

        #content {
            display: grid;
            gap: 0;
        }

        section {
            width: 100%;

            &#intro
            {
                h2 {
                    padding-top: 0;
                }

                p:first-of-type {
                    font-size: 1.25rem;
                }
            }
        }

        figure {
            /*background: var(--bg);*/
            align-items: center;
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
            justify-content: center;
            margin: 2rem 0;
            padding: 0;
            position: relative;

            img {
                max-width: 100%;

                &.desktop {
                    aspect-ratio: 1.4 / 1;
                }
                &.mobile {
                    aspect-ratio: 0.46 / 1;
                    height: 20rem;
                }
            }

            figcaption {
                color: var(--muted);
                font-size: 0.875rem;
                line-height: 1.5;
                font-style: italic;
                padding-left: 0.125rem;

                p {
                    margin: 0;
                }
            }
        }

        ul {
            li {
                margin-bottom: 1rem;
            }
        }
    }
}

/* list content */

section#studies {
    background: var(--black);
    display: grid;
    justify-items: center;
    padding: 5rem 0 3rem;

    h1 {
        border-bottom: 0.25rem solid var(--white);
        color: #fff;
        margin-bottom: 3rem;
        max-width: var(--column-width);
        padding-bottom: 1rem;
        width: var(--column-width);

    }

    article {
        background-color: var(--blue);
        background-image: var(--card-bg);
        background-position: top 20rem right -2rem; /* mobile position */
        background-repeat: no-repeat;
        background-size: 50% auto; /* mobile size */
        border: none;
        color: #fff;
        transition: transform 150ms ease-in, background-position 150ms ease-in;

        > a {
            color: inherit;
            display: block;
            height: 100%;
            padding: 1.5rem;
            text-decoration: none;
            width: 100%;
        }

        h2 {
            font-size: 2.5rem;
            padding-top: 0;
            text-shadow: none;
            font-weight: 700;
        }

        p:first-of-type {
            color: #fff;
            font-size: 1.35rem;
            font-weight: 500;
            line-height: 1.4;
            margin: 0 0 0.5rem;
            text-shadow: none;
        }

        &:hover {
            background-position: top 19.5rem right -2rem;
            transform: translateY(-0.5rem);
        }

        div {
            display: flex;
            flex-direction: column;
            gap: 1rem;
            padding-top: 1rem;

            > figure {
                margin: 0;

                .icon {
                    color: color-mix(in srgb, var(--icon-color), #fff 50%);
                    width: 1.25rem;
                    height: 1.25rem;
                }

                figcaption {
                    font-size: 0.875rem;
                    font-weight: 700;
                    text-transform: uppercase;
                }
            }
        }
    }
}

/* table of contents */
nav {
    align-self: start;
    position: sticky;
    margin-left: -1.5rem;
    top: 0;
    width: calc(100% + 3rem);
    overflow-x: hidden;
    z-index: 2;

    ol {
        display: flex;
        flex-direction: row;
        list-style: decimal-leading-zero;
        list-style-position: inside;
        margin: 0;
        overflow-x: auto;
        padding: 0;

        a {
            color: var(--muted);
            text-decoration: none;
            transition: padding 125ms ease;

            &:hover {
                color: var(--text);
            }
        }

        li {
            background: var(--white);
            border-bottom: 1px solid var(--faded);
            height: 3rem;
            padding: 0.6rem 1.5rem 0.5rem;
            position: relative;
            white-space: nowrap;

            &::marker {
                color: var(--muted);
            }

            &:last-child {
                /*border: none;*/
            }

            &.active
            {
                &::after {
                    background: var(--black);
                    bottom: 0;
                    content: '';
                    display: block;
                    height: 4px;
                    left: 1.5rem;
                    position: absolute;
                    width: calc(100% - 3rem);
                }

                a {
                    color: var(--text);
                    font-weight: 700;
                }
            }
        }
    }
}

/**
 * study elements
 */

.icon {
    align-items: center;
    display: inline-flex;
    flex: 0 0 auto;
    height: 1em;
    justify-content: center;
    line-height: 1;
    width: 1em;
}

.icon svg {
    display: block;
    height: 100%;
    width: 100%;
}

.problem
{
    &:first-of-type mark {
        --mark-color: var(--yellow-body);
    }
    &:nth-of-type(2) mark {
        --mark-color: var(--red-body);
    }
    &:nth-of-type(3) mark {
        --mark-color: var(--green);
    }
}

.responses {
    display: flex;
    flex-direction: column;

    .response {

        h3:first-of-type {
            margin-top: 1rem;
        }

        .lede {
            margin-bottom: 1rem;
        }

        h4 + p {
        }
    }
}

.response-body {
    p:first-child {
        margin-top: 0;
    }
}

details {
    border-top: 1px solid var(--light);

    &:first-of-type {
        border-top-width: 3px;
        margin-top: 2rem;
    }
    &:last-of-type {
        border-bottom: 1px solid var(--light);
        margin-bottom: 1.5rem;
    }

    summary {
        align-items: center;
        color: var(--muted);
        cursor: pointer;
        display: flex;
        font-weight: 700;
        font-size: 1.1rem;
        line-height: 1.3;
        min-height: 3rem;
        padding: 0.625rem 0 0.625rem 2px;
        position: relative;
        text-decoration-color: transparent;
        transition: padding 125ms ease, color 125ms ease, text-decoration 150ms ease;

        &:hover {
            text-decoration: underline;
            text-decoration-color: currentColor;
            text-decoration-thickness: 1.5px;
            text-underline-offset: 0.2rem;
        }

        &::before {
            content: "→";
            display: block;
            font-size: 1.5rem;
            font-weight: normal;
            left: -2rem;
            opacity: 0;
            position: absolute;
            top: 0.5rem;
            visibility: invisible;
            transition: opacity 250ms ease, visibility 250ms ease, left 250ms ease;
        }
    }

    div {
        padding-left: 2px;

        p:first-child {
            margin-top: 0.25rem;
        }
    }

    &[open] summary,
    summary:hover {
        color: var(--text);
        padding-left: 0.5rem;
    }

    &[open] summary::before {
        left: -1.25rem;
        opacity: 100;
        visibility: visible;
    }
}

mark {
    --mark-color: var(--blue);
    color: var(--mark-color);
    font-weight: 900 !important;
    background-color: transparent;
    background-image: repeating-linear-gradient(
        to bottom,
        var(--muted) 0 1px,
        transparent 1px 3px
    );
    background-repeat: no-repeat;
    background-size: 100% 9px;
    background-position: left bottom;
    padding-bottom: 0.25rem;

    &[color="yellow"] {
        --mark-color: var(--yellow-body);
    }

    &[color="red"] {
        --mark-color: var(--red-body);
    }

    &[color="green"] {
        --mark-color: var(--green);
    }

    p & {
        padding-bottom: clamp(7px, 0.33rem, 9px);
    }

    h3 & {
        font-weight: 700;
        --mark-height: 0.72em;
        --mark-overlap: 0.2rem;
    }
}

span[color="blue"] {
    color: var(--blue);
}
span[color="red"] {
    color: var(--red-body);
}
span[color="yellow"] {
    color: var(--yellow-body);
}


/**
 * specific page handling
 */
body#default
{
    main > header {
        overflow-x: hidden;
        position: relative;
        justify-items: center;
        width: 100%;

        #circle,
        #rectangle,
        #semicircle,
        #square,
        #triangle {
            position: absolute;
            transition: transform 2000ms ease-in-out;
        }

        #semicircle {
            background: var(--green);
            bottom: 12dvw;
            height: 10dvw;
            border-radius: 10dvw 10dvw 0 0;
            left: 52dvw;
            width: 20dvw;
        }

        #square {
            background: var(--black);
            height: 12dvw;
            width: 12dvw;
            bottom: 0;
        }

        #circle {
            background: var(--blue);
            border-radius: 50%;
            height: 20dvw;
            bottom: 5dvh;
            left: 4dvw;
            width: 20dvw;

            &:hover {
                transform: translateX(1rem);
            }
        }

        #rectangle {
            background: var(--yellow);
            height: 5dvh;
            width: 36dvw;
            left: 2dvw;
            bottom: 0;
            transform-origin: 38%;
        }

        #triangle {
            background: var(--red);
            height: 40dvw;
            width: 40dvw;
            bottom: 0;
            right: 0;
            clip-path: polygon(100% 0, 100% 100%, 0 100%);
        }
    }
}
body#legacy
{
    main > header {
        background-image: url('/img/nyc.svg');
        background-position: bottom 0 right -15dvw;
        background-repeat: no-repeat;
        background-size: clamp(300px, 50dvw, 800px) auto;
        position: relative;

        > svg {
            bottom: 0;
            height: auto;
            left: -5dvw;
            width: clamp(150px, 20dvw, 320px);
            position: absolute;
        }
    }
}


/**
 * display queries */

.tablet-show,
.laptop-show,
.display-show {
    display: none;
}

/* small height screens override */
@media (max-height: 720px)
{
    main > header {
        grid-auto-rows: auto auto;
        height: auto;
        max-height: 100%;
        padding-bottom: 3rem;
    }
}

/* bigger than phones */
@media (min-width: 420px)
{
    body#legacy
    {
        main > header {
            background-position: bottom 0 right 0;

            svg {
                left: 0;
            }
        }
    }
}

/* tablets */
@media (min-width: 640px)
{
    html {
        font-size: 16px;
    }

    body > header {
        padding: 0 2rem;

        menu {
            display: flex;
        }
    }

    main > header {
        min-height: 860px;

        > hgroup {
            padding-top: 4rem;

            .lede {
                max-width: 80%;
            }
        }

        > aside {
            flex-direction: row;

            figure {
                grid-template-columns: auto;
                grid-template-rows: 2rem 2rem auto;
                max-width: 16%;
                padding-right: 1rem;

                figcaption {
                    grid-column-start: 1;

                    &.min {
                        width: min-content;
                    }

                    span {
                        display: inline-block;
                        white-space: nowrap;
                    }
                }
            }
        }
    }

    .tablet-show {
        display: block;
    }
    .tablet-hide {
        display: none;
    }
}

/* landscape tablets */
@media (min-width: 800px)
{
    section#studies
    {
        article {
            background-position: top 2rem right 2rem;
            background-size: 20% auto;
            width: var(--column-width);

            &:hover {
                background-position: top 1.5rem right 2rem;
            }

            a {
                padding: 2rem;
            }

            p {
                max-width: 67%;
            }

            div {
                flex-direction: row;
                gap: 2rem;
            }
        }
    }
}

/* laptops (nav/article move to columns now) */
@media (min-width: 1024px)
{
    :root {
        --article-grid: 12rem var(--content-width);
        --article-gap: 3rem;
        --article-top: 2.5rem;
    }

    h1 {
        max-width: 75%;
    }

    main > header {
        > hgroup {
            .lede {
                max-width: 60%;
            }
        }
    }

    nav {
        margin-left: 0;
        top: var(--article-top);
        width: 12rem;

        ol {
            border-top: 3px solid var(--muted);
            flex-direction: column;
            margin-top: 0.75rem;
            overflow-x: none;

            li {
                height: 2.5rem;
                padding: 0.4rem 0.25rem 0;

                &.active
                {
                    &::after {
                        display: none;
                    }

                    a {
                        padding-left: 0.25rem;
                    }
                }
            }
        }
    }

    body#default main
    {
        > header {
            padding: 0 1.5rem;

            hgroup {
                padding: 10dvh 0 0;
            }

            #semicircle {
                bottom: 57dvh;
                height: 12dvh;
                border-radius: 12dvh 12dvh 0 0;
                width: 24dvh;
                left: auto;
                right: -1dvw;

                &:hover {
                    transform: rotate(6deg) translateY(0.25dvh);

                    + #square {
                        transform: rotate(6deg) translateY(0.25dvh) translateX(0.5dvw);
                    }
                }
            }

            #square {
                bottom: 45dvh;
                height: 12dvh;
                width: 12dvh;
                right: 2dvw;

                &:has(+ #circle:hover) {
                    transform: translateX(-0.125dvw);
                }
            }

            #circle {
                height: 15dvh;
                left: auto;
                bottom: 30dvh;
                right: 3dvw;
                width: 15dvh;
            }

            #rectangle {
                height: 5dvh;
                left: auto;
                width: 36dvw;
                right: -16dvw;
                bottom: 25dvh;

                &:hover {
                    transform: rotate(-6deg) translateY(-0.125dvh);
                }
            }

            #triangle {
                height: 25dvh;
                right: 6dvw;
                width: 25dvh;
            }
        }

        section#studies {
            padding-left: 1.5rem;
            padding-right: 1.5rem;
        }
    }
}

/* desktops */
@media (min-width: 1280px)
{
    :root {
        --article-grid: 16rem var(--content-width) 8rem;
        --article-gap: 0;
        --article-top: 3rem;
    }

    html {
        font-size: 17px;
    }

    main > header
    {
        > hgroup {
            padding-top: 6rem;
        }
    }
}

/* displays */
@media (min-width: 1440px)
{
    :root {
        --article-grid: 16rem var(--content-width) 8rem;
        --article-top: 4rem;
    }

    html {
        font-size: 18px;
    }

    body {
        line-height: 1.6;
    }

    main
    {
        > header > aside {
            gap: 2rem;
        }

        > article {
            padding-right: 0;
            padding-left: 0;

            figure {
                align-items: flex-end;
                flex-direction: row;
                gap: 2rem;

                figcaption {
                    font-size: 0.75rem;
                    position: absolute;
                    right: -9.5rem;
                    bottom: 1rem;
                    width: 8rem;
                    font-style: normal;
                }
            }
        }

        nav {
            font-size: 0.925rem;

            ol li {
                    padding-top: 0.5rem;
            }
        }
    }

    section#studies
    {
        article {
            width: calc(var(--column-width) + 4rem);
        }
    }
}

@media (min-width: 1560px)
{
    :root {
        --article-grid: 17rem var(--content-width) 7rem;
    }
}