@layer pages {
  /*
   * The global layout gives content-wrapper children z-index: 1, creating a
   * stacking context that traps the lightbox below the sticky header/mobile
   * nav. Raise only the page shell while this page's lightbox is open.
   */
  body.showcase-lightbox-open .page-shell {
    z-index: var(--z-modal, 1050);
  }

  .showcase__attribution {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 1;
    display: flex;
    max-width: calc(100% - 20px);
    opacity: 1;
    transition: opacity 180ms ease;
  }

  .showcase__creator-link {
    position: relative;
    display: inline-flex;
    box-sizing: border-box;
    min-width: 0;
    min-height: 44px;
    align-items: center;
    padding: 0 10px;
    border-radius: 999px;
    color: #fff;
    text-decoration: none;
    transition: color 140ms ease;
  }

  /* Como na home, o selo ocupa 30px; a área de toque transparente tem 44px. */
  .showcase__creator-link::before {
    position: absolute;
    top: 7px;
    right: 0;
    left: 0;
    height: 30px;
    border: 1px solid transparent;
    border-radius: inherit;
    background: #05040b;
    content: '';
    transition: background-color 140ms ease;
  }

  .showcase__creator-link:focus-visible {
    color: #05040b;
    outline: 3px solid var(--showcase-accent, #00d9ff);
    outline-offset: 3px;
  }

  .showcase__creator-link:focus-visible::before {
    background:
      linear-gradient(#fff, #fff) padding-box,
      linear-gradient(110deg, var(--neon-cyan), var(--neon-purple), var(--neon-pink)) border-box;
    box-shadow: 0 0 7px rgb(179 136 255 / 16%);
  }

  /* O card em destaque (hover ou foco) mostra o selo branco da home. */
  .showcase__grid.is-showcase-attribution-hover .is-showcase-attribution-active .showcase__creator-link {
    color: #05040b;
  }

  .showcase__grid.is-showcase-attribution-hover .is-showcase-attribution-active .showcase__creator-link::before {
    background:
      linear-gradient(#fff, #fff) padding-box,
      linear-gradient(110deg, var(--neon-cyan), var(--neon-purple), var(--neon-pink)) border-box;
    box-shadow: 0 0 7px rgb(179 136 255 / 16%);
  }

  /* Só aplica hover onde existe mouse/trackpad; toque mantém o selo escuro. */
  @media (hover: hover) and (pointer: fine) {
    .showcase__creator-link:hover {
      color: #05040b;
    }

    .showcase__creator-link:hover::before {
      background:
        linear-gradient(#fff, #fff) padding-box,
        linear-gradient(110deg, var(--neon-cyan), var(--neon-purple), var(--neon-pink)) border-box;
      box-shadow: 0 0 7px rgb(179 136 255 / 16%);
    }
  }

  /*
   * A grade só recebe is-showcase-attribution-hover quando o JavaScript
   * confirma hover com ponteiro fino. Fora desse modo, todas as atribuições
   * continuam visíveis, inclusive sem JavaScript, exceto no layout mobile
   * definido abaixo. any-hover/any-pointer
   * cobre perfil híbrido (toque + mouse); o toque remove a classe.
   */
  @media (any-hover: hover) and (any-pointer: fine) {
    .showcase__grid.is-showcase-attribution-hover .showcase__card .showcase__attribution {
      opacity: 0;
      pointer-events: none;

      /* A duração também vale ao deixar de ser vizinho, durante o fade-out. */
      transition: opacity 240ms ease;
    }

    .showcase__grid.is-showcase-attribution-hover :focus-within > .showcase__attribution,
    .showcase__grid.is-showcase-attribution-hover .is-showcase-attribution-active .showcase__attribution,
    .showcase__grid.is-showcase-attribution-hover .is-showcase-attribution-neighbor .showcase__attribution {
      opacity: 1;
      pointer-events: auto;
    }

    .showcase__grid.is-showcase-attribution-hover .is-showcase-attribution-active .showcase__attribution,
    .showcase__grid.is-showcase-attribution-hover :focus-within > .showcase__attribution {
      transition: opacity 140ms ease;
    }
  }

  /* Usa strong, como na home, sem herdar a regra global de spans do tema claro. */
  .showcase__creator-handle {
    position: relative;
    min-width: 0;
    overflow: hidden;
    color: inherit;
    font-weight: 650;
    font-size: 0.78rem;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  @media (width <= 720px) {
    /* A grade mobile fica limpa; o crédito continua no lightbox e nos nomes acessíveis. */
    .showcase__grid .showcase__attribution {
      display: none;
    }
  }

  /* Filtro de criador ativo */
  .showcase__creator-filter-banner {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
  }

  .showcase__empty-actions {
    margin-top: 1rem;
  }

  .showcase__creator-filter-active {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: 9999px;
    background: rgb(255 255 255 / 6%);
    border: 1px solid var(--showcase-border, rgb(179 136 255 / 20%));
    font-size: 0.85rem;
  }

  .showcase__creator-filter-label {
    color: var(--showcase-muted, #a0a0b0);
  }

  .showcase__creator-filter-name {
    font-weight: 700;
    color: var(--showcase-accent, #00d9ff);
  }

  .showcase__clear-creator {
    margin-left: 0.25rem;
    color: #fff;
    text-decoration: none;
    font-size: 0.8rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    background: rgb(255 255 255 / 10%);
    transition: background 0.15s ease, color 0.15s ease;
  }

  .showcase__clear-creator:hover {
    background: rgb(239 68 68 / 30%);
    color: #fca5a5;
  }

  /* Lightbox actions */
  .showcase__lightbox-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: min(calc(100vw - 2rem), 1600px);
  }

  .showcase__lightbox-image {
    max-height: calc(100dvh - 7.5rem);
  }

  .showcase__lightbox-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: min(100%, 32rem);
    box-sizing: border-box;
    margin-top: 0;
  }

  .showcase__lightbox-creator-link {
    flex: 1 1 12rem;
    min-width: 0;
    overflow-wrap: anywhere;
    color: var(--showcase-accent, #00d9ff);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.15s ease;
  }

  .showcase__lightbox-creator-link:hover {
    text-decoration: underline;
  }

  .showcase__lightbox-creator-link:focus-visible {
    outline: 2px solid var(--showcase-accent, #00d9ff);
    outline-offset: 2px;
  }

  .showcase__lightbox-actions .showcase__lightbox-post-link {
    position: static;
    flex: 0 1 auto;
    max-width: 100%;
    box-sizing: border-box;
  }

  @media (prefers-reduced-motion: reduce) {
    .showcase__attribution,
    .showcase__creator-link,
    .showcase__creator-link::before,
    .showcase__grid.is-showcase-attribution-hover .showcase__card .showcase__attribution,
    .showcase__grid.is-showcase-attribution-hover .is-showcase-attribution-neighbor .showcase__attribution,
    .showcase__grid.is-showcase-attribution-hover .is-showcase-attribution-active .showcase__attribution,
    .showcase__grid.is-showcase-attribution-hover :focus-within > .showcase__attribution {
      transition: none;
    }
  }
}

@layer theme {
  .light-mode .showcase__lightbox-creator-link,
  .light-mode .showcase__lightbox-creator-link:focus-visible {
    color: var(--neon-cyan, #0284c7);
  }
}
