/* ==========================================================================
   Work-first pages: homepage, project index, case studies.
   Sits on top of style.css and reuses its tokens. The one bright thing on
   the page is the work itself: the real app screens.
   ========================================================================== */

:root {
    --container-wide: 1040px;
    --frame: #111110;
    --bar: rgba(28, 27, 25, 0.3);
    --bar-strong: var(--accent);
}

html[data-theme="dark"] {
    --frame: #0B0504;
    --bar: rgba(241, 229, 207, 0.3);
}

.container--wide {
    max-width: var(--container-wide);
}

.top-nav {
    display: flex;
    align-items: center;
    gap: var(--s4);
}

.top-link[aria-current="page"] {
    color: var(--ink);
}

/* --------------------------------------------------------------------------
   Statement
   -------------------------------------------------------------------------- */

.statement--work {
    padding-bottom: clamp(2.5rem, 7vh, 4rem);
}

.statement--work h1 {
    max-width: 22ch;
}

.statement--work .lede {
    margin-top: 1.5rem;
    max-width: 46ch;
    color: var(--ink-soft);
    font-size: 1.125rem;
    line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Flagship
   -------------------------------------------------------------------------- */

.flagship {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 320px);
    gap: clamp(2rem, 6vw, 5rem);
    align-items: center;
    padding: var(--s6) 0 var(--s7);
}

.flagship h2,
.section-title {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1.625rem, 3.6vw, 2.25rem);
    line-height: 1.25;
    letter-spacing: -0.005em;
    margin: 0.75rem 0 1.25rem;
    text-wrap: balance;
}

.flagship p {
    color: var(--ink-soft);
    max-width: 50ch;
}

.flagship p + p {
    margin-top: 1rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s3) var(--s4);
    align-items: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 1.25rem;
    border: 1px solid var(--ink);
    font-family: var(--font-display);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink);
    -webkit-tap-highlight-color: transparent;
}

.btn:hover,
.btn:active {
    background: var(--ink);
    color: var(--canvas);
}

.btn:active {
    transform: scale(0.97);
}

.text-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-family: var(--font-display);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.text-link:hover,
.text-link:active {
    color: var(--accent);
}

/* The phone: a plain dark slab, the screen does the talking */
.device {
    justify-self: center;
    width: 100%;
    max-width: 300px;
}

.device-body {
    position: relative;
    aspect-ratio: 1206 / 2622;
    padding: 9px;
    border-radius: 46px;
    background: var(--frame);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.08) inset,
        0 30px 60px -28px rgba(20, 10, 4, 0.55),
        0 12px 24px -16px rgba(20, 10, 4, 0.4);
}

.device-screen {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 38px;
    overflow: hidden;
    background: #07090d;
}

.device-screen img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}

/* --------------------------------------------------------------------------
   Project index: each row carries its own year of commits
   -------------------------------------------------------------------------- */

.work {
    padding-bottom: var(--s7);
}

.projects {
    list-style: none;
}

.project::after {
    content: '';
    display: block;
    height: 5px;
    background: var(--rule) repeat-x center / 600px 5px;
}

.project-row {
    display: grid;
    grid-template-columns: 3.25rem minmax(0, 1fr) 9.5rem;
    grid-template-areas: "no body status";
    gap: 1.25rem;
    align-items: center;
    padding: 1.5rem 1rem;
    margin: 0 -1rem;
}

a.project-row:hover,
a.project-row:active {
    background-color: var(--tint);
}

.p-body { grid-area: body; }
.p-status { grid-area: status; }

.p-name {
    display: block;
    font-size: 1.1875rem;
    font-weight: 500;
    line-height: 1.35;
    transition: color 200ms ease;
}

a.project-row:hover .p-name {
    color: var(--accent);
}

.p-line {
    display: block;
    margin-top: 0.25rem;
    color: var(--ink-soft);
    font-size: 1rem;
    line-height: 1.5;
    max-width: 52ch;
}

.p-stack {
    display: block;
    margin-top: 0.5rem;
    font-family: var(--font-display);
    font-size: 0.625rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.p-status {
    justify-self: end;
    text-align: right;
    font-family: var(--font-display);
    font-size: 0.625rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-faint);
    white-space: nowrap;
}

.p-status.is-live {
    color: var(--ink);
}

.p-status.is-live::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 0.6em;
    border-radius: 50%;
    background: var(--accent);
    vertical-align: 1px;
}

