/* ============================================================
   Luiz Henrique Almeida — Portfolio 2026
   Graphite screening room. The work is the only color on the
   page: floating fragments of it fill the hero, the grid shows
   it big, one bone-white pause for the bio, dark close.
   ============================================================ */

:root {
  /* graphite room (default theme) */
  --bg: #1a1a1d;
  --surface: #232327;
  --ink: #f2f0eb;
  --dim: #86847d;
  --line: rgba(242, 240, 235, 0.14);

  --pad: clamp(20px, 4vw, 64px);
  --radius: 14px;
  --font-sans: "Archivo", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

/* bone gallery */
.theme-light {
  --bg: #f2f0eb;
  --surface: #e6e3db;
  --ink: #1a1a1d;
  --dim: #77756c;
  --line: rgba(26, 26, 29, 0.16);
}

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

/* in-page jumps are hand-tweened in main.js (ease-in-out, distance-
   scaled); the native curve isn't tunable and would fight it */

/* iOS Safari won't reliably clip from body alone — it needs the root
   to say so too, or a stray-wide child still scrolls the page */
html { overflow-x: hidden; }

body {
  background: #1a1a1d;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: #f2f0eb; color: #1a1a1d; }
.theme-light ::selection { background: #1a1a1d; color: #f2f0eb; }

a { color: inherit; text-decoration: none; }

video { display: block; }

.mono {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}

/* ---------------- sheets: sections sliding over the pinned hero ----- */

.sheet {
  position: relative;
  background: var(--bg);
  color: var(--ink);
  overflow: clip;
}

.sheet-work {
  z-index: 2;
  /* one step deeper than the hero so the seam reads as depth */
  --bg: #141416;
  --surface: #1f1f23;
}

.about { z-index: 3; }
.site-footer { z-index: 4; }

/* ---------------- header ---------------- */

.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px var(--pad);
  mix-blend-mode: difference;
  color: #f2f0eb;
  transition: transform 0.35s ease;
}

.site-header.hidden { transform: translateY(-110%); }

.wordmark {
  font-variation-settings: "wdth" 125;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.wordmark .reg {
  font-size: 0.5em;
  vertical-align: super;
  font-weight: 500;
}

.site-nav {
  display: flex;
  gap: clamp(16px, 3vw, 40px);
}

.site-nav a {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  position: relative;
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: -4px;
  height: 1px;
  background: currentColor;
  transition: right 0.3s ease;
}

.site-nav a:hover::after,
.site-nav a:focus-visible::after { right: 0; }

/* ---------------- language toggle ---------------- */

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: clamp(10px, 1.5vw, 18px);
  margin-left: clamp(2px, 1vw, 10px);
  border-left: 1px solid rgba(242, 240, 235, 0.25);
}

.lang-btn {
  background: none;
  border: 0;
  padding: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: inherit;
  opacity: 0.45;
  cursor: pointer;
  transition: opacity 0.25s ease;
}

.lang-btn.is-active { opacity: 1; }

.lang-btn:hover { opacity: 0.8; }
.lang-btn.is-active:hover { opacity: 1; }

.lang-sep {
  font-family: var(--font-mono);
  font-size: 11px;
  opacity: 0.3;
}

/* ---------------- hero (pinned behind the sheets) ---------------- */

.hero {
  position: sticky;
  top: 0;
  z-index: 0;
  min-height: 100svh;
  /* one step lighter than the work sheet it dives under */
  background: #1e1e21;
  display: flex;
}

/* full-bleed background: color/texture already final, played straight */
.hero-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.hero-bg video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-inner {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: calc(var(--pad) + 60px) var(--pad) var(--pad);
}

.hero-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: clamp(20px, 4vh, 48px);
}

.pulse {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.25; transform: scale(0.8); }
}

.hero-title {
  font-variation-settings: "wdth" 125;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.015em;
  line-height: 0.96;
  font-size: clamp(48px, 10.2vw, 168px);
  /* flex items size to their content unless told otherwise: without
     this a headline too wide for the phone widens the page itself */
  min-width: 0;
  max-width: 100%;
  /* keep the headline readable over drifting cards */
  text-shadow: 0 2px 40px rgba(26, 26, 29, 0.55);
}

