/* ---------- Tokens ---------- */
:root {
  --bg: #0e0e0f;
  --surface: #18181a;
  --line: #2a2a2d;
  --text: #f2efe9;
  --muted: #a09c94;
  --accent: #d9b77e;
  --accent-ink: #1a1408;
  --gap: 4px;
  --pad: 14px;
  --radius: 3px;
  color-scheme: dark;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (min-width: 700px)  { :root { --gap: 6px; --pad: 28px; } }
@media (min-width: 1100px) { :root { --pad: 40px; } }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
h1, h2 { font-family: var(--serif); font-weight: 500; line-height: 1.1; margin: 0; }
h2 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.skip {
  position: absolute; left: -999px; top: 8px; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: var(--radius);
}
.skip:focus { left: 8px; }

.eyebrow {
  margin: 0 0 8px;
  font-size: .75rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 22px;
  border: 1px solid var(--line); border-radius: 999px;
  font-weight: 500; font-size: .9375rem;
  transition: border-color .2s, background .2s, color .2s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { color: var(--accent-ink); filter: brightness(1.08); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px var(--pad);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--serif); font-size: 1.375rem; font-weight: 600; line-height: 1; white-space: nowrap; }
.brand span {
  display: block; margin-top: 3px;
  font: 500 .625rem var(--sans); letter-spacing: .22em; text-transform: uppercase; color: var(--muted);
}
.nav { display: flex; align-items: center; gap: 4px; font-size: .9375rem; }
.nav a { padding: 10px 12px; border-radius: 999px; color: var(--muted); transition: color .2s; }
.nav a:hover { color: var(--text); }
/* No celular o "Portfólio" sai (a galeria já é o começo da página) e o
   "Instagram" continua, como um botão discreto. */
@media (max-width: 480px) {
  .nav a[href="#portfolio"] { display: none; }
  .nav a[href="#instagram"] { color: var(--text); border: 1px solid var(--line); padding: 7px 14px; font-size: .875rem; }
}

/* Área de toque de 44 px em telas de toque, sem mudar o tamanho visível */
@media (pointer: coarse) {
  .chip, .btn-sm, .lb-link, .nav a { position: relative; }
  .chip::after, .btn-sm::after, .lb-link::after, .nav a::after {
    content: ""; position: absolute; left: -2px; right: -2px;
    top: 50%; height: 44px; transform: translateY(-50%);
  }
}

/* ---------- Filtros ---------- */
/* Fixos logo abaixo do topo ao rolar (--topbar-h é medido no JS) */
.filters {
  position: sticky; top: var(--topbar-h, 60px); z-index: 15;
  display: flex; gap: 8px;
  padding: 10px var(--pad);
  overflow-x: auto; scrollbar-width: none;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
}
.filters:empty { display: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 34px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: none; color: var(--muted);
  font: 500 .8125rem var(--sans); cursor: pointer;
  transition: all .2s;
}
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip .count { margin-left: 6px; font-size: .75rem; opacity: .8; font-variant-numeric: tabular-nums; }

/* ---------- Galeria em linhas justificadas ----------
   Cada foto mantém a proporção real (--r = largura/altura): verticais em pé,
   panorâmicas deitadas. As fotos de cada linha crescem juntas até preencher
   a largura toda, então não sobram buracos. */
.mosaic {
  --row: 110px;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 3px;
}
@media (min-width: 600px)  { .mosaic { --row: 150px; } }
@media (min-width: 900px)  { .mosaic { --row: 180px; } }
@media (min-width: 1300px) { .mosaic { --row: 210px; } }
/* "Mola" invisível no fim: a última linha fica no tamanho natural em vez de
   esticar (esticar cortaria as fotos em cima e embaixo). */
.mosaic::after { content: ""; flex: 1000000 1 0; }

.tile {
  flex: calc(var(--r, 1.5) * 1000) 1 calc(var(--r, 1.5) * var(--row));
  aspect-ratio: var(--r, 1.5);
  position: relative; overflow: hidden;
  padding: 0; border: 0; border-radius: 0;
  background: var(--surface); color: #fff;
  cursor: zoom-in; text-align: left;
}

/* Fotos abaixo da primeira tela surgem suavemente ao entrar na tela */
.tile.reveal { opacity: 0; transform: translateY(18px); }
.tile.reveal.in { opacity: 1; transform: none; transition: opacity .7s ease, transform .7s cubic-bezier(.2, .7, .2, 1); }

/* Esqueleto enquanto a primeira visita carrega a lista de fotos */
.tile.skeleton {
  cursor: default;
  background: linear-gradient(100deg, var(--surface) 30%, #232326 50%, var(--surface) 70%);
  background-size: 300% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -200% 0; } }

.tile img {
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transform: scale(1.03);
  transition: opacity .6s ease, transform .8s cubic-bezier(.2, .7, .2, 1);
}
.tile img.loaded { opacity: 1; transform: none; }
.tile:hover img.loaded, .tile:focus-visible img.loaded { transform: scale(1.05); }

.tile-info {
  position: absolute; inset: auto 0 0 0;
  display: flex; flex-direction: column; gap: 2px;
  padding: 32px 10px 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .7));
  opacity: 0; transform: translateY(6px);
  transition: opacity .3s, transform .3s;
  pointer-events: none;
}
.tile:hover .tile-info, .tile:focus-visible .tile-info { opacity: 1; transform: none; }
.tile-info strong { font: 500 1rem/1.2 var(--serif); }
.tile-info small { font-size: .6875rem; letter-spacing: .14em; text-transform: uppercase; opacity: .8; }
@media (hover: none) { .tile-info { display: none; } }