/* --------------------------------------------------------------------------
   Method
   -------------------------------------------------------------------------- */

.method {
    padding-bottom: var(--s7);
}

.method-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--s5);
    margin-top: var(--s5);
}

.method-grid h3 {
    font-family: var(--font-body);
    font-size: 1.1875rem;
    font-weight: 500;
    line-height: 1.35;
    margin: 0.625rem 0 0.625rem;
}

.method-grid p {
    color: var(--ink-soft);
    font-size: 1rem;
    line-height: 1.65;
}

.section-intro {
    max-width: 54ch;
    color: var(--ink-soft);
}

.index-head a.micro:hover {
    color: var(--accent);
}

/* --------------------------------------------------------------------------
   Case study
   -------------------------------------------------------------------------- */

.case-head {
    padding: clamp(3.5rem, 10vh, 6rem) 0 var(--s5);
}

.case-head h1 {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1.875rem, 5vw, 3rem);
    line-height: 1.22;
    max-width: 20ch;
    margin-top: 1rem;
    text-wrap: balance;
}

.case-head .lede {
    margin-top: 1.5rem;
    max-width: 52ch;
    font-size: 1.125rem;
    color: var(--ink-soft);
    line-height: 1.6;
}

.case-section {
    padding: var(--s6) 0 0;
}

.case-section > p {
    color: var(--ink-soft);
}

.case-section > p + p {
    margin-top: 1rem;
}

.case-section strong {
    color: var(--ink);
    font-weight: 500;
}

/* System diagram */
.system {
    margin-top: var(--s5);
}

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

.system .box {
    fill: var(--tint);
    stroke: var(--hairline);
}

.system .box--core {
    stroke: var(--accent);
}

.system .wire {
    stroke: var(--ink-faint);
    stroke-width: 1;
    fill: none;
}

.system .t {
    font-family: var(--font-body);
    font-size: 15px;
    fill: var(--ink);
}

.system .s {
    font-family: var(--font-display);
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    fill: var(--ink-faint);
}

.system .arrow {
    fill: var(--ink-faint);
}

/* Hard parts */
.stories {
    display: grid;
    gap: var(--s5);
    margin-top: var(--s5);
}

.story {
    display: grid;
    grid-template-columns: 3.25rem minmax(0, 1fr);
    gap: 1.25rem;
}

.story h3 {
    font-family: var(--font-body);
    font-size: 1.1875rem;
    font-weight: 500;
    line-height: 1.35;
}

.story p {
    margin-top: 0.5rem;
    color: var(--ink-soft);
}

.story code,
.case-section code {
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 0.8125em;
    padding: 0.1em 0.35em;
    background: var(--tint);
    color: var(--ink);
}

/* The math, live */
.calc {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--s5);
    align-items: center;
    margin-top: var(--s5);
    padding: var(--s5);
    background: var(--tint);
}

.calc-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s3);
}

.calc label {
    display: block;
    font-family: var(--font-display);
    font-size: 0.625rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.calc input {
    width: 100%;
    min-height: 48px;
    margin-top: 0.375rem;
    padding: 0 0.75rem;
    border: 1px solid var(--hairline);
    border-radius: 0;
    background: var(--canvas);
    color: var(--ink);
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-variant-numeric: tabular-nums;
    -webkit-appearance: none;
    appearance: none;
}

.calc input:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 2px;
}

.calc-out b {
    display: block;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(2.25rem, 6vw, 3.25rem);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.calc-out span {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.9375rem;
    font-style: italic;
    color: var(--ink-soft);
}

.case-next {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--s3);
    padding: var(--s6) 0 0;
}

/* --------------------------------------------------------------------------
   Small screens
   -------------------------------------------------------------------------- */

@media (max-width: 860px) {
    .flagship {
        grid-template-columns: 1fr;
        padding-top: var(--s5);
    }

    .device {
        max-width: 300px;
    }

    .method-grid {
        grid-template-columns: 1fr;
        gap: var(--s4);
    }

    .project-row {
        grid-template-columns: 2.25rem minmax(0, 1fr);
        grid-template-areas: "no body" ". status";
        row-gap: 0.875rem;
        align-items: start;
    }

    .project-row .e-no {
        padding-top: 0.5rem;
    }

    .p-status {
        justify-self: start;
        text-align: left;
    }

        .calc {
        grid-template-columns: 1fr;
        padding: var(--s4);
    }
}

@media (max-width: 560px) {

    .top-nav {
        gap: var(--s3);
    }

    .story {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }
}

