/* gonfsilva.pt — built on the CV system.
   Familjen Grotesk, light grey on black, no rules, no blocks. Orange marks anything
   that responds: hovers, focus, selection and loading bars.
   A fixed left column like the CV's sidebar, the work on the right.
   Labels are small capitals, spaced a little apart, like the top bar of every page. */

@font-face{font-family:"Familjen Grotesk";font-style:normal;font-weight:400;font-display:swap;
  src:url("../fonts/FamiljenGrotesk-Regular.otf") format("opentype")}
@font-face{font-family:"Familjen Grotesk";font-style:italic;font-weight:400;font-display:swap;
  src:url("../fonts/FamiljenGrotesk-Italic.otf") format("opentype")}
@font-face{font-family:"Familjen Grotesk";font-style:normal;font-weight:700;font-display:swap;
  src:url("../fonts/FamiljenGrotesk-Bold.otf") format("opentype")}
@font-face{font-family:"Familjen Grotesk";font-style:italic;font-weight:700;font-display:swap;
  src:url("../fonts/FamiljenGrotesk-BoldItalic.otf") format("opentype")}

:root{
  --ease:cubic-bezier(.3,.7,.2,1);   /* starts at once, settles softly: every hover move uses it */
  --paper:#000000;
  --ink:#d4d4d4;          /* light grey, 14.0:1 on the background */
  --mid:#8c8c8c;          /* secondary text, 6.2:1 */
  --well:#161616;         /* behind an image while it loads, and the empty tiles */
  --accent:#ff6a2b;       /* orange: hover, focus, selection, loading */
  --radius:8px;
  --side:340px;
  --gap:20px;             /* one margin for everything: page edge, column gap, grid gap */
  color-scheme:dark;
}

*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
/* the page's own scrollbar: no grey track, just a thin, faint handle on the black */
html{scrollbar-width:thin;scrollbar-color:rgba(212,212,212,.28) transparent}
html::-webkit-scrollbar{width:8px;background:transparent}
html::-webkit-scrollbar-track{background:transparent}
html::-webkit-scrollbar-thumb{background:rgba(212,212,212,.28);border-radius:8px}
body{margin:0;background:var(--paper);color:var(--ink);
  font:400 16px/1.45 "Familjen Grotesk",ui-sans-serif,system-ui,sans-serif;
  -webkit-font-smoothing:antialiased;font-feature-settings:"kern" 1}
::selection{background:var(--accent);color:var(--paper)}
a{color:inherit}
:focus-visible{outline:2px solid var(--accent);outline-offset:3px;border-radius:2px}
img{max-width:100%}

/* ── the two columns ───────────────────────────────────────────────────── */
.page{display:grid;grid-template-columns:var(--side) minmax(0,1fr);column-gap:var(--gap);
  margin:0 auto;
  padding-block:var(--gap);
  padding-left:max(var(--gap),env(safe-area-inset-left,0px));
  padding-right:max(var(--gap),env(safe-area-inset-right,0px))}

/* the sidebar stays put while the work scrolls, as the CV's left column would */
.side{position:sticky;top:var(--gap);align-self:start;
  min-height:calc(100vh - var(--gap)*2);display:flex;flex-direction:column}

/* keyboard users can jump past the sidebar; invisible until focused */
.skip{position:absolute;left:-9999px;top:8px;z-index:10;padding:8px 12px;
  background:var(--accent);color:var(--paper);text-decoration:none;border-radius:var(--radius)}
.skip:focus{left:max(var(--gap),env(safe-area-inset-left,0px))}


/* labels: small capitals, spaced a little apart, the same as the top bar and the tags */
.label{font-size:12px;line-height:1.45;font-weight:400;letter-spacing:.06em;text-transform:uppercase;margin:0 0 8px}


/* ── the work ──────────────────────────────────────────────────────────── */
.work{min-width:0}
/* The home page's work fills exactly one screen: one viewport tall minus the page margins.
   Three columns show at once; the strip scrolls sideways to the fourth and the archive.
   Each image fills its cell (square artwork is cropped to fit). */
.fit{position:relative;display:flex;flex-direction:column;
  height:calc(100vh - var(--gap)*2);height:calc(100dvh - var(--gap)*2);min-height:520px}
/* The scroller reaches 20px past the column on every side, so a card that pops up on
   hover isn't clipped; the padding gives that room back, so nothing moves. */
