/* 03 Projects: the archive. A segmented filter with a plate that slides to the choice, a
   sort, and the tiles as hairline-ringed plates that lean toward the pointer. A tile opens
   its project in a sheet; its picture travels into the sheet (projects.js). */
.projects-screen{position:relative;min-height:100svh;padding:calc(var(--topbar) + 28px) var(--gutter) 48px;scroll-margin-top:0;overflow-x:clip}
.projects-intro{display:grid;justify-items:center;max-width:760px;margin:0 auto 40px;text-align:center}
.projects-intro h2{margin:0;font:520 clamp(2.6rem,5vw,4.6rem)/1 var(--sans);letter-spacing:-.04em;color:var(--ink)}

/* Categories and view controls share a compact bar. */
.projects-controls{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:0 14px;max-width:1240px;margin:0 auto 22px;padding:6px 14px;border:1px solid var(--line);border-radius:12px;background:color-mix(in srgb,var(--plate) 94%,transparent)}
.project-filters{position:relative;min-width:0;display:flex;flex-wrap:nowrap;overflow-x:auto;align-items:center;gap:2px;isolation:isolate;padding:3px 0;scrollbar-width:thin}
.project-filters button{position:relative;min-height:40px;padding:0 14px;border:0;border-radius:6px;background:none;color:var(--muted);font:500 13px/1 var(--sans);white-space:nowrap;cursor:pointer;transition:color .2s}
.project-filters button[aria-pressed=true]{color:var(--ink)}
@media(hover:hover){.project-filters button:hover{color:var(--ink)}}
.project-filters button:focus-visible{outline-offset:-2px}
.project-filters:not([data-hl]) button[aria-pressed=true]{background:var(--stone);box-shadow:inset 0 0 0 1px var(--line-2)}
.filter-hl{position:absolute;left:0;top:0;z-index:-1;width:var(--w,0);height:var(--h,0);translate:var(--x,0) var(--y,0);border-radius:6px;background:var(--stone);box-shadow:inset 0 0 0 1px var(--line-2);pointer-events:none}
.project-filters[data-ready] .filter-hl{transition:translate .45s var(--ease-drawer),width .45s var(--ease-drawer),height .45s var(--ease-drawer)}
.project-views{display:flex;align-items:center;gap:3px;padding-left:14px;border-left:1px solid var(--line)}
.project-views button{display:grid;place-items:center;width:38px;height:38px;padding:0;border:1px solid transparent;border-radius:6px;background:none;color:var(--muted);cursor:pointer;transition:color .2s,background-color .2s,border-color .2s}
.project-views button svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round}
.project-views button[aria-pressed=true]{background:var(--stone);color:var(--ink);border-color:var(--line-2)}
@media(hover:hover){.project-views button:hover{color:var(--ink)}}
.project-views button:focus-visible{outline-offset:2px}
/* Bring the archive controls closer to the folders without shifting the artwork. */
.projects-screen[data-view=archive] .projects-controls{position:relative;z-index:2;translate:0 clamp(18px,4vw,48px)}
.projects-screen[data-view=archive] .projects-grid{display:none}
.projects-screen:not([data-view=archive]) .archive{display:none}

/* The archive: the tray of folders, centred and large; each folder wears its project's picture,
   the one that is out plays its preview, and the caption names it (archive.js). */
.archive{display:grid;justify-items:center;max-width:1240px;margin:4px auto 0}
.archive-stage{position:relative;width:min(100%,1080px,calc(76svh * var(--archive-ratio,1.2)));aspect-ratio:var(--archive-ratio,1.2);cursor:pointer;touch-action:pan-y;-webkit-tap-highlight-color:transparent}
.archive-stage:focus-visible{outline:1.5px solid var(--ink);outline-offset:4px;border-radius:18px}
.archive-stage svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}
/* One tray per category stands in a row; the row slides to the chosen one, and the trays to
   either side wait dimmed until clicked or swiped to. */
