/* Option B on a phone. Every option B page loads this last, with b-phone.js.

   - Pictures run from edge to edge. On a phone held upright they're tall too, and the wide ones
     pan sideways as you scroll (b-phone.js), so they're big and nothing is cut off for good.
   - A project opens with its name and a picture. Each chapter's text sits between the pictures,
     right above the work it's about (tools/notes.py), and the longer ones fold.
   - What happens on hover with a mouse happens here to whatever is in the middle of the screen.
   Up to 860px there's one column; up to 640px it's a phone held upright.
   Nothing moves for anyone whose system asks for less motion. */

/* ── touch, at any size ──────────────────────────────────────────────────── */
html{-webkit-tap-highlight-color:transparent}
a,button,.b-about .w{touch-action:manipulation}
button,.mt-cap,.mt-chips,.mt-tabs,.b-about .w{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
.by-touch{display:none}
@media (hover:none){
  .by-mouse{display:none}
  .by-touch{display:inline}
}
/* a press answers straight away */
.b-nextcard,.mt-chips button,.mt-tabs button,.mt-theme button,.b-consent button{transition:background-color .3s ease,color .3s ease,border-color .25s ease,scale .16s var(--ease)}
.mt-chips button:active,.mt-tabs button:active,.mt-theme button:active,.b-consent button:active{scale:.96}
.b-nextcard:active{scale:.985}
.b-hang a .b-pic{transition:scale .16s var(--ease)}
.b-hang a:active .b-pic{scale:.985}
@media (hover:none){.b-foot .big:active,.b-legal a:active,.b-arch:active,.crumbs a:active{color:var(--accent)}}

/* ── the notes between the pictures: only in one column ──────────────────── */
.b-note{display:none}

@media (max-width:860px){
  .bp .project .chapters,.bp .project.page .chapters{display:none}
  .b-note{display:block;position:relative;padding:60px var(--gap) 28px}
  .b-note::before{content:"";position:absolute;left:var(--gap);right:var(--gap);top:44px;height:1px;
    background:rgba(212,212,212,.28);transform-origin:0 50%}
  /* two in a row sit closer together */
  .b-note + .b-note{padding-top:22px}
  .b-note + .b-note::before{top:6px}
  .b-note h2{margin:0 0 10px;font-size:12px;font-weight:400;line-height:1.45;letter-spacing:.06em;
    text-transform:uppercase;color:var(--mid)}
  .b-note button{display:flex;align-items:center;justify-content:space-between;width:calc(100% + 24px);min-height:44px;
    margin:-12px -12px -10px;padding:0 12px;border:0;background:none;color:inherit;font:inherit;letter-spacing:inherit;
    text-transform:inherit;text-align:left;cursor:pointer}
  .b-note .plus{width:13px;height:13px;color:var(--ink)}
  .b-note .plus::before{top:6px}
  .b-note .plus::after{left:6px}
  .b-note.open .plus::before{background:var(--accent)}
  .b-note.open .plus::after{transform:scaleY(0)}
  .b-note p{margin:0;font-size:19px;line-height:1.36;letter-spacing:-.01em;max-width:34em;text-wrap:pretty}
  .b-rest p{padding-top:12px;font-size:16px;line-height:1.5;letter-spacing:0;color:#b4b4b4}
  .b-rest{display:grid;grid-template-rows:1fr}
  .b-rest > div{min-height:0;overflow:hidden}
}
/* folded only where scripts run, so without them all the text shows */
@media (max-width:860px) and (scripting:enabled){
  .b-rest{grid-template-rows:0fr;transition:grid-template-rows .5s var(--ease)}
  .b-rest > div{visibility:hidden;opacity:0;transition:opacity .25s ease,visibility 0s .5s}
  .b-note.open .b-rest{grid-template-rows:1fr}
  .b-note.open .b-rest > div{visibility:visible;opacity:1;transition:opacity .45s ease .12s,visibility 0s}
}

/* ── one column: edge to edge, with a big name on top ────────────────────── */
@media (max-width:860px){
  /* clip: pictures come in from the sides, and must never make the page wider than the screen */
  .bp .project .work.stack{margin-inline:calc(-1*var(--gap));overflow-x:clip}
  .b-work{overflow-x:clip}
  .bp .project .crumbs{margin-bottom:44px}
  .bp .project .title{margin-bottom:28px}
  .bp .title h1{font-size:clamp(44px,13.4vw,84px);line-height:.95;letter-spacing:-.04em;overflow-wrap:anywhere}
  .bp .project .title h1{padding-bottom:.08em;animation:ph-name 1s var(--ease) both}
  .bp .project .tags{animation:ph-name .9s var(--ease) .12s both}
  @keyframes ph-name{from{opacity:0;translate:0 28px}}
  .bp .tags{margin-top:16px;gap:4px 16px}
  .bp .stack img{outline:0}

  /* a picture opens up as it comes on screen: the frame spreads out to the edges */
  .b-in .bp .stack > img,.b-in .bp .stack > .mt-b{opacity:0;translate:0 40px;clip-path:inset(0 7% 14% 7%);
    transition:opacity .7s ease,translate 1.1s var(--ease),clip-path 1.2s var(--ease)}
  .b-in .bp .stack > img.seen,.b-in .bp .stack > .mt-b.seen{opacity:1;translate:0 0;clip-path:inset(0)}
  /* these hold two or more pictures, and each picture opens by itself (b-phone.js) */
  .b-in .bp .stack > .pair,.b-in .bp .stack > .mt-duo,.b-in .bp .stack > .mt-print{opacity:1;translate:0 0;clip-path:none;transition:none}
  .ph-in .bp .pair > img,.ph-in .mt-duo > div,.ph-in .mt-print > div{opacity:0;translate:-36px 0;clip-path:inset(0 14% 0 0);
    transition:opacity .7s ease,translate 1.1s var(--ease),clip-path 1.2s var(--ease)}
  .ph-in .bp .pair > img:nth-child(2),.ph-in .mt-duo > div:nth-child(2),.ph-in .mt-print > div:nth-child(2){translate:36px 0;clip-path:inset(0 0 0 14%)}
  .ph-in .bp .pair > img.seen,.ph-in .mt-duo > div.seen,.ph-in .mt-print > div.seen{opacity:1;translate:0 0;clip-path:inset(0)}

  /* the notes: the line draws across, then the words rise */
  .ph-in .b-note::before{transform:scaleX(0);transition:transform 1.1s var(--ease)}
  .ph-in .b-note > h2,.ph-in .b-note > p{opacity:0;translate:0 22px}
  .ph-in .b-note.seen::before{transform:none}
  .ph-in .b-note.seen > h2,.ph-in .b-note.seen > p{opacity:1;translate:0 0;
    transition:opacity .8s ease .12s,translate .9s var(--ease) .12s}
  .ph-in .b-note.seen > p{transition-delay:.2s}

  /* the next project: one big picture, fading through three */
  .b-nextcard{padding:28px 0 0;margin-top:56px;grid-template-rows:auto auto;row-gap:24px}
  .n-text{padding:0 var(--gap)}
  .n-name{font-size:clamp(34px,10vw,60px);line-height:1;letter-spacing:-.035em;white-space:normal}
  .n-sub{margin-top:8px;line-height:1.3;white-space:normal}
  .n-foot{margin-top:22px;align-items:center}
  .n-arrow{width:24px;height:24px}
  .n-pics{position:relative;display:block;height:auto;aspect-ratio:16/10}
  .n-pics img{position:absolute;inset:0;width:100%;height:100%}
  .n-pics img:nth-child(2){animation:ph-two 10.5s ease-in-out infinite}
  .n-pics img:nth-child(3){animation:ph-three 10.5s ease-in-out infinite}
  @keyframes ph-two{0%,27%{opacity:0}33%,66%{opacity:1}72%,100%{opacity:0}}
  @keyframes ph-three{0%,60%{opacity:0}66%,94%{opacity:1}100%{opacity:0}}
}

/* ── the case studies on a phone held upright ────────────────────────────── */
@media (max-width:640px){
  /* framed pictures take their phone shape; the script makes them as wide as they really are,
     and pans them. Until then, and with less motion, they sit centred. */
  .stack > .mt-pic,.stack > .cs-drift{aspect-ratio:var(--ph,4/5)!important}
  .ph-pan .stack > [data-pan] img{position:absolute;inset:0 auto auto 0;width:auto;max-width:none;height:100%;will-change:translate}
  .ph-pan .cs-drift.go img{animation:none}
  .mt-film{aspect-ratio:1/1}

  /* pairs: one above the other, each as wide as the screen */
  .bp .pair,.mt-duo,.mt-print{grid-template-columns:minmax(0,1fr);gap:6px}
  .bp .pair img{aspect-ratio:4/5;object-fit:cover}
  .mt-mascot .mt-cap{display:block}

  /* the colours: rows instead of columns, so every name fits. They grow in from the left, and a
     tap opens one up. */
  .mt-colours{flex-direction:column;aspect-ratio:4/5}
  .mt-colours div{flex-direction:row;align-items:center;justify-content:space-between;gap:16px;padding:0 var(--gap);
    font-size:16px;min-height:0;transform-origin:0 50%}
  .mt-colours span{font-size:14px}
  .mt-colours div.big{flex-grow:2.6}
  .mt-colours.wait div{transform:scaleX(0)}

  /* the scene changer: tall, each picture drifting sideways while it shows, and one row of names
     you can swipe. Swipe the picture to move on. */
  .mt-scenes{aspect-ratio:4/5;touch-action:pan-y}
  .mt-scenes.cs-mj{aspect-ratio:1/1}
  .mt-scenes img{inset:0 auto auto 0;width:auto;max-width:none;height:100%;scale:1;
    translate:calc((100vw - 100%)*var(--a,.4)) 0;transition:opacity .9s ease,translate .1s linear 1s}
  .mt-scenes img.on{scale:1;translate:calc((100vw - 100%)*var(--b,.6)) 0;transition:opacity .9s ease,translate 5.6s cubic-bezier(.2,.5,.4,1)}
  .mt-chips{left:0;right:0;bottom:16px;max-width:none;flex-wrap:nowrap;gap:6px;padding:0 var(--gap);border-radius:0;
    overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:none;background:none;box-shadow:none;
    -webkit-backdrop-filter:none;backdrop-filter:none}
  .mt-chips::-webkit-scrollbar{display:none}
  .mt-chips button{flex:none;min-height:44px;padding:0 18px;font-size:15px;background:rgba(18,18,18,.82)}

  /* the website: three big screens down a tall frame */
  .mt-site{aspect-ratio:4/5}
  .mt-scr.s1{left:5%;top:5%;width:74%}
  .mt-scr.s2{right:-4%;top:35%;width:68%;z-index:3}
  .mt-scr.s3{left:-3%;bottom:5%;width:76%;z-index:4}

  /* Diary: big enough to read. Swipe it sideways to see the rest. */
  .mt-diary{padding:16px 0 20px var(--gap)}
  .mt-dctl{gap:8px;margin:0 var(--gap) 14px 0}
  .mt-tabs,.mt-theme{padding:4px}
  .mt-tabs{width:100%;justify-content:space-between}
  .mt-tabs button,.mt-theme button{min-height:40px;padding:0 13px;font-size:14px}
  .mt-dframe{border-radius:10px 0 0 10px}
  .mt-dview{aspect-ratio:4/5;overflow-x:auto;overflow-y:hidden;overscroll-behavior-x:contain;scrollbar-width:none}
  .mt-dview::-webkit-scrollbar{display:none}

  /* Hello: the phone up front, the desktop behind it */
  .mt-hello{aspect-ratio:4/5}
  .hl-desk{left:7%;top:8%;width:128%}
  .hl-phone{right:8%;bottom:7%;width:43%;border-radius:30px}
  .hl-phone .hl-screen{border-radius:24px}
  .mt-hello .mt-cap{max-width:38%;line-height:1.3}

  /* the LinkedIn posts and the badges: one line you swipe, each one nearly as wide as the screen */
  .mt-li,.cs-logos{display:flex;justify-content:flex-start;overflow-x:auto;overflow-y:hidden;overscroll-behavior-x:contain;
    scroll-snap-type:x mandatory;scroll-padding-inline:var(--gap);scrollbar-width:none}
  .mt-li::-webkit-scrollbar,.cs-logos::-webkit-scrollbar{display:none}
  .mt-li{gap:14px;padding:36px var(--gap) 44px}
  .mt-li .li-card,.mt-li .li-card:nth-child(n+2){display:block;flex:none;width:80vw;max-width:none;font-size:14px;scroll-snap-align:center}
  .cs-logos{gap:8px;padding:0 var(--gap)}
  .cs-logos > .cs-badge{flex:none;width:76vw;scroll-snap-align:center}
  /* the badge in the middle grows inside its frame, as it does under a mouse */
  .cs-badge.mid video{scale:1.12}
  .b-in .bp .cs-logos > .cs-badge{translate:80px 0;transition:opacity .8s ease calc(var(--i)*90ms),translate 1.1s var(--ease) calc(var(--i)*90ms)}
  .b-in .bp .cs-logos.seen > .cs-badge{translate:0 0}

  /* the stickers: the same sheet, nearly twice the size */
  .cs-stickers{aspect-ratio:4/5}
  .cs-stickers .sheet{inset:auto;left:50%;top:48%;height:78%;aspect-ratio:16/9;translate:-50% -50%}

  /* the cloud: the badge keeps pace with its rings, which grow with the taller frame */
  .cs-puff{aspect-ratio:4/5}
  .cs-puff img{width:calc(var(--w)*2.222)}
}

/* ── the home page ───────────────────────────────────────────────────────── */
/* the words you can tap light up in turn, a few times, until one is tapped */
.b-tap{display:none}
@media (hover:none){
  .ph-in .b-hero.hint .b-about .w{animation:ph-word 6.3s ease-in-out calc(var(--k,0)*.22s + 2.2s) 4}
  @keyframes ph-word{0%,14%,100%{color:var(--bright)}6%{color:var(--accent)}}
  .b-tap{display:block;position:absolute;left:0;right:0;top:calc(100% + 22px);margin:0;text-align:center;font-size:12px;
    letter-spacing:.06em;text-transform:uppercase;color:var(--mid);transition:opacity .4s ease}
  /* the picture comes in front of the text, with its name on it */
  .b-peek.touch{z-index:6}
  .b-peek.touch .b-peek-cap{left:10px;top:auto;bottom:10px;padding:7px 9px;background:var(--paper)}
  .b-hero:not(.hint) .b-tap,.b-hero.peeking .b-tap{opacity:0}
  .b-hero.peeking.hint .b-about .w{animation:none}
}

@media (max-width:860px){
  .b-hero{padding-bottom:140px}
  .b-about{font-size:clamp(38px,11.2vw,64px)}
  /* the four cards: the first and last fill the screen, the two between run off one side each */
  .b-hang{gap:88px}
  .b-hang li{--l:var(--gap);--r:var(--gap)}
  .b-hang .h1,.b-hang .h4{width:auto;justify-self:stretch;margin:0 calc(-1*var(--gap))}
  .b-hang .h2{width:auto;justify-self:stretch;margin:0 calc(-1*var(--gap)) 0 8px;--l:0px}
  .b-hang .h3{width:auto;justify-self:stretch;margin:0 8px 0 calc(-1*var(--gap));--r:0px}
  .c-top,.c-foot{margin-left:var(--l);margin-right:var(--r)}
  .c-title{font-size:clamp(30px,8.6vw,48px);letter-spacing:-.035em;line-height:1}
  .c-desc{font-size:13px;flex:0 1 15ch}
  .c-foot{margin-top:14px}
  .c-media{display:block;position:relative}
  /* the year stands in a notch cut out of the picture's corner */
  .c-year{position:absolute;right:0;top:0;z-index:4;padding:0 4px 10px 9px;background:var(--paper)}
  .soon .c-year{display:none}
  /* it bobs a little, but without the sway: turning a picture this wide would show its corners */
  .b-hang li > a,.b-hang li > .b-block{animation-name:ph-float}
  @keyframes ph-float{50%{transform:translate3d(0,-8px,0)}}
  .b-in .b-hang li .c-media{translate:0 60px;clip-path:inset(0 8% 18% 8%)}
  .b-in .b-hang li.seen .c-media{clip-path:inset(0);transition:opacity .8s ease .1s,translate 1.2s var(--ease) .1s,clip-path 1.2s var(--ease) .1s}
  /* the tools fit on one line */
  .b-logos{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:0}
  .b-logos li{justify-self:start}
}
@media (max-width:640px){
  .b-hang .b-pic{aspect-ratio:4/5}
  .b-hang .h2 .b-pic,.b-hang .h3 .b-pic{aspect-ratio:1/1}
  .ph-pan .b-hang .b-pic img{position:absolute;inset:0 auto auto 0;width:auto;max-width:none;height:100%;will-change:translate;transition:opacity .6s ease-in-out}
  .ph-pan .b-hang .b-pic img.snap{transition:none}
  .b-info{padding-top:72px}
  .t-name{font-size:21px}
  .b-foot{padding-top:160px}
}
/* in the middle of the screen: what a mouse would do */
@media (hover:none){
  .b-hang li.mid .c-title,.b-hang li.mid .c-view{color:var(--accent)}
  .b-hang li.mid .c-view .arr{translate:3px -3px}
  .b-hang li.mid .c-desc,.b-hang li.mid .c-kind{color:#d9d9d9}
  .b-things li.mid .t-name,.b-things li.mid .t-num,.index li.mid .name{color:var(--accent)}
  .b-things li.mid .t-name,.b-things li.mid .t-desc{translate:6px 0}
}

/* ── the archive ─────────────────────────────────────────────────────────── */
@media (max-width:860px){
  .bp .index{margin-inline:calc(-1*var(--gap));gap:44px}
  .bp .index .meta{margin-inline:var(--gap);font-size:14px}
  .ph-in .bp .index .frame{opacity:0;translate:0 40px;clip-path:inset(0 7% 14% 7%);
    transition:opacity .7s ease,translate 1.1s var(--ease),clip-path 1.2s var(--ease)}
  .ph-in .bp .index li.seen .frame{opacity:1;translate:0 0;clip-path:inset(0)}
}
@media (max-width:640px){
  .bp .index .frame{aspect-ratio:5/4}
}
@media (hover:none){
  .bp .index .note{font-size:19px;padding:0 32px}
  /* a plus in the corner says there's a line about it; it turns into a cross while it's open */
  .bp .index .frame::after{content:"";position:absolute;right:14px;bottom:14px;z-index:3;width:32px;height:32px;border-radius:50%;
    background:linear-gradient(#f4f4f4,#f4f4f4) 50%/13px 1px no-repeat,linear-gradient(#f4f4f4,#f4f4f4) 50%/1px 13px no-repeat,rgba(0,0,0,.55);
    transition:rotate .4s var(--ease),background-color .3s ease}
  .bp .index li.open .frame::after{rotate:45deg;background-color:var(--accent)}
}

@media (prefers-reduced-motion:reduce){
  .bp .project .title h1,.bp .project .tags,.n-pics img,.b-hero.hint .b-about .w{animation:none!important}
  .n-pics img:nth-child(n+2){opacity:0}
  .b-rest,.b-rest > div,.b-note.open .b-rest > div{transition:none}
  .mt-scenes img,.mt-scenes img.on{transition:none}
}
