/* ============================================================
   João Zakaluka — portfolio
   Colors, type and grid in one place. Change a token here and
   it updates everywhere.
   ============================================================ */

:root {
  --bg: #FAFAF7;        /* off-white base */
  --ink: #111111;       /* near-black text */
  --muted: #6B6B6B;     /* secondary text */
  --line: #E4E4E0;      /* grid lines, light dividers */
  --ph: #E4E4E0;        /* image placeholders */

  --margin: 40px;       /* outer page margin */
  --cols: 4;            /* grid columns */
  --cell: 16px;         /* padding inside each column */

  --font: 'Instrument Sans', system-ui, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); }
a:hover { color: var(--muted); }
img, video { display: block; max-width: 100%; }
h1, h2, p { margin: 0; }

/* ---------- Grid lines (background) ---------- */
.grid-lines {
  position: fixed;
  inset: 0 var(--margin);
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  pointer-events: none;
  z-index: 0;
}
.grid-lines span { border-left: 1px solid var(--line); }
.grid-lines span:last-child { border-right: 1px solid var(--line); }

/* ---------- Layout ---------- */
.page { position: relative; z-index: 1; }

.wrap { padding: 0 var(--margin); }

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
}
.grid > * { padding: 0 var(--cell); }

.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: 1 / -1; }
.col-2 { grid-column: 2; }
.col-3 { grid-column: 3; }
.col-4 { grid-column: 4; }
.col-2-4 { grid-column: 2 / 5; }
.col-3-4 { grid-column: 3 / 5; }

.rule { border-top: 1px solid var(--ink); }
.rule-light { border-top: 1px solid var(--line); }

/* ---------- Header: logo + nav ---------- */
.topbar { position: relative; }
.logo {
  position: absolute;
  left: calc(var(--margin) + var(--cell));
  top: 38px;
  z-index: 2;
  color: var(--ink);
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.04em;
  text-decoration: none;
  white-space: nowrap;
}

/* Full wordmark on wide screens, reduced mark (J–Z) on tablets and phones */
.logo-full { display: block; height: 20px; width: auto; margin-top: -2px; }   /* optical: caps centered on the menu pills */
.logo-short { display: none; height: 16px; width: auto; }
@media (max-width: 1023px) {
  .logo-full { display: none; }
  .logo-short { display: block; }
}

/* ---------- Nav ---------- */
.nav {
  display: flex;
  justify-content: flex-end;   /* menu sits on the right, aligned to the grid */
  flex-wrap: wrap;
  gap: 8px;
  padding: 32px calc(var(--margin) + var(--cell)) 0;
}
.pill {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
}
.pill:hover { background: var(--ink); color: var(--bg); }
.pill[aria-current="page"] { background: var(--ink); color: var(--bg); }
.pill-lg { padding: 10px 18px; font-size: 15px; }

/* ---------- Type ---------- */
.display {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: -0.04em;
  line-height: 0.95;
}
.muted { color: var(--muted); }

.hero-title { font-size: clamp(34px, 5vw, 72px); max-width: 986px; }
@media (min-width: 1024px) {
  .hero-title { font-size: clamp(72px, 4.8vw, 92px); max-width: 75%; }   /* bigger headline on desktop, spans 3 columns */
}
.about-title { font-size: clamp(40px, 4.45vw, 64px); line-height: 0.92; letter-spacing: -0.045em; }
.section-title { font-size: clamp(32px, 3.9vw, 56px); }
.statement { font-size: clamp(26px, 3.05vw, 44px); line-height: 0.98; letter-spacing: -0.035em; }
.talk { font-size: clamp(52px, 7.2vw, 104px); line-height: 0.92; letter-spacing: -0.045em; white-space: nowrap; }

.label { font-size: 13px; line-height: 1.5; color: var(--muted); }
.value { font-size: 15px; line-height: 1.5; }
.lead { font-size: 22px; font-weight: 500; line-height: 1.35; letter-spacing: -0.01em; }

/* ---------- Placeholders (swap for <img> or <video>) ---------- */
.ph {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--ph);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-align: center;
  text-decoration: none;
  overflow: hidden;
}
.ph img, .ph video { width: 100%; height: 100%; object-fit: cover; }

/* Project loop: stacked images, only the active one shows (hard cut) */
.loop { position: relative; }
.loop img { position: absolute; inset: 0; opacity: 0; }
.loop img.is-active { opacity: 1; }