.archive-track{position:absolute;inset:0;translate:calc(var(--at,0) * -106% + var(--drag,0px)) 0;transition:translate .8s cubic-bezier(.32,.72,0,1)}
.archive-track.is-dragging{transition:none}
.archive-tray{position:absolute;inset:0;translate:calc(var(--i) * 106%) 0;opacity:.34;transition:opacity .5s}
.archive-tray.is-front{opacity:1}
@media(hover:hover){.archive-tray:not(.is-front):hover{opacity:.6}}
.archive-stage :where(.label text){fill:var(--hl-edge);font:500 3.2px/1 var(--mono);letter-spacing:.05em}
.archive-stage :where(path,polygon,ellipse,line,circle){fill:var(--hl-plate);stroke:var(--hl-mid);stroke-width:var(--hl-w);vector-effect:non-scaling-stroke;stroke-linejoin:round;stroke-linecap:round;transition:stroke .26s cubic-bezier(.5,0,.1,1),fill .26s cubic-bezier(.5,0,.1,1)}
.archive-stage .speck{fill:var(--hl-plate);fill-opacity:.01;stroke:none}
.archive-stage :where(.nf){fill:none}
.archive-stage :where(.fo){stroke:none}
.archive-stage :where(.sil){stroke:var(--hl-edge)}
.archive-stage :where(.hi){stroke:var(--hl-hi)}
.archive-stage :where(.lo){stroke:var(--hl-lo)}
.archive-stage :where(.dot){stroke:none;fill:var(--hl-hi)}
.archive-stage :where(.dot.m){fill:var(--hl-edge)}
.archive-stage :where(.dot.off){fill:var(--hl-lo)}
.archive-preview{position:absolute;left:0;top:0;width:320px;height:180px;overflow:hidden;transform-origin:0 0;opacity:0;pointer-events:none;background:var(--stone)}
.archive-preview img,.archive-preview video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.archive-caption{display:grid;justify-items:center;gap:2px;max-width:640px;margin-top:4px;text-align:center}
.archive-title{margin:8px 0 0;font:560 clamp(1.45rem,1rem + 1.2vw,2.1rem)/1.15 var(--sans);letter-spacing:-.03em;color:var(--ink);text-wrap:balance}
.archive-sub{margin:0 0 16px;font-size:15px;line-height:1.5;color:var(--muted)}
.archive-open{display:inline-flex;align-items:center;gap:10px;height:40px;padding:0 14px 0 16px;border:0;border-radius:11px;background:var(--ink);color:var(--paper);font:500 14px/1 var(--sans);cursor:pointer;box-shadow:var(--lift);transition:background-color .2s,transform .16s var(--ease-out)}
.archive-open svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;transition:transform .3s var(--ease-out)}
@media(hover:hover){.archive-open:hover{background:color-mix(in srgb,var(--ink) 84%,var(--paper))}.archive-open:hover svg{transform:translateX(3px)}}
.archive-open:focus-visible{outline-offset:3px;border-radius:11px}

.projects-grid{display:flex;flex-wrap:wrap;justify-content:center;gap:16px;max-width:1240px;margin:0 auto}
.project-tile{position:relative;display:flex;flex-direction:column;flex:0 0 calc((100% - 32px) / 3);min-width:0;border-radius:16px;background:var(--plate);box-shadow:var(--card),var(--lift);transform:perspective(1100px) rotateX(var(--rx,0deg)) rotateY(var(--ry,0deg)) translateY(var(--lift-y,0px));transition:transform .6s var(--ease-out),box-shadow .4s var(--ease-out)}
.project-tile[hidden]{display:none}
.project-tile::before{content:'';position:absolute;inset:0;z-index:2;border-radius:inherit;background:radial-gradient(380px circle at var(--mx,50%) var(--my,50%),color-mix(in srgb,var(--ink) 6%,transparent),transparent 62%);opacity:0;transition:opacity .35s;pointer-events:none}
.project-image{position:relative;aspect-ratio:16/9;margin:6px 6px 0;overflow:hidden;border-radius:11px;background:var(--stone);isolation:isolate}
.project-image img,.project-image video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;transform:scale(1.002) translate(var(--px,0px),var(--py,0px));transition:transform .8s var(--ease-expo)}
.project-meta{flex:1;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:14px 14px 14px 16px}
.project-tile h3{margin:0 0 3px;font:560 16px/1.25 var(--sans);letter-spacing:-.015em;color:var(--ink)}
.project-meta p{margin:0;font-size:13px;line-height:1.45;color:var(--muted)}
.project-open{padding:0;border:0;background:none;color:inherit;font:inherit;letter-spacing:inherit;text-align:left;cursor:pointer}
.project-open::after{content:'';position:absolute;inset:0;z-index:3;border-radius:16px}
.project-open:focus-visible{outline:0}
.project-open:focus-visible::after{outline:1.5px solid var(--ink);outline-offset:2px}
.project-arrow{display:grid;place-items:center;flex-shrink:0;width:34px;height:34px;border-radius:50%;background:var(--stone);color:var(--ink);transition:background-color .25s,color .25s}
.project-arrow svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;transition:transform .35s var(--ease-out)}
.project-tile:focus-within .project-arrow{background:var(--ink);color:var(--paper)}
@media(hover:hover){
  .project-tile:hover{box-shadow:var(--card),var(--lift-lg);--lift-y:-3px}
  .project-tile:hover::before{opacity:1}
  .project-tile:hover .project-image img,.project-tile:hover .project-image video{transform:scale(1.05) translate(var(--px,0px),var(--py,0px))}
  .project-tile:hover .project-arrow{background:var(--ink);color:var(--paper)}
  .project-tile:hover .project-arrow svg{transform:rotate(-45deg)}
}
/* While the pointer drives the lean, it follows quickly. Tiles also carry the shared reveal, whose
   transition list would otherwise replace theirs, so both lists are written out here. */
