/* ============================================================
   sections — hero (phase 2). Other sections arrive in 3 and 4.
   ============================================================ */

/* ---------- hero ---------- */
.hero {
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 560px;
  overflow: hidden;
  isolation: isolate;
  background: var(--fog);
}

.hero__name { font-size: inherit; font-weight: inherit; }

/* The two halves of the name sit on separate layers:
   "Davide" behind the portrait, "Sega" in front of it. */
.hero__line {
  --wdth: 125;
  --wght: 820;
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  z-index: 1;
  margin: 0;
  /* JS fits "Davide" to the exact width; this is the no-JS estimate */
  font-size: var(--name-size, calc((100vw - 2 * var(--gutter)) * 0.205));
  line-height: 0.8;
  font-weight: 800;
  font-variation-settings: "wdth" var(--wdth), "wght" var(--wght);
  letter-spacing: -0.012em;
  text-transform: uppercase;
  white-space: nowrap;
  will-change: transform;
}
.hero__line--back {
  top: calc(var(--header-h) + 4.5svh);
  color: var(--ink);
}
.hero__line--front {
  top: 52svh;
  z-index: 3;
  text-align: right;
  color: var(--ink);
}

/* "Sega" in layers (built by hero.js): solid ink underneath, fog
   copies on top, masked by the portrait's silhouette. The fog boxes
   are padded so the mask never clips the glyphs at the line box. */
.hero__layer--fog {
  position: absolute;
  left: 0; right: 0;
  top: -0.25em; bottom: -0.25em;
  padding-top: 0.25em;
  color: var(--fog);
  visibility: hidden;
  pointer-events: none;
}
/* With JS the fog copies are painted from the first frame, under an
   empty mask: when the real mask arrives only the mask changes, so the
   name never counts as a late "largest paint". */
.has-halftone .hero__layer--fog {
  visibility: visible;
  -webkit-mask-image: linear-gradient(transparent, transparent);
  mask-image: linear-gradient(transparent, transparent);
}

/* no halftone (no JS, or the portrait failed): the plain photo is
   shown, and a difference blend keeps "Sega" readable on it */
.hero:not(.has-halftone) .hero__line--front {
  color: var(--fog);
  mix-blend-mode: difference;
}
.hero:not(.has-halftone) .hero__layer--fog { display: none; }

/* letters rise from a mask: the clip only cuts the bottom edge */
.hero__mask {
  display: inline-block;
  clip-path: inset(-40% -4% -0.02em -4%);
}
.hero__char { display: inline-block; will-change: transform; }

.hero__portrait {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  will-change: transform;
}
.hero__img {
  position: absolute;
  bottom: 0;
  left: 50%;
  height: min(94svh, 150vw);
  width: auto;
  aspect-ratio: 3 / 4;
  /* base.css caps images at 100% width; this one is meant to be
     wider than a phone screen, so the cap would squash it */
  max-width: none;
  transform: translateX(-47%);
  filter: grayscale(1);
  user-select: none;
}
.hero__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.has-halftone .hero__img { visibility: hidden; }


