/* ============================================================
   RODRIGO CARNEIRO — PORTFOLIO STYLES
   In the spirit of paulcalver.cc: white, black text, edge-to-edge
   images, lots of air, smooth fades. App-like, not one long scroll.
   ============================================================ */

:root {
  --ink:    #111111;
  --paper:  #ffffff;
  --muted:  #8a8a8a;
  --gap:    10px;                 /* space between image tiles */
  --pad:    clamp(14px, 3vw, 34px); /* page side padding */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Hanken Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0.02em;   /* same tracking as Paul's site */
  -webkit-font-smoothing: antialiased;
}

a, button { color: inherit; font: inherit; text-decoration: none; }
button { background: none; border: none; cursor: pointer; }
img, video { display: block; width: 100%; }


/* ============================================================
   TOP MENU
   ============================================================ */
.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-start;      /* menu sits in the corner (left), like the backup */
  gap: clamp(12px, 2vw, 22px);
  padding: 20px var(--pad);
  background: var(--paper);
}
.nav__name {
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  margin-right: clamp(6px, 1.6vw, 16px);
}
.nav__menu {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(14px, 2.5vw, 30px);
}
.nav__menu button {
  font-weight: 700;
  color: var(--ink);
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;   /* the underline lives here */
  transition: opacity 0.2s ease;
}
.nav__menu button:hover { opacity: 0.55; }
.nav__menu button.is-active { border-bottom-color: var(--ink); }   /* current section */