.project-tile[data-tilt]{transition:transform .18s var(--ease-out),box-shadow .4s var(--ease-out)}
.motion-ready .project-tile.reveal{transition:opacity .8s var(--ease-expo) var(--reveal-delay,0ms),translate 1s var(--ease-expo) var(--reveal-delay,0ms),filter .8s var(--ease-expo) var(--reveal-delay,0ms),transform .6s var(--ease-out),box-shadow .4s var(--ease-out)}
.motion-ready .project-tile.reveal[data-tilt]{transition:opacity .8s var(--ease-expo) var(--reveal-delay,0ms),translate 1s var(--ease-expo) var(--reveal-delay,0ms),filter .8s var(--ease-expo) var(--reveal-delay,0ms),transform .18s var(--ease-out),box-shadow .4s var(--ease-out)}
@media(max-width:1000px){.project-tile{flex-basis:calc((100% - 16px) / 2)}}
@media(max-width:620px){.project-tile{flex-basis:100%}.project-meta p{font-size:14px}}
@media(max-width:700px){
  .projects-controls{padding:6px 10px;gap:0 8px}
  .project-filters{gap:2px;padding:3px 0}
  .project-filters button{padding:0 10px;min-height:40px}
  .project-views{padding-left:8px}
  .archive-stage{width:100%}
}

