/* ==========================================================================
   1. ESTRUTURA DO ARQUIVO 3D (GAVETA)
   ========================================================================== */
.archive-hero {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  height: 85svh;
  justify-content: end;
  align-content: center;
  user-select: none;
}

section:last-of-type {
  padding: 0 !important;
}

.archive-links-container {
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  width: 80vw;
  padding-bottom: 3rem;
  border: 1px solid black;
  -webkit-transform: perspective(40vw) rotateX(5deg) scale(0.97);
  transform: perspective(40vw) rotateX(5deg) scale(0.97);
}

.archive-front-container {
  backface-visibility: hidden;
  margin-top: -1.5rem;
  -webkit-transform: perspective(40vw) rotateX(-10deg) scale(1);
  transform: perspective(40vw) rotateX(-10deg) scale(1);
  pointer-events: none;
}

.archive-front-top {
  height: 1rem;
  width: 80vw;
  background-color: #ffffff;
  border: 1px solid black;
  border-bottom: none;
  -webkit-transform: perspective(40vw) rotateX(15deg) scale(0.997);
  transform: perspective(40vw) rotateX(15deg) scale(0.997);
}

.archive-front {
  height: 10svh;
  width: 80vw;
  background-color: white;
  z-index: 99;
  border: 1px solid black;
  border-bottom: 0;
}

/* ==========================================================================
   2. AS ABAS E BOTÕES (COM RESET NATIVO E VARIÁVEIS NUNJUCKS)
   ========================================================================== */
.archive-link {
  display: flex;
  flex-direction: column;
  width: 79vw;
  margin: 0 auto;
  -webkit-transform: perspective(40vw) rotateX(-15deg);
  transform: perspective(40vw) rotateX(-15deg);
  pointer-events: none;
}

/* A BASE DA TAG (Serve tanto para o botão em cima quanto para a div estática embaixo) */
.archive-tag-container {
  position: relative;
  width: fit-content;
  max-height: 2rem;
  justify-self: start;
  margin-left: 2vw; /* Devolve a margem lateral da pasta aberta para ela não grudar na borda */
}

/* O COMPORTAMENTO DO BOTÃO (Exclusivo para as abas interativas do arquivo 3D) */
button.archive-tag-container {
  appearance: none;
  -webkit-appearance: none;
  background: transparent !important;
  border: none;
  padding: 0;
  margin: 0;
  margin-top: 1rem;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
  display: block;
  width: 100%;
  opacity: 1 !important;
  outline: none;
  box-shadow: none;
  margin-left: var(--tab-offset);
  pointer-events: auto;
  z-index: 10;
}

.archive-tag-container,
.archive-tag-small,
.archive-tag {
  min-width: 180px;
  max-width: 15%;
}

.archive-tag {
  background: #181818;
  height: 2rem;
  clip-path: polygon(0 100%, 0 30%, 7% 0, 93% 0, 100% 30%, 100% 100%);
}

.archive-tag-small {
  position: absolute;
  background: white;
  width: auto;
  height: auto;
  top: 2px;
  left: 0px;
  right: 0px;
  bottom: -5px;
  clip-path: polygon(0 100%, 0 30%, 7% 1%, 93% 1%, 100% 30%, 100% 100%);
  scale: 0.99;
  z-index: 3;
}

.archive-tag-year {
  position: absolute;
  left: 1.5rem;
  top: 0.5rem;
  font-weight: 400;
  z-index: 4;

  /* Correção de Nitidez 3D */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transform: translateZ(1px);
  backface-visibility: hidden;
  text-shadow: 0 0 1px rgba(0, 0, 0, 0.05);
}

.line {
  height: 2px;
  background: black;
}

.line-empty {
  height: 1px;
  margin-top: 3rem;
}

#archive-link-empty {
  margin-left: 14vw;
  z-index: 5;
}

/* ==========================================================================
   3. TRANSIÇÕES E ESTADOS DE HOVER
   ========================================================================== */