.hero-title .line {
  display: flex;
  align-items: center;
  gap: 0.14em;
  overflow: hidden;
}

.hero-title .word { white-space: nowrap; }

/* pt-br lines run longer ("pra mexer" vs "move") — one size down.
   The floor has to clear the narrowest phone: at 44px "pra mexer" +
   its chip measured 407px against 350px of usable width, and since
   .hero-title is a flex item it grew to fit instead of shrinking —
   dragging 57px of horizontal scroll across the whole page. */
html:lang(pt-BR) .hero-title { font-size: clamp(28px, 9.2vw, 152px); }

/* "Trabalhos selecionados" is nearly three times the length of
   "Selected work" — the shared floor overshot the phone by 2px */
html:lang(pt-BR) .section-title { font-size: clamp(25px, 7.5vw, 88px); }

.hero-title .line > * {
  animation: rise 0.9s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.hero-title .line:nth-child(1) > * { animation-delay: 0.05s; }
.hero-title .line:nth-child(2) > * { animation-delay: 0.15s; }
.hero-title .line:nth-child(3) > * { animation-delay: 0.25s; }

@keyframes rise {
  from { transform: translateY(110%); }
  to { transform: translateY(0); }
}

/* video chips living inside the headline */
.chip {
  flex: 0 0 auto;
  display: inline-block;
  height: 0.72em;
  aspect-ratio: 21 / 9;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}

.chip video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-top: clamp(24px, 5vh, 56px);
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* ---------------- ticker ---------------- */

.ticker {
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
}

.ticker-track {
  display: flex;
  gap: 48px;
  width: max-content;
  animation: ticker 40s linear infinite;
}

.ticker-track span {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
}

.ticker-track span::after {
  content: "·";
  margin-left: 48px;
  opacity: 0.4;
}

@keyframes ticker {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* ---------------- work grid ---------------- */

.work {
  padding: clamp(64px, 10vh, 140px) var(--pad);
  scroll-margin-top: 40px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: clamp(32px, 5vh, 64px);
}

.section-title {
  font-variation-settings: "wdth" 125;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.015em;
  line-height: 0.92;
  font-size: clamp(36px, 6vw, 88px);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(28px, 4vw, 56px) clamp(16px, 2.5vw, 40px);
}

.tile { grid-column: span 1; }

.tile.featured { grid-column: span 2; }

.tile-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  cursor: pointer;
  will-change: transform;
}

.tile.featured .tile-media { aspect-ratio: 21 / 10; }

.tile-media video,
.tile-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (hover: hover) {
  .tile-media:hover video,
  .tile-media:hover img { transform: scale(1.035); }
}

.tile-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 14px 2px 0;
}

.tile-client {
  font-variation-settings: "wdth" 125;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  font-size: clamp(15px, 1.6vw, 22px);
}

.tile-label { text-align: right; }

/* ---------------- about ---------------- */

.about { padding: clamp(64px, 12vh, 160px) var(--pad); }

.about-eyebrow { margin-bottom: clamp(28px, 5vh, 56px); }

.about-cols {
  display: grid;
  grid-template-columns: minmax(0, 8fr) minmax(0, 3fr);
  gap: clamp(32px, 6vw, 96px);
}

.about-lede {
  font-size: clamp(22px, 3.4vw, 44px);
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.about-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-self: end;
}