/* style.css pins .e-no to a named grid area; stories have no named areas */
.story .e-no {
    grid-area: auto;
    padding-top: 0.5rem;
}

.wordmark {
    white-space: nowrap;
}

@media (max-width: 560px) {
    .work .index-head {
        flex-direction: column;
        gap: 0.25rem;
    }

}

/* --------------------------------------------------------------------------
   The phone you can use: captures stacked as layers, tap targets on top
   -------------------------------------------------------------------------- */

.proto-screen {
    cursor: default;
    isolation: isolate;
}

.proto-layer {
    position: absolute;
    inset: 0;
    visibility: hidden;
    background: #07090d;
    will-change: transform, opacity;
}

/* the capture scrolls; the chrome above it does not */
.proto-scroll {
    position: absolute;
    inset: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.proto-scroll::-webkit-scrollbar {
    display: none;
}

.proto-page {
    position: relative;
    width: 100%;
}

.device-screen .proto-page img,
.device-screen .proto-top img {
    position: absolute;
    inset: 0 0 auto 0;
    width: 100%;
    height: auto;
    object-fit: fill;
    -webkit-user-drag: none;
    user-select: none;
}

.proto-fixed {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.proto-fixed .proto-hot {
    pointer-events: auto;
}

.proto-top {
    position: absolute;
    inset: 0 0 auto 0;
    overflow: hidden;
}

.device-screen img.proto-tabbar {
    position: absolute;
    inset: auto;
    object-fit: fill;
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.55));
    -webkit-user-drag: none;
    user-select: none;
}

.proto-layer.is-on,
.proto-layer.is-in,
.proto-layer.is-out {
    visibility: visible;
}

.proto-layer.is-in { z-index: 2; }
.proto-layer.is-out { z-index: 1; }
.proto-layer.is-out .proto-hot,
.proto-layer.is-in .proto-hot { pointer-events: none; }

.proto-layer.is-in.is-fade { animation: proto-fade 300ms ease both; }
.proto-layer.is-in.is-push { animation: proto-push 380ms cubic-bezier(0.22, 0.8, 0.24, 1) both; box-shadow: -18px 0 40px rgba(0, 0, 0, 0.5); }
.proto-layer.is-out.is-push { animation: proto-recede 380ms cubic-bezier(0.22, 0.8, 0.24, 1) both; }
.proto-layer.is-out.is-pop { z-index: 3; animation: proto-pop 340ms cubic-bezier(0.4, 0, 0.6, 1) both; box-shadow: -18px 0 40px rgba(0, 0, 0, 0.5); }
.proto-layer.is-in.is-pop { animation: proto-return 340ms cubic-bezier(0.4, 0, 0.6, 1) both; }

@keyframes proto-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes proto-push { from { transform: translateX(100%); } to { transform: none; } }
@keyframes proto-recede { from { transform: none; opacity: 1; } to { transform: translateX(-24%); opacity: 0.5; } }
@keyframes proto-pop { from { transform: none; } to { transform: translateX(100%); } }
@keyframes proto-return { from { transform: translateX(-24%); opacity: 0.5; } to { transform: none; opacity: 1; } }

.proto-hot {
    position: absolute;
    z-index: 4;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.proto-hot::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: 0 0 0 1.5px rgba(120, 225, 255, 0.9), 0 0 18px rgba(0, 212, 255, 0.45);
    background: rgba(0, 212, 255, 0.08);
    opacity: 0;
    transition: opacity 160ms ease;
}

.proto-hot:hover::after,
.proto-hot:focus-visible::after { opacity: 0.7; }
.proto-hot:active::after { opacity: 1; background: rgba(0, 212, 255, 0.2); }
.proto-hot:focus-visible { outline: none; }

/* before the first tap, the targets breathe so nobody mistakes this for a picture */
[data-proto]:not(.is-touched) .proto-layer.is-on .proto-hot::after {
    animation: proto-invite 2.8s ease-in-out 1.2s 3 both;
}
@keyframes proto-invite { 0%, 100% { opacity: 0; } 50% { opacity: 0.6; } }

/* a missed tap shows every target once (after the invite so it wins) */
[data-proto].is-flash .proto-layer.is-on .proto-hot::after { animation: proto-flash 900ms ease both; }
@keyframes proto-flash { 0%, 100% { opacity: 0; } 25%, 60% { opacity: 0.85; } }

.proto-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s3);
    margin-top: var(--s3);
    min-height: 44px;
}