.hero__corner {
  position: absolute;
  bottom: var(--gutter);
  z-index: 3;
  color: var(--ink);
  font-size: var(--fs-l);
  line-height: 1.15;
  font-weight: 500;
  font-variation-settings: "wdth" 100;
}
.hero__corner--bl { left: var(--gutter); }
.hero__corner--br {
  right: var(--gutter);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.hero__corner p { margin: 0; }
html:not(.js) .hero__time { display: none; }

/* phones: taller frame, the portrait owns the middle */
@media (max-width: 720px) {
  .hero { min-height: 600px; }
  .hero__line--back { top: calc(var(--header-h) + 2.5svh); }
  /* sits on the dense part of the shoulders, above the fade */
  .hero__line--front { top: auto; bottom: calc(var(--gutter) + 9rem); }
  /* bigger than the screen on purpose: the shoulders bleed off
     both edges and the head reaches up behind "Davide". The bottom
     stops above the corner texts, so they sit on clean fog. */
  .hero__img {
    bottom: 4rem;
    height: min(88svh, 210vw);
    transform: translateX(-50%);
  }
  .hero__corner { font-size: var(--fs-m); }
}

@media (max-width: 720px) and (max-height: 640px) {
  .hero__line--front { bottom: calc(var(--gutter) + 7.6rem); }
}

/* ============================================================
   manifesto — the hands (phase 3)
   ============================================================ */
.manifesto {
  position: relative;
  background: var(--ink);
  color: var(--white);
}
.manifesto__stage {
  --hw: 80vw;
  --cy: 42%;
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 520px;
  overflow: hidden;
}
.manifesto__canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* no JS / reduced motion: the final composition, as plain images */
.manifesto__hand {
  position: absolute;
  width: calc(var(--hw) * var(--s, 1));
  max-width: none;
  height: auto;
  top: calc(var(--cy) - var(--hw) * var(--s, 1) * 0.5625 * var(--ty));
  user-select: none;
  pointer-events: none;
}
.manifesto__hand--l { left: calc(50% - 3px - var(--hw) * var(--s, 1) * var(--tx)); }
.manifesto__hand--r { left: calc(50% + 3px - var(--hw) * var(--s, 1) * var(--tx)); }
.manifesto.has-halftone .manifesto__hand { visibility: hidden; }

.manifesto__text {
  position: absolute;
  left: var(--gutter); right: var(--gutter);
  top: 64%;
  text-align: center;
}
.manifesto__title {
  font-size: clamp(2.25rem, 1rem + 5.2vw, 6.5rem);
  line-height: 0.95;
  font-weight: 760;
  font-variation-settings: "wdth" 88;
  letter-spacing: -0.02em;
}
.manifesto__mask { display: block; overflow: hidden; padding-bottom: 0.08em; }
.manifesto__line { display: block; }
.manifesto__sub {
  margin-top: 18px;
  font-size: var(--fs-l);
  color: rgba(255, 255, 255, 0.72);
}

@media (max-width: 720px) {
  .manifesto__stage { --hw: 175vw; --cy: 46%; }
  .manifesto__text { top: 60%; }
}

/* ============================================================
   work — "Lavori (3)" and the project panels
   ============================================================ */
.work {
  padding: calc(var(--header-h) + clamp(48px, 7vw, 96px)) var(--gutter) clamp(96px, 12vw, 180px);
}
.work__title {
  display: flex;
  align-items: flex-start;
  gap: 0.12em;
  font-size: var(--fs-display);
  line-height: 0.82;
  font-weight: 800;
  font-variation-settings: "wdth" 100;
  letter-spacing: -0.03em;
  margin-bottom: clamp(56px, 9vw, 140px);
}
.work__count {
  font-size: 0.3em;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1;
  margin-top: 0.12em;
}

.panels { display: block; }

/* chips (case study roles; Info extends them in contact.css) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.chip {
  padding: 5px 11px 6px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
}

/* ---------- one project: the same layout for every one ---------- */
.proj + .proj { margin-top: clamp(120px, 16vh, 200px); }

.proj__meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--ink);
  font-size: var(--fs-s);
  font-weight: 500;
}
.proj__meta span:last-child { color: var(--graphite); text-align: right; }

.proj__grid {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 6fr);
  column-gap: clamp(24px, 4vw, 72px);
  margin-top: clamp(28px, 3.4vw, 48px);
  align-items: start;
}