.about-list li {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

/* ---------------- footer / contact ---------------- */

.site-footer { padding: clamp(64px, 12vh, 160px) var(--pad) 28px; }

.footer-eyebrow { margin-bottom: 24px; }

.footer-mail {
  display: block;
  font-variation-settings: "wdth" 125;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.015em;
  line-height: 0.92;
  /* Sized so the longest line ("FALAR →") clears the narrowest phone:
     at 16vw it ran 67px past the edge on a 320px screen, and since
     html/body clip overflow that read as the word being chopped off
     rather than as a scroll. 15vw leaves ~20px of slack at 320 for
     Safari's slightly wider metrics. */
  font-size: clamp(46px, 15vw, 240px);
}

.footer-mail-line { display: block; transition: opacity 0.3s ease; }

.footer-mail:hover .footer-mail-line { opacity: 0.55; }

/* typewriter: characters pre-rendered, revealed in place */
.tw-char { opacity: 0; }
.tw-char.on { opacity: 1; }

.tw-caret {
  display: inline-block;
  width: 0.55em;
  height: 0.74em;
  margin-left: 0.06em;
  background: currentColor;
  animation: caret-blink 0.85s steps(1) infinite;
}

@keyframes caret-blink {
  0%, 60% { opacity: 1; }
  61%, 100% { opacity: 0; }
}

.contact-rows {
  margin-top: clamp(40px, 8vh, 88px);
  display: flex;
  flex-direction: column;
}

.contact-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 2px;
  border-top: 1px solid var(--line);
  transition: opacity 0.25s ease;
}

.contact-row:hover { opacity: 0.55; }

.contact-val {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  font-size: clamp(15px, 2vw, 20px);
  letter-spacing: -0.01em;
}

.wa-icon { width: 18px; height: 18px; }

.footer-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
  margin-top: clamp(40px, 8vh, 80px);
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* ---------------- lightbox ----------------
   Resting values below are the closed state. `.is-open` animates in
   over 0.8s landing on a hard ease-out; `.is-closing` snaps back in
   0.42s on a hard ease-in. Timings live on the state classes so each
   direction keeps its own curve. */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 64px);
  color: #f2f0eb;
  background: rgba(18, 18, 20, 0);
  -webkit-backdrop-filter: blur(0px);
  backdrop-filter: blur(0px);
}

.lightbox[hidden] { display: none; }

/* the carousel stage. Slides carry their own translateX, so the
   open/close scale lives here — on the group — or it would clobber
   the carousel's transform. */
.lb-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  transform: scale(0.9);
  opacity: 0;
  will-change: transform;
  touch-action: pan-y;
}

/* The slide takes the media's own shape — --ar comes from the file,
   so nothing is letterboxed. The centre is deliberately short of the
   stage: that surplus is what the gap and the peeks live in. */
.lb-slide {
  --maxw: 66vw;
  --maxh: 72vh;
  position: absolute;
  top: 50%;
  left: 50%;
  aspect-ratio: var(--ar, 1.7778);
  width: min(var(--maxw), calc(var(--maxh) * var(--ar, 1.7778)));
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  will-change: transform;
}

/* a lone piece has no neighbours to make room for */
.lb-stage.is-single .lb-slide { --maxw: 90vw; --maxh: 82vh; }

.lb-slide video,
.lb-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* the peeks wash out to a pale sliver, so a dark clip still reads as
   "there's more over here" */
.lb-slide::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #f2f0eb;
  opacity: 0.7;
  pointer-events: none;
  transition: opacity 0.6s cubic-bezier(0.65, 0, 0.35, 1);
}

.lb-slide.is-active::after { opacity: 0; }

.lb-counter {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  color: #f2f0eb;
  opacity: 0;
  transition: opacity 0.5s ease 0.15s;
  pointer-events: none;
}

.lightbox .lightbox-title,
.lightbox .lightbox-close { opacity: 0; }