.strip{flex:1;min-height:0;display:flex;
  margin:calc(-1*var(--gap)) calc(-1*var(--gap)) 0;padding:var(--gap) var(--gap) 0;
  overflow-x:auto;overflow-y:hidden;overscroll-behavior-x:contain;scrollbar-width:none}
.strip::-webkit-scrollbar{display:none}
/* but on the left the cards stop at the column's edge, so as they scroll past they never
   run up against the sidebar; the first card grows rightwards on hover, so it isn't cut */
.strip{clip-path:inset(0 0 0 var(--gap))}
.card:first-child{transform-origin:0 50%}
/* Five tall columns, image over caption, sized so that exactly three fit the view.
   Cards share the two rows through subgrid, so every image is the same height.
   The gap lives inside each card as padding, not between them, so the pointer never
   falls into a dead strip between two cards and the hover never flickers off and on. */
.grid{list-style:none;padding:0;display:grid;min-height:0;flex-shrink:0;
  margin:0 0 0 calc(var(--gap)/-2);
  width:calc((100% + var(--gap))/3*5);
  grid-template-columns:repeat(5,minmax(0,1fr));
  grid-template-rows:minmax(0,1fr) auto;gap:0;
  transition:grid-template-columns .7s var(--ease)}

/* hover: the column under the pointer widens to three shares, lifts towards you, and
   the rest narrow and fade back. The strip keeps its width, so the scroll doesn't jump.
   All of it moves slowly on purpose. */
.card{padding-inline:calc(var(--gap)/2);transition:opacity .5s var(--ease),transform .7s var(--ease)}
@media (hover:hover) and (min-width:861px){
  .grid:has(.card:nth-child(1):hover){grid-template-columns:3fr 1fr 1fr 1fr 1fr}
  .grid:has(.card:nth-child(2):hover){grid-template-columns:1fr 3fr 1fr 1fr 1fr}
  .grid:has(.card:nth-child(3):hover){grid-template-columns:1fr 1fr 3fr 1fr 1fr}
  .grid:has(.card:nth-child(4):hover){grid-template-columns:1fr 1fr 1fr 3fr 1fr}
  .grid:has(.card:nth-child(5):hover){grid-template-columns:1fr 1fr 1fr 1fr 3fr}
  .grid:has(.card:hover) .card:not(:hover){opacity:.3}
  .card:hover{transform:translateY(-8px) scale(1.02)}
}
@media (min-width:861px){
  .grid:has(.card:nth-child(1) :focus-visible){grid-template-columns:3fr 1fr 1fr 1fr 1fr}
  .grid:has(.card:nth-child(2) :focus-visible){grid-template-columns:1fr 3fr 1fr 1fr 1fr}
  .grid:has(.card:nth-child(5) :focus-visible){grid-template-columns:1fr 1fr 1fr 1fr 3fr}
  .grid:has(.card :focus-visible) .card:not(:has(:focus-visible)){opacity:.3}
  .card:has(:focus-visible){transform:translateY(-8px) scale(1.02)}
}

/* the dark fade and the arrows say there is more to the right (and, once you've moved,
   to the left); each fades away at its end of the strip */
.fade{position:absolute;top:calc(-1*var(--gap));bottom:0;right:calc(-1*var(--gap));width:clamp(80px,12vw,220px);pointer-events:none;
  background:linear-gradient(to right,rgba(0,0,0,0),var(--paper) 85%);transition:opacity .35s ease}
.more{position:absolute;top:calc(50% - 40px);right:0;z-index:2;
  width:48px;height:48px;display:grid;place-items:center;padding:0;cursor:pointer;
  color:var(--ink);background:rgba(0,0,0,.55);border:0;border-radius:50%;
  -webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);
  transition:opacity .35s ease,color .2s ease}
.more svg{width:20px;height:20px;animation:nudge 2.4s ease-in-out infinite}
.more:hover{color:var(--accent)}
/* the same fade on the left, once you've scrolled; it starts at the column's edge */
.fade.left{right:auto;left:0;background:linear-gradient(to left,rgba(0,0,0,0),var(--paper) 85%)}
.more.back{right:auto;left:0}
.more.back svg{animation-name:nudgeback}
@keyframes nudge{0%,60%,100%{translate:0 0}75%{translate:4px 0}}
@keyframes nudgeback{0%,60%,100%{translate:0 0}75%{translate:-4px 0}}
.fit.at-end .fade:not(.left),.fit.at-end .more:not(.back),.fit.at-start .fade.left,.fit.at-start .more.back{opacity:0;pointer-events:none}
.fit.no-scroll .fade,.fit.no-scroll .more{display:none}
html:not(.js) .more{display:none}