/* ---------- Home: hero ---------- */
.hero { padding-top: 120px; }
.hero-loop { margin-top: 56px; position: relative; z-index: 3; }   /* moving box passes over the headline */
.hero-title { position: relative; z-index: 2; }
.hero-loop .ph { will-change: transform; pointer-events: none; }
.hero-loop .ph { height: 192px; }

/* Click on the hero: a frozen copy of the loop stays where it was and fades out */
.loop-stamp {
  position: absolute;
  border-radius: 6px;
  overflow: hidden;
  pointer-events: none;
  transition: opacity 1000ms ease;   /* fade length */
}
.loop-stamp img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }   /* round the image itself too: some browsers drop the clip while fading */
.loop-stamp.is-fading { opacity: 0; }

.facts { margin-top: 40px; padding-top: 20px; }
.facts > div { display: flex; flex-direction: column; align-items: flex-start; }
.facts .values { display: flex; flex-wrap: wrap; gap: 0 6px; }   /* several pills in one fact (e.g. Services) */
.facts .values-2x2 { display: grid; grid-template-columns: repeat(2, max-content); justify-items: start; }   /* Services: two rows of two */
.facts .value {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 12px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--bg);
  line-height: 1.4;
  white-space: nowrap;
}

/* ---------- Home: work ---------- */
.section { margin-top: 160px; }
.section-head { align-items: end; padding-bottom: 32px; }
.section-head .label, .section-head .value { padding-bottom: 6px; }

.cards { row-gap: 56px; padding-top: 40px; }
.card { text-decoration: none; color: var(--ink); display: block; }
.card .ph { aspect-ratio: 648 / 440; }
.card-name { margin-top: 20px; font-size: 20px; font-weight: 500; line-height: 1.3; }
.card-meta { margin-top: 4px; font-size: 15px; line-height: 1.4; color: var(--muted); }
.card:hover .card-name { color: var(--muted); }

.approach { padding-top: 22px; }

