@layer pages {
  /* Variante da página: o widget da busca global mantém seu próprio layout. */
  .showcase__hero:has(.showcase-header-search) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(20rem, 28rem);
    column-gap: 2rem;
    align-items: start;
  }

  .showcase__hero:has(.showcase-header-search) .showcase__hero-actions {
    grid-column: 1 / -1;
  }

  .showcase-header-search {
    min-width: 0;
    margin-top: 1.5rem;
  }

  .showcase-header-search__form {
    --showcase-search-background: rgb(15 12 24 / 60%);
    --showcase-search-button-background: rgb(138 180 248 / 5%);

    position: relative;
    display: flex;
    align-items: center;
    min-width: 0;
    min-height: 44px;
    border: 1px solid var(--showcase-border);
    border-radius: 999px;
    background: var(--showcase-search-background);
  }

  .showcase-header-search__form:focus-within {
    border-color: transparent;
    outline: none;
    box-shadow: 0 0 7px rgb(179 136 255 / 12%);
  }

  .showcase-header-search__form:focus-within::after {
    /* A máscara mantém o fundo translúcido: o degradê aparece só na borda. */
    position: absolute;
    inset: -1px;
    padding: 1px;
    border-radius: inherit;
    background: linear-gradient(110deg, var(--neon-cyan), var(--neon-purple), var(--neon-pink));
    background-size: 200% 200%;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    pointer-events: none;
    content: '';
    animation: showcase-search-border-flow 8s ease-in-out infinite;
  }

  @keyframes showcase-search-border-flow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
  }

  @media (prefers-reduced-motion: reduce) {
    .showcase-header-search__form:focus-within::after {
      animation: none;
    }
  }

  .showcase-header-search__form input[type='search'] {
    box-sizing: border-box;
    flex: 1;
    width: 0;
    min-width: 0;
    min-height: 44px;
    padding: 0.6rem 0 0.6rem 1rem;
    border: 0;
    border-radius: 999px 0 0 999px;
    background: transparent;
    color: var(--text-primary, #f4f6fb);
    font: inherit;
    font-size: 0.9rem;
  }

  .showcase-header-search__form input[type='search']:focus-visible {
    /* O contorno do formulário já identifica o campo, sem desenhar dois anéis. */
    outline: none;
  }

  .showcase-header-search__form input::placeholder {
    color: var(--showcase-muted);
    opacity: 0.75;
  }

  .showcase-header-search__form button {
    display: inline-flex;
    flex: 0 0 44px;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--showcase-muted);
    font: inherit;
    cursor: pointer;
  }

  .showcase-header-search__form button:hover {
    color: var(--showcase-accent);
  }

  .showcase-header-search__form .showcase-header-search__submit {
    flex-basis: 56px;
    border-left: 1px solid var(--showcase-border);
    border-radius: 0 999px 999px 0;
    background: var(--showcase-search-button-background);
  }

  .showcase-header-search__form .showcase-header-search__submit:hover {
    border-left-color: var(--showcase-accent);
  }

  .showcase-header-search__form button:disabled {
    cursor: wait;
    opacity: 0.6;
  }

  .showcase-header-search__form [hidden] {
    display: none;
  }

  .showcase-header-search__meta {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 8px;
    padding-inline: 1rem;
    color: var(--showcase-muted);
    font-size: 0.75rem;
    line-height: 20px;
  }

  .showcase-header-search__help {
    display: flex;
  }

  .showcase-header-search__help summary {
    display: grid;
    place-items: center;
    min-width: 44px;
    min-height: 44px;
    box-sizing: border-box;
    /* Usa os vãos de 8/16px para manter o toque de 44px sem inflar a linha. */
    margin-block: -8px -16px;
    padding-bottom: 8px;
    cursor: pointer;
    list-style: none;
  }

  .showcase-header-search__help summary::-webkit-details-marker {
    display: none;
  }

  .showcase-header-search__help p {
    position: absolute;
    z-index: 5;
    top: 100%;
    right: 0;
    box-sizing: border-box;
    width: min(20rem, 100%);
    margin: 0;
    padding: 0.85rem;
    border: 1px solid var(--showcase-border);
    border-radius: 0.75rem;
    background: var(--bg-surface, #1e1e24);
    color: var(--text-primary, #f4f6fb);
    font-size: 0.85rem;
    line-height: 1.6;
    box-shadow: 0 8px 24px rgb(0 0 0 / 20%);
  }

  .showcase-header-search__form button:focus-visible,
  .showcase-header-search__help summary:focus-visible {
    outline: 2px solid var(--showcase-accent);
    outline-offset: 2px;
  }

  .showcase-visual-search--integrated {
    margin: 0 0 2rem;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
  }

  .showcase:not(.showcase--visual-search-active) .showcase-visual-search--integrated {
    display: none;
  }

  @media (820px < width <= 1200px) {
    .showcase__hero:has(.showcase-header-search) {
      grid-template-columns: minmax(0, 1fr) clamp(17.5rem, 30.5vw, 23rem);
      column-gap: 1rem;
    }

    .showcase-header-search {
      margin-top: 1rem;
    }

    .showcase-header-search__form input[type='search'] {
      padding: 0.6rem 0.35rem 0.6rem 0.85rem;
      font-size: 0.83rem;
    }

    .showcase-header-search__form .showcase-header-search__submit {
      flex-basis: 46px;
    }

    .showcase-header-search__meta {
      padding-inline: 0.85rem;
    }
  }

  @media (width <= 820px) {
    .showcase__hero:has(.showcase-header-search) {
      grid-template-columns: minmax(0, 1fr);
    }

    .showcase-header-search {
      margin-top: 0;
    }
  }

  @media (width <= 600px) {
    .showcase__hero:has(.showcase-header-search) .showcase__hero-actions {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 0.75rem 0.5rem;
      align-items: center;
    }

    .showcase__hero:has(.showcase-header-search) .showcase__filters {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      box-sizing: border-box;
      grid-row: 1;
      grid-column: 1 / -1;
      overflow: visible;
    }

    .showcase__hero:has(.showcase-header-search) .showcase__sort {
      grid-column: 2;
      justify-content: flex-end;
    }

    .showcase__hero:has(.showcase-header-search) .showcase__sort select {
      max-width: 10rem;
      min-height: 44px;
    }

    .showcase__hero:has(.showcase-header-search) .showcase__sort label {
      display: none;
    }

    .showcase__hero:has(.showcase-header-search) .hero-metric-card {
      flex-wrap: wrap;
      gap: 0.35rem;
      padding-right: 0;
    }

    .showcase__hero:has(.showcase-header-search) .showcase__filter-chip {
      flex-direction: column;
      justify-content: center;
      gap: 0.25rem;
      min-height: 44px;
      box-sizing: border-box;
      padding: 0.5rem 0.2rem;
      font-size: 0.75rem;
    }
  }
}

@layer theme {
  .light-mode .showcase-header-search__form {
    --showcase-search-background: rgb(255 255 255 / 65%);
    --showcase-search-button-background: rgb(3 105 161 / 5%);
  }

  /* O tema compartilhado define o fundo do widget; esta variante não é um cartão. */
  .light-mode .showcase-visual-search--integrated {
    background: none;
  }
}
