/* Products (t140u): listing, search, product page and header typeahead. Colours come from the skin tokens. */

/* header typeahead */
.site-search { position: relative; }
.typeahead { position: absolute; z-index: 60; top: 100%; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-top: 0;
  box-shadow: 0 8px 24px rgba(0,0,0,.15); max-height: 70vh; overflow-y: auto; text-align: left; }
.typeahead[hidden] { display: none; }
.typeahead a { display: grid; grid-template-columns: 44px 1fr; gap: 4px 10px; align-items: center; padding: 8px 12px; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border-soft); }
.typeahead a:hover, .typeahead a.is-active { background: var(--surface-muted); }
.typeahead img { width: 44px; height: 44px; object-fit: contain; grid-row: span 2; background: #fff; }
.typeahead__title { font-size: 14px; line-height: 1.3; }
.typeahead__codes { font-size: 12px; color: var(--text-muted); }
.typeahead__codes strong { color: var(--brand-primary); }
.typeahead__all { display: block !important; text-align: center; font-weight: 700; color: var(--link) !important; }
.typeahead__none { padding: 10px 12px; color: var(--text-muted); font-size: 14px; }

/* listing layout */
.catalogue .page__title { margin-bottom: var(--space-half); }
.catalogue__layout { display: grid; grid-template-columns: 260px 1fr; gap: var(--space); align-items: start; }
.catalogue-nav { background: var(--surface-muted); border-radius: var(--radius); padding: 12px 14px; }
.catalogue-nav summary { font-weight: 700; color: var(--brand-ink); cursor: pointer; padding: 4px 0; }
.catalogue-nav ul { list-style: none; margin: 0; padding: 0; }
.catalogue-nav ul ul { padding-left: 12px; border-left: 2px solid var(--border-soft); margin: 2px 0 6px 4px; }
.catalogue-nav a { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; color: var(--text); text-decoration: none; font-size: 15px; }
.catalogue-nav a:hover { color: var(--link-hover); }
.catalogue-nav a[aria-current="page"] { color: var(--brand-primary); font-weight: 700; }
.catalogue-nav .count { color: var(--text-muted); font-size: 12px; font-weight: 400; }

.catalogue-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-bottom: var(--space-half); padding-bottom: 12px; border-bottom: 1px solid var(--border-soft); }
.catalogue-toolbar__count { margin: 0 auto 0 0; font-weight: 700; }
.catalogue-toolbar__scope { font-weight: 400; color: var(--text-muted); }
.catalogue-toolbar__field { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.catalogue-toolbar select { height: 38px; border: 1px solid var(--border); border-radius: var(--radius); padding: 0 8px; background: var(--surface); max-width: 240px; }

.product-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.product-grid--wide { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.product-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 12px; transition: box-shadow .15s, border-color .15s; }
.product-card:hover { border-color: var(--border); box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.product-card__link { color: var(--text); text-decoration: none; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.product-card__media { display: block; aspect-ratio: 1; background: #fff; }
.product-card__media img { width: 100%; height: 100%; object-fit: contain; }
.product-card__title { font-size: 14px; line-height: 1.35; font-weight: 600; color: var(--brand-ink); }
.product-card__link:hover .product-card__title { color: var(--link-hover); }
.product-card__codes { margin: 8px 0 0; font-size: 12px; color: var(--text-muted); }
.product-card__codes div { display: flex; gap: 4px; }
.product-card__codes dt::after { content: ":"; }
.product-card__codes dd { margin: 0; color: var(--text); font-weight: 600; word-break: break-all; }
.product-card__brand { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.product-price { margin-top: 8px; font-size: 13px; color: var(--text-muted); min-height: 1.4em; }
.product-price__net { font-size: 18px; font-weight: 700; color: var(--brand-primary); }
.product-price__gross { display: block; font-size: 12px; }
.product-price--large .product-price__net { font-size: 28px; }
.product-price--large { margin: var(--space-half) 0; font-size: 14px; }

/* t250: brand sits to the right of the price, wrapping below on a narrow row */
.product__price-row { display: flex; align-items: center; gap: 12px 20px; margin: var(--space-half) 0; flex-wrap: wrap; }
.product__price-row .product-price,
.product__price-row .product__signin { margin: 0; flex: 0 1 auto; min-width: 0; }
.product__price-row .product__brand { margin: 0 0 0 auto; flex: 0 0 auto; gap: 0; }

.pagination { margin: var(--space) 0; }
.pagination ul { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 0; padding: 0; }
.pagination a, .pagination span { display: inline-flex; min-width: 38px; height: 38px; align-items: center; justify-content: center; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; }
.pagination a:hover { border-color: var(--brand-primary); color: var(--brand-primary); }
.pagination [aria-current="page"] { background: var(--brand-primary); border-color: var(--brand-primary); color: var(--brand-primary-contrast, #fff); font-weight: 700; }
.pagination__gap { padding: 8px 2px; }
.catalogue__empty { padding: var(--space) 0; }

.catalogue-search { display: flex; gap: 8px; max-width: 640px; margin-bottom: var(--space-half); }
.catalogue-search input { flex: 1; height: 44px; border: 1px solid var(--border); border-radius: var(--radius); padding: 0 12px; font-size: 16px; }

/* product page */
.product__layout { display: grid; grid-template-columns: minmax(280px, 480px) 1fr; gap: var(--space); align-items: start; margin-top: var(--space-half); }
.product__image { margin: 0; border: 1px solid var(--border-soft); border-radius: var(--radius); background: #fff; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; }
.product__image img { max-width: 100%; max-height: 100%; object-fit: contain; }
.product__thumbs { list-style: none; display: flex; gap: 8px; padding: 0; margin: 10px 0 0; }
.product__thumbs button { border: 1px solid var(--border); background: #fff; padding: 2px; cursor: pointer; }
.product__brand { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.product__brand-logo { height: 70px; max-height: 70px; width: auto; max-width: 200px; object-fit: contain; }
.product__brand-name { font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; font-size: 13px; }
.product__ean { appearance: none; background: none; border: 0; padding: 0; margin: 0; font: inherit; font-weight: 600; color: var(--link, var(--brand-primary)); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.product__ean:hover, .product__ean:focus-visible { color: var(--link-hover, var(--brand-ink)); }
.product__title { font-size: var(--h3-size); line-height: 1.3; color: var(--brand-ink); margin: 0 0 var(--space-half); }
.product__codes-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin: 0 0 var(--space-half); }
.product__codes-row .product__codes { flex: 1 1 16rem; min-width: 0; margin: 0; }
.product__codes-row .product__gas-safe { flex: 0 0 auto; margin: 0; display: flex; align-items: center; justify-content: center; }
.product__codes { display: grid; gap: 6px; margin: 0; padding: 12px 14px; background: var(--surface-muted); border-radius: var(--radius); }
.product__codes div { display: grid; grid-template-columns: 200px 1fr; gap: 8px; }
.product__codes dt { color: var(--text-muted); }
.product__codes dd { margin: 0; font-weight: 600; word-break: break-word; }
.product__code { color: var(--brand-primary); font-size: 18px; }
.product__oldcodes { font-size: 13px; color: var(--text-muted); }
.product__signin { margin: var(--space-half) 0; }
.product__branch .button { display: inline-flex; align-items: center; gap: 6px; }
.is-placeholder { opacity: .9; }

@media (max-width: 900px) {
  .catalogue__layout { grid-template-columns: 1fr; gap: var(--space-half); }
  .catalogue-nav:not([open]) { padding-bottom: 12px; }
  .product__layout { grid-template-columns: 1fr; }
  .product__codes div { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 480px) {
  .product__codes-row { align-items: stretch; }
  .product__codes-row .product__gas-safe { width: 100%; justify-content: flex-start; padding-top: 2px; }
}
@media (max-width: 600px) {
  .product-grid, .product-grid--wide { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .product-card { padding: 8px; }
  .catalogue-toolbar__field { flex: 1 1 100%; justify-content: space-between; }
  .catalogue-toolbar select { max-width: 65%; flex: 1; }
}

/* Customer API product details (t140u) */
.product__stocking { margin: .75rem 0; }
.product__kit { margin: 1rem 0; }
.product__kit h2 { font-size: 1rem; margin: 0 0 .4rem; }
.product__kit ul { margin: 0; padding-left: 1.1rem; }
.product__kit li { margin: .2rem 0; font-size: .9rem; }
.product .notice--warning { background: #fffaeb; border: 1px solid #fedf89; color: #93370d; padding: .6rem .8rem; border-radius: 4px; }

/* image fallback (t145u): a manufacturer logo stands in for a missing photo, contained and centred on white */
img.is-logo { object-fit: contain; object-position: center; background: #fff; padding: 14%; box-sizing: border-box; }
.typeahead img.is-logo { padding: 4px; }

/* t144u: "About Us" moved to the footer when Products would make the top nav wrap */
.site-nav__item.js-nav-about.is-moved { display: none; }

/* t175u / t179: optional site-list banner + imported description above the product grid */
.site-cat__banner { margin: 0 0 var(--space-half); overflow: hidden; border-radius: 6px; }
.site-cat__banner img { display: block; width: 100%; height: auto; }
.site-cat__desc { margin: 0 0 var(--space); }

/* t187: a description H1 stands in for the template title — same colour, font and weight.
   Inline typography on imported HTML is stripped at display time; these rules cover any remainder. */
.catalogue .site-cat__desc h1,
.catalogue .site-cat__desc h1.page__title {
  /* Same tokens as the template h1.page__title: ink when the skin sets it, otherwise primary. */
  color: var(--brand-ink, var(--brand-primary));
  font-family: var(--font-heading);
  font-size: var(--h1-size);
  font-weight: 700;
  font-style: normal;
  line-height: 1.2;
  letter-spacing: normal;
  margin: 0 0 var(--space-half);
}


/* t189 / t190: alternative products (full block + out-of-stock promo by the buy box) */
.alternates { margin: var(--space) 0 0; }
.alternates__heading,
.alternates-promo__heading { font-size: 1.15rem; font-weight: 700; color: var(--brand-ink, var(--brand-primary)); margin: 0 0 var(--space-half); }
.alternates-promo { margin: 1rem 0 0; padding: .85rem .9rem; border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--surface); }
.alternates-promo[hidden] { display: none !important; }
.alternates-promo__grid { margin: 0; }
.product-grid--compact { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
/* Sparesbase skin forces .product-grid--compact to 5 columns (home strips). Beat that
   specificity so alternate cards have a usable width. */
body.site-sparesbase ul.product-grid.product-grid--wide.alternates__grid,
ul.product-grid.alternates__grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)) !important;
}
body.site-sparesbase ul.product-grid.product-grid--compact.alternates-promo__grid,
ul.product-grid.alternates-promo__grid {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 12px !important;
}
.alternates-promo .product-card { overflow: hidden; }
@media (max-width: 520px) {
  body.site-sparesbase ul.product-grid.product-grid--compact.alternates-promo__grid,
  ul.product-grid.alternates-promo__grid { grid-template-columns: 1fr !important; }
}
.alternates-promo__grid,
.alternates__grid { width: 100%; }
.alternates-promo .product-card,
.alternates .product-card { min-width: 0; width: 100%; }
.product-card--unavailable { position: relative; filter: grayscale(1); opacity: .78; min-height: 240px; }
.product-card--unavailable .product-card__static { display: flex; flex-direction: column; gap: 10px; flex: 1; color: var(--text); pointer-events: none; }
.product-card--unavailable .product-card__overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(28, 28, 27, .58); color: #fff; font-weight: 700; font-size: 14px; line-height: 1.35;
  text-align: center; padding: 12px; border-radius: inherit; pointer-events: none; overflow: hidden;
}
.product-card--unavailable .product-card__overlay > span {
  display: block; text-align: center; max-width: 16rem;
}
.product-card--unavailable, .product-card--unavailable * { cursor: default; }
.product-card.is-alt-stock { box-shadow: 0 0 0 2px var(--brand-primary, #0a7); }
.js-alternates-full.is-hidden-for-promo { display: none; }
@media (max-width: 600px) {
  .product-grid--compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* t251: EAN barcode modal (local SVG, black on white, quiet zones in the SVG) */
.ean-modal[hidden] { display: none; }
.ean-modal { position: fixed; inset: 0; z-index: 1100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.ean-modal__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }
.ean-modal__dialog { position: relative; z-index: 1; background: #fff; color: #111; width: min(640px, 100%); max-height: calc(100vh - 32px); overflow: auto; border-radius: var(--radius, 8px); box-shadow: 0 16px 48px rgba(0, 0, 0, .28); padding: 16px 16px 24px; }
.ean-modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 8px; }
.ean-modal__title { margin: 0; font-size: 1.05rem; line-height: 1.3; color: #111; }
.ean-modal__close { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin: -8px -8px 0 0; border: 0; border-radius: 50%; background: transparent; color: #111; cursor: pointer; }
.ean-modal__close:hover, .ean-modal__close:focus-visible { background: #f0f0f0; }
.ean-modal__barcode { background: #fff; padding: 16px 8px 8px; filter: none; }
.ean-modal__barcode svg { display: block; width: 100%; height: auto; max-height: 240px; background: #fff; }
html.ean-open { overflow: hidden; }
html.ean-open .to-top { opacity: 0 !important; pointer-events: none !important; }
.ean-modal__dialog:focus { outline: none; }
@media (max-width: 767px) {
  .product__price-row { align-items: center; }
  .ean-modal { padding: 8px; align-items: flex-end; }
  .ean-modal__dialog { width: 100%; max-height: calc(100vh - 16px); padding: 12px 12px 20px; }
  .ean-modal__barcode { padding: 20px 2px 12px; }
  .ean-modal__barcode svg { max-height: none; }
}