.archive-tag,
.archive-tag-small,
.archive-tag-year,
.line {
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (hover: hover) and (pointer: fine) {
  .archive-link button.archive-tag-container:hover .archive-tag,
  .archive-link button.archive-tag-container:hover .archive-tag-small,
  .archive-link button.archive-tag-container:hover .archive-tag-small + .archive-tag-year,
  .archive-link button.archive-tag-container:hover + .line {
    transform: translateY(-2rem);
  }
}

/* ==========================================================================
   4. ESTADOS DA PASTA (SHEETS) PELO JAVASCRIPT
   ========================================================================== */
.archive-sheets-container {
  display: flex;
  flex-direction: column;
  position: relative;
  margin-top: 0;
  gap: 10svh;
}

.archive-sheet {
  height: 0;
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
  pointer-events: none;
  margin-top: 0;
  transition: opacity 0.5s ease;
}

.archive-sheet.is-open {
  height: auto;
  opacity: 1;
  visibility: visible;
  overflow: visible;
  pointer-events: auto;
  margin: 10svh 0;
}

/* ==========================================================================
   5. MASONRY GRID E IMAGENS
   ========================================================================== */
.archive-item-container {
  border: 1px solid black;
  border-top: 3px solid black;
  width: 80vw !important;
  column-count: 4;
  column-gap: 0;
}

.archive-item {
  width: 100% !important;
  padding: 1.5rem;
  display: block;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
}

.archive-item a {
  display: block;
  width: 100%;
  overflow: hidden;
}
.archive-item a picture,
.archive-item a img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.archive-img {
  width: 100%;
  height: auto;
  display: block;
}

.archive-item a:hover {
  text-decoration: none;
}

/* ==========================================================================
   6. BOTÃO DE RETORNO (GLASSMORPHISM)
   ========================================================================== */
.close-folder-btn {
  position: fixed;
  bottom: 8svh;
  right: 10vw;

  background-color: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 0, 0, 0.05);
  color: #000;
  padding: 1rem 1.5rem;
  font-size: var(--fs-0);
  text-transform: uppercase;
  font-weight: 400;
  letter-spacing: 1px;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 10px 30px 0 rgba(0, 0, 0, 0.05);
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition:
    opacity 0.4s ease,
    transform 0.4s ease,
    background-color 0.2s ease,
    backdrop-filter 0.2s ease;
}

.close-folder-btn.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

@media (hover: hover) and (pointer: fine) {
  .close-folder-btn:hover {
    background-color: rgba(255, 255, 255, 0.95);
    color: #000;

    text-decoration: line-through;
  }
}

/* ==========================================================================
   COMPENSAÇÃO DE PERSPECTIVA 3D (BOTÕES MAIORES E MAIS NÍTIDOS)
   ========================================================================== */
button.archive-tag-container {
  max-height: 2.8rem; /* Aumenta o limite de altura da aba */
}

button.archive-tag-container,
button.archive-tag-container .archive-tag-small,
button.archive-tag-container .archive-tag {
  min-width: 230px; /* Alarga para caber textos grandes como Identidade Visual */
  max-width: 35%; /* Libera o limite que estava apertando a tag */
}

button.archive-tag-container .archive-tag {
  height: 2.8rem; /* Aumenta a altura física antes da redução do 3D */
}

button.archive-tag-container .archive-tag-year {
  font-size: 1.1rem; /* Fonte reduzida para um tamanho mais elegante */
  top: 0.75rem;
  left: 1.5rem; /* Alinhamento movido para a esquerda */
  right: auto; /* Limpa qualquer resquício do alinhamento anterior */
}

/* ==========================================================================
   7. RESPONSIVIDADE (MOBILE OVERRIDES)
   ========================================================================== */
@media (max-width: 1000px) {
  .archive-sheets-container {
    margin-top: -12svh;
    gap: 10svh;
  }
  #archive-link-empty {
    margin-left: 26vw;
  }

  /* Variável Dinâmica de Espaçamento para o Botão */
  button.archive-tag-container,
  button.archive-tag-container .archive-tag-small,
  button.archive-tag-container .archive-tag,
  .archive-tag-container,
  .archive-tag-small,
  .archive-tag {
    min-width: 120px;
    max-width: 35%;
  }

  /* Devolve a altura normal no celular */
  button.archive-tag-container .archive-tag {
    height: 2rem;
  }

  button.archive-tag-container .archive-tag-year,
  .archive-tag-year,
  .archive-tag-year .zero {
    left: 0.8rem; /* Alinhamento à esquerda com respiro para telas finas */
    right: auto;
    top: 0.5rem;
    font-size: var(--fs-0);
  }

  button.archive-tag-container {
    margin-left: var(--tab-offset-mobile);
  }

  .archive-hero {
    padding-bottom: 12svh;
  }
  .archive-sheet.is-open {
    margin-top: 10svh;
  }
  .archive-item {
    padding: 1rem;
  }
  .archive-item a div {
    display: none;
  }
  .archive-links-container {
    width: 75vw;
    align-self: center;
    padding-bottom: 2rem;
  }
  .archive-link {
    width: 72vw;
  }
  .archive-front-container {
    margin-top: -1rem;
  }

  .archive-front-top {
    -webkit-transform: perspective(40vw) rotateX(15deg) scale(0.991);
    transform: perspective(40vw) rotateX(15deg) scale(0.991);
  }

  .archive-tag-container,
  .archive-tag-small,
  .archive-tag {
    min-width: 120px;
    max-width: 30%;
  }

  .archive-tag-year,
  .archive-tag-year .zero {
    right: 0.6rem;
    font-size: var(--fs-0);
  }

  .archive-item-container {
    column-count: 2;
  }
}

@media (max-width: 600px) {
  .archive-item-container {
    column-count: 1;
  }
}

@media (min-width: 2500px) {
  .archive-item-container {
    column-count: 5;
  }
}
