/* Romesh Bothalage, portfolio */

/* Fonts are self-hosted. Satoshi: official Fontshare web files, unmodified (ITF Free Font License,
   see docs/licenses). tools/build_site.py keeps the ?v= versions in these URLs up to date. */
@font-face {
  font-family: "Satoshi";
  src: url("../fonts/Satoshi-Light.woff2?v=e8f33c22") format("woff2");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Satoshi";
  src: url("../fonts/Satoshi-Regular.woff2?v=e0350217") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Satoshi";
  src: url("../fonts/Satoshi-Medium.woff2?v=16317ba6") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Avenue X";
  src: url("../fonts/AvenueX-Regular.otf?v=7d958d49") format("opentype");
  font-weight: 400;
  font-display: swap;
}

:root {
  --ink: #111111;
  --wall: #EDEDEB;
  --ov: #F5F5F3;
  --white: #FFFFFF;
  --ph: #ECECEC;
  --mut: #8F8F8C;
  --acc: #C08A4E;

  --sans: "Satoshi", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --avenue: "Avenue X", "Satoshi", "Helvetica Neue", Arial, sans-serif;
  --display: clamp(22px, 2.7vw, 50px);
  --side: 20px;
  --pad: 56px 20px 64px;
  --ease-out: cubic-bezier(.2, .7, .2, 1);
}