/* opening */
.lightbox.is-open {
  background: rgba(18, 18, 20, 0.86);
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
  transition:
    background-color 0.8s cubic-bezier(0.16, 1, 0.3, 1),
    -webkit-backdrop-filter 0.8s cubic-bezier(0.16, 1, 0.3, 1),
    backdrop-filter 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.lightbox.is-open .lb-stage {
  transform: scale(1);
  opacity: 1;
  transition:
    transform 0.8s cubic-bezier(0.19, 1, 0.22, 1),
    opacity 0.45s ease;
}

.lightbox.is-open .lightbox-title,
.lightbox.is-open .lightbox-close,
.lightbox.is-open .lb-counter { opacity: 1; }

/* closing — the dark holds while the player accelerates away, then
   both leave together. A harder ease-in hides the scale entirely:
   the shrink lands after the fade already took the frame. */
.lightbox.is-closing {
  transition:
    background-color 0.42s cubic-bezier(0.5, 0, 0.9, 0.4),
    -webkit-backdrop-filter 0.42s cubic-bezier(0.5, 0, 0.9, 0.4),
    backdrop-filter 0.42s cubic-bezier(0.5, 0, 0.9, 0.4);
}

.lightbox.is-closing .lb-stage {
  transition:
    transform 0.42s cubic-bezier(0.6, 0, 0.85, 0.15),
    opacity 0.18s ease 0.22s;
}

.lightbox-title {
  position: absolute;
  top: 24px;
  left: var(--pad);
  color: #f2f0eb;
  transition: opacity 0.5s ease 0.15s;
}

.lightbox-close {
  position: absolute;
  top: 18px;
  right: var(--pad);
  background: none;
  border: 1px solid rgba(242, 240, 235, 0.3);
  border-radius: 999px;
  color: #f2f0eb;
  padding: 10px 18px;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, opacity 0.5s ease 0.15s;
}

.lightbox-close:hover {
  background: #f2f0eb;
  color: #1a1a1d;
}

/* the cursor pill says Close out here — the button would be noise */
@media (hover: hover) and (pointer: fine) {
  .lightbox-close { display: none; }
}

/* ---------------- custom cursor ----------------
   A small dot that inverts against whatever it crosses
   (difference blend), and morphs into a labeled pill over
   anything interactive — the label rises masked from below. */

@media (hover: hover) and (pointer: fine) {
  * { cursor: none !important; }
}

.cursor {
  position: fixed;
  z-index: 200;
  top: 0; left: 0;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #fff;
  border: 1.5px solid transparent;
  mix-blend-mode: difference;
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition:
    width 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    height 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    background-color 0.3s ease,
    border-color 0.3s ease,
    opacity 0.2s ease;
}

.cursor.badge {
  width: var(--cw, 120px);
  height: var(--ch, 44px);
}

/* Contact block only: plain bone pill, no blend. Difference straddling
   the giant type there splits the label into two inverted halves. */
.cursor.solid {
  mix-blend-mode: normal;
  background: #f2f0eb;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.35);
}

.cursor.ring {
  width: 40px;
  height: 40px;
  background: transparent;
  border-color: #fff;
}

.cursor.off { opacity: 0; }

.cursor-label-wrap { overflow: hidden; width: max-content; }

.cursor-label {
  display: block;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #1a1a1d;
  transform: translateY(130%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) 0.06s;
}

.cursor.badge .cursor-label { transform: translateY(0); }

@media (hover: none), (pointer: coarse) {
  .cursor { display: none; }
}

/* ---------------- scroll reveals ---------------- */

.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.in {
  opacity: 1;
  transform: translateY(0);
}

/* ---------------- responsive ---------------- */

@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; }
  .tile.featured { grid-column: span 1; }
  .tile.featured .tile-media { aspect-ratio: 16 / 9; }
  .about-cols { grid-template-columns: 1fr; }
  .scroll-hint { display: none; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  /* the phone has no room to spend: give the centre the screen and let
     the peeks fall back to a ~22px hint, which the veil keeps legible */
  .lb-slide { --maxw: 80vw; --maxh: 62vh; }
  .lb-stage.is-single .lb-slide { --maxw: 94vw; --maxh: 72vh; }
  .hero-title { font-size: clamp(38px, 11.8vw, 168px); }
  .chip { height: 0.6em; }
  /* balance the tall viewport: status pins under the header */
  .hero-status { margin-bottom: auto; }
  .contact-row { flex-direction: column; align-items: flex-start; gap: 6px; }

}

/* ---------------- reduced motion ---------------- */

@media (prefers-reduced-motion: reduce) {
  .hero-title .line > * { animation: none; }
  .ticker-track { animation: none; }
  .pulse { animation: none; }
  .tile-media video, .tile-media img { transition: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .lightbox, .lb-stage, .lb-slide,
  .lightbox-title, .lightbox-close, .lb-counter { transition: none !important; }
  .lightbox.is-open .lb-stage { transform: none; }
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}
