/* ============ ROME® PORTFOLIO ============ */

@font-face {
  font-family: 'Extenda Peta';
  src: url('../fonts/Extenda-80-Peta-trial.ttf') format('truetype');
  font-weight: 900;
  font-display: block;
}
@font-face {
  font-family: 'Extenda Hecto';
  src: url('../fonts/Extenda-40-Hecto-trial.ttf') format('truetype');
  font-weight: 400;
  font-display: block;
}

:root {
  --bg: #0b0b0b;
  --ink: #f2efe9;
  --tile: #141414;
  --line: #2a2a2a;
  --muted: #8a8a8a;
  --accent: var(--ink); /* destaque no mesmo tom do título */
  --display: 'Extenda Peta', sans-serif;
  --text: 'Extenda Hecto', sans-serif;
}
[data-theme="light"] {
  --bg: #f2efe9;
  --ink: #0f0e0c;
  --tile: #e4e0d6;
  --line: #d6d1c4;
  --muted: #7a766c;
}

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

/* a trial da Extenda desenha algarismos como pontos — números usam mono de timecode */
.mono, .loader__tc, .chapter__num {
  font-family: 'SF Mono', 'Menlo', 'Courier New', monospace;
}

html { background: var(--bg); }
html.has-smooth, html.has-smooth body { overscroll-behavior: none; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--text);
  text-transform: uppercase;
  letter-spacing: .04em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background .5s ease, color .5s ease;
}

::selection { background: var(--ink); color: var(--bg); }

.has-smooth .smooth {
  position: fixed;
  top: 0; left: 0; width: 100%;
  will-change: transform;
}

/* ---------- PRELOADER ---------- */
.loader {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2rem;
  transition: transform .9s cubic-bezier(.76, 0, .24, 1);
}
.loader.done { transform: translateY(-101%); }
.loader__logo {
  font-family: var(--display);
  font-size: clamp(5rem, 24vw, 24rem);
  line-height: .8;
  animation: pulse 1.4s ease-in-out infinite alternate;
}
@keyframes pulse { from { opacity: .25; } to { opacity: 1; } }
.loader__tc {
  font-size: .8rem; letter-spacing: .3em; color: var(--ink);
}
.loader__bar {
  width: min(320px, 60vw); height: 1px; background: var(--line);
}
.loader__bar span {
  display: block; height: 100%; width: 0%;
  background: var(--ink);
  transition: width .3s ease;
}