.card{min-width:0;min-height:0;grid-row:span 2;display:grid;grid-template-rows:subgrid}
.card a,.card .block{grid-row:1 / -1;display:grid;grid-template-rows:subgrid;min-height:0;text-decoration:none}
.card .pending{display:flex;align-items:center;justify-content:center;height:100%;
  font-size:12px;letter-spacing:.06em;text-transform:uppercase;color:var(--mid);text-align:center;padding:0 8px}
/* the archive tile cycles through the older covers in black and white, so it reads as
   a step back from the current projects */
.archive .thumb img{filter:saturate(0)}

/* on a placeholder photo the label sits on top, darkened behind so it always reads */
.thumb img + .pending{position:absolute;inset:0;color:var(--ink);
  background:linear-gradient(rgba(0,0,0,.25),rgba(0,0,0,.45))}
.card .thumb{display:block;position:relative;min-height:0;background:var(--well);
  overflow:hidden;border-radius:var(--radius)}
.card a:focus-visible{outline:none}
.card a:focus-visible .thumb{outline:2px solid var(--accent);outline-offset:-2px}
.card img{display:block;width:100%;height:100%;object-fit:cover}
/* the crossfade's top layer: it fades in over the frame below, then drops away unseen */
.layer{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;
  opacity:0;transition:opacity .6s ease-in-out}
.layer.on{opacity:1}
.layer.snap{transition:none}
.card a:hover .name,.card a:focus-visible .name{color:var(--accent)}
.card .name{transition:color .2s ease}
/* name over type, one line each: the caption never changes height as a column narrows,
   so the images don't jump. Whatever doesn't fit is trimmed with an ellipsis. */
.card .meta{display:grid;margin-top:8px;font-size:13px;line-height:1.35}
.card .name,.card .kind{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* loading bars: a thin orange line at the foot of a frame while its image comes in.
   On the home page it tracks the real download of each animation; on a case study it
   sweeps until the picture has arrived. */
.bar{position:absolute;left:0;right:0;bottom:0;height:2px;background:var(--accent);
  transform:scaleX(0);transform-origin:0 50%;transition:transform .2s linear,opacity .4s ease .2s}
.bar.busy{transform:scaleX(.3);animation:sweep 1.1s linear infinite}
.bar.done{transform:scaleX(1);opacity:0}
@keyframes sweep{from{translate:-100% 0}to{translate:340% 0}}
.js .stack img:not(.in){background:var(--well) linear-gradient(var(--accent),var(--accent)) no-repeat;
  background-size:30% 2px;background-position:-50% 100%;animation:sweepbg 1.1s linear infinite}
@keyframes sweepbg{to{background-position:150% 100%}}
.card .name{font-weight:700}
.card .kind{color:var(--mid)}
.card .year{font-variant-numeric:tabular-nums}

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

/* ── the colophon: running text, kept to a readable measure ───────────── */
.prose{max-width:62ch}
.prose p{margin:0 0 14px}
.prose .label{margin-top:34px}
.prose .label:first-child{margin-top:0}
.prose a{text-underline-offset:3px}

/* ── the archive: older projects, three to a row ───────────────────────── */
.index{list-style:none;margin:0;padding:0;display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));gap:36px var(--gap)}
.index .frame{display:block;position:relative;aspect-ratio:16/9;background:var(--well);
  border-radius:var(--radius);overflow:hidden}
.index .frame img{display:block;width:100%;height:100%;object-fit:cover}
.index .frame .layer{position:absolute;inset:0}
/* the line about each project: hidden until you hover (or tab to) it. Then the cover
   blurs and darkens behind it, and the line rises into the middle, big enough to read */