.empty { padding: 48px var(--pad); color: var(--muted); text-align: center; }

/* ---------- Rodapé / Instagram ---------- */
.footer { background: var(--surface); border-top: 1px solid var(--line); padding-top: clamp(32px, 6vw, 56px); }
/* Mesmo estilo do nome no topo (.brand): nome em serifa e legenda pequena embaixo */
.insta-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 var(--pad) 14px;
}
.insta-head .brand { margin: 0; }
.insta-head .brand a:hover { color: var(--accent); }
.btn-sm { min-height: 36px; padding: 0 16px; font-size: .875rem; }

/* Mesmo visual da galeria: linhas justificadas de ponta a ponta, proporção real
   de cada publicação (--r é medido quando a imagem carrega). Sem "mola": com
   poucas publicações a linha preenche a largura toda. */
/* Computador: as 6 publicações sempre numa única linha (nunca sobra uma sozinha
   e gigante embaixo). Celular: grade 3×2 de quadrados iguais. */
.insta-grid {
  --row: 150px;
  display: flex; flex-wrap: nowrap;
  gap: 3px; padding: 3px;
}
@media (min-width: 900px)  { .insta-grid { --row: 180px; } }
@media (min-width: 1300px) { .insta-grid { --row: 210px; } }
.insta-grid .insta-item { min-width: 0; }
@media (max-width: 699px) {
  .insta-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
  .insta-grid .insta-item { aspect-ratio: 1; }
}

.insta-item {
  flex: calc(var(--r, 1) * 1000) 1 calc(var(--r, 1) * var(--row));
  aspect-ratio: var(--r, 1);
  position: relative; overflow: hidden;
  background: var(--bg);
}
.insta-item img {
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transform: scale(1.03);
  transition: opacity .6s ease, transform .8s cubic-bezier(.2, .7, .2, 1);
}
.insta-item img.loaded { opacity: 1; transform: none; }
.insta-item:hover img.loaded, .insta-item:focus-visible img.loaded { transform: scale(1.05); }
.insta-item { cursor: zoom-in; }

.footer-bottom {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px;
  padding: 24px var(--pad);
  color: var(--muted); font-size: .8125rem;
}
.footer-bottom a:hover { color: var(--text); }
.about { flex-basis: 100%; margin: 0 0 4px; font: italic 500 1.0625rem var(--serif); color: var(--text); }

/* ---------- Lightbox ---------- */
.lightbox {
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; overflow: hidden;
  background: #08080a; color: #fff;
}
/* Fundo: a própria foto, bem desfocada e escurecida */
.lb-bg {
  position: absolute; inset: -60px; z-index: 0;
  background: center / cover no-repeat var(--lb-img, none);
  filter: blur(40px) saturate(1.2) brightness(.35);
}
.lightbox figure { position: relative; z-index: 1; transition: transform .25s ease, opacity .25s ease; }
.lightbox figure.swiping { transition: none; }
.lightbox[open] { display: grid; place-items: center; animation: fade .25s ease; }
.lightbox::backdrop { background: #000; }
@keyframes fade { from { opacity: 0; } }

.lightbox figure {
  margin: 0; max-width: 100vw;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 56px 12px 16px;
}
.lightbox img { max-width: 100%; max-height: calc(100dvh - 130px); object-fit: contain; border-radius: 2px; }
/* O quadro já abre no tamanho final; a versão grande entra por cima com fade */
.lb-frame { position: relative; }
.lb-frame #lb-img { display: block; }
#lb-full {
  position: absolute; inset: 0; width: 100%; height: 100%; max-height: none;
  opacity: 0; transition: opacity .35s ease;
}
#lb-full.on { opacity: 1; }
.lightbox figcaption {
  display: flex; justify-content: space-between; gap: 24px; width: 100%;
  font-size: .875rem; color: rgba(255, 255, 255, .7);
}
#lb-title { font: 500 1.125rem var(--serif); color: #fff; }
#lb-title small {
  margin-left: 10px; font: 500 .6875rem var(--sans); letter-spacing: .16em;
  text-transform: uppercase; color: var(--accent);
}
#lb-title small:only-child { margin-left: 0; }
.lightbox figcaption { align-items: center; }
#lb-title { flex: 1; min-width: 0; }
.lb-link {
  flex: none; display: inline-flex; align-items: center; min-height: 34px; padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, .25); border-radius: 999px;
  font-size: .8125rem; font-weight: 500; color: #fff; white-space: nowrap;
  transition: border-color .2s, color .2s;
}
.lb-link:hover { border-color: var(--accent); color: var(--accent); }

.lb-btn {
  position: fixed; z-index: 2;
  width: 48px; height: 48px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .1); color: #fff;
  font-size: 1.5rem; line-height: 1; cursor: pointer;
  transition: background .2s;
}
.lb-btn:hover { background: rgba(255, 255, 255, .22); }
.lb-close { top: 12px; right: 12px; font-size: 1.125rem; }
.lb-prev, .lb-next { top: 50%; transform: translateY(-50%); }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
@media (max-width: 700px) {
  .lb-prev, .lb-next { top: auto; bottom: 16px; transform: none; }
  .lightbox figure { padding-bottom: 76px; }
  .lightbox img { max-height: calc(100dvh - 190px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