/* The project sheet. */
html{scrollbar-gutter:stable}
html.project-modal-open{overflow:hidden}
.project-modal{width:min(920px,calc(100vw - 32px));max-width:none;max-height:none;padding:0;border:0;background:none;color:var(--ink);overflow:visible}
.project-modal::backdrop{background:color-mix(in srgb,var(--paper) 52%,transparent);-webkit-backdrop-filter:blur(10px) saturate(1.1);backdrop-filter:blur(10px) saturate(1.1)}
.project-modal[open]{animation:sheet-in .5s var(--ease-drawer)}
.project-modal[open]::backdrop{animation:sheet-fade .35s ease-out}
.project-modal[data-vt][open],.project-modal[data-vt][open]::backdrop{animation:none}
.project-modal[data-closing]{animation:sheet-out .22s var(--ease-out) forwards}
.project-modal[data-closing]::backdrop{animation:sheet-fade .22s ease-in reverse forwards}
@keyframes sheet-in{from{opacity:0;transform:translateY(24px) scale(.97)}}
@keyframes sheet-out{to{opacity:0;transform:translateY(12px) scale(.985)}}
@keyframes sheet-fade{from{opacity:0}}
.project-modal-card{position:relative;display:flex;flex-direction:column;max-height:calc(100svh - 48px);overflow:auto;padding:8px;border-radius:20px;background:var(--plate);box-shadow:var(--card),var(--lift-lg);overscroll-behavior:contain}
.project-modal-media{position:relative;aspect-ratio:16/9;max-height:58svh;width:100%;overflow:hidden;border-radius:14px;background:var(--stone)}
.project-modal-media img,.project-modal-media video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.project-modal-body{padding:22px 22px 24px}
.project-modal h3{margin:0 0 8px;font:520 clamp(1.9rem,3.6vw,2.9rem)/1.05 var(--sans);letter-spacing:-.035em}
.project-modal-sub{margin:0 0 16px;font-size:15px;color:var(--ink-2)}
.project-modal-text{max-width:62ch;margin:0;font-size:16px;line-height:1.65;color:var(--muted);text-wrap:pretty}
/* First in the sheet and sticky, so the close button stays in reach however far the sheet scrolls. */
.project-modal-close{position:sticky;top:10px;z-index:2;align-self:flex-end;flex-shrink:0;margin:10px 10px -46px 0;display:grid;place-items:center;width:36px;height:36px;padding:0;border:0;border-radius:50%;background:color-mix(in srgb,var(--paper) 82%,transparent);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);color:var(--ink);box-shadow:var(--card);cursor:pointer;transition:background-color .2s,color .2s,transform .16s var(--ease-out)}
.project-modal-close svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round}
@media(hover:hover){.project-modal-close:hover{background:var(--ink);color:var(--paper)}}
.project-modal-close:active{transform:scale(.92)}
.project-modal-close:focus-visible{outline-offset:3px;border-radius:50%}
::view-transition-group(project-media){animation-duration:.55s;animation-timing-function:cubic-bezier(.32,.72,0,1)}
::view-transition-old(project-media),::view-transition-new(project-media){height:100%;object-fit:cover}
@media(max-width:700px){.project-modal-body{padding:18px 12px 16px}.project-modal-text{font-size:15.5px}}
@media(prefers-reduced-motion:reduce){
  .project-image img,.project-image video{display:block;transition:none}
  .project-image video{display:none}
  .project-tile{transition:box-shadow .2s}
  .archive-track,.archive-tray{transition:none}
  .project-modal[open],.project-modal[open]::backdrop,.project-modal[data-closing],.project-modal[data-closing]::backdrop{animation:none}
}
/* Project collections */
.project-modal-card{max-height:calc(100dvh - 32px)}
.project-modal-media img,.project-modal-media video{object-fit:contain}
.project-modal-media video{background:#111}
.project-modal-media .model-viewer{position:absolute;inset:0;display:grid;place-items:center;color:var(--muted);font-size:14px}
.model-viewer canvas{width:100%;height:100%;display:block;touch-action:none;cursor:grab}
.model-viewer canvas:active{cursor:grabbing}
.model-viewer canvas:focus-visible{outline:2px solid var(--ink);outline-offset:-4px}
.project-gallery{margin-top:28px}
.project-gallery h4{margin:0 0 12px;font:500 12px/1 var(--mono);letter-spacing:.04em;color:var(--muted)}
.gallery-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(118px,1fr));gap:10px}
.gallery-item{position:relative;display:flex;flex-direction:column;gap:7px;min-width:0;padding:4px;border:1px solid transparent;border-radius:9px;background:none;color:var(--ink);text-align:left;cursor:pointer}
.gallery-item[aria-pressed=true]{border-color:var(--ink);background:var(--stone)}
.gallery-item img{display:block;width:100%;aspect-ratio:4/3;object-fit:cover;border-radius:5px;background:var(--stone)}
.gallery-item span{padding:0 2px 3px;font:500 12px/1.3 var(--sans);overflow-wrap:anywhere}
.gallery-item b{position:absolute;z-index:1;top:10px;left:10px;padding:4px 6px;border-radius:4px;background:var(--plate);color:var(--ink);font:500 10px/1 var(--mono)}
.gallery-item:focus-visible{outline:2px solid var(--ink);outline-offset:2px}
@media(hover:hover){.gallery-item:hover{background:var(--stone)}}
@media(max-width:700px){.gallery-list{grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}.gallery-item span{font-size:11px}.project-modal-media{max-height:46dvh}}
.model-hint{position:absolute;left:16px;bottom:14px;padding:6px 9px;border-radius:5px;background:var(--plate);color:var(--ink);font:400 11px/1 var(--mono);pointer-events:none}
.project-modal-media iframe{position:absolute;inset:0;width:100%;height:100%;border:0;background:var(--stone)}
/* A single preview with a compact, scrollable collection across all project types. */
.project-gallery{margin-top:20px;min-width:0}
.gallery-list{display:flex;gap:8px;overflow-x:auto;overscroll-behavior-inline:contain;padding:3px 3px 10px;scrollbar-width:thin;scrollbar-color:var(--line-2) transparent}
.gallery-item{flex:0 0 106px}
.gallery-item img{aspect-ratio:4/3}
.gallery-item span{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;min-height:2.6em}
@media(max-width:700px){.gallery-list{display:flex;gap:6px}.gallery-item{flex-basis:90px}}
.gallery-item .gallery-placeholder{display:flex;align-items:end;justify-content:flex-start;width:100%;aspect-ratio:4/3;min-height:0;padding:8px;border-radius:5px;background:#172129;color:#e8edf0;font:500 12px/1.15 var(--sans);overflow-wrap:normal}

.project-image iframe,.archive-preview iframe{position:absolute;inset:0;width:100%;height:100%;border:0;pointer-events:none}
