/* Theme and base styles */
:root {
  color-scheme: light;
  --ink: #102f44;
  --muted: #49677a;
  --line: #c6d9e3;
  --teal: #00645f;
  --inset: clamp(16px, 2.4vw, 52px);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: #f3f7fa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  line-height: 1.5;
}

h1, h2, h3, p {
  margin: 0;
}

a {
  color: #074f76;
  text-underline-offset: .2em;
}

a:hover {
  text-decoration: underline;
}

button, input, select {
  font: inherit;
}

button, a, input, select, summary {
  touch-action: manipulation;
}

:focus-visible {
  outline: 3px solid #007cc3;
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

/* Site navigation */
.mast, .foot {
  padding: 12px var(--inset);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: #fff;
}

.mast {
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .7em;
  color: var(--ink);
  font-weight: 650;
  text-decoration: none;
}

.brand img {
  width: 104px;
  height: 42px;
  object-fit: contain;
}

.brand span {
  border-left: 1px solid var(--line);
  padding-left: .7em;
}

.mast nav, .tabs, .linkrow, .pager {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.mast nav a {
  font-size: .9rem;
  font-weight: 600;
  padding: 8px;
}

/* Catalogue banner */
.hero {
  padding: clamp(26px, 3.7vw, 70px) var(--inset);
  min-height: clamp(160px, 15vw, 265px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  background: #ddebfa linear-gradient(95deg, #edf6fc 4%, #edf6fcec 33%, #edf6fc44 56%, transparent 75%);
  background-image: linear-gradient(95deg,#edf6fc 4%,#edf6fcec 33%,#edf6fc44 56%,transparent 75%),url("https://websdocs.com/asg-directory/images/catalogue-banner.png?v=full-width-4");
  background-size: cover;
  background-position: center;
}

.hero h1, .category-page h1 {
  font-size: clamp(2.1rem, 3.8vw, 4.6rem);
  letter-spacing: -.047em;
  line-height: 1.04;
  max-width: 24ch;
  overflow-wrap: anywhere;
}

.hero p {
  max-width: min(45ch, 48%);
  margin-top: .6em;
  color: #274961;
}

/* Search and filters */
.search-panel {
  padding: 18px var(--inset);
  background: #fff;
  border-block: 1px solid var(--line);
}

.searchbar {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, .9fr) minmax(0, .9fr) auto;
  gap: 10px;
  align-items: end;
}

label {
  font-size: .86rem;
  font-weight: 650;
  display: grid;
  gap: 4px;
  min-width: 0;
}

input, select, .category-picker {
  width: 100%;
  min-height: 44px;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid #a5bdcd;
  border-radius: 7px;
  background: white;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 400;
}

.primary, .pager a, .pill, .pick {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 13px;
  background: white;
  color: var(--ink);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.primary {
  min-height: 44px;
  background: var(--teal);
  color: white;
  border-color: var(--teal);
  font-weight: 650;
}

.tabs {
  margin: 12px 0 0;
}

.more-filters {
  margin-top: 10px;
}

summary {
  cursor: pointer;
  font-weight: 650;
  min-height: 35px;
  padding: 4px 0;
  width: fit-content;
}

.facets {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 8px 0;
}

.filterlinks {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  font-size: .89rem;
}

.results, .category-page {
  padding: 20px var(--inset) clamp(28px, 3vw, 54px);
  min-width: 0;
}

.status {
  display: flex;
  align-items: baseline;
  gap: 12px;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.status h2, .category-page h2 {
  font-size: clamp(1.15rem, 2vw, 1.65rem);
  letter-spacing: -.025em;
}

.status p, .muted, .category-page p {
  color: var(--muted);
  font-size: .92rem;
}

/* Product grid and featured rails */
.grid-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "main";
  gap: clamp(12px, 1.25vw, 24px);
  align-items: start;
}

.grid-layout.left {
  grid-template-columns: minmax(140px, 14%) minmax(0, 1fr);
  grid-template-areas: "left main";
}

.grid-layout.right {
  grid-template-columns: minmax(0, 1fr) minmax(140px, 14%);
  grid-template-areas: "main right";
}

.grid-layout.left.right {
  grid-template-columns: minmax(140px, 14%) minmax(0, 1fr) minmax(140px, 14%);
  grid-template-areas: "left main right";
}

.grid-layout main, .feed {
  grid-area: main;
  min-width: 0;
}

.rail[data-side=left] {
  grid-area: left;
}

.rail[data-side=right] {
  grid-area: right;
}

.cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: stretch;
  gap: clamp(9px, 1.1vw, 20px);
}

.cards+.cards {
  margin-top: clamp(9px, 1.1vw, 20px);
}

/* Product cards */
.tile {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #fff;
  border: 1px solid #c1d6df;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.tile:hover, .tile:focus-within {
  border-color: #79a6ba;
}

.tile > img {
  display: block;
  width: 100%;
  aspect-ratio: 16/10;
  object-fit: cover;
  background: #e8f0f4;
}

.icon {
  display: grid;
  place-items: center;
  margin: 14px 0 0 14px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #dfedf2;
  color: #0b676b;
}

.icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
}

.tile-copy {
  padding: 13px;
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.tile h3 {
  font-size: clamp(.98rem, 1.1vw, 1.23rem);
  line-height: 1.3;
  font-weight: 650;
}

.tile h3 a {
  color: var(--ink);
  text-decoration: none;
}

.tile h3 a:hover {
  text-decoration: underline;
}

.price {
  font-weight: 700;
  color: #075852;
  margin-top: 4px;
}

.meta, .desc {
  font-size: .86rem;
  color: var(--muted);
  margin-top: 6px;
}

.desc {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile footer {
  display: flex;
  align-items: center;
  gap: 6px 10px;
  justify-content: space-between;
  flex-wrap: wrap;
  margin: 0 13px;
  padding: 9px 0;
  border-top: 1px solid #deeaef;
  font-size: .83rem;
  overflow-wrap: anywhere;
}

.tile footer a {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}

.tile footer a:last-child {
  font-weight: 650;
}

.mark {
  align-self: flex-start;
  border-radius: 4px;
  background: #d6efed;
  color: #134f4d;
  font-size: .73rem;
  padding: 2px 6px;
  margin: 10px 12px 0;
  font-weight: 700;
}

.tile:has(>img) .mark {
  position: absolute;
  top: 0;
  left: 0;
}

.pager {
  margin-top: 20px;
}

.pager a {
  font-weight: 650;
}

.foot {
  border-top: 1px solid var(--line);
  font-size: .88rem;
}

/* Category browser */
.category-page {
  background: white;
  min-height: 70vh;
}

.category-page p {
  margin: 10px 0 20px;
}

.cat-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 8px;
  margin: 12px 0;
  padding: 0;
}

.cat-list a {
  display: block;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  text-decoration: none;
}

.cat-list a:hover {
  background: #ecf5f8;
}

.pick {
  justify-content: flex-start;
  width: 100%;
}

.picker-title {
  display: grid;
  gap: 4px;
  font-size: .86rem;
  font-weight: 650;
}

dialog {
  max-width: min(640px, 94vw);
  width: 100%;
  max-height: 83vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  padding: 18px;
}

dialog::backdrop {
  background: #132f4099;
}

dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

dialog ul {
  list-style: none;
  display: grid;
  padding: 0;
  gap: 4px;
}

dialog li button {
  cursor: pointer;
  width: 100%;
  border: 0;
  text-align: left;
  padding: 9px;
  background: #eff5f7;
  color: var(--ink);
  border-radius: 4px;
}

dialog li button:hover {
  background: #d9ebef;
}

dialog .pill {
  min-height: 36px;
}

/* Responsive layout */
@media (max-width: 1400px) {
  .cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

}

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

  .facets {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

}

@media (max-width: 800px) {
  .searchbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-layout.left, .grid-layout.right, .grid-layout.left.right {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas: "left right" "main main";
  }

  .grid-layout.left:not(.right) {
    grid-template-areas: "left left" "main main";
  }

  .grid-layout.right:not(.left) {
    grid-template-areas: "right right" "main main";
  }

  .rail .tile > img {
    aspect-ratio: 2.5;
  }

  .rail .desc {
    display: none;
  }

  .hero p {
    max-width: 60%;
  }

}

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

  .mast nav {
    gap: 2px;
  }

  .mast nav a {
    font-size: .83rem;
    padding: 4px;
  }

  .brand img {
    width: 78px;
    height: 32px;
  }

  .brand {
    gap: .35em;
  }

  .hero p {
    max-width: 72%;
  }

  .hero {
    background-position: center, 57% center;
    background-image: linear-gradient(90deg,#edf6fc 5%,#edf6fcf2 42%,#edf6fcb8 64%,transparent 94%),url("https://websdocs.com/asg-directory/images/catalogue-banner.png?v=full-width-4");
  }

  .facets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .searchbar {
    gap: 8px;
  }

  .tile-copy {
    padding: 10px;
  }

  .tile footer {
    margin: 0 10px;
  }

  .desc {
    -webkit-line-clamp: 2;
  }

}

@media (max-width: 365px) {
  .mast {
    gap: 4px;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .searchbar, .facets {
    grid-template-columns: 1fr;
  }

  .grid-layout.left.right {
    grid-template-columns: 1fr;
    grid-template-areas: "left" "right" "main";
  }

}

.tabs a[aria-current=true] {
  color: #fff;
  background: #16435b;
  border-color: #16435b;
}

.tabs .pill {
  font-size: .9rem;
  min-height: 37px;
  padding: 6px 12px;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -5rem;
  background: white;
  color: #13384f;
  padding: .6rem;
  z-index: 3;
}

.skip:focus {
  top: .5rem;
}

/* One local image supplies the flags in the country picker and on product cards. */
.country-flag {
  display: inline-block;
  flex: 0 0 24px;
  width: 24px;
  height: 16px;
  background-image: url("./flags.png");
  background-size: 384px 256px;
  background-repeat: no-repeat;
  background-position: var(--flag-x) var(--flag-y);
}
#choose-country, 
#country-dialog li button, 
.seller-location {
  display: flex;
  align-items: center;
  gap: 8px;
}
#choose-country {
  min-height: 44px;
}
.seller-location {
  color: var(--muted);
  margin-top: 6px;
  font-size: .86rem;
}

/* Both pickers stay in the page. Their index link remains available as a second action. */
.cat-menu { position: relative; min-width: 0; }
.cat-trigger {
  display: flex; align-items: center; gap: .55rem;
  padding: .58rem .75rem; min-height: 44px; cursor: pointer; list-style: none;
  color: #133d52; font-weight: 650; border-radius: 9px;
}
.cat-trigger::-webkit-details-marker { display: none; }
.cat-menu[open] { z-index: 8; }
.cat-trigger:hover, .cat-menu[open] > summary { background: #edf8f6; }
.picker-title .cat-trigger { border: 1px solid var(--line); background-color: #fff; }
.cat-grid-icon { font-size: 1.15rem; color: #076961; }
.cat-chevron { margin-inline-start: auto; }
.cat-menu[open] .cat-chevron { transform: rotate(180deg); }
.cat-popup {
  position: absolute; z-index: 10; top: calc(100% + 5px); right: 0;
  width: min(345px, calc(100vw - 32px)); max-height: min(66vh, 510px); overflow-y: auto;
  overscroll-behavior: contain; border: 1px solid #b6d5d8; border-radius: 14px;
  background: #fff; box-shadow: 0 14px 46px #193f5333; padding: 12px; color: var(--ink);
}
.cat-popup label { display: grid; gap: 4px; font-size: .85rem; font-weight: 600; line-height: 1.4; }
.cat-popup input { width: 100%; min-width: 0; padding: .55em .75em; border: 1px solid var(--line); border-radius: 7px; }
.cat-popup ul { list-style: none; margin: .5rem 0; padding: 0; max-height: min(35vh, 260px); overflow-y: auto; }
.cat-popup li a { display: flex; gap: .65rem; align-items: center; padding: .4rem; min-height: 40px; text-decoration: none; color: #193b4b; font-size: .89rem; font-weight: 530; }
.cat-popup li a:hover, .cat-popup li a:focus-visible { background: #e7f5f2; border-radius: 6px; }
.category-icon { flex: 0 0 1.8rem; display: grid; place-items: center; height: 1.8rem; color: #006862; background: #e8f4f2; border-radius: 6px; font-size: 1.12rem; }
.cat-popup [data-more], .cat-popup .category-index { font-size: .83rem; min-height: 36px; padding: 7px; }
.cat-popup [data-more] { color: #075950; border: 1px solid var(--line); border-radius: 7px; background: #fff; cursor: pointer; }
.cat-popup .category-index { display: inline-flex; align-items: center; }
[data-category-status]:empty { display: none; }

/* House campaigns use their own photos and never occupy a product slot. */
.rail { min-width: 0; display: grid; align-content: start; gap: 12px; }
.trade-slider { min-width: 0; overflow: hidden; background: #123746; color: white; border-radius: 12px; }
.trade-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: thin; overscroll-behavior-x: contain; }
.trade-slider:has(.trade-controls:not([hidden])) .trade-track { scrollbar-width: none; }
.trade-card {
  display: flex; position: relative; isolation: isolate; overflow: hidden; flex: 0 0 100%; min-width: 0;
  min-height: 230px; aspect-ratio: 3 / 4.4; color: white; background: #123746;
  align-items: flex-end; scroll-snap-align: start; text-decoration: none;
}
.trade-card::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(to top, #031e27 1%, #042634eb 18%, #041e2b75 50%, transparent 76%);
}
.trade-card > img { position: absolute; z-index: -2; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.trade-card:focus-visible { outline-offset: -4px; }
.trade-copy { display: grid; align-content: end; gap: .45rem; width: 100%; padding: clamp(10px, 1.05vw, 24px); }
.trade-copy small { font-size: .66rem; letter-spacing: .025em; color: #cde9e9; }
.trade-copy strong { font: 500 clamp(1.45rem, 1.85vw, 2.8rem)/1.05 Georgia, serif; overflow-wrap: anywhere; }
.trade-link { font-size: .78rem; font-weight: 650; color: #aff0df; }
.trade-card:hover { text-decoration: none; }
.trade-card:hover .trade-link { text-decoration: underline; }
.trade-controls { display: flex; align-items: center; justify-content: space-evenly; border-top: 1px solid #ffffff26; background: #102f3c; }
.trade-controls button {
  display: grid; place-items: center; min-width: 30px; min-height: 40px; padding: 0 4px;
  font: inherit; color: #fff; background: none; border: 0; cursor: pointer;
}
.trade-controls button:hover { background: #225064; }
.trade-controls span { color: #cee4e5; font-size: .73rem; font-variant-numeric: tabular-nums; }
@media (min-width: 801px) {
  .rail { position: sticky; top: 12px; }
}
@media (max-width: 800px) {
  .trade-card { min-height: 145px; aspect-ratio: 1.75; }
  .trade-copy { padding: 12px; }
  .trade-copy strong { font-size: clamp(1.33rem, 3.5vw, 1.75rem); }
  .trade-controls button { min-height: 44px; }
  .grid-layout.left.right { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "left right" "main main"; }
  .picker-title .cat-popup { right: auto; left: 0; }
}
@media (max-width: 580px) {
  .mast .cat-menu { position: static; }
  .mast { position: relative; }
  .mast .cat-popup { top: calc(100% - 3px); right: 12px; }
  .mast .cat-trigger { gap: .3rem; padding-inline: 4px; font-size: .83rem; }
}

/* Marketplace search */
.searchbar { grid-template-columns: minmax(180px, 1.65fr) minmax(135px, .8fr) minmax(140px, .9fr) minmax(110px, .65fr) auto; }
.searchbar .cat-trigger { width: 100%; }
.keyword-wrap { position: relative; min-width: 0; display: grid; gap: 4px; }
.keyword-wrap:has(.keyword-suggestions:not([hidden])) { z-index: 7; }
.keyword-suggestions {
  position: absolute; top: calc(100% + 5px); inset-inline: 0; padding: 8px;
  background: white; border: 1px solid #bfd6dc; box-shadow: 0 12px 36px #15374724; border-radius: 11px;
}
.keyword-suggestions ul { list-style: none; margin: 0; padding: 0; max-height: min(44vh,300px); overflow-y: auto; }
.keyword-suggestions li { display: flex; align-items: center; gap: .65rem; min-height: 42px; padding: 6px; border-radius: 6px; font-size: .88rem; cursor: pointer; overflow-wrap: anywhere; }
.keyword-suggestions li:hover, .keyword-suggestions li[aria-selected=true] { background: #e6f5f1; }
.keyword-suggestions img { width: 34px; height: 32px; flex-shrink: 0; object-fit: cover; border-radius: 4px; }
.suggest-head { display: flex; justify-content: space-between; align-items: center; padding: 5px 6px; color: var(--muted); font-size: .8rem; font-weight: 650; }
.suggest-head button { background: none; color: #13655c; border: 0; cursor: pointer; }
@media (max-width: 940px) {
  .searchbar { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .keyword-wrap { grid-column: 1 / -1; }
}
@media (max-width: 580px) {
  .search-city { grid-column: 1; }
  .searchbar > .primary { grid-column: 2; }
  .searchbar .picker-title:has(.cat-menu) .cat-popup { left: auto; right: 0; }
  .cat-popup { max-width: calc(100vw - 32px); }
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chips:empty { display: none; }
.filter-chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; color: #14594e; background: #edf7f3; border: 1px solid #c4dfd7; border-radius: 20px; font-size: .85rem; text-decoration: none; }

.trade-controls button, .trade-link b { font-variant-emoji: text; }

.mast nav a.seller-cta { display: inline-flex; gap: 8px; align-items: center; padding: 8px 15px; border-radius: 9px; background: #00645f; color: white; text-decoration: none; }
.account-page { max-width: 32rem; margin: clamp(24px,8vh,88px) auto; padding: 26px; display: grid; gap: 16px; background: white; border: 1px solid var(--line); border-radius: 14px; }
.account-page h1 { font-size: clamp(1.85rem,4vw,2.55rem); line-height: 1.12; }
.account-page form { display: grid; gap: 12px; }
.account-note:empty { display: none; }
@media (max-width: 650px) {
  .mast nav .directory-link { display: none; }
  .mast nav { column-gap: .35rem; }
  .account-page { margin: 20px 12px; padding: 20px; }
}
@media (min-width: 581px) and (max-width: 1000px) {
  .mast { position: relative; }
  .mast .cat-menu { position: static; }
  .mast .cat-popup { top: calc(100% - 3px); right: var(--inset); }
}
