:root {
    --text: #111;
    --muted: #6c757d;
    --link: #dc3545;

    /* ======================= DESKTOP TUNING KNOBS =======================
       Text widths
         --domain-desc-max : the blurb under "Machine behavior" / "Human
                             behavior". Lower = wraps sooner.
         --project-desc-max: the blurb under each project (QuickScope, NFTs...).
       Artwork
         --art-w           : figure width. Height follows the image's aspect.
         --art-top         : how far above the section it starts. More negative
                             = higher. Watch the navbar on the first section.
         --art-x           : sideways nudge on BOTH cards. Positive moves the
                             figure right, negative left.
         --art-pull        : left-hand card only -- how far the figure hangs
                             past the section's left edge on a wide window. It
                             stops pulling automatically once that would run
                             off-screen, so narrow windows never clip it.
         --art-clear       : gap reserved to the LEFT of the right-hand figure,
                             so the domain blurb wraps before reaching it.
         --art-indent      : how far the left-hand section's text is pushed in
                             from the figure. Roughly --art-w + the gap you want.
       ==================================================================== */
    --domain-desc-max: 34rem;
    --project-desc-max: 43rem;

    /* Project row typography (desktop). The mobile modal keeps its own sizes. */
    --project-title-size: 1.15rem;
    --project-desc-size: 0.92rem;
    --project-desc-color: #8f979e;
    --art-w: 155px;
    --art-top: -3.1rem;
    --art-x: 0rem;
    --art-pull: -4rem;
    --art-clear: 11rem;
    --art-indent: 11.3rem;
}

/* Per-card overrides (desktop). Anything set here beats the shared values
   above, so you can move one figure without touching the other. */
.software-domain[data-domain="machine-behavior"] {
    --art-w: 155px;
    --art-top: -1.1rem;
    --art-x: -1rem;
    --art-clear: 11rem;
}

.software-domain[data-domain="human-behavior"] {
    --art-w: 155px;
    --art-top: -3.1rem;
    --art-x: 0rem;
    --art-pull: -4rem;
    --art-indent: 11.3rem;
}

body {
    overflow-x: hidden;
}

.navbar-brand {
    font-size: 1rem !important;
}

.container.mt-5 {
    margin-top: 1rem !important;
}

.software-wrap {
    max-width: 750px;
    margin: 2rem auto 4rem;
    padding: 0 1rem;
}

.software-domain {
    border-top: 1px solid #e1e4e7;
    padding: 2.25rem 0 0;
    position: relative;
}

.software-domain:first-child {
    border-top: 0;
    padding-top: 0.75rem;
}

.software-domain-header {
    position: static;
}

.software-domain-title,
.software-domain-description {
    position: relative;
    z-index: 1;
}

.software-domain-title {
    color: var(--text);
    font-family: "CMU Bright", "CMU Serif", Georgia, serif;
    font-size: 1.7rem;
    font-weight: 400;
    line-height: 1.1;
    margin: 0 0 0.45rem;
}

.software-domain-description {
    color: var(--muted);
    line-height: 1.55;
    margin: 0;
    max-width: var(--domain-desc-max);
}

/* The artwork is anchored to the section's right edge, so its left edge always
   sits ~13.5rem in from there. Cap the copy against that instead of a fixed
   width, and it wraps as the window narrows rather than sliding underneath.
   The figure is lifted clear of the project rows, so only the header needs it. */
.software-domain--visual-right .software-domain-title,
.software-domain--visual-right .software-domain-description {
    max-width: min(var(--domain-desc-max), calc(100% - var(--row-clear, var(--art-clear))));
}

/* The PNGs are cropped to their content, so the box is the figure -- no more
   invisible padding to position around. Height follows the image's aspect. */
.software-domain-visual {
    margin: 0;
    opacity: 0.95;
    pointer-events: none;
    position: absolute;
    right: calc(-1 * var(--art-x));
    top: var(--art-top);
    width: var(--art-w);
    z-index: 0;
}

.software-domain-visual img {
    display: block;
    height: auto;
    width: 100%;
}

/* --sec-left is how far the section's own left edge sits from the viewport.
   --art-left hangs the artwork 10rem past that edge on a wide window, but stops
   pulling once doing so would push it off-screen (body has overflow-x hidden,
   so it used to just get cut off). The copy shifts by the same amount, keeping
   the gap between artwork and text constant at every width. */