/* The hovered work's title — sits over the name + menu and replaces them */
.nav__name, .nav__menu { transition: opacity 0.2s ease; }
.nav__work {
  position: absolute;
  left: var(--pad);
  top: 20px;                 /* matches the nav's top padding */
  text-align: left;          /* work title sits in the corner, where the menu was */
  font-weight: 700;
  letter-spacing: 0.01em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.nav.show-work .nav__name,
.nav.show-work .nav__menu { opacity: 0; }   /* hide name + menu while hovering a work */
.nav.show-work .nav__work { opacity: 1; }   /* show the work title instead */


/* ============================================================
   VIEWS — fade in when they become active
   ============================================================ */
.view { display: none; padding: clamp(10px, 2vw, 24px) var(--pad) 80px; }
.view.is-active { display: block; animation: viewIn 0.5s ease both; }

/* Photography bleeds close to the screen edges (the wide, spacious feel) */
#view-photography { padding-left: var(--gap); padding-right: var(--gap); padding-top: 8px; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}


/* ============================================================
   GALLERIES
   ============================================================ */
.gallery { width: 100%; }

/* Photography — HORIZONTAL masonry: scroll sideways, images bleed off
   the right edge (like Paul's). Two rows, with tiles of varying size. */
/* Photography — scattered, OFF-LEVEL columns (asymmetric, like Paul's).
   Column widths and start-heights are set per-column in script.js so
   nothing lines up. Images keep their natural shapes (your random sizes). */
.gallery--scatter { display: flex; align-items: flex-start; gap: clamp(16px, 2vw, 40px); }
.scatter-col { display: flex; flex-direction: column; gap: clamp(22px, 3.5vw, 60px); min-width: 0; }
.gallery--scatter .tile__cover img { height: auto; }
/* a little horizontal jitter so even within a column nothing aligns */
.scatter-col .tile:nth-child(even) { width: 86%; }
.scatter-col .tile:nth-child(3n)   { margin-left: auto; }
/* spotlight: only once you hover an actual photo, the OTHERS grey out.
   Normal state (cursor not on a photo) = everything full and normal. */
.gallery--scatter .tile { transition: opacity 0.3s ease, filter 0.3s ease; }
.gallery--scatter.is-spotlighting .tile { opacity: 0.4; filter: grayscale(0.35); }
.gallery--scatter .tile:hover           { opacity: 1;   filter: none; }

/* Fotografia — an ORDERED grid. Photos read left→right, top→bottom and keep
   that order however far you scroll. The off-level / scattered feel comes from
   per-column vertical offsets + slight width jitter — never from reordering. */
/* Fotografia — JUSTIFIED rows (like Google Photos): photos stay in order and
   each row is scaled to one height that fills the full width — no big white
   gaps, nothing cropped. layoutJustified() in script.js sets the exact sizes. */
.gallery--photos { display: flex; flex-wrap: wrap; align-items: flex-start; }
.gallery--photos .tile {
  display: block;
  overflow: hidden;
  transition: opacity 0.3s ease, filter 0.3s ease;
}
.gallery--photos .tile__cover { width: 100%; height: 100%; }
.gallery--photos .tile__cover img { width: 100%; height: 100%; object-fit: cover; }
/* spotlight: only once you hover a photo do the OTHERS grey out */
.gallery--photos.is-spotlighting .tile { opacity: 0.4; filter: grayscale(0.35); }
.gallery--photos .tile:hover           { opacity: 1;   filter: none; }

/* Visual Research — tidy grid of 16:9 video thumbnails (no scattered gaps) */
.gallery--research {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  column-gap: clamp(12px, 1.6vw, 22px);
  row-gap: clamp(22px, 2.4vw, 34px);
}
.gallery--research .tile { transition: opacity 0.3s ease, filter 0.3s ease; }
/* same "levemente bagunçadinho" off-level stagger as Photography (off on mobile) */
@media (min-width: 561px) {
  .gallery--research .tile:nth-child(6n+1) { transform: translateY(0); }
  .gallery--research .tile:nth-child(6n+2) { transform: translateY(16px); }
  .gallery--research .tile:nth-child(6n+3) { transform: translateY(6px); }
  .gallery--research .tile:nth-child(6n+4) { transform: translateY(20px); }
  .gallery--research .tile:nth-child(6n+5) { transform: translateY(10px); }
  .gallery--research .tile:nth-child(6n+6) { transform: translateY(2px); }
}
.gallery--research .tile__cover { aspect-ratio: 16 / 9; }
.gallery--research .tile__cover img { height: 100%; object-fit: cover; }
.gallery--research.is-spotlighting .tile { opacity: 0.4; filter: grayscale(0.35); }
.gallery--research .tile:hover           { opacity: 1;   filter: none; }

@media (max-width: 900px) { .gallery--research { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .gallery--research { grid-template-columns: 1fr; } }

/* Direction (Motion) — a centred row of 16:9 films that all loop.
   Hovering one "spotlights" it and greys the others out. */
.gallery--motion {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: clamp(16px, 3vw, 48px);
  overflow-x: auto;
  padding: 6vh 0;
}
.gallery--motion .tile {
  flex: 0 0 auto;
  width: clamp(280px, 44vw, 760px);
  transition: opacity 0.3s ease, filter 0.3s ease;
}
.gallery--motion .tile__cover  { aspect-ratio: 16 / 9; }
.gallery--motion .tile__preview { opacity: 1; }                    /* always visible + playing */
.gallery--motion:hover .tile    { opacity: 0.4; filter: grayscale(0.35); }  /* dim the rest */
.gallery--motion .tile:hover    { opacity: 1;   filter: none; }             /* spotlight */

/* kept for reference: two-up grid (no longer used by Direction) */
.gallery--two   { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--gap); }

/* Visual Research — three across */
.gallery--three { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }

@media (max-width: 760px) { .gallery--three { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px) { .gallery--two, .gallery--three { grid-template-columns: 1fr; } }


/* ============================================================
   A TILE (cover image + small title underneath)
   ============================================================ */
.tile { display: block; cursor: pointer; }

.tile__cover {
  position: relative;
  overflow: hidden;
  background: #f1f1f1;
}
/* Direction/Research tiles keep a steady shape; photography keeps natural height */
.gallery--two   .tile__cover,
.gallery--three .tile__cover { aspect-ratio: 4 / 3; }

.tile__cover img {
  height: 100%;
  object-fit: cover;
  transition: opacity 0.4s ease;
}
.tile:hover .tile__cover img { opacity: 0.9; }

/* The silent hover-loop preview (Visual Research) sits over the still */
.tile__preview {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 0.4s ease; pointer-events: none;
}
.tile__preview.is-playing { opacity: 1; }
/* iOS shows a big play-button overlay on a video it won't autoplay — hide it,
   so a paused loop just shows its first frame cleanly (no ugly play symbol). */
.tile__preview::-webkit-media-controls-start-playback-button,
.tile__preview::-webkit-media-controls { display: none !important; -webkit-appearance: none; }

/* The work's name, tucked into the bottom-left CORNER of the photo, shown on
   hover (like our backup — Gui preferred this over the title in the top menu) */
.tile__title {
  position: absolute;
  left: 12px; bottom: 12px;
  z-index: 2;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  text-shadow: 0 0 14px rgba(255, 255, 255, 0.85);  /* keeps it readable on busy photos */
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;     /* clicks still go to the image underneath */
}
.tile:hover .tile__title { opacity: 1; }
.tile__title span { font-weight: 400; }


/* ============================================================
   ABOUT
   ============================================================ */
/* Bio is the landing: text on one side, the DD film on the other */
.about {
  max-width: 1700px;
  margin: 0 auto;
  padding-top: clamp(8px, 2vh, 28px);
  display: flex;
  align-items: flex-start;          /* bio + film start at the top of the page */
  gap: clamp(36px, 6vw, 100px);
}
.about__text { flex: 0 0 auto; width: 360px; max-width: 360px; }
.about p { font-size: clamp(17px, 2.2vw, 21px); line-height: 1.6; }
.about .about__contact { margin-top: 28px; font-size: 15px; line-height: 2; }
.about .about__contact a { border-bottom: 1px solid #d8d8d8; }
.about .about__contact a:hover { border-bottom-color: var(--ink); }

/* The film beside the bio (silent loop; click opens the full film) */
/* cap the width so the 3:2 height never exceeds the viewport (no bottom crop) */
.about__film { flex: 1 1 auto; max-width: calc(80vh * 1.5); display: block; cursor: pointer; }
.about__film video {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  background: #000;
  transition: opacity 0.3s ease;
}
.about__film:hover video { opacity: 0.92; }
/* small credit line under the landing film */
.about__film-cap {
  margin-top: 10px;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.about__film-cap span { color: var(--muted); }

@media (max-width: 760px) {
  .about { flex-direction: column; align-items: stretch; }
  .about__text { width: auto; max-width: 100%; }
}


/* ============================================================
   PROJECT OVERLAY (fades in over everything)
   ============================================================ */
.project {
  position: fixed; inset: 0; z-index: 100;
  background: var(--paper);
  overflow-y: auto;
  opacity: 0; visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}
.project.is-open { opacity: 1; visibility: visible; }

.project__bar {
  position: sticky; top: 0;
  display: flex; gap: 28px; justify-content: center;
  padding: 18px;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(6px);
  font-weight: 700; font-size: 14px;
}
.project__nav { transition: opacity 0.2s ease; }
.project__nav:hover { opacity: 0.5; }
.project__nav:disabled { opacity: 0.25; cursor: default; }

.project__body {
  max-width: 1000px;
  margin: 0 auto;
  padding: 30px var(--pad) 80px;
}
.project__body h2 {
  font-size: 15px; font-weight: 700; letter-spacing: 0.02em;
  text-align: center; margin-bottom: 30px;
}

/* A film inside a project keeps a 16:9 frame */
.project__video {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background: #000; margin-bottom: 28px;
}
.project__video iframe, .project__video video {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}

/* The image series — stacked, full width, generous spacing */
.project__img { margin-bottom: 22px; height: auto; }

/* A "work-showing" screen recording inside a project — full width, looping */
.project__doc { width: 100%; height: auto; margin-bottom: 22px; background: #000; }

/* A single photo, opened large — centred, fits the screen, never cropped */
.project__img--single {
  margin: 0 auto;
  width: auto;
  max-width: 100%;
  max-height: 88vh;
  object-fit: contain;
}
/* the photo's series name, shown under it when opened (the "smart" reveal) */
.photo-cap {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* Tile caption: hidden on desktop (hover puts the title in the menu).
   On mobile there's no hover, so reveal it under each Research tile. */
.tile__label { display: none; }
@media (max-width: 620px) {
  .gallery--research .tile__label {
    display: block;
    margin-top: 8px;
    font-size: 13px;
    letter-spacing: 0.02em;
    color: var(--ink);
  }
}