.index li{outline:none}
.index .frame img{transition:scale .8s var(--ease),filter .5s ease}
.index .note{position:absolute;inset:0;z-index:2;display:flex;align-items:center;justify-content:center;
  padding:0 clamp(20px,9%,64px);text-align:center;text-wrap:balance;
  font-size:clamp(17px,1.55vw,24px);line-height:1.3;letter-spacing:-.01em;color:#f4f4f4;
  background:rgba(0,0,0,.45);-webkit-backdrop-filter:blur(10px) saturate(.8);backdrop-filter:blur(10px) saturate(.8);
  text-shadow:0 1px 18px rgba(0,0,0,.45);
  opacity:0;transition:opacity .45s ease}
.index li:hover .note,.index li:focus-visible .note{opacity:1}
.index .note > span{translate:0 14px;transition:translate .7s var(--ease) .05s}
.index li:hover .note > span,.index li:focus-visible .note > span,.index li.open .note > span{translate:0 0}
.index li:hover .frame > img,.index li:focus-visible .frame > img{scale:1.05}
.index li:focus-visible .frame{outline:2px solid var(--accent);outline-offset:3px}
.index li:hover .name{color:var(--accent)}
.index .name{transition:color .2s ease}
/* no hover on a touch screen: a tap on a cover shows its line, another tap hides it (site.js) */
@media (hover:none){
  .index .note{padding:0 20px;font-size:15px;line-height:1.3}
  .index li.open .note{opacity:1}
}
.index .meta{display:grid;margin-top:8px;font-size:13px;line-height:1.35}
.index .name{font-weight:700}
.index .kind{color:var(--mid)}

/* ── case studies ──────────────────────────────────────────────────────────
   Left: where you are, the name, a few tags, and short chapters that open one at a time
   as their pictures pass. Right: pictures packed close, full width or in 4:5 pairs. */
.crumbs{display:flex;align-items:center;gap:14px;margin:0 0 56px;
  font-size:12px;letter-spacing:.06em;text-transform:uppercase}
