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

body {
  font-family: 'Inter', sans-serif;
  background: #fff;
  color: #111;
}

/* ─── Fullscreen photo overlay (scroll-stop) ──────────── */

#fs-overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  overflow: hidden;
}

#fs-overlay[hidden] { display: none; }

#fs-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

@keyframes fsGlitch {
  0%   { clip-path: inset(0 0 96% 0); transform: translateX(-12px); }
  9%   { clip-path: inset(50% 0 42% 0); transform: translateX(14px); }
  18%  { clip-path: inset(80% 0 4% 0); transform: translateX(-8px); }
  27%  { clip-path: inset(10% 0 76% 0); transform: translateX(10px); }
  36%  { clip-path: inset(62% 0 20% 0); transform: translateX(-6px); }
  45%  { clip-path: inset(0 0 0 0); transform: translateX(6px); }
  54%  { clip-path: inset(36% 0 54% 0); transform: translateX(-8px); }
  63%  { clip-path: inset(0 0 0 0); transform: translateX(3px); }
  72%  { clip-path: inset(0 0 0 0); transform: translateX(-1px); }
  82%  { clip-path: inset(0 0 0 0); transform: translateX(0); }
  100% { clip-path: inset(0 0 0 0); transform: translateX(0); }
}

#fs-bg.glitch-anim {
  animation: fsGlitch 0.48s steps(1) forwards;
}

#fs-dim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.18);
}

/* ─── Header ─────────────────────────────────────────── */

header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 40px;
  position: relative;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: baseline; /* o nome alinha com os filtros; o subtítulo desce */
  gap: 32px;
}

header h1 {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #111;
  white-space: nowrap;
  line-height: 1.25;
}

.social-links {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: calc(1.02rem * 1.25); /* mantém os ícones na linha do nome */
}

.social-links a,
#share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888;
  text-decoration: none;
  transition: color 0.15s;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.social-links a:hover,
#share-btn:hover {
  color: #111;
}

/* Toast de confirmação */
#share-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #111;
  color: #fff;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  padding: 8px 18px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 2000;
}

#share-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Filtros ─────────────────────────────────────────── */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 22px;
}