/* ---------- Footer ---------- */
.footer { margin-top: 160px; }
.footer .talk-row { align-items: start; padding-top: 56px; }
.footer .email { padding-top: 20px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.footer-bottom { padding: 120px 0 48px; }

/* ---------- About ---------- */
.about-hero { padding-top: 120px; row-gap: 32px; }
.portrait { aspect-ratio: 4 / 5; }   /* matches the photos, nothing cropped */
.portrait-swap { display: block; width: 100%; padding: 0; border: 0; font: inherit; cursor: pointer; }
.portrait-swap:focus-visible { outline: 1px solid var(--ink); outline-offset: 4px; }
.bio > * + * { margin-top: 24px; }
.bio .lead { margin-top: 32px; }

.principles { padding-top: 24px; row-gap: 32px; }
.principle .num { font-size: 13px; color: var(--muted); }
.principle h3 { margin: 8px 0 0; font-size: 20px; font-weight: 500; line-height: 1.3; }
.principle p { margin-top: 10px; font-size: 15px; line-height: 1.5; color: var(--muted); }

.list-row { padding: 22px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.list-row .role { font-size: 18px; font-weight: 500; line-height: 1.3; }
.list-row .meta { font-size: 16px; line-height: 1.3; color: var(--muted); }

.skills { padding-top: 22px; row-gap: 14px; }
.skills p { font-size: 20px; font-weight: 500; line-height: 1.3; }

/* ---------- Case study pages ---------- */
.case-hero { padding-top: 120px; }
.case-head { row-gap: 0; }
.case-hero .facts { margin-top: 72px; }
.case-title { grid-column: 1 / 3; grid-row: 1; font-size: clamp(56px, 6.4vw, 112px); line-height: 0.9; letter-spacing: -0.04em; }
.case-thesis { grid-column: 1 / 3; grid-row: 2; margin-top: 10px; font-size: clamp(26px, 2.8vw, 46px); line-height: 1; letter-spacing: -0.03em; }
.case-intro { grid-column: 3 / 5; grid-row: 1 / 3; align-self: end; }

.case-media { margin-top: 40px; row-gap: 32px; }
.shot { margin: 0; }
.shot img, .shot video { display: block; width: 100%; height: auto; border-radius: 6px; background: var(--ph); }
.caption-note { font-size: 14px; color: var(--muted); margin-top: -16px; }

/* Exnor: list of units with a pill per name */
.units { list-style: none; margin: 20px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.units li { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.units .value { padding: 4px 12px; border: 1px solid var(--ink); border-radius: 999px; background: var(--bg); line-height: 1.4; }
.shot figcaption { margin-top: 10px; font-size: 14px; line-height: 1.45; color: var(--muted); }
.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: calc(var(--cell) * 2); }

.case-block { margin-top: 120px; }
.case-row { padding-top: 22px; }
.case-label span { color: var(--ink); }
.case-text { grid-column: 2 / 4; }
.case-text h2 { font-size: clamp(28px, 3.2vw, 44px); text-wrap: balance; }
.case-text p { margin-top: 16px; max-width: 60ch; }
.case-text h2 + p { margin-top: 20px; }

.swap { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 20px; }
.swap .value { padding: 4px 12px; border: 1px solid var(--ink); border-radius: 999px; background: var(--bg); line-height: 1.4; }
.swap .from { border-color: var(--line); color: var(--muted); text-decoration: line-through; }

.case-next { margin-top: 56px; align-items: baseline; }

.case-next a { text-decoration: none; }

/* ============================================================
   Mobile (two columns)
   ============================================================ */
@media (max-width: 760px) {
  :root { --margin: 16px; --cols: 2; --cell: 12px; }

  body { font-size: 16px; }

  /* Two background lines columns on mobile: hide the extra two and close the right edge */
  .grid-lines span:nth-child(n+3) { display: none; }
  .grid-lines span:nth-child(2) { border-right: 1px solid var(--line); }

  .logo { top: 27px; font-size: 20px; }
  .logo-short { height: 14px; }
  .nav { padding: 20px calc(var(--margin) + var(--cell)) 0; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
  .pill { padding: 5px 10px; font-size: 12px; }
  .pill-lg { padding: 10px 18px; font-size: 15px; }

  .span-3, .col-2-4, .col-3-4, .span-2 { grid-column: 1 / -1; }
  .col-2, .col-3, .col-4 { grid-column: auto; }

  .hero { padding-top: 72px; }
  .hero-loop { margin-top: 40px; }
  .hero-loop > div { grid-column: 1 / -1; }
  .principles { grid-template-columns: minmax(0, 1fr); }
  .hero-loop .ph { height: 200px; }
  .facts { row-gap: 18px; padding-top: 16px; }
  .facts .value { margin-top: 6px; padding: 4px 9px; font-size: 13px; }
  .label { font-size: 12px; }
  .value { font-size: 14px; }

  .section { margin-top: 96px; }
  .section-head { row-gap: 8px; padding-bottom: 20px; }
  .cards { row-gap: 40px; padding-top: 24px; }
  .card-name { margin-top: 12px; font-size: 17px; }
  .card-meta { font-size: 14px; }

  .approach { row-gap: 12px; padding-top: 16px; }

  .footer { margin-top: 96px; }
  .footer .talk-row { padding-top: 32px; }
  .footer .email { padding-top: 24px; }
  .footer-bottom { padding: 64px 0 32px; row-gap: 4px; }
  .footer-bottom p { font-size: 12px; }

  .about-hero { padding-top: 72px; }
  .lead { font-size: 18px; }
  .bio > * + * { margin-top: 18px; }

  .principles { row-gap: 0; padding-top: 0; }
  .principle { padding-top: 16px !important; padding-bottom: 18px !important; border-bottom: 1px solid var(--line); }
  .principle h3 { font-size: 17px; }

  .list-row { padding: 16px 0; row-gap: 4px; }
  .list-row .role { font-size: 16px; }
  .list-row .meta { font-size: 14px; }

  .skills p { font-size: 16px; }

  .case-hero { padding-top: 72px; }
  .case-title, .case-thesis, .case-intro { grid-column: 1 / -1; grid-row: auto; }
  .case-intro { margin-top: 32px; align-self: start; }
  .case-hero .facts { margin-top: 40px; }
  .case-block { margin-top: 72px; }
  .case-label { grid-column: 1 / -1; padding-bottom: 12px !important; }
  .case-text { grid-column: 1 / -1; }
  .case-media { margin-top: 24px; row-gap: 20px; }
  .trio { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .case-next { row-gap: 8px; }
  .case-next a { grid-column: 1 / -1; }
}

/* Small phones: tighten the menu so logo and nav stay on one row */
@media (max-width: 400px) {
  .nav { gap: 4px; }
  .nav .pill { padding: 5px 8px; font-size: 11px; }
}
