/* ==========================================================================
   Diogo Santos — Portfolio  ·  v2 "Swiss editorial"
   Built like a printed presentation: running heads, numbered chapters,
   black chapter openers, one grotesk family set big and tight.
   The site itself stays black & white — colour belongs to the projects.
   Type: Inter Tight (display + text). Tight tracking at large sizes gives
   the Neue Haas / Helvetica Now feel of a print deck, for free.
   ========================================================================== */

:root {
  --paper: #f4f4f1;
  --card: #e9e9e5;
  --ink: #0b0b0b;
  --ink-2: #2b2b2a;
  --muted: #8b8b86;
  --rule: #0b0b0b;
  --rule-soft: rgba(11, 11, 11, 0.14);
  --night: #0b0b0b;
  --night-text: #f4f4f1;
  --night-muted: #7d7d78;

  --font: "Inter Tight", "Helvetica Neue", Helvetica, Arial, sans-serif;

  --gutter: clamp(16px, 2.4vw, 36px);
  --gap: clamp(12px, 1.4vw, 20px);
  --max: 1760px;

  --fs-giant: clamp(4.2rem, 22vw, 26rem);
  --fs-h1: clamp(3rem, 9vw, 10rem);
  --fs-h2: clamp(2.2rem, 5.2vw, 5.6rem);
  --fs-h3: clamp(1.6rem, 2.8vw, 3rem);
  --fs-body: clamp(0.98rem, 0.25vw + 0.9rem, 1.1rem);
  --fs-small: 0.86rem;
  --fs-xs: 0.72rem;

  --track-giant: -0.065em;
  --track-h: -0.045em;

  --ease: cubic-bezier(0.2, 0.7, 0.1, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.45;
  font-feature-settings: "ss02", "cv11";
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
p { margin: 0 0 1em; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
ul, ol { margin: 0; padding: 0; list-style: none; }
::selection { background: var(--ink); color: var(--paper); }

/* *stars* in content = the quiet half of a headline */
em { font-style: normal; color: var(--muted); }
.night em { color: var(--night-muted); }

.wrap { max-width: var(--max); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap); }

.xs { font-size: var(--fs-xs); line-height: 1.35; letter-spacing: 0.005em; }
.sm { font-size: var(--fs-small); line-height: 1.4; }
.muted { color: var(--muted); }
.night .muted { color: var(--night-muted); }

.h-giant { font-size: var(--fs-giant); line-height: 0.8; letter-spacing: var(--track-giant); font-weight: 600; }
.h1 { font-size: var(--fs-h1); line-height: 0.86; letter-spacing: var(--track-giant); font-weight: 600; }
.h2 { font-size: var(--fs-h2); line-height: 0.92; letter-spacing: var(--track-h); font-weight: 600; }
.h3 { font-size: var(--fs-h3); line-height: 1; letter-spacing: -0.035em; font-weight: 600; }

/* Unknown facts. Visible on purpose until filled in. */
mark.todo {
  background: #ffe46b; color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.72rem; font-weight: 400; letter-spacing: 0; line-height: 1.5;
  padding: 0.1em 0.4em; border-radius: 2px;
  vertical-align: middle; display: inline;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
body.hide-todo mark.todo { display: none; }

/* ---------- Running head (the "page header" of every spread) ---------- */
.runhead { display: grid; grid-template-columns: repeat(12, minmax(0,1fr)); column-gap: var(--gap); padding: 14px 0; align-items: baseline; }
.runhead > :nth-child(1) { grid-column: 1 / span 3; }
.runhead > :nth-child(2) { grid-column: 4 / span 3; }
.runhead > :nth-child(3) { grid-column: 7 / span 3; }
.runhead > :nth-child(4) { grid-column: 10 / span 3; text-align: right; }
@media (max-width: 760px) {
  .runhead > :nth-child(1) { grid-column: 1 / span 6; }
  .runhead > :nth-child(2), .runhead > :nth-child(3) { display: none; }
  .runhead > :nth-child(4) { grid-column: 7 / span 6; }
}

/* ---------- Site header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--paper);
  border-bottom: 1px solid var(--rule-soft);
}
.site-header .runhead { padding: 12px 0; }
.site-header nav { display: flex; justify-content: flex-end; gap: clamp(12px, 1.8vw, 24px); }
.site-header nav a { position: relative; }
.site-header nav a::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 1px; background: currentColor; transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease); }
.site-header nav a:hover::after, .site-header nav a[aria-current="page"]::after { transform: scaleX(1); }
.brand { font-weight: 600; letter-spacing: -0.01em; }

/* ---------- Spread = one "slide" of the presentation ---------- */
.spread { padding-bottom: clamp(56px, 9vw, 140px); }
.spread + .spread { border-top: 1px solid var(--rule-soft); }
.spread .runhead { margin-bottom: clamp(28px, 5vw, 80px); }

/* ---------- Cover ---------- */
.cover { min-height: calc(100svh - 45px); display: flex; flex-direction: column; justify-content: space-between; padding-bottom: 0; overflow-x: clip; overflow-y: visible; }
.cover-meta { display: grid; grid-template-columns: repeat(12, minmax(0,1fr)); column-gap: var(--gap); row-gap: 8px; padding-top: clamp(16px, 3vw, 40px); }
.cover-meta > * { grid-column: span 3; }
.cover-meta .who { grid-column: 1 / span 3; }
@media (max-width: 760px) { .cover-meta > *, .cover-meta .who { grid-column: span 6; } }
.cover-word { font-size: min(24vw, 40svh); line-height: 1.3; padding-bottom: 0.04em; margin: 0 0 0 -0.055em; white-space: nowrap; } /* sized by width AND viewport height so the whole word, incl. the g descender, always fits on screen */

/* ---------- Hello (photo + text only) ---------- */
.hello .grid { row-gap: 32px; align-items: stretch; }
.hello-img { grid-column: 1 / span 6; }
/* Wider frame, same proportions of the photo (cropped, never stretched) */
.hello-img .frame { aspect-ratio: 6 / 5; width: calc(100% + var(--gap) - var(--gutter)); } /* space before the text = the page side margin */
.hello-img .frame img { object-fit: cover; object-position: 50% 30%; }
/* Text block is scaled by JS (--hb) so its height matches the photo exactly on desktop */
.hello-body { grid-column: 7 / -1; display: flex; flex-direction: column; justify-content: space-between; font-size: var(--hb, clamp(0.95rem, 0.3vw + 0.85rem, 1.15rem)); }
.hello-body p { color: var(--ink-2); font-size: 1em; line-height: var(--blh, 1.45); margin: 0; }
.hello-body p + p { margin-top: 0.9em; }
.hello-body > .lead { font-size: var(--lead, 3.2em); line-height: 0.98; letter-spacing: -0.045em; color: var(--ink); font-weight: 600; margin: -0.08em 0 0; }
.hello-body .rest { margin-top: 1.4em; }
@media (max-width: 900px) {
  .hello-img .frame { width: 100%; }
  .hello-img { grid-column: 1 / span 8; }
  .hello-body { grid-column: 1 / -1; }
}
@media (max-width: 600px) { .hello-img { grid-column: 1 / -1; } }

/* ---------- What I do ---------- */
.doing .grid { row-gap: 32px; }
.doing-title { grid-column: 1 / span 6; }
.doing-list { grid-column: 7 / span 6; display: grid; grid-template-columns: 1fr 1fr; column-gap: var(--gap); align-self: end; }
.doing-list li { border-top: 1px solid var(--rule); padding: 10px 0 14px; font-weight: 500; letter-spacing: -0.01em; display: flex; gap: 14px; }
.doing-list li span { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.tools-line { grid-column: 7 / span 6; }
@media (max-width: 900px) { .doing-title, .doing-list, .tools-line { grid-column: 1 / -1; } }

/* ---------- Where I've worked ---------- */
.worked .grid { row-gap: 32px; }
.worked-title { grid-column: 1 / span 5; }
.worked-col { grid-column: 7 / span 6; }
.worked-sub { font-weight: 400; margin: 0 0 10px; }
.worked-table + .worked-sub { margin-top: clamp(28px, 4vw, 56px); }
.worked-table li { display: grid; grid-template-columns: 1.1fr 1.4fr 2fr; column-gap: var(--gap); padding: 12px 0; border-top: 1px solid var(--rule-soft); align-items: baseline; }
.worked-table li:first-child { border-top: 1px solid var(--rule); }
.worked-table .role { font-weight: 500; }
@media (max-width: 900px) { .worked-title, .worked-col { grid-column: 1 / -1; } }
@media (max-width: 560px) { .worked-table li { grid-template-columns: 1fr 2fr; row-gap: 4px; } .worked-table li .desc { grid-column: 2; } }

/* ---------- Contents ---------- */
.contents .grid { row-gap: 32px; align-items: center; }
.contents-title { grid-column: 1 / span 5; }
.toc { grid-column: 6 / span 7; align-self: center; counter-reset: toc; }
.toc li { border-top: 1px solid var(--rule-soft); }
.toc li:last-child { border-bottom: 1px solid var(--rule); }
.toc li:first-child { border-top: 1px solid var(--rule); }
.toc a { display: grid; grid-template-columns: 3rem 1fr auto; column-gap: var(--gap); padding: 14px 0; align-items: baseline; transition: padding .35s var(--ease); }
.toc .n { font-variant-numeric: tabular-nums; }
.toc .t { font-size: var(--fs-h3); line-height: 1; letter-spacing: -0.035em; font-weight: 600; text-align: right; }
.toc .d { display: none; }
.toc a:hover { padding-left: 10px; }
.toc a:hover .t { color: var(--muted); }
@media (min-width: 1100px) { .toc a { grid-template-columns: 3rem 1fr 14rem auto; } .toc .d { display: block; } .toc .t { order: 4; } }
@media (max-width: 900px) { .contents-title, .toc { grid-column: 1 / -1; } }

/* ---------- Chapter opener (black) ---------- */
.night { background: var(--night); color: var(--night-text); }
.chapter { position: relative; display: block; min-height: min(78svh, 820px); overflow: hidden; }
.chapter-title.fit { font-size: 30vw; }
.fit { white-space: nowrap; }
.chapter .wrap { min-height: inherit; display: flex; flex-direction: column; justify-content: space-between; padding-bottom: clamp(20px, 3vw, 40px); }
.chapter .runhead { border-bottom: 1px solid rgba(244,244,241,0.18); }
.chapter-arrow { position: absolute; right: var(--gutter); top: clamp(80px, 12vw, 180px); width: clamp(56px, 7vw, 120px); height: auto; transition: transform .5s var(--ease); }
a.chapter:hover .chapter-arrow { transform: translateX(14px); }
.chapter-title { margin-left: -0.05em; }
.chapter-sub { max-width: 34ch; margin-top: 18px; color: var(--night-muted); font-size: clamp(1rem, 0.6vw + 0.9rem, 1.35rem); letter-spacing: -0.01em; }

/* ---------- Making-of intro (after each chapter) ---------- */
.making .grid { row-gap: 28px; align-items: end; }
.making-title { grid-column: 1 / span 8; }
.making-list { grid-column: 10 / span 3; }
.making-list li { padding-left: 14px; position: relative; line-height: 1.5; }
.making-list li::before { content: ""; position: absolute; left: 0; top: 0.62em; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.making-cta { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--rule); padding-top: 14px; }
.making-cta a { font-weight: 600; letter-spacing: -0.01em; }
.making-cta a:hover { color: var(--muted); }
.making-img { grid-column: 1 / -1; }
@media (max-width: 900px) { .making-title, .making-list { grid-column: 1 / -1; } }

/* ---------- Frames & placeholders (16:9 "slides") ---------- */
.frame { position: relative; overflow: hidden; background: var(--card); }
.frame img { width: 100%; height: 100%; object-fit: cover; }
.r-16x9 { aspect-ratio: 16 / 9; } .r-4x3 { aspect-ratio: 4 / 3; } .r-3x2 { aspect-ratio: 3 / 2; }
.r-1x1 { aspect-ratio: 1 / 1; } .r-4x5 { aspect-ratio: 4 / 5; } .r-9x16 { aspect-ratio: 9 / 16; } .r-21x9 { aspect-ratio: 21 / 9; }
.ph { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 14px 16px; background: var(--tone, var(--card)); color: rgba(11,11,11,.72); }
.ph.dark { color: rgba(244,244,241,.72); }
.ph .top, .ph .bot { display: flex; justify-content: space-between; gap: 12px; }
.ph b { font-weight: 600; color: var(--ink); }
.ph.dark b { color: var(--night-text); }
.ph .cross { position: absolute; inset: 0; background:
  linear-gradient(to top right, transparent calc(50% - .5px), currentColor 50%, transparent calc(50% + .5px)),
  linear-gradient(to bottom right, transparent calc(50% - .5px), currentColor 50%, transparent calc(50% + .5px));
  opacity: .12; pointer-events: none; }
.caption { display: flex; justify-content: space-between; gap: 16px; padding-top: 8px; }

/* ---------- Case study ---------- */
.cs-open { min-height: calc(100svh - 45px); }
.cs-meta { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: var(--gap); padding-top: 14px; border-top: 1px solid rgba(244,244,241,.18); margin-top: clamp(24px, 4vw, 48px); }
.cs-meta .v { color: var(--night-text); margin-top: 4px; }
@media (max-width: 760px) { .cs-meta { grid-template-columns: 1fr 1fr; row-gap: 16px; } }

.block .grid { row-gap: 20px; }
.block-head { grid-column: 1 / span 6; }
.block-head .idx { display: block; margin-bottom: 14px; }
.block-body { grid-column: 8 / span 5; align-self: end; }
.block-body p { color: var(--ink-2); max-width: 48ch; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tags li { border: 1px solid var(--rule-soft); border-radius: 999px; padding: 5px 11px; font-size: var(--fs-small); }
@media (max-width: 900px) { .block-head, .block-body { grid-column: 1 / -1; } }

.images .grid { row-gap: var(--gap); }
.images .full { grid-column: 1 / -1; }
.images .half { grid-column: span 6; }
.images .third { grid-column: span 4; }
.images .wide { grid-column: span 8; }
.images .narrow { grid-column: span 4; }
@media (max-width: 760px) { .images .half, .images .third, .images .wide, .images .narrow { grid-column: 1 / -1; } }

.pull .h1 { max-width: 16ch; }

.stats .grid { row-gap: 40px; }
.stat { grid-column: span 4; border-top: 1px solid var(--rule); padding-top: 12px; }
.stat .big { font-size: var(--fs-h1); line-height: .9; letter-spacing: var(--track-giant); font-weight: 600; margin-top: clamp(20px, 4vw, 60px); font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .stat { grid-column: 1 / -1; } }

.disclaimer { padding-bottom: 32px; }

.next-chapter .chapter { min-height: min(70svh, 720px); }

/* ---------- Playground ---------- */
.play-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: var(--gap); }
@media (max-width: 900px) { .play-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .play-grid { grid-template-columns: 1fr; } }

/* ---------- Footer / contact ---------- */
.site-footer { padding-bottom: 20px; }
.site-footer .runhead { border-bottom: 1px solid rgba(244,244,241,.18); }
.foot-big { padding: clamp(40px, 8vw, 120px) 0 clamp(40px, 6vw, 96px); }
.foot-big a { display: inline-block; transition: color .3s; }
.foot-big a:hover { color: var(--night-muted); }
.talk-arrow { width: 1.05em; height: 0.53em; vertical-align: 0.12em; margin-left: 0.08em; overflow: visible; }
.foot-row { display: grid; grid-template-columns: repeat(12, minmax(0,1fr)); column-gap: var(--gap); row-gap: 12px; border-top: 1px solid rgba(244,244,241,.18); padding-top: 14px; }
.foot-row > * { grid-column: span 3; }
@media (max-width: 760px) { .foot-row > * { grid-column: span 6; } }

/* ---------- Motion ---------- */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .8s var(--ease), transform .8s var(--ease); }
.js .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .js .reveal { opacity: 1; transform: none; transition: none; } * { transition: none !important; scroll-behavior: auto !important; } }

.todo-toggle { position: fixed; right: 12px; bottom: 12px; z-index: 200; font: 500 11px/1 var(--font); background: #ffe46b; color: var(--ink); border: 1px solid var(--ink); padding: 9px 11px; cursor: pointer; }

/* ---------- Slide-only project pages (the PDF, as is) ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.slides { display: flex; flex-direction: column; gap: clamp(6px, 0.8vw, 12px); padding-top: clamp(6px, 0.8vw, 12px); }
.slide { margin: 0; aspect-ratio: 16 / 9; overflow: hidden; }
.slide img, .slide video { display: block; width: 100%; height: 100%; object-fit: cover; }
.slides-nav { display: flex; justify-content: space-between; align-items: baseline; padding-top: 18px; padding-bottom: clamp(40px, 6vw, 80px); }
.slides-nav a:hover { color: var(--muted); }

/* Home: under each black chapter, just the cover image + link (no header row, title or list) */
.making-home { padding-top: clamp(16px, 2vw, 28px); }

/* Home: one block per project = cover image as the base + chapter info on top */
.project-block { padding-top: clamp(12px, 1.4vw, 20px); }
.project-block:last-of-type { padding-bottom: clamp(40px, 6vw, 96px); }
.project-card { position: relative; display: block; overflow: hidden; }
.project-card .frame { transition: transform 1s var(--ease); }
.project-card:hover .frame { transform: scale(1.015); }
.project-over { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 0 clamp(14px, 2vw, 28px) clamp(10px, 1.6vw, 22px); pointer-events: none; }
.project-over .runhead { border-bottom: 1px solid currentColor; border-bottom-color: color-mix(in srgb, currentColor 25%, transparent); }
.project-over .chapter-arrow { top: clamp(56px, 7vw, 110px); right: clamp(14px, 2vw, 28px); width: clamp(44px, 5vw, 90px); }
.project-card:hover .chapter-arrow { transform: translateX(10px); }
.project-title { margin-left: -0.04em; }
.project-card.on-light { color: var(--ink); }
.project-card.on-dark { color: var(--night-text); }
@media (max-width: 600px) { .project-over .runhead > :nth-child(4) { display: none; } .project-over .runhead > :nth-child(1) { grid-column: 1 / -1; } }
.project-card .ph .top, .project-card .ph .bot { visibility: hidden; } /* placeholder labels would clash with the overlay */

/* Project pages: smaller title in the black intro (fit.js still shrinks long names to the width) */
.cs-open .chapter-title.fit { font-size: min(15vw, 26svh); }

/* Playground videos: muted looping preview; click for sound + controls */
.play-video { cursor: pointer; }
.play-video video { width: 100%; height: 100%; object-fit: cover; display: block; }
.play-sound { position: absolute; right: 10px; bottom: 10px; background: rgba(11,11,11,.7); color: var(--night-text); padding: 5px 9px; border-radius: 999px; pointer-events: none; transition: opacity .3s; }
.play-video.on .play-sound { opacity: 0; }
.play-videos { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: clamp(28px,4vw,56px) var(--gap); margin-bottom: clamp(32px, 5vw, 72px); }
.play-videos .v-wide { grid-column: span 2; }
.play-videos .v-tall { grid-column: span 1; }
@media (max-width: 760px) { .play-videos { grid-template-columns: 1fr 1fr; } .play-videos .v-wide { grid-column: 1 / -1; } }
/* Descenders (g, y, p) must clear the subtitle */
.cs-open .chapter-title { line-height: 1; padding-bottom: 0.02em; }
.cs-open .chapter-sub { margin-top: 0; max-width: 54ch; }
.play-open .chapter-title { padding-bottom: 0.18em; }