.proto-bar .micro b {
    font-weight: 500;
    color: var(--ink);
}

.proto-reset {
    min-height: 44px;
    padding: 0 0.25rem;
    background: none;
    border: 0;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    touch-action: manipulation;
    font-family: var(--font-display);
    font-size: 0.625rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-faint);
    visibility: hidden;
}

.is-deep .proto-reset { visibility: visible; }
.proto-reset:hover { color: var(--accent); }
.proto-reset:active { transform: scale(0.95); }

.proto-invite {
    margin-top: 0.25rem;
    font-size: 0.9375rem;
    font-style: italic;
    line-height: 1.5;
    color: var(--ink-soft);
}

@media (prefers-reduced-motion: reduce) {
    .proto-layer.is-in,
    .proto-layer.is-out,
    .proto-hot::after { animation: none !important; }
}

.proto-bar .micro,
.proto-reset {
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Case study hero with the phone beside the title
   -------------------------------------------------------------------------- */

.case-hero {
    padding-top: var(--s5);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 300px);
    gap: clamp(2rem, 6vw, 5rem);
    align-items: center;
    padding-bottom: var(--s6);
}

.case-hero .case-head {
    padding-bottom: 0;
}

/* --------------------------------------------------------------------------
   Goal to plan: two devices and the line between them
   -------------------------------------------------------------------------- */

.loop {
    display: grid;
    grid-template-columns: minmax(0, 290px) minmax(0, 1fr) minmax(0, 290px);
    gap: var(--s4);
    align-items: center;
    margin-top: var(--s5);
}

.loop figure figcaption,
.shots figcaption {
    margin-top: var(--s3);
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--ink-soft);
}

.loop figcaption b,
.shots figcaption b {
    display: block;
    margin-bottom: 0.25rem;
    font-family: var(--font-display);
    font-size: 0.625rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.loop .device-body,
.shots .device-body {
    padding: 7px;
    border-radius: 38px;
}

.loop .device-screen,
.shots .device-screen {
    border-radius: 31px;
}

.loop-wire {
    align-self: center;
    text-align: center;
}

.loop-wire svg {
    display: block;
    width: 100%;
    height: 56px;
    overflow: visible;
}

.loop-wire .track {
    stroke: var(--hairline);
    stroke-width: 1;
    fill: none;
}

.loop-wire .beam {
    stroke: var(--accent);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 0.08 0.92;
    fill: none;
    animation: beam 2.6s linear infinite;
}

.loop-wire .beam--back {
    animation-direction: reverse;
    animation-duration: 3.4s;
    opacity: 0.55;
}

@keyframes beam {
    from { stroke-dashoffset: 1; }
    to { stroke-dashoffset: 0; }
}

.loop-steps {
    list-style: none;
    margin-top: var(--s3);
    display: grid;
    gap: 0.875rem;
    text-align: left;
}

.loop-steps li {
    display: grid;
    grid-template-columns: 1.75rem minmax(0, 1fr);
    gap: 0.5rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--ink-soft);
}

.loop-steps .e-no {
    grid-area: auto;
    padding-top: 0.35rem;
}

.loop-steps b {
    color: var(--ink);
    font-weight: 500;
}

/* the calendar's own verdict line, set large */
.verdict {
    margin-top: var(--s5);
    padding: var(--s4) 0;
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: clamp(0.875rem, 2.2vw, 1.25rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink);
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
}

.verdict span + span::before {
    content: '\00B7';
    margin-right: 1.25rem;
    color: var(--ink-faint);
}

.verdict .is-call {
    color: var(--accent);
}

.verdict-note {
    font-size: 0.9375rem;
    font-style: italic;
    color: var(--ink-soft);
}

/* live web app in a frame */
.live-frame {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: #0d1117;
}

.live-frame iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 390px;
    border: 0;
    transform-origin: 0 0;
}

/* --------------------------------------------------------------------------
   Wearables: the heartbeat that draws itself
   -------------------------------------------------------------------------- */

.pulse {
    margin-top: var(--s5);
}

.pulse-svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.pulse-grid {
    stroke: var(--hairline);
    stroke-width: 1;
    stroke-dasharray: 2 6;
}

.pulse-axis,
.pulse-label {
    font-family: var(--font-display);
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    fill: var(--ink-faint);
}

.pulse-num {
    font-family: var(--font-display);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    fill: var(--ink);
}

