/*!
 * USP.Center static search widget — supplements the theme's existing
 * .ais-* / .hit-item / .pagination styles. Scoped to body.usp-search-on,
 * which is added by search-widget.js only after successful init.
 */

body.usp-search-on .searchbox-algolia {
  display: block;
  width: 4.4rem;
  min-width: 4.4rem;
  overflow: visible;
}

body.usp-search-on .algolia-search-icon {
  cursor: pointer;
  border: none;
  background-color: transparent;
  min-width: 3.4rem;
  height: 2.8rem;
  background-repeat: no-repeat;
}

.--algolia .product-modal__inner {
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
}

.--algolia .hit-item {
  display: block;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid #e3efe5;
}

.--algolia .hit-item:hover .hit-primary,
.--algolia .hit-item:focus .hit-primary {
  text-decoration: underline;
}

.--algolia .hit-section {
  display: inline-block;
  margin-left: 0.8rem;
  padding: 0.1rem 0.8rem;
  border-radius: 1rem;
  background: #e3efe5;
  color: #1b1e4b;
  font-size: 1.1rem;
  font-weight: 400;
  vertical-align: middle;
  white-space: nowrap;
}

.--algolia .hit-snippet {
  font-size: 1.3rem;
  line-height: 1.5;
  color: #444;
  margin-bottom: 0.5rem;
}

.--algolia mark.ais-Highlight-highlighted {
  background: #fff3b0;
  color: inherit;
  padding: 0;
  font-style: normal;
}

.--algolia #stats {
  padding: 0 1rem;
  font-size: 1.2rem;
  color: #666;
}

/* Valid, flat pagination markup shared by themed and fallback modals. */
.usp-search-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  list-style: none;
  gap: 0.4rem;
  margin: 2rem 0 0;
  padding: 0;
}

.usp-search-pagination li {
  margin: 0;
  padding: 0;
  list-style: none;
}

.usp-search-page a {
  display: inline-block;
  min-width: 2em;
  padding: 0.2em 0.3em;
  text-align: center;
  text-decoration: none;
  color: inherit;
}

.--algolia .usp-search-page a {
  color: #1b1e4b;
  font-size: 1.5rem;
}

.usp-search-pagination .pagination__arrow a {
  display: inline-flex;
  align-items: center;
}

/* --- Fallback icon for themes without their own search markup ----------- */

.usp-search-fallback {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  z-index: 50;
}

@media (max-width: 991px) {
  .usp-search-fallback {
    right: 60px;
  }
}

.usp-search-fallback-icon {
  display: block;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  cursor: pointer;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 22px 22px;
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23374957' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  opacity: 0.85;
}

.usp-search-fallback-icon:hover,
.usp-search-fallback-icon:focus {
  opacity: 1;
}

/* --- Complete modal styling, scoped to the widget-created modal only ----- */

.usp-search-fallback-modal {
  width: 100vw;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  display: none;
  overflow: auto;
  background: rgba(0, 0, 0, 0.45);
  z-index: 10000;
  font-size: 16px;
  line-height: 1.5;
}

.usp-search-fallback-modal .product-modal__inner {
  width: 94%;
  max-width: 680px;
  margin: 6vh auto;
  padding: 24px 24px 32px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  max-height: 86vh;
  overflow-y: auto;
}

.usp-search-fallback-modal .product-modal__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.usp-search-fallback-modal .product-modal__top h2 {
  margin: 0;
  font-size: 1.4em;
}

.usp-search-fallback-modal .product-modal__close {
  cursor: pointer;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.usp-search-fallback-modal .ais-SearchBox-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 1em;
  border: 1px solid #ccc;
  border-radius: 8px;
  box-sizing: border-box;
}

.usp-search-fallback-modal #stats {
  margin: 10px 0 4px;
  font-size: 0.85em;
  color: #666;
}

.usp-search-fallback-modal .hit-item {
  display: block;
  padding: 12px 4px;
  border-bottom: 1px solid #eee;
  color: inherit;
  text-decoration: none;
}

.usp-search-fallback-modal .hit-primary {
  font-weight: 600;
  margin-bottom: 4px;
}

.usp-search-fallback-modal .no-results {
  padding: 16px 4px;
  color: #666;
}

.usp-search-fallback-modal .pagination__arrow svg {
  width: 32px;
  height: auto;
}

.usp-search-fallback-modal .pagination__arrow--prev {
  transform: scaleX(-1);
}

/* Fallback icon rendered as a nav menu item. */
.usp-search-fallback-item {
  display: inline-flex;
  align-items: center;
  list-style: none;
}

.usp-search-fallback-item .usp-search-fallback-icon {
  width: 28px;
  height: 28px;
  background-size: 20px 20px;
}

/* Wyniki jako h3/p — reset domyslnych marginesow naglowka i akapitu */
.--algolia h3.hit-primary,
.usp-search-fallback-modal h3.hit-primary {
  margin: 0 0 4px;
  font-size: 1.05em;
  line-height: 1.4;
}

.--algolia p.hit-snippet,
.usp-search-fallback-modal p.hit-snippet {
  margin: 0 0 0.5rem;
}

.usp-search-fallback-modal .hit-section {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 10px;
  border-radius: 999px;
  background: #eef1f6;
  color: #444;
  font-size: 0.75em;
  font-weight: 400;
  vertical-align: middle;
}

/* --- Card results ------------------------------------------------------- *
 * Enabled by the index layout hint (auto = themes without their own search
 * modal, once the index carries thumbnails). Mirrors the CMS search results
 * page: thumbnail + title + date and reading time.
 */

.usp-search--cards .product-modal__inner {
  max-width: 1040px;
}

.usp-search--cards #stats {
  margin: 16px 0 12px;
  font-size: 1.15em;
  font-weight: 500;
  color: inherit;
}

.usp-search--cards .usp-search-stats__count,
.usp-search--cards .usp-search-stats__query {
  font-weight: 700;
}

.usp-search-hits--cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px 16px;
}

.usp-search-hits--cards .hit-item {
  display: block;
  padding: 0;
  border: 0;
  color: inherit;
  text-decoration: none;
}

.usp-search-hits--cards .hit-card__media {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-bottom: 12px;
  overflow: hidden;
  border-radius: 16px;
  background: #f1efe9;
}

.usp-search-hits--cards .hit-card__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.usp-search-hits--cards .hit-card__body {
  display: block;
}

.usp-search-hits--cards h3.hit-primary {
  margin: 0;
  font-size: 1.05em;
  font-weight: 600;
  line-height: 1.35;
}

.usp-search-hits--cards .hit-meta {
  margin: 6px 0 0;
  font-size: 0.85em;
  color: #6b7280;
}

.usp-search-hits--cards .hit-item:hover h3.hit-primary,
.usp-search-hits--cards .hit-item:focus h3.hit-primary {
  text-decoration: underline;
}

@media (max-width: 1100px) {
  .usp-search-hits--cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .usp-search-hits--cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Narrow screens follow the theme's mobile listing: thumbnail beside text. */
@media (max-width: 560px) {
  .usp-search-hits--cards {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .usp-search-hits--cards .hit-item {
    display: grid;
    grid-template-columns: 40% minmax(0, 1fr);
    gap: 12px;
    align-items: start;
  }

  .usp-search-hits--cards .hit-card__media {
    margin-bottom: 0;
  }
}