.software-domain--visual-left {
    --sec-left: max(1rem, calc((100vw - 750px) / 2 + 1rem));
    --art-left: max(var(--art-pull), calc(1rem - var(--sec-left)));
}

.software-domain--visual-left .software-domain-visual {
    left: calc(var(--art-left) + var(--art-x));
    right: auto;
    top: var(--art-top);
    width: var(--art-w);
}

.software-domain--visual-left .software-domain-header,
.software-domain--visual-left .software-project-list {
    margin-left: calc(var(--art-left) + var(--art-indent));
}

.software-project-list {
    list-style: none;
    margin: 1.7rem 0 2.5rem;
    padding: 0;
    position: relative;
    z-index: 1;
}

.software-project-item,
.software-domain-header {
    /* set by syncArtClearance() on blocks the left-hand figure reaches into */
    padding-left: var(--row-shift, 0px);
}

.software-project-item {
    padding: 1.25rem 0;
}

.software-project-footer {
    align-items: baseline;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
}

.software-project-year,
.software-project-actions {
    font-family: Inconsolata, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.software-project-year {
    color: var(--muted);
    flex-shrink: 0;
    font-size: 0.75rem;
    letter-spacing: 0.01em;
    text-align: right;
    white-space: nowrap;
}

.software-project-title {
    color: var(--text);
    font-family: "CMU Bright", "CMU Serif", Georgia, serif;
    font-size: var(--project-title-size);
    font-weight: 400;
    line-height: 1.2;
    margin: 0;
    max-width: calc(100% - var(--row-clear, 0px));
}

.software-project-title-link {
    color: inherit;
    display: none;
    text-decoration: none;
}

.software-project-description {
    color: var(--project-desc-color);
    font-size: var(--project-desc-size);
    font-style: italic;
    line-height: 1.55;
    margin: 0.45rem 0 0.7rem;
    max-width: min(var(--project-desc-max), calc(100% - var(--row-clear, 0px)));
}

.software-project-actions {
    display: flex;
    flex-wrap: wrap;
    font-size: 0.9rem;
    gap: 0.45rem;
}

.software-project-action {
    color: var(--link);
    text-decoration: none;
}

.software-project-icon {
    display: inline-block;
    height: 0.95em;
    margin-right: 0.3rem;
    vertical-align: -0.08em;
    width: 0.95em;
}

.software-project-action:hover {
    color: #b02a37;
    text-decoration: underline;
}

.software-project-sep {
    color: #a0a6ac;
    user-select: none;
}

.software-domain-close {
    font: inherit;
}

/* Both are mobile-only: on desktop the project list is already on the page. */
.software-domain-hit,
.software-domain-cta {
    display: none;
}

@media (max-width: 576px) {
    body.software-modal-open {
        overflow: hidden;
    }

    .software-wrap {
        margin-top: 1.5rem;
    }

    .software-domain {
        /* ---- tuning knobs ----
           --art-drop: how far the artwork hangs below the card. More negative
                       pushes it further down. Try -2rem .. -6rem.
           --art-bleed: how far it hangs off the left/right edge.
           --art-size:  its width, as a share of the card.
           --art-fade:  its opacity.
           --art-nudge: shifts the artwork sideways. Negative moves it left,
                        positive right. Works on both cards.
           --card-desc-max / --card-desc-max-left: how wide the card blurb runs
                        before wrapping, for the right- and left-image cards. */
        --art-drop: -1.75rem;
        --art-bleed: -1.25rem;
        --art-nudge: 0rem;
        --art-size: 46%;
        --art-fade: 0.28;
        --card-desc-max: 16.5rem;
        --card-desc-max-left: 17rem;

        background: #faf9f8;
        border: 1px solid #e7eaed;
        border-radius: 18px;
        cursor: pointer;
        margin-bottom: 0.9rem;
        min-height: 190px;
        /* clips the artwork against the rounded corner so it reads as a
           deliberate bleed rather than an overflowing image */
        overflow: hidden;
        padding: 1.15rem 1.15rem 1.05rem;
        position: relative;
    }

    /* Stretched over the whole card, so any tap opens the domain. */
    /* ---- per-card overrides (mobile) ----
       Set any knob here to move ONE card's artwork or retype its blurb width;
       these win over the shared values above.
       --card-desc-max note: at 15.4rem the Machine blurb breaks before "and".
       The window that produces that break is 240px-253px; below 240 the second
       line splits too, above 253 "and" climbs back up to line one. */
    .software-domain[data-domain="machine-behavior"] {
        --art-drop: -6.75rem;
        --art-bleed: -1.25rem;
        --art-nudge: 0rem;
        --art-size: 46%;
        --card-desc-max: 16.4rem;
    }

    .software-domain[data-domain="human-behavior"] {
        --art-drop: -10.75rem;
        --art-bleed: -1.25rem;
        --art-nudge: 0rem;
        --art-size: 46%;
        --card-desc-max: 17rem;
    }

    .software-domain-hit {
        background: none;
        border: 0;
        display: block;
        inset: 0;
        padding: 0;
        position: absolute;
        width: 100%;
        z-index: 3;
    }

    .software-domain-hit:focus-visible {
        border-radius: 18px;
        outline: 2px solid var(--link);
        outline-offset: -3px;
    }

    .software-domain:active {
        background: #f5f3f1;
    }

    .software-domain-header,
    .software-domain--visual-left .software-domain-header {
        display: block;
        min-height: 0;
        padding-bottom: 0;
        position: relative;
        z-index: 2;
    }

    .software-domain-title {
        margin-bottom: 0.5rem;
        width: 100%;
    }

    /* The desktop cap that keeps copy clear of the right-hand figure is sized
       for a 750px column; on a phone it would squeeze the title to ~142px.
       Here the artwork sits behind the text instead, so drop it. */
    .software-domain--visual-right .software-domain-title {
        max-width: none;
    }

    /* Every line starts on the same edge as the title. The artwork sits behind
       the text now, so nothing has to flow around it. */
    .software-domain-description {
        color: var(--muted);
        display: block;
        line-height: 1.55;
        margin: 0;
    }

    /* Listed at three specificities so this beats the desktop rule that caps
       the right-hand card's blurb against its artwork. */
    .software-domain-description,
    .software-domain--visual-right .software-domain-description,
    .software-domain--visual-left .software-domain-description {
        max-width: var(--card-desc-max);
    }

    /* Large, faint, and anchored past the card's edges: the PNGs carry real
       alpha, so they wash behind the text instead of sitting in a box. */
    .software-domain-visual,
    .software-domain--visual-left .software-domain-visual {
        bottom: var(--art-drop);
        float: none;
        margin: 0;
        opacity: var(--art-fade);
        position: absolute;
        top: auto;
        width: var(--art-size);
        z-index: 0;
    }

    .software-domain--visual-right .software-domain-visual {
        left: auto;
        right: calc(var(--art-bleed) - var(--art-nudge));
    }

    .software-domain--visual-left .software-domain-visual {
        left: calc(var(--art-bleed) + var(--art-nudge));
        right: auto;
    }

    .software-domain-visual img {
        border-radius: 0;
    }

    /* Keep the densest part of the artwork out from under the copy. */
    .software-domain--visual-left .software-domain-title,
    .software-domain--visual-left .software-domain-description,
    .software-domain--visual-left .software-domain-cta {
        margin-left: auto;
        text-align: right;
    }

    .software-domain-cta {
        color: var(--link);
        font-family: Inconsolata, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
        font-size: 0.8rem;
        display: block;
        margin: 0.9rem 0 0;
    }

    .software-domain-cta::after {
        content: " \2192";
    }

    .software-domain--visual-left .software-domain-header,
    .software-domain--visual-left .software-project-list {
        margin-left: 0;
    }

    .software-domain-title {
        font-size: 1.5rem;
    }

    .software-project-list {
        display: none;
        margin-top: 1.15rem;
    }

    .software-project-item {
        align-items: start;
        column-gap: 0.8rem;
        display: block;
        grid-template-columns: 3rem minmax(0, 1fr);
        padding: 1rem 0 1.5rem;
        row-gap: 0.4rem;
    }

    .software-project-year {
        margin-top: 0.6rem;
        padding: 0;
        text-align: right;
    }

    .software-project-content {
        display: block;
    }

    .software-project-footer {
        display: block;
    }

    .software-project-title {
        font-size: 1.25rem;
    }

    .software-project-title-text {
        display: none;
    }

    .software-project-title-link {
        display: inline;
    }

    .software-project-actions {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.4rem;
        grid-column: 1;
        grid-row: 2;
        margin: 0;
    }

    .software-project-action {
        align-items: center;
        background: #f5f5f5;
        border: 1px solid #d7dce1;
        border-radius: 50%;
        display: inline-flex;
        height: 40px;
        justify-content: center;
        padding: 0;
        transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
        width: 40px;
    }

    .software-project-action:hover,
    .software-project-action:focus-visible {
        background: #fff;
        border-color: var(--link);
        outline: none;
        text-decoration: none;
    }

    .software-project-action-label {
        display: none;
    }

    /* icon buttons stack in a column here; no dividers needed */
    .software-project-sep {
        display: none;
    }

    /* the desktop row styling above is deliberately not carried onto the
       phone; the modal keeps upright text at its own size */
    .software-project-description {
        color: var(--muted);
        font-size: 1rem;
        font-style: normal;
        margin: 0;
    }

    .software-project-icon {
        flex: 0 0 1.2rem;
        height: 1.2rem;
        margin: 0;
        object-fit: contain;
        vertical-align: 0;
        width: 1.2rem;
    }

    .software-project-action i.software-project-icon {
        align-items: center;
        display: inline-flex;
        justify-content: center;
        line-height: 1;
        text-align: center;
    }

    .software-domain-modal {
        /* --modal-top: how far down the window the panel starts.
           Raise it to drop the pop-up lower. Try 4rem .. 30vh. */
        --modal-top: 18vh;

        background: rgba(17, 17, 17, 0.45);
        inset: 0;
        padding: var(--modal-top) 0.9rem 1.25rem;
        position: fixed;
        z-index: 1000;
    }

    .software-domain-modal[hidden] {
        display: none;
    }

    .software-domain-modal-panel {
        background: #fff;
        border-radius: 16px;
        box-shadow: 0 18px 42px rgba(0, 0, 0, 0.18);
        margin: 0 auto;
        max-height: min(calc(100vh - var(--modal-top) - 2.5rem), 720px);
        max-width: 420px;
        overflow-y: auto;
        padding: 1rem 1rem 0.5rem;
        position: relative;
    }

    .software-domain-modal-title {
        color: var(--text);
        font-family: "CMU Bright", "CMU Serif", Georgia, serif;
        font-size: 1.4rem;
        font-weight: 400;
        margin: 0 2rem 0.5rem 0;
    }

    .software-domain-close {
        background: transparent;
        border: none;
        color: var(--muted);
        cursor: pointer;
        font-size: 1.9rem;
        line-height: 1;
        padding: 0;
        position: absolute;
        right: 0.9rem;
        top: 0.7rem;
    }

    .software-domain-close:hover,
    .software-domain-close:focus-visible {
        color: var(--text);
        outline: none;
    }

    .software-domain-modal .software-project-list {
        display: block;
        margin: 0;
    }

    .software-domain-modal .software-project-item {
        border-top: 1px solid #e8ebee;
        display: block;
        padding: 0.8rem 0;
    }

    .software-domain-modal .software-project-item:first-child {
        border-top: 0;
    }

    .software-domain-modal .software-project-year {
        color: var(--muted);
        font-size: 0.8rem;
        text-align: right;
    }

    .software-domain-modal .software-project-title {
        font-size: 1.1rem;
        margin-top: 0.15rem;
    }

    .software-domain-modal .software-project-description {
        margin-top: 0.35rem;
    }

    .software-domain-modal .software-project-actions {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }

    .software-domain-modal .software-project-action {
        background: #f7f7f7;
        border-radius: 999px;
        display: inline-flex;
        height: auto;
        padding: 0.3rem 0.7rem;
        width: auto;
    }

    .software-domain-modal .software-project-action-label {
        display: inline;
    }

    .software-domain-modal .software-project-icon {
        display: inline-block;
        margin-right: 0.25rem;
    }
}