/* info column (sticky while the images go by) */
.proj__info {
  position: sticky;
  top: calc(var(--header-h) + 24px);
}
.proj__title {
  font-size: clamp(2.75rem, 1.2rem + 4.4vw, 6.25rem);
  line-height: 0.9;
  font-weight: 800;
  font-variation-settings: "wdth" 82;
  letter-spacing: -0.025em;
}
.proj__client { margin-top: 14px; font-size: var(--fs-l); font-weight: 500; }
.proj__summary { margin-top: 14px; max-width: 42ch; line-height: 1.5; color: #2b2b29; }
.proj__did { margin-top: 28px; }
.proj__did-title { font-size: var(--fs-s); font-weight: 600; }
.proj__did-list { margin-top: 8px; border-top: 1px solid rgba(0, 0, 0, 0.18); }
.proj__did-list li {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.18);
}
.proj__did-list li::before { content: "—"; color: var(--graphite); }
.proj__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 24px;
  margin-top: 28px;
}

/* the main button: solid black, always visible */
.btn-solid {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 26px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--white);
  font-weight: 600;
  transition: background-color 0.2s, transform 0.2s;
}
.btn-solid:hover { background: #2a2a2a; }
.btn-solid:active { transform: scale(0.98); }
.proj__visit { font-weight: 600; }
.proj__visit::after { transform: scaleX(1); opacity: 0.35; }
.proj__visit:hover::after { opacity: 1; }

/* window around the main image: title | domain | Apri progetto */
.proj__window {
  border: 1px solid var(--frame);
  background: var(--paper);
  cursor: pointer;
  transition: transform 0.35s var(--ease-out), border-color 0.25s, box-shadow 0.35s var(--ease-out);
}
.proj__bar {
  display: flex;
  align-items: center;
  height: 40px;
  padding-right: 6px;
  background: var(--fog);
  border-bottom: 1px solid rgba(0, 0, 0, 0.32);
  font-size: var(--fs-xs);
  transition: border-color 0.25s;
}
.proj__tab {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: stretch;
  padding: 0 14px;
  background: var(--paper);
  border-right: 1px solid rgba(0, 0, 0, 0.32);
  font-weight: 600;
  white-space: nowrap;
}
.proj__tab::before {
  content: "";
  width: 11px; height: 9px;
  border: 1px solid var(--ink);
  border-radius: 1px 2px 1px 1px;
  background: var(--finder);
}
.proj__path {
  flex: 1;
  min-width: 0;
  padding: 0 14px;
  color: var(--graphite);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.proj__open {
  flex: none;
  height: 28px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.2s, color 0.2s;
}
.proj__screen { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: #d4d4d1; }
.proj__screen picture { position: absolute; inset: 0; display: block; }
.proj__screen img {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: 50% 0;
}
.proj__window:hover, .proj__window:focus-within {
  border-color: var(--ink);
  transform: translateY(-4px);
  box-shadow: 0 4px 0 0 var(--ink);
}
.proj__window:hover .proj__bar, .proj__window:hover .proj__tab { border-color: var(--ink); }
.proj__window:hover .proj__open,
.proj__open:focus-visible { background: var(--ink); color: var(--white); }

/* three thumbnails: one regular row, same height, flush with the window */
.proj__thumbs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--g);
  margin-top: var(--g);
}
.proj__thumb {
  display: block;
  width: 100%;
  transition: transform 0.3s var(--ease-out);
}
.proj__thumb .gcell { aspect-ratio: 4 / 3; }
.proj__thumb:hover { transform: translateY(-3px); }
.proj__thumb:hover .gcell { border-color: var(--ink); }
.proj__thumb:focus-visible { outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  .proj__window, .proj__thumb { transition: border-color 0.2s; }
  .proj__window:hover, .proj__window:focus-within, .proj__thumb:hover { transform: none; }
}

/* phones: meta → title → text → what I did → window → thumbnails
   (sideways scroll) → full-width button → visit link */
@media (max-width: 900px) {
  .proj__grid { display: flex; flex-direction: column; align-items: stretch; }
  .proj__info { display: contents; }
  .proj__title { order: 1; }
  .proj__client { order: 2; }
  .proj__summary { order: 3; }
  .proj__did { order: 4; margin-bottom: 24px; }
  .proj__media { order: 5; }
  .proj__actions { order: 6; flex-direction: column; align-items: stretch; text-align: center; }
  .proj__actions .btn-solid { width: 100%; height: 52px; }
  .proj__visit { align-self: center; }
  .proj__thumbs {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin-right: calc(var(--gutter) * -1);
    padding-right: var(--gutter);
    scrollbar-width: none;
  }
  .proj__thumbs::-webkit-scrollbar { display: none; }
  .proj__thumbs li { flex: 0 0 62%; scroll-snap-align: start; }
  .proj__thumbs { gap: var(--g); }
}
@media (max-width: 480px) {
  .proj__path { display: none; }
  .proj__tab { flex: 1; }
}

/* video media */
.vid video { display: block; width: 100%; height: 100%; object-fit: cover; }
.vid__sound {
  position: absolute;
  right: 12px; bottom: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: var(--white);
  font-size: var(--fs-xs);
}
.vid__sound[aria-pressed="true"] { background: var(--finder); }

/* no JS: a plain list of the work */
.work__fallback { display: grid; gap: 28px; }
.work__fallback h3 { font-size: var(--fs-xl); line-height: 1; }
.work__fallback p { margin-top: 8px; max-width: 60ch; }
.has-panels .work__fallback { display: none; }

/* ============================================================
   case-study window
   ============================================================ */
.cw {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vh, 32px) var(--gutter);
}
.cw[hidden] { display: none; }
.cw__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
}
.cw__win {
  position: relative;
  width: min(1180px, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--ink);
  overflow: hidden;
}
.cw__bar {
  flex: none;
  display: flex;
  align-items: stretch;
  height: 52px;
  background: var(--fog);
  border-bottom: 1px solid var(--ink);
  font-size: var(--fs-s);
}
.cw__tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: var(--paper);
  border-right: 1px solid var(--ink);
  font-weight: 600;
}
.cw__tab::before {
  content: "";
  width: 14px; height: 11px;
  border: 1px solid var(--ink);
  border-radius: 1px 3px 1px 1px;
  background: var(--finder);
}
.cw__path {
  display: flex;
  align-items: center;
  padding: 0 16px;
  color: var(--graphite);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.cw__close {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-left: 1px solid var(--ink);
  font-size: var(--fs-m);
  font-weight: 600;
  transition: background-color 0.15s, color 0.15s;
}
.cw__close svg { width: 16px; height: 16px; }
.cw__close:hover { background: var(--ink); color: var(--white); }
.cw__close:active { background: var(--finder); }
.cw__close:focus-visible { outline-offset: -4px; }

.cw__body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(20px, 3vw, 40px);
}
.cw__head {
  display: grid;
  grid-template-columns: 1fr minmax(0, 360px);
  gap: 24px;
  align-items: end;
  margin-bottom: clamp(24px, 3vw, 40px);
}
.cw__title {
  font-size: clamp(2.5rem, 1rem + 5vw, 5.5rem);
  line-height: 0.88;
  font-weight: 800;
  font-variation-settings: "wdth" 80;
  letter-spacing: -0.025em;
}
.cw__meta { color: var(--graphite); }
.cw__info .chips { margin-top: 12px; }