.pulse-line {
    fill: none;
    stroke: var(--accent);
    stroke-width: 1.75;
    stroke-linejoin: round;
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
}

.pulse-set {
    opacity: 0;
}

.pulse-set rect {
    fill: var(--accent);
    opacity: 0.13;
}

.is-live .pulse-line {
    animation: pulse-draw 2.6s cubic-bezier(0.4, 0, 0.3, 1) 0.3s forwards;
}

.is-live .pulse-set {
    animation: pulse-set 500ms ease forwards;
}

@keyframes pulse-draw { to { stroke-dashoffset: 0; } }
@keyframes pulse-set { to { opacity: 1; } }

.pulse-caption {
    margin-top: var(--s2);
    font-size: 0.875rem;
    font-style: italic;
    color: var(--ink-faint);
}

.sources {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s5);
    margin-top: var(--s5);
}

.sources h3 {
    font-family: var(--font-body);
    font-size: 1.1875rem;
    font-weight: 500;
    margin: 0.5rem 0;
}

.sources p {
    color: var(--ink-soft);
    font-size: 1rem;
    line-height: 1.65;
}

.shots {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 220px));
    gap: var(--s4);
    margin-top: var(--s5);
}

.case-section blockquote {
    margin: var(--s4) 0;
    padding-left: var(--s4);
    border-left: 1px solid var(--accent);
    max-width: 56ch;
    font-size: 1.1875rem;
    line-height: 1.55;
    font-style: italic;
    color: var(--ink);
}

.case-section blockquote cite {
    display: block;
    margin-top: 0.5rem;
    font-family: var(--font-display);
    font-size: 0.625rem;
    font-style: normal;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.case-section h3.sub {
    font-family: var(--font-body);
    font-size: 1.1875rem;
    font-weight: 500;
    margin: var(--s4) 0 0.5rem;
}

@media (max-width: 860px) {
    .case-hero {
        grid-template-columns: 1fr;
    }

    .loop {
        grid-template-columns: 1fr 1fr;
    }

    .loop-wire {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .loop-wire svg {
        display: none;
    }

    .sources {
        grid-template-columns: 1fr;
        gap: var(--s4);
    }

}

@media (prefers-reduced-motion: reduce) {
    .loop-wire .beam { animation: none; }
    .pulse-line { stroke-dashoffset: 0; animation: none !important; }
    .pulse-set { opacity: 1; animation: none !important; }
}

a.inline {
    color: var(--ink);
    box-shadow: 0 -1px 0 var(--accent) inset;
}

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

/* Links that are also tap targets */
.index-head a.micro,
.case-head .micro a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
}

.btn,
.text-link {
    touch-action: manipulation;
}

.proto-screen:focus {
    outline: none;
}

/* The system diagram keeps its size and scrolls sideways on small screens */
.system {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 760px) {
    .system svg {
        min-width: 720px;
    }
}

/* One device per row on phones, so the live calendar is big enough to use */
@media (max-width: 560px) {
    .loop {
        grid-template-columns: 1fr;
    }

    .loop figure {
        width: 100%;
        max-width: 300px;
        justify-self: center;
    }

    .loop-wire {
        grid-row: auto;
    }

    .pulse-axis,
    .pulse-label { font-size: 13px; letter-spacing: 0.08em; }
    .pulse-num { font-size: 16px; }
}

/* Small touches: five looping vignettes */
.touches {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: var(--s4);
    margin-top: var(--s5);
}

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

@media (max-width: 560px) {
    .touches { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.touches li {
    display: flex;
    flex-direction: column;
}

.touches b {
    margin-top: 0.75rem;
    font-family: var(--font-body);
    font-size: 1.0625rem;
    font-weight: 500;
    color: var(--ink);
}

.touches span {
    margin-top: 0.25rem;
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--ink-soft);
}

.touch-svg {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--hairline);
    background: var(--tint);
}

.touch-svg .t-box { fill: var(--canvas); stroke: var(--hairline); }
.touch-svg .t-rule { fill: none; stroke: var(--hairline); }
.touch-svg .t-lab { font-family: var(--font-display); font-size: 9px; font-weight: 500; letter-spacing: 0.14em; fill: var(--ink-faint); }
.touch-svg .t-txt { font-family: var(--font-display); font-size: 12px; font-weight: 500; fill: var(--ink); }
.touch-svg .t-big { font-family: var(--font-display); font-size: 30px; font-weight: 600; fill: var(--ink); font-variant-numeric: tabular-nums; }
.touch-svg .t-acc { fill: var(--accent); }
.touch-svg .t-line,
.touch-svg .t-tick { fill: none; stroke: var(--ink-faint); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.touch-svg .t-tick,
.touch-svg .t-acc-s { stroke: var(--accent); }
.touch-svg .t-dot { fill: var(--accent); animation: touch-blink 1s steps(2, start) infinite; }
.touch-svg .t-chip { fill: var(--accent); }
.touch-svg .t-chiptxt { font-family: var(--font-display); font-size: 10px; font-weight: 600; letter-spacing: 0.12em; fill: var(--canvas); }
.touch-svg .t-bar { fill: var(--bar); transform-box: fill-box; transform-origin: bottom; animation: touch-grow 7s ease-out infinite both; }
.touch-svg .t-bar--on { fill: var(--accent); }
.touch-svg .t-draw { stroke-dasharray: 1; animation: touch-draw 7s ease-out infinite both; }
.touch-svg .t-in { animation: touch-in 7s ease-out infinite both; }
.touch-svg .t-d1 { animation-delay: 0.5s; }
.touch-svg .t-d2 { animation-delay: 1s; }
.touch-svg .t-d3 { animation-delay: 1.6s; }

@keyframes touch-draw { 0%, 6% { stroke-dashoffset: 1; } 26%, 100% { stroke-dashoffset: 0; } }
@keyframes touch-in { 0%, 8% { opacity: 0; } 22%, 100% { opacity: 1; } }
@keyframes touch-grow { 0%, 6% { transform: scaleY(0); } 24%, 100% { transform: scaleY(1); } }
@keyframes touch-blink { to { opacity: 0.25; } }

@media (prefers-reduced-motion: reduce) {
    .touch-svg .t-bar,
    .touch-svg .t-draw,
    .touch-svg .t-in,
    .touch-svg .t-dot { animation: none; }
}

/* How it is built: one row per part */
.parts {
    margin-top: var(--s5);
    border-top: 1px solid var(--hairline);
}

.parts > div {
    display: grid;
    grid-template-columns: 11rem minmax(0, 1fr);
    gap: var(--s4);
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--hairline);
}

.parts dt {
    font-family: var(--font-display);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-faint);
    padding-top: 0.3rem;
}