.filter-btn {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 400;
  color: #888;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}

.filter-btn:hover { color: #333; }

.filter-btn.active {
  color: #111;
  font-weight: 500;
}

/* ─── Dropdowns ───────────────────────────────────────── */

.dropdown {
  position: relative;
}

.dropdown-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 400;
  color: #888;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
  white-space: nowrap;
}

.dropdown-btn:hover { color: #333; }

.dropdown-btn.has-active {
  color: #111;
  font-weight: 500;
}

.dropdown-btn .chevron {
  width: 12px;
  height: 12px;
  transition: transform 0.15s;
  flex-shrink: 0;
}

.dropdown.open .chevron { transform: rotate(180deg); }

.dropdown-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #FFE600;
  color: #111;
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 17px;
  height: 17px;
  border-radius: 8px;
  padding: 0 4px;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  min-width: 150px;
  z-index: 100;
  overflow: hidden;
}

.dropdown.open .dropdown-menu { display: block; }

/* Menu único com as categorias aninhadas */
.filters-menu {
  min-width: 190px;
  max-height: min(70vh, 460px);
  overflow-y: auto;
  padding: 4px 0;
}

.dropdown-group + .dropdown-group {
  border-top: 1px solid #f0f0f0;
  margin-top: 4px;
  padding-top: 4px;
}

.dropdown-group-title {
  font-size: 0.63rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #bbb;
  padding: 6px 16px 4px;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 16px;
  font-size: 0.8rem;
  color: #555;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.dropdown-item:hover { background: #f5f5f5; color: #111; }

.dropdown-item .box {
  width: 13px;
  height: 13px;
  border: 1px solid #ccc;
  border-radius: 3px;
  flex-shrink: 0;
  position: relative;
  transition: background 0.1s, border-color 0.1s;
}

.dropdown-item.active {
  color: #111;
  font-weight: 500;
}

.dropdown-item.active .box {
  background: #111;
  border-color: #111;
}

.dropdown-item.active .box::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 3px;
  height: 7px;
  border-right: 1.5px solid #fff;
  border-bottom: 1.5px solid #fff;
  transform: rotate(45deg);
}

/* ─── Setas da galeria ────────────────────────────────── */

.gallery-nav {
  position: fixed;
  top: calc(57px + (100vh - 57px) / 2);
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #aaa;
  padding: 16px;
  z-index: 15;
  transition: color 0.2s, opacity 0.2s;
}

.gallery-nav:hover { color: #555; }

.gallery-prev { left: 4px; }
.gallery-next { right: 4px; }

.gallery-nav.hidden { opacity: 0; pointer-events: none; }

/* ─── Galeria ─────────────────────────────────────────── */

main {
  overflow-x: scroll;
  overflow-y: hidden;
  height: calc(100vh - 57px);
  padding: 0;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.gallery {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 0;
  height: 100%;
  width: max-content;
}

.gallery-item {
  flex-shrink: 0;
  border-radius: 0;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  width: 100vw;
  padding-bottom: 28px;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  overflow: hidden;
}

.gallery-item img {
  height: calc((100vh + 335px) / 2);
  width: auto;
  display: block;
  border-radius: 0;
  transition: opacity 0.2s;
  -webkit-user-drag: none;
  user-select: none;
}

.photo-wrapper {
  position: relative;
  display: inline-block;
  line-height: 0;
}

/* Escudo transparente sobre as imagens */
.img-shield {
  position: absolute;
  inset: 0;
  z-index: 1;
  cursor: pointer;
  -webkit-user-drag: none;
}

/* Escudo no visualizador — posicionado sobre a foto */
.viewer-img-shield {
  position: absolute;
  cursor: default;
  pointer-events: all;
}


.gallery-item-caption { display: none; }

/* ─── Modo grid (filtro ativo) ────────────────────────── */

body.grid-mode {
  background: #fff;
}

body.grid-mode main {
  overflow-x: hidden;
  overflow-y: auto;
  height: calc(100vh - 57px);
  scroll-snap-type: none;
  padding: 12px;
  background: #fff;
}

body.grid-mode .gallery {
  display: block;
  columns: 3;
  column-gap: 8px;
  width: 100%;
  height: auto;
}

body.grid-mode .gallery-item {
  display: block;
  break-inside: avoid;
  margin-bottom: 8px;
  width: 100%;
  height: auto;
  padding-bottom: 0;
  scroll-snap-align: none;
  scroll-snap-stop: normal;
  overflow: hidden;
  border-radius: 4px;
  background: transparent;
}

body.grid-mode .gallery-item img {
  width: 100%;
  height: auto;
  max-height: none;
  /* Sem isto a altura é zero antes de carregar, o item nunca entra na
     viewport, o loading=lazy nunca dispara e a imagem nunca carrega. O
     "auto" faz a proporção real substituir esta assim que ela existir. */
  aspect-ratio: auto 3 / 4;
  background: #f4f4f4;
}

body.grid-mode .photo-wrapper {
  width: 100%;
  display: block;
}

body.grid-mode .gallery-nav { display: none; }

/* Transição suave entre modos */
main {
  transition: background 0.25s;
}

.empty {
  text-align: center;
  color: #aaa;
  padding: 100px 20px;
  font-size: 0.85rem;
  line-height: 1.8;
  grid-column: 1 / -1;
}

.empty code {
  font-family: monospace;
  background: #f4f4f4;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.82rem;
}

/* ─── Visualizador ────────────────────────────────────── */

.viewer {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer[hidden] {
  display: none;
}

/* Topo do viewer */
.viewer-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 18px 40px;
  z-index: 10;
}

.viewer-title {
  font-size: 0.93rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #111;
  text-decoration: none;
  white-space: nowrap;
}

.viewer-title:hover { opacity: 0.6; }

.viewer-controls {
  display: flex;
  gap: 14px;
  align-items: center;
}

/* Botões do viewer-top: mesmo estilo dos ícones do header */
.viewer-top .viewer-controls button {
  background: none;
  border: none;
  width: auto;
  height: auto;
  border-radius: 0;
  padding: 0;
  color: #888;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
  box-shadow: none;
}

.viewer-top .viewer-controls button:hover {
  border-color: transparent;
  color: #111;
}

.viewer-counter {
  font-size: 0.75rem;
  color: #555;
  letter-spacing: 0.04em;
}

.viewer-controls {
  display: flex;
  gap: 4px;
}

.viewer-controls button {
  background: none;
  border: 1px solid #ddd;
  color: #888;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}

.viewer-controls button:hover {
  border-color: #aaa;
  color: #111;
}

/* Conteúdo */
.viewer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 90vw;
  padding-top: 50px;
  padding-bottom: 10px;
}

.viewer-img {
  max-width: 100%;
  max-height: calc(100vh - 160px);
  object-fit: contain;
  display: block;
}

/* Textos e setas ficam brancos quando a foto preenche a tela */
body.fs-open header h1,
body.fs-open .filter-btn,
body.fs-open .dropdown-btn,
body.fs-open .social-links a,
body.fs-open #share-btn,
body.fs-open .gallery-nav {
  color: #fff;
  transition: color 0.4s;
}

/* Info da foto */
.viewer-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 14px;
  font-size: 0.73rem;
  color: #888;
  letter-spacing: 0.03em;
  text-align: center;
}

.viewer-info .info-filename {
  color: #111;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Setas de navegação */
.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: #ccc;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  z-index: 10;
}

.nav-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.18);
  color: #fff;
}

.nav-btn:disabled {
  opacity: 0.2;
  cursor: default;
}

.nav-btn.prev { left: 18px; }
.nav-btn.next { right: 18px; }

/* ─── Responsivo ──────────────────────────────────────── */

@media (max-width: 768px) {
  /* Header — alinhado à esquerda, igual ao desktop */
  header {
    flex-direction: column;
    align-items: flex-start;
    padding: 20px 20px 14px;
    gap: 10px;
  }

  .header-left {
    display: contents;
  }

  .brand {
    order: 1;
    text-align: left;
  }

  header h1 {
    /* 1.4× do desktop, mas encolhe se o nome não couber na largura da tela */
    font-size: min(calc(1.02rem * 1.4), calc(6vw - 2.5px));
  }

  .social-links {
    order: 2;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 18px;
  }

  .social-links a {
    color: #666;
  }

  .admin-link {
    display: none;
  }

  .filters {
    order: 3;
    justify-content: flex-start;
    gap: 0 16px;
  }


  /* Esconder navegação desktop */
  .gallery-nav { display: none; }

  /* Main - scroll vertical */
  main {
    overflow-x: hidden;
    overflow-y: scroll;
    height: calc(100vh - 90px);
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
  }

  /* Gallery - coluna */
  .gallery {
    flex-direction: column;
    width: 100%;
    height: auto;
    padding: 0;
    gap: 0;
    align-items: center;
  }

  /* Item = tela inteira */
  .gallery-item {
    width: 100vw;
    height: calc(100vh - 90px);
    padding: 0 0 32px 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  /* Foto */
  .photo-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .gallery-item img {
    height: auto;
    max-height: 62vh;
    max-width: 88vw;
    width: auto;
  }

  /* Viewer */
  .viewer-content { max-width: calc(100vw - 40px); }
}