.cw__text {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(24px, 4vw, 64px);
  margin-top: clamp(32px, 4vw, 56px);
  padding-top: 24px;
  border-top: 1px solid var(--ink);
}
.cw__summary { font-size: var(--fs-l); line-height: 1.35; max-width: 34ch; }
.cw__visit { margin-top: 24px; height: 44px; }
.cw__specs-title { font-size: var(--fs-s); font-weight: 600; margin-bottom: 12px; }
.cw__specs dl { margin: 0; }
.cw__specs dl > div {
  display: grid;
  grid-template-columns: 9.5em 1fr;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid rgba(0, 0, 0, 0.14);
}
.cw__specs dt { color: var(--graphite); }
.cw__specs dd { margin: 0; }

.cw-open, .cw-open body { overflow: hidden; }

@media (max-width: 720px) {
  .cw { padding: 0; }
  .cw__win { border: 0; }
  .cw__head { grid-template-columns: 1fr; gap: 12px; }
  .cw__text { grid-template-columns: 1fr; }
  .cw__specs dl > div { grid-template-columns: 1fr; gap: 2px; }
}

/* ============================================================
   browser window around a desktop screenshot (panels + case study)
   ============================================================ */
.frame--browser { background: none; }
.browser {
  border: 1px solid var(--ink);
  background: var(--paper);
}
.browser__bar {
  display: flex;
  align-items: stretch;
  height: 30px;
  background: var(--fog);
  border-bottom: 1px solid var(--ink);
  font-size: var(--fs-xs);
  line-height: 1;
}
.browser__tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--paper);
  border-right: 1px solid var(--ink);
  font-weight: 600;
  white-space: nowrap;
}
.browser__tab::before {
  content: "";
  width: 11px; height: 9px;
  border: 1px solid var(--ink);
  border-radius: 1px 2px 1px 1px;
  background: var(--finder);
}
.browser__path {
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: var(--graphite);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.browser__screen { position: relative; overflow: hidden; }
.browser__screen picture { position: absolute; inset: 0; display: block; }
.browser__screen img {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: 50% 0;
}
.cw__path[hidden] { display: none; }


/* case study: next project */
.cw__next {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: clamp(40px, 5vw, 72px);
  padding: 28px 0 8px;
  border-top: 1px solid var(--ink);
}
.cw__next-label { font-size: var(--fs-s); color: var(--graphite); }
.cw__next-title {
  font-size: clamp(1.75rem, 1rem + 2.6vw, 3.25rem);
  line-height: 1;
  font-weight: 800;
  font-variation-settings: "wdth" 82;
  letter-spacing: -0.02em;
  transition: transform 0.3s var(--ease-out);
}
.cw__next:hover .cw__next-title { transform: translateX(6px); }

/* case-study bar on phones: the title stays on one line */
.cw__tab { white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 520px) {
  .cw__path { display: none !important; }
  .cw__tab { flex: 1; }
  .cw__close { padding: 0 16px; }
}

/* ============================================================
   galleries — one grid, one gutter (--g) both ways, one hairline
   ============================================================ */
/* the window's bar stays opaque on top; content starts below it */
.cw__bar { position: relative; z-index: 2; background: var(--fog); }
.cw__body { padding-top: clamp(24px, 3vw, 40px); scroll-padding-top: clamp(24px, 3vw, 40px); }

.cw__gallery { display: grid; gap: var(--g); }
.grow { display: grid; gap: var(--g); align-items: start; }
.grow--half { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grow--third { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gfig { margin: 0; min-width: 0; }
.gcap {
  margin-top: 8px;
  font-size: var(--fs-xs);
  color: var(--graphite);
  line-height: 1.3;
}

/* a cell: the image fills it edge to edge, framed by one hairline */
.gcell {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--frame);
  background: #d9d9d5;
  transition: border-color 0.2s;
}
.gcell picture, .gcell .vid { position: absolute; inset: 0; display: block; }
.gcell img, .gcell video {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: 50% 0;
  display: block;
}
.gcell--contain img { object-fit: contain; object-position: 50% 50%; }

/* a phone screenshot: the whole screen, as a phone, on a fog cell */
.gcell--phone { background: var(--fog); }
.gcell--phone picture { display: flex; align-items: center; justify-content: center; }
.gcell--phone img {
  width: auto;
  height: 90%;
  object-fit: contain;
  border: 1px solid var(--frame);
  border-radius: clamp(8px, 1.4vw, 18px);
  background: var(--white);
}

@media (max-width: 720px) {
  .cw__body { padding-left: 16px; padding-right: 16px; }
}