.parts dd {
    color: var(--ink-soft);
}

@media (max-width: 560px) {
    .parts > div { grid-template-columns: 1fr; gap: 0.25rem; }
}

/* Print: reference pairs and before / after */
.refs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--s5) var(--s4);
    margin-top: var(--s5);
}

.ref-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.ref-pair--one {
    grid-template-columns: 1fr;
}

.refs img,
.compare img {
    display: block;
    width: 100%;
    height: auto;
}

.refs figcaption,
.compare figcaption {
    margin-top: 0.75rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--ink-soft);
}

.refs figcaption b,
.compare figcaption b {
    display: block;
    font-family: var(--font-display);
    font-size: 0.625rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin-bottom: 0.25rem;
}

.compares {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s4);
    margin-top: var(--s5);
}

.compare-frame {
    --cut: 50%;
    position: relative;
    overflow: hidden;
    background: var(--frame);
    cursor: ew-resize;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.compare-frame img {
    -webkit-user-drag: none;
    pointer-events: none;
}

.compare-frame.is-dragging .compare-line::after {
    transform: scale(0.92);
}

.compare-top {
    position: absolute;
    inset: 0;
    clip-path: inset(0 calc(100% - var(--cut)) 0 0);
}

.compare-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--cut);
    width: 2px;
    margin-left: -1px;
    background: #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
    pointer-events: none;
}

.compare-line::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.compare-tag {
    position: absolute;
    top: 0.625rem;
    padding: 0.2rem 0.45rem;
    font-family: var(--font-display);
    font-size: 0.5625rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    pointer-events: none;
}

.compare-tag--l { left: 0.625rem; }
.compare-tag--r { right: 0.625rem; }

/* Keyboard-only control: focusable, never in the pointer's way */
.compare-frame input[type="range"] {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 1px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

.compare-frame:focus-within {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

@media (max-width: 760px) {
    .compares { grid-template-columns: 1fr; }
}

/* A project page without a phone beside the title: let the intro run wide */
.case-head:not(.case-hero .case-head) .lede {
    max-width: none;
}

.compares {
    max-width: 880px;
}

.case-section > .compares + p,
.case-section > .refs + p {
    margin-top: var(--s5);
}
