/**
 * OWNERSHIP: resources/css/frontend/search.css
 * Scoped styles for [zype_search]. No global element selectors.
 *
 * Width contract: .zype-search.alignwide is the sole wide/content-body boundary.
 * It participates in the theme wide-size system (same tokens as header/footer).
 * Form, source header, results, and pagination share that width. Nested
 * carousels remain max-width 100% of .zype-search — they must not break out.
 */

.zype-search {
  --zype-search-gap: 0.75rem;
  --zype-search-border: rgba(0, 0, 0, 0.12);
  --zype-search-muted: rgba(0, 0, 0, 0.65);
  /*
   * Prefer theme wide column (header/footer .alignwide), then content-size,
   * then parent width. Do not hard-code theme pixel values.
   */
  --zype-search-wide: var(
    --wp--style--global--wide-size,
    var(--zype-wide-width, var(--wp--style--global--content-size, 100%))
  );
  display: block;
  width: 100%;
  max-width: min(100%, var(--zype-search-wide));
  min-width: 0;
  margin: 0 auto 1.5rem;
  margin-inline: auto;
  box-sizing: border-box;
  /*
   * Keep form chrome unclipped. Nested carousels still contain horizontal
   * overflow. Clipping this root hid the input’s left border/outline
   * (theme chrome and :focus outline-offset) at the start edge.
   */
  overflow-x: visible;
}

/*
 * WordPress constrained-layout wide alignment (direct child of
 * .is-layout-constrained / .entry-content / .wp-block-post-content).
 */
.zype-search.alignwide {
  width: 100%;
  max-width: min(100%, var(--zype-search-wide));
  min-width: 0;
  margin-left: auto;
  margin-right: auto;
  margin-inline: auto;
  box-sizing: border-box;
}

.zype-search *,
.zype-search *::before,
.zype-search *::after {
  box-sizing: border-box;
}

.zype-search__form,
.zype-search__status,
.zype-search__results,
.zype-search__source,
.zype-search__source-header,
.zype-search__pagination {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.zype-search__form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--zype-search-gap);
  align-items: stretch;
  margin: 0 0 1rem;
  /*
   * Keep input/button borders and :focus outlines inside the search
   * column when a parent clips the wide-align breakout by a pixel.
   */
  padding-inline: 0.25rem;
  overflow: visible;
}

.zype-search__label.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  word-wrap: normal !important;
}

.zype-search__input {
  flex: 1 1 12rem;
  min-width: 0;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--zype-search-border);
  border-radius: 2px;
  font: inherit;
  line-height: 1.4;
  background: #fff;
  color: inherit;
}

.zype-search__input:focus {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.zype-search__submit {
  flex: 0 0 auto;
  padding: 0.65rem 1.1rem;
  border: 1px solid currentColor;
  border-radius: 2px;
  font: inherit;
  line-height: 1.4;
  cursor: pointer;
  background: transparent;
  color: inherit;
}

.zype-search__submit:focus {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.zype-search__submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.zype-search__status:empty {
  display: none;
}

.zype-search__status p,
.zype-search__empty p,
.zype-search__error p {
  margin: 0 0 0.75rem;
  color: var(--zype-search-muted);
}

.zype-search__results {
  display: block;
}

.zype-search__source {
  margin: 0 0 1.75rem;
}

.zype-search__source-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  margin: 0 0 0.75rem;
}

.zype-search__source-heading {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.3;
}

.zype-search__result-count {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--zype-search-muted);
  white-space: nowrap;
}

.zype-search-playlists,
.zype-search-categories,
.zype-search-zobjects {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
}

.zype-search-playlists__item,
.zype-search-categories__item,
.zype-search-zobjects__item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.75rem;
  border: 1px solid var(--zype-search-border);
  border-radius: 2px;
}

.zype-search-playlists__thumb,
.zype-search-zobjects__thumb {
  flex: 0 0 5.5rem;
  width: 5.5rem;
  height: 3.1rem;
  background-size: cover;
  background-position: center;
  background-color: rgba(0, 0, 0, 0.06);
  border-radius: 2px;
}

.zype-search-playlists__title,
.zype-search-categories__title,
.zype-search-zobjects__title {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  line-height: 1.3;
}

.zype-search-playlists__description,
.zype-search-categories__friendly,
.zype-search-categories__values,
.zype-search-zobjects__description,
.zype-search-zobjects__type,
.zype-search-zobjects__id {
  margin: 0;
  font-size: 0.9rem;
  color: var(--zype-search-muted);
}

.zype-search__pagination {
  margin: 1rem 0 0;
}

.zype-search__pagination-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
}

.zype-search__pagination-link:focus {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/*
 * Contain nested video carousels to the search content body.
 * Standalone [zype_carousel] may break out to the theme wide column;
 * search results must not.
 */
.zype-search .zype-carousel,
.zype-search .zype-carousel.zype-playlist-grid-shortcode,
.zype-search .zype-search-videos.zype-carousel {
  --zype-carousel-wide: 100%;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-left: 0;
  margin-right: 0;
  margin-inline: 0;
  overflow-x: clip;
}

.zype-search-videos.zype-carousel {
  margin: 0;
}

.zype-search .zype-carousel__viewport,
.zype-search .zype-carousel__track {
  max-width: 100%;
  min-width: 0;
}

/*
 * Video search results reuse catalog/carousel poster cards (2:3).
 * Orientation + definite item width come from carousel.css
 * (--zype-carousel-poster-card-width) and catalog_cards.css media ratio.
 * Do not reintroduce landscape / 16:9 rules for .zype-search-videos.
 * Do not inset/pad/scale the poster <img> here — that shrinks visible artwork
 * and fights the shared carousel full-bleed cover contract.
 */
.zype-search-videos .zype-carousel__item--poster,
.zype-search-videos .zype-carousel__item[data-thumbnail-orientation="poster"] {
  /* Definite flex width owned by carousel poster contract; keep title under poster. */
  align-self: flex-start;
}

.zype-search-videos .zype-grid-video-card--poster .zype-grid-video-card__media,
.zype-search-videos .zype-grid-video-card.zype-poster .zype-grid-video-card__media,
.zype-search-videos .zype-grid-video-card__media--poster {
  aspect-ratio: 2 / 3;
  width: 100%;
}

.zype-search-videos .zype-grid-video-card__image {
  object-fit: cover;
  object-position: center;
}

.zype-search-videos__card.zype-grid-video-card--poster,
.zype-search-videos__card.zype-poster {
  width: var(--zype-carousel-poster-card-width, 200px);
  max-width: 100%;
}

.zype-search-videos__title,
.zype-search-videos__description {
  margin: 0.5rem 0 0;
  font-size: 0.95rem;
  line-height: 1.3;
}

.zype-search-videos__description {
  margin-top: 0.25rem;
  color: var(--zype-search-muted);
  font-size: 0.875rem;
}

@media (max-width: 600px) {
  .zype-search__form {
    flex-direction: column;
  }

  .zype-search__submit {
    width: 100%;
  }
}