.crumbs > *{color:var(--mid);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.crumbs > :first-child{color:var(--ink)}
.crumbs a{text-decoration:none;padding-block:4px}
.crumbs a:hover{color:var(--accent)}
.crumbs .back{margin-left:auto;display:grid;padding:2px;color:var(--ink);overflow:visible}
.crumbs .back svg{width:20px;height:20px}

.title h1{font-size:28px;line-height:1.1;font-weight:400;letter-spacing:-.01em;margin:0}
.tags{list-style:none;display:flex;flex-wrap:wrap;gap:4px 18px;margin:18px 0 0;padding:0;
  font-size:12px;letter-spacing:.06em;text-transform:uppercase;color:var(--mid)}

.chapters{margin-top:44px}
.lede + .chapters{margin-top:28px}
.list{list-style:none;margin:0;padding:4px 0 10px;font-size:14px;line-height:1.6}
/* a grey dash before each item; a long item wraps under its words, not under the dash */
.list li{position:relative;padding-left:18px}
.list li::before{content:"–";position:absolute;left:0;color:var(--mid)}
.chapter h2{margin:0;font-size:12px;font-weight:400}
.chapter button{display:flex;align-items:center;justify-content:space-between;width:100%;
  padding:5px 0;border:0;background:none;color:var(--mid);cursor:pointer;text-align:left;
  font-family:inherit;font-size:12px;line-height:1.45;font-weight:400;letter-spacing:.06em;text-transform:uppercase;
  transition:color .3s ease}
.chapter.open button{color:var(--ink)}
.chapter button:hover{color:var(--accent)}
/* a plus that turns into an orange minus when its chapter is open */
.plus{position:relative;width:9px;height:9px;flex:none}
.plus::before,.plus::after{content:"";position:absolute;background:currentColor;transition:transform .4s var(--ease),background-color .3s ease}
.plus::before{left:0;right:0;top:4px;height:1px}
.plus::after{top:0;bottom:0;left:4px;width:1px}
.chapter.open .plus::before{background:var(--accent)}
.chapter.open .plus::after{transform:scaleY(0)}
/* each chapter folds open by animating its row from nothing to its own height */
.chapter .body{display:grid;grid-template-rows:1fr}
/* no animation while the page sets the chapters up, only once someone scrolls or presses */
.chapters.ready .chapter .body{transition:grid-template-rows .55s var(--ease)}
.chapter .body > div{overflow:hidden;min-height:0;padding-bottom:6px}
/* the home page's about stays open; its text matches the chapters' */
.lede{margin-top:28px}   /* the same step as from the about text down to the chapters */
/* on the home page the role sits right under the name, as one block */
.title p.tags{margin-top:6px}
.lede p,.chapter .body p{margin:0;padding:6px 0 8px;font-size:14px;line-height:1.5;max-width:34ch}
.js .chapters.live .chapter:not(.open) .body{grid-template-rows:0fr}
.js .chapters.live .chapter:not(.open) .body > div{visibility:hidden}
.js .chapters.live.ready .chapter:not(.open) .body > div{transition:visibility 0s .55s}

.side-foot{margin-top:auto;padding-top:32px}
.with{margin:0;font-size:13px;color:var(--mid)}
.links{list-style:none;margin:0;padding:0}
/* inline-block with a little padding so every link is at least 24px tall (WCAG 2.5.8) */
.links a{display:inline-block;padding-block:2px;text-decoration:none;
  background:linear-gradient(var(--accent),var(--accent)) 0 100%/0 1px no-repeat;
  transition:background-size .2s ease,color .2s ease}
.links a:hover{background-size:100% 1px;color:var(--accent)}

.stack{display:grid;gap:8px;align-content:start}
.stack img{display:block;width:100%;height:auto;background:var(--well);border-radius:var(--radius)}
.pair{display:grid;grid-template-columns:1fr 1fr;gap:8px}

.next-project{padding:120px 0 calc(40vh - 120px);display:grid;justify-items:start}
.next-project .kicker,.next-project .all{font-size:12px;font-weight:400;letter-spacing:.06em;
  text-transform:uppercase;color:var(--mid);margin:0 0 14px}
.next-project .go{display:grid;text-decoration:none;font-size:clamp(28px,3.4vw,48px);line-height:1.08;letter-spacing:-.015em}
.next-project .go:hover .name{color:var(--accent)}
.next-project .name{transition:color .2s ease}
.next-project .all{margin:22px 0 0;text-decoration:none;padding-block:4px}
.next-project .all:hover{color:var(--accent)}

/* ── narrow screens: one column, sidebar on top ───────────────────────── */
@media (max-width:860px){
  .page{grid-template-columns:minmax(0,1fr)}
  /* the sidebar dissolves, so its parts can be reordered around the work */
  .side{display:contents}
  .work{order:2}
  /* on the home page the work comes straight after the name; on a case study the
     reader gets every chapter, open, before the pictures */
  .crumbs{order:0;margin-bottom:36px}
  .title{order:1}
  .chapters{order:3;margin:36px 0 28px}
  .project .chapters{order:2;margin-top:28px}
  .chapter .plus{display:none}
  .chapter button{color:var(--ink);cursor:default}
  .project .work{order:3}
  .side-foot{order:4;padding-top:0}
  .title h1{font-size:24px}
  .title{margin-bottom:24px}
  .project .title{margin-bottom:0}
  .next-project{padding:72px 0 56px}
  /* on a phone the four sit two by two as squares, still all inside the first screen */
  .fit{height:auto;min-height:0}
  .strip{display:block;margin:0;padding:0;overflow:visible;clip-path:none}
  .grid{width:auto;margin:0}
  .card{padding-inline:0}
  .fade,.more{display:none}
  .grid{grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:repeat(6,auto);column-gap:12px}
  .card:nth-child(-n+4) .meta{padding-bottom:16px}
  /* the archive sits under the four as one wide, shorter tile */
  .archive{grid-column:1 / -1}
  .card.archive .thumb{aspect-ratio:3/1}
  .card .thumb{aspect-ratio:1/1}
  .card .meta{font-size:12px;margin-top:6px}
  .card .name,.card .kind{white-space:normal}
  .chapter .body p,.lede p{max-width:none}
  .lede{order:3;margin-top:36px}
  .lede + .chapters{margin-top:20px}
  .stack,.pair{gap:6px}
  .index{grid-template-columns:minmax(0,1fr);gap:24px}
  .index .meta{font-size:12px;margin-top:6px}
}

@media (prefers-reduced-motion:reduce){
  .grid,.card,.links a{transition:none}
  .card:hover,.card:has(:focus-visible){transform:none}
  .more svg{animation:none}
  .bar.busy,.js .stack img:not(.in){animation:none}
  .chapter .body,.plus::before,.plus::after{transition:none}
}