/* ---------- WIPE (transição de página) ---------- */
.wipe { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.wipe__panel {
  position: absolute; inset: 0;
  transform: translateY(101%);
}
.wipe__panel--accent { background: var(--ink); }
.wipe__panel--dark {
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.wipe__label {
  font-family: var(--display);
  font-size: clamp(3rem, 14vw, 14rem);
  color: var(--ink);
  line-height: .8;
}
.wipe.in .wipe__panel--accent { animation: wipeIn .5s cubic-bezier(.76,0,.24,1) forwards; }
.wipe.in .wipe__panel--dark { animation: wipeIn .5s .08s cubic-bezier(.76,0,.24,1) forwards; }
.wipe.out .wipe__panel--dark { animation: wipeOut .5s cubic-bezier(.76,0,.24,1) forwards; }
.wipe.out .wipe__panel--accent { animation: wipeOut .5s .08s cubic-bezier(.76,0,.24,1) forwards; }
@keyframes wipeIn { from { transform: translateY(101%); } to { transform: translateY(0); } }
@keyframes wipeOut { from { transform: translateY(0); } to { transform: translateY(-101%); } }

/* ---------- GRAIN ---------- */
.grain {
  position: fixed; inset: -100%; z-index: 80; pointer-events: none;
  opacity: .06;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 300 300' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 8s steps(10) infinite;
}
@keyframes grain {
  0%,100% { transform: translate(0,0); } 10% { transform: translate(-5%,-10%); }
  20% { transform: translate(-15%,5%); } 30% { transform: translate(7%,-25%); }
  40% { transform: translate(-5%,25%); } 50% { transform: translate(-15%,10%); }
  60% { transform: translate(15%,0%); } 70% { transform: translate(0%,15%); }
  80% { transform: translate(3%,35%); } 90% { transform: translate(-10%,10%); }
}

/* ---------- HEADER ---------- */
.header {
  position: fixed; z-index: 85;
  top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.25rem 1.5rem;
  mix-blend-mode: difference;
}
.header a { color: #f2efe9; text-decoration: none; }
.header__logo {
  font-family: var(--display);
  font-size: 1.6rem; line-height: 1;
}
.header__logo sup { font-size: .5em; }
.header__nav { display: flex; gap: 2rem; align-items: center; font-size: .75rem; letter-spacing: .18em; }
.header__nav a { position: relative; padding: .25rem 0; }
.header__nav a::after {
  content: ''; position: absolute; left: 0; bottom: 0;
  width: 100%; height: 1px; background: #f2efe9;
  transform: scaleX(0); transform-origin: right;
  transition: transform .4s cubic-bezier(.76,0,.24,1);
}
.header__nav a:hover::after { transform: scaleX(1); transform-origin: left; }
.theme-toggle {
  width: 15px; height: 15px;
  border: 1px solid #f2efe9;
  border-radius: 50%;
  background: linear-gradient(90deg, #f2efe9 50%, transparent 50%);
  cursor: pointer; padding: 0;
  transition: transform .4s cubic-bezier(.76,0,.24,1);
}
.theme-toggle:hover { transform: rotate(180deg); }

/* ---------- HERO ---------- */
.hero {
  min-height: 100svh;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  position: relative;
  padding: 6rem 0 4rem;
}
.hero__logo {
  font-family: var(--display);
  font-size: 27.5vw;
  line-height: .78;
  letter-spacing: 0;
  display: flex;
}
.reveal-letters span {
  display: inline-block;
  transform: translateY(110%);
  transition: transform 1s cubic-bezier(.76,0,.24,1);
}
.reveal-letters { overflow: hidden; }
.revealed.reveal-letters span { transform: translateY(0); }
.reveal-letters span:nth-child(2) { transition-delay: .06s; }
.reveal-letters span:nth-child(3) { transition-delay: .12s; }
.reveal-letters span:nth-child(4) { transition-delay: .18s; }
.reveal-letters span:nth-child(5) { transition-delay: .24s; }
.hero__meta {
  display: flex; gap: 3rem;
  margin-top: 3rem;
  font-size: .75rem; letter-spacing: .25em; color: var(--muted);
}
.hero__scroll {
  position: absolute; bottom: 1.5rem; right: 1.5rem;
  font-size: .7rem; letter-spacing: .3em; color: var(--muted);
  animation: bob 1.6s ease-in-out infinite alternate;
}
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(8px); } }

/* ---------- MARQUEE ---------- */
.marquee { overflow: hidden; width: 100%; margin-top: 4rem; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.marquee__track {
  display: flex; white-space: nowrap;
  animation: marquee 22s linear infinite;
}
.marquee__track span {
  font-family: var(--display);
  font-size: 2rem; line-height: 1.6;
  padding-right: 1rem;
  color: transparent;
  -webkit-text-stroke: 1px var(--muted);
}
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ---------- CAPÍTULOS ---------- */
.chapter { padding: 18vh 0 8vh; }
.chapter__head {
  min-height: 62svh;
  display: flex; flex-direction: column;
  justify-content: center;
  padding: 0 1.5rem;
  position: relative;
}
.chapter__num {
  font-size: .8rem; letter-spacing: .35em; color: var(--accent);
  margin-bottom: 1rem;
}
.chapter__title {
  font-family: var(--display);
  font-size: clamp(4rem, 15.5vw, 17rem);
  line-height: .82;
  display: flex; flex-direction: column;
}
.chapter__title .stroke {
  color: transparent;
  -webkit-text-stroke: 2px var(--ink);
}
.chapter__title span {
  display: block;
  transform: translateY(40%); opacity: 0;
  transition: transform 1s cubic-bezier(.76,0,.24,1), opacity 1s;
}
.chapter__head.revealed .chapter__title span { transform: translateY(0); opacity: 1; }
.chapter__head.revealed .chapter__title span:nth-child(2) { transition-delay: .1s; }

.chapter__note {
  margin-top: 1.4rem;
  font-size: .7rem; letter-spacing: .3em; color: var(--accent);
}

/* ---------- MOSAICO (referência Africa: linhas crescem ao subir) ----------
   Linhas são absolutas com altura FIXA de layout; crescimento e posição são
   100% transform (scale + translateY) pra nunca redimensionar <video> em layout. */
.mosaic {
  position: relative;
  overflow: hidden;
  margin: 6vh 0 10vh;
  min-height: 60vh; /* fallback sem JS; o JS define a altura real por frame */
}
.mrow {
  position: absolute; top: 0; left: 0;
  width: 100%;
  height: 30vh; /* altura base de layout — constante */
  transform-origin: top center;
  will-change: transform;
}
.mrow__track {
  display: flex; gap: 1vh;
  height: 100%;
  width: max-content;
  will-change: transform;
}
.tile {
  position: relative;
  height: 100%;
  aspect-ratio: 16 / 9;
  flex: 0 0 auto;
  overflow: hidden;
  background: var(--tile);
  cursor: pointer;
}
.tile video, .tile img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.tile__label {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 2.2rem .9rem .7rem;
  display: flex; gap: .9rem; align-items: baseline;
  background: linear-gradient(transparent, rgba(0,0,0,.65));
  opacity: 0;
  transition: opacity .45s ease;
  pointer-events: none;
}
.mrow.is-big .tile__label, .tile:hover .tile__label { opacity: 1; }
.tile__title {
  font-family: var(--display);
  font-size: clamp(.95rem, 1.6vw, 1.6rem);
  line-height: 1;
  color: #f2efe9; /* sobre o gradiente escuro do vídeo, em qualquer tema */
}
.tile__tag { font-size: .58rem; letter-spacing: .22em; color: #f2efe9; opacity: .7; font-family: var(--text); }
.tile__title .mono, .lightbox__title .mono { font-size: .55em; letter-spacing: .1em; }

/* ---------- FOOTER ---------- */
.footer {
  min-height: 90svh;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  gap: 2.5rem;
  text-align: center;
  padding: 10vh 1.5rem 12vh;
}
.footer__cta {
  font-family: var(--display);
  font-size: clamp(3rem, 10.5vw, 10.5rem);
  line-height: .85;
  display: flex; flex-direction: column;
  align-items: center;
  text-align: center;
}
.footer__cta .stroke {
  color: transparent;
  -webkit-text-stroke: 2px var(--ink);
}
.footer__cta span {
  display: block;
  transform: translateY(40%); opacity: 0;
  transition: transform 1s cubic-bezier(.76,0,.24,1), opacity 1s;
}
.footer.revealed .footer__cta span { transform: translateY(0); opacity: 1; }
.footer.revealed .footer__cta span:nth-child(2) { transition-delay: .1s; }
.footer.revealed .footer__cta span:nth-child(3) { transition-delay: .2s; }
.footer__contact {
  width: clamp(70px, 9vw, 110px);
  height: clamp(70px, 9vw, 110px);
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink);
  transition: background .35s ease, color .35s ease, transform .35s cubic-bezier(.76,0,.24,1);
}
.footer__contact svg { width: 42%; height: 42%; }
.footer__contact:hover {
  background: var(--ink);
  color: var(--bg);
  transform: rotate(45deg);
}
.footer__meta {
  display: flex; gap: 2.5rem; flex-wrap: wrap; justify-content: center;
  font-size: .7rem; letter-spacing: .25em; color: var(--muted);
}

/* ---------- LIGHTBOX ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 96;
  background: rgba(4,4,4,.96);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .45s ease;
}
.lightbox.open { opacity: 1; pointer-events: auto; }
.lightbox__media {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  transform: scale(.92);
  transition: transform .6s cubic-bezier(.22,1,.36,1);
}
.lightbox.open .lightbox__media { transform: scale(1); }
.lightbox__media video, .lightbox__media img {
  max-width: 94vw; max-height: 88svh;
  width: auto; height: auto;
  display: block;
}
.lightbox { color: #f2efe9; } /* lightbox é sempre escuro, em qualquer tema */
.lightbox__close {
  position: absolute; top: 1.25rem; right: 1.5rem; z-index: 2;
  background: none; border: none;
  color: #f2efe9; font-family: var(--text);
  font-size: .8rem; letter-spacing: .25em;
  cursor: pointer; text-transform: uppercase;
  padding: .5rem;
}
.lightbox__close:hover { opacity: .55; }
.lightbox__title {
  position: absolute; left: 1.5rem; bottom: 1.25rem;
  font-family: var(--display);
  font-size: clamp(1.2rem, 3vw, 2.2rem);
}

/* ---------- MOBILE ---------- */
@media (max-width: 760px) {
  .header__nav { gap: 1rem; font-size: .62rem; }
  .hero__meta { gap: 1.2rem; font-size: .62rem; }
  .tile__label { padding: 1.4rem .6rem .5rem; }
}

/* telas de toque: cortar o que pesa na GPU do celular */
@media (hover: none) {
  /* grain animado + camada 9x maior que a tela = jank; estático resolve */
  .grain { animation: none; inset: 0; opacity: .045; }
  /* mix-blend-mode força recompor a página inteira — usar cor do tema direto */
  .header { mix-blend-mode: normal; }
  .header a { color: var(--ink); }
  .header__nav a::after { background: var(--ink); }
  .theme-toggle {
    border-color: var(--ink);
    background: linear-gradient(90deg, var(--ink) 50%, transparent 50%);
  }
}