@media (max-width: 759px) {
  :root { --side: 16px; --pad: 28px 16px 48px; }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
html.lock, html.lock body { overflow: hidden; }

body {
  min-height: 100vh;
  background: var(--wall);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 600ms ease;
}
body[data-page="works"] { background: var(--ov); }
body.intro { background: var(--wall); }

a { color: inherit; text-decoration: none; transition: opacity 450ms ease, color 450ms ease; }
button { all: unset; cursor: pointer; transition: opacity 450ms ease, color 450ms ease; }
h1, h2, h3, p, figure { margin: 0; }
picture { display: contents; }
picture > source { display: none; }
img { -webkit-user-drag: none; user-select: none; }
[hidden] { display: none !important; }
/* Visually hidden, still read by search engines and screen readers. */
.vh {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* Both languages are in the page; only the active one shows. */
html:not([lang="it"]) [data-l="it"], html[lang="it"] [data-l="en"] { display: none; }
/* Without JavaScript the site is shown straight away, with no loading overlay. */
.no-js .welcome, .no-js .stage, .no-js .loadnum, .no-js .cur { display: none; }

/* Every link and button turns to the accent on hover. */
@media (hover: hover) {
  a:hover, button:hover { color: var(--acc); opacity: 1; }
}

/* ---------- Custom cursor (desktop only) ---------- */
@media (hover: hover) and (pointer: fine) {
  html.has-cur, html.has-cur * { cursor: none !important; }
}
.cur {
  position: fixed; left: 0; top: 0; width: 0; height: 0;
  z-index: 2147483647; pointer-events: none;
  opacity: 0; transition: opacity 200ms ease;
}
.cur svg { position: absolute; left: -30px; top: -30px; overflow: visible; }
.cur g { transition: transform 320ms var(--ease-out); transform-box: fill-box; transform-origin: center; }
.cur.on g { transform: rotate(45deg); }

/* ---------- App shell ---------- */
.app { transition: opacity 900ms ease; }
.js .app { opacity: 0; }
.js body.intro .app { pointer-events: none; }

/* Header, desktop */
.hd {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  column-gap: 8px;
  align-items: baseline;
  padding: 16px 20px 0;
  height: 40px;
  position: relative;
  z-index: 3;
}
.hd > *, .hd-m > * { transition: opacity 250ms ease, color 450ms ease; }
.logo { font-size: 15px; font-weight: 500; letter-spacing: -0.01em; white-space: nowrap; }
.hd-nav {
  grid-column: 2 / 5;
  display: flex; justify-content: space-around; align-items: baseline; gap: 16px;
}
.nv, .lang, .menu-btn {
  font-size: 12px; font-weight: 400; letter-spacing: 0.02em; white-space: nowrap;
}
.nv { transition: opacity 400ms ease, color 400ms ease; }
.nv.is-on { color: var(--acc); }
.works { display: flex; gap: 14px; align-items: baseline; }
.sw { display: flex; gap: 6px; align-items: baseline; }
.sw .nv { opacity: 0.35; }
.sw .nv.is-on { opacity: 1; }
.lang { justify-self: end; display: flex; gap: 4px; }
.lang [data-lang], .menu-lang [data-lang] { transition: opacity 400ms ease, color 450ms ease; opacity: 0.35; }
.lang [data-lang].is-on, .menu-lang [data-lang].is-on { opacity: 1; }

/* Header, mobile */
.hd-m {
  display: none;
  justify-content: space-between; align-items: baseline;
  padding: 16px 16px 0; height: 40px;
  position: relative; z-index: 3;
}
.menu-btn { padding: 12px 0 12px 16px; margin: -12px 0; }

@media (max-width: 759px) {
  .hd { display: none; }
  .hd-m { display: flex; }
}

/* Logo hover dims everything else */
main { transition: opacity 250ms ease; }
body.logo-dim main,
body.logo-dim .hd > :not(.logo),
body.logo-dim .hd-m > :not(.logo) { opacity: 0.22; }

/* Mobile menu */
.menu {
  position: fixed; inset: 0; z-index: 9;
  background: var(--wall); color: var(--ink);
  display: flex; flex-direction: column;
  padding: 16px 16px 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
.menu-top { display: flex; justify-content: space-between; align-items: baseline; height: 24px; }
.menu-nav { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }
.menu-nav a {
  font-size: clamp(34px, 10vw, 56px); font-weight: 400; line-height: 1.04;
  letter-spacing: -0.02em; text-transform: uppercase;
}
.menu-nav .lbl { margin-right: 10px; }
.menu-lang { display: flex; gap: 6px; margin-top: 40px; font-size: 12px; font-weight: 400; letter-spacing: 0.02em; }
.menu-lang > * { padding: 10px 0; }

/* ---------- Type ---------- */
.d {
  margin: 0;
  font-size: var(--display);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  text-wrap: pretty;
}
.lbl {
  font-size: 12px; font-weight: 300; letter-spacing: 0.02em;
  text-transform: uppercase; white-space: nowrap;
  vertical-align: top; margin-right: 14px;
}
.small {
  font-size: 12px; font-weight: 300; letter-spacing: 0.02em;
  text-transform: uppercase; white-space: nowrap;
}
/* Superscript number: baseline + relative offset renders the same in Safari and Chrome. */
.n {
  font-size: 0.22em; font-weight: 300; letter-spacing: 0.02em;
  vertical-align: baseline; line-height: 0;
  position: relative; bottom: 2.55em; margin-left: 0.25em;
  color: var(--acc);
}
/* Thin slash between titles */
.sl {
  display: inline-block; width: 1px; height: 0.78em;
  background: currentColor; transform: rotate(18deg);
  margin: 0 0.32em 0 0.22em; vertical-align: -0.04em;
}

/* ---------- Pages ---------- */
.pg { padding: var(--pad); }

/* Double-page system */
.spread {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: calc(100vh - 160px);
}
.spread .pl, .spread .pr { display: flex; flex-direction: column; min-width: 0; }
.spread .pl { padding-right: clamp(12px, 2vw, 32px); }
.spread .pr { border-left: 1px solid var(--ink); padding-left: clamp(12px, 2vw, 32px); }
.rh { margin-bottom: 28px; }
.pr > .rh { align-self: flex-end; }
.foot { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 24px; }
.pr > .foot { align-self: flex-end; }
.foot svg { display: block; flex: 0 0 auto; }
.foot .small { font-variant-numeric: tabular-nums; }

@media (max-width: 759px) {
  .spread { grid-template-columns: minmax(0, 1fr); }
  .spread .pl { padding-right: 0; }
  .spread .pr { border-left: 0; padding-left: 0; margin-top: 40px; }
}

/* Index */
.proj { margin: 0 0 clamp(20px, 2.6vw, 44px); }
.idx .t { transition: opacity 250ms ease, color 250ms ease; }
.idx.has-hot .t:not(.is-hot) { opacity: 0.22; }
.idx .t.is-hot { color: var(--acc); }
.idx.locked .t { pointer-events: none; }
.idx .t.skip:hover { color: inherit; }

/* Phone only: the Index right page ends with "Overview", set like the work titles, instead of the work count. */
.ov-btn { display: none; }
@media (max-width: 759px) {
  .idx .foot-count { display: none; }
  .idx .ov-btn { display: flex; align-items: center; gap: 10px; align-self: flex-end; color: var(--acc); }
  .idx .ov-btn:hover, .idx .ov-btn:active { color: var(--acc); }
  /* After the welcome: grey everything but the logo and "Overview", then fade back. */
  .idx .rh, .idx .proj, .idx .foot-count, .idx .pl > .foot, .hd-m > .menu-btn {
    transition: opacity 700ms ease, color 450ms ease;
  }
  body.hint .idx .rh, body.hint .idx .proj, body.hint .idx .pl > .foot, body.hint .hd-m > .menu-btn { opacity: 0.22; }
}

/* Overview */
.ov-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  column-gap: 8px; row-gap: 28px;
  align-items: start;
}
.card { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.card-lbl { height: 17px; line-height: 17px; }
.card-img {
  position: relative; aspect-ratio: 4 / 5;
  background: var(--ph); overflow: hidden;
  transition: opacity 700ms ease;
}
.card-img img {
  position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover;
  transition: opacity 900ms ease;
}
.js .card-img img { opacity: 0; }
.js .card-img img.on { opacity: 1; }
.card-n { font-size: 9px; font-weight: 300; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
@media (hover: hover) {
  .card:hover .card-img { opacity: 0.55; }
}
@media (max-width: 759px) {
  .ov-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* About me */
.about { display: flex; flex-direction: column; gap: clamp(24px, 3.5vw, 56px); }
.about .stmt { line-height: 1.14; }
.muted { color: var(--mut); }
.cv-gap { height: clamp(40px, 6vw, 120px); }
/* CV opener: a full-width rule, then "(3) CV" + title, like Bio and Statement. */
.cv-head { border-top: 1px solid var(--ink); padding-top: 10px; }
.cv-head .lbl { margin-right: 14px; }
.cv {
  display: grid;
  grid-template-columns: clamp(140px, 13vw, 240px) minmax(0, 1fr);
  column-gap: 14px; row-gap: 8px;
}
.cv-lbl { padding-top: 0.3em; }
.cv.muted .n { color: inherit; }
.cv-rows { display: flex; flex-direction: column; }
.cv-row { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: start; }
.cv-year { font-size: 12px; font-weight: 300; letter-spacing: 0.02em; padding-top: 0.3em; font-variant-numeric: tabular-nums; }
@media (max-width: 759px) {
  .cv { grid-template-columns: minmax(0, 1fr); }
}

/* Exhibitions, "Provini" */
.exh-group { margin: 0 0 clamp(20px, 2.6vw, 44px); }
.exh-group .small { display: block; margin-bottom: 10px; }
.exh-group .line { display: block; }
.exh .x { transition: opacity 250ms ease, color 250ms ease; }
.exh.has-hot .x:not(.is-hot) { opacity: 0.22; }
.exh .x.is-hot { color: var(--acc); }
.sheet {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(56px, 5.2vw, 100px), 1fr));
  gap: 6px; align-content: start;
}
.sheet img {
  display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: cover;
  background: var(--ph);
  filter: grayscale(1);
  transition: filter 600ms ease, opacity 400ms ease;
}
.sheet img.is-hot { filter: grayscale(0); }
.exh.has-hot .sheet img:not(.is-hot) { opacity: 0.3; }
.sheet-cap { margin-top: 14px; align-self: flex-end; min-height: 17px; }

/* Contact, "Colophon" */
.contact {
  height: calc(100vh - 40px);
  height: calc(100dvh - 40px);
  padding: 56px 20px 18px;
  display: flex; flex-direction: column; overflow: hidden;
}
.c-row {
  display: flex; flex-direction: row; justify-content: space-between;
  column-gap: 32px; row-gap: 16px;
  font-size: var(--display);
  border-top: 1px solid var(--ink); padding-top: 10px;
}
.c-item { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.c-val {
  font-size: 1em; font-weight: 400; line-height: 1.04; letter-spacing: -0.02em;
  text-transform: uppercase; white-space: nowrap;
}
.c-foot { margin-top: auto; padding-top: 24px; }
.c-index {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  row-gap: 20px; border-top: 1px solid var(--ink); padding-top: 10px;
}
.c-index .pl, .c-index .pr {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 8px; row-gap: 20px; min-width: 0;
}
.c-index .pl { padding-right: clamp(12px, 2vw, 32px); }
.c-index .pr { border-left: 1px solid var(--ink); padding-left: clamp(12px, 2vw, 32px); }
.c-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.c-links { display: flex; flex-direction: column; }
.c-links > * {
  font-size: 12px; font-weight: 400; letter-spacing: 0.02em; text-transform: uppercase;
  line-height: 1.7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 759px) {
  .contact { padding: 28px 16px 16px; }
  .c-row { flex-direction: column; }
  .c-index { grid-template-columns: minmax(0, 1fr); }
  .c-index .pl { padding-right: 0; }
  .c-index .pr { border-left: 0; padding-left: 0; }
}

/* ---------- Welcome ---------- */
.welcome {
  position: fixed; inset: 0; z-index: 3;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transform: translateY(8px);
  transition: opacity 900ms ease 200ms, transform 900ms ease 200ms;
}
.welcome.on { opacity: 1; transform: none; }
.welcome-t {
  margin: 0; padding: 0 16px;
  font-family: var(--avenue); font-weight: 400;
  font-size: clamp(48px, 7vw, 140px); line-height: 1.05; letter-spacing: -0.01em;
  color: var(--ink);
}
.welcome .acc { color: var(--acc); }

/* ---------- Loading ---------- */
.stage {
  position: fixed; inset: 0; z-index: 4;
  background: var(--white); overflow: hidden;
  transition: opacity 700ms ease;
}
.stage img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: 0; will-change: opacity;
}
.stage.out { opacity: 0; pointer-events: none; }
.loadnum {
  position: fixed; left: 20px; bottom: 16px; z-index: 5;
  font-size: clamp(20px, 2.4vw, 42px); font-weight: 400; line-height: 1; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: #fff; mix-blend-mode: difference;
  pointer-events: none;
  transition: opacity 500ms ease;
}
.loadnum.out { opacity: 0; }

/* ---------- Viewer ---------- */
.vw {
  position: fixed; inset: 0; z-index: 10;
  background: var(--white); color: var(--ink);
  opacity: 0; transition: opacity 600ms ease;
  overflow: hidden;
  touch-action: manipulation;
}
.vw.on { opacity: 1; }
.vw-stage { position: absolute; inset: 56px 20px; }
.vw-layer { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.vw-layer img {
  display: block; max-width: 100%; max-height: 100%; object-fit: contain;
  opacity: 0;
}
.vw-flash {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; color: #fff; mix-blend-mode: difference;
  opacity: 0;
}
.vw-flash span {
  font-size: clamp(36px, 13vw, 260px); font-weight: 400; letter-spacing: -0.03em; line-height: 0.9;
  text-transform: uppercase; text-align: center; text-wrap: balance; padding: 0 16px;
}
.vw-top {
  position: absolute; left: 20px; right: 20px; top: 16px;
  display: flex; justify-content: flex-end;
  font-size: 12px; font-weight: 300; letter-spacing: 0.02em;
  color: #fff; mix-blend-mode: difference;
}
.vw-close { color: #fff; white-space: nowrap; }
.vw-cap {
  position: absolute; left: 20px; right: 20px; bottom: 18px;
  display: flex; justify-content: space-between; align-items: baseline;
  flex-wrap: wrap; column-gap: 24px; row-gap: 2px;
  font-size: 12px; font-weight: 300; letter-spacing: 0.02em; text-transform: uppercase;
  color: var(--ink); pointer-events: none;
}
.vw-cap .nw { white-space: nowrap; }
.vw-cap .ttl { white-space: nowrap; font-weight: 400; }
.vw-cap .med { text-align: center; }
.vw-label {
  position: fixed; left: 0; top: 0; pointer-events: none;
  font-size: 12px; font-weight: 300; letter-spacing: 0.02em;
  color: #fff; mix-blend-mode: difference; white-space: nowrap;
  font-variant-numeric: tabular-nums;
  opacity: 0; transition: opacity 200ms ease;
}
@media (max-width: 759px) {
  .vw-stage { inset: 48px 0 96px; }
  /* Phone caption: the medium starts on its own line, aligned left with the title. */
  .vw-cap { left: 16px; right: 16px; }
  .vw-cap .med { order: 3; flex: 0 0 100%; text-align: left; }
  .vw-cap > :last-child { order: 4; }
}
/* Horizontal swipes are handled by the viewer; vertical panning and pinch-zoom stay with the browser. */
.vw { touch-action: pan-y pinch-zoom; }
