:root {
  --color-bg: #f4f5f7;
  --color-header: #ffffff;
  --color-card: #ffffff;
  --color-primary: #1f3a5f;
  --color-primary-dark: #162a45;
  --color-accent: #14b8a6;
  --color-accent-dark: #0f9488;
  --color-text: #2b3440;
  --color-muted: #6b7684;
  --color-border: #e4e8ee;
  --color-footer-link: #6a9fd4;
  --color-footer-link-hover: #4a83c4;
  --shadow-sm: 0 1px 2px rgba(31, 58, 95, 0.06);
  --shadow-md: 0 6px 18px rgba(31, 58, 95, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Header ---------- */
.site-header {
  background: var(--color-header);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.site-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
}

.site-logo {
  display: inline-flex;
}

.site-logo img {
  height: 40px;
  width: auto;
  display: block;
}

/* Same type scale as .footer-nav a, so header and footer links read as a set. */
.header-contact {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  color: var(--color-primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: color 0.15s ease;
}

.header-contact:hover {
  color: var(--color-primary-dark);
}

/* Underline the wording only — the icon inherits the colour but not the rule. */
.header-contact:hover .header-contact__label {
  text-decoration: underline;
}

.header-contact__icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

/* ---------- Main / intro ---------- */
.site-main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

.page-intro {
  margin-bottom: 28px;
  text-align: center;
}

.page-intro h1 {
  margin: 0 0 6px;
  font-size: 28px;
  color: var(--color-primary);
}

.page-intro p,
.page-intro h2 {
  margin: 0;
  color: var(--color-muted);
}

/* Same size and colour as the paragraph it replaced — just bold. */
.page-intro h2 {
  font-size: 1rem;
  font-weight: 700;
}

/* ---------- Toolbar (result count + search) ---------- */
/* Uses the same track geometry as .card-grid so its edges line up exactly with
   the cards; a plain full-width row drifts when 1fr columns round down. */
.toolbar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  align-items: center;
  margin-bottom: 22px;
}

.toolbar__count {
  grid-column: 1 / 2;
  margin: 0;
  font-size: 15px;
  color: var(--color-muted);
}

/* Clear sits in the middle column, right up against the search bar. */
.toolbar__clear {
  grid-column: 2 / 3;
  justify-self: end;
  color: var(--color-primary);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.toolbar__clear:hover {
  text-decoration: underline;
}

/* ---------- Search ---------- */
/* Border and radius live on the form so the input and button read as one
   control, with a single focus ring around the whole thing. */
.search {
  grid-column: 3 / -1;      /* one full track = exactly one card wide */
  display: flex;
  /* Fill the track explicitly rather than relying on justify-self: stretch,
     so the bar never falls back to its intrinsic content width. */
  width: 100%;
  min-width: 0;
  background: #fff;
  border: 1px solid #d5dce6;
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(31, 58, 95, 0.12);
}

.search__input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--color-text);
  background: transparent;
  border: none;
}

.search__input::placeholder {
  color: var(--color-muted);
}

.search__input:focus {
  outline: none;
}

.search__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  background: var(--color-primary);
  color: #ffffff;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.search__button:hover {
  background: var(--color-primary-dark);
}

.search__icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

/* Follow .card-grid's column counts so the search stays one card wide. */
@media (max-width: 900px) {
  .toolbar {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Two tracks: count and Clear share the first, search takes the second.
     Reserve room so a long count can't run underneath the Clear link. */
  .toolbar__clear {
    grid-column: 1 / 2;
  }

  .toolbar__count {
    padding-right: 56px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .search {
    grid-column: 2 / -1;
  }
}

@media (max-width: 520px) {
  .toolbar {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .toolbar__count {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .toolbar__clear {
    grid-column: 1 / -1;
    grid-row: 1;
    justify-self: end;
  }

  .search {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

/* ---------- Card grid ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

/* Name is the identifier, domain the supporting detail. Stretching the block
   and clamping the name to one line keeps the logo panels aligned across a row. */
.card__head {
  align-self: stretch;
  margin-bottom: 14px;
}

.card__name {
  margin: 0 0 3px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Name links to the brand site but stays underline-free on hover. */
.card__name a {
  color: inherit;
  text-decoration: none;
}

.card__domain {
  margin: 0;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--color-muted);
  word-break: break-word;
}

.card__domain a {
  color: inherit;
  text-decoration: none;
}

/* No underline (matching the name link); the colour shift keeps a hover cue. */
.card__domain a:hover {
  color: var(--color-primary);
}

/* A 4:3 panel (rather than a fixed 2:1 height) lets square-ish product photos
   render far larger, and scales with the card as the grid reflows. */
.card__logo {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  padding: 10px;
  background: #f0f3f7;
  border-radius: 8px;
  overflow: hidden;
}

/* The link and <picture> fill the panel so the image below still sizes against
   the full box (<picture> is inline by default, which would collapse it). */
.card__logo a,
.card__logo picture {
  display: block;
  width: 100%;
  height: 100%;
}

/* width/height (not max-*) so images scale UP to fill the box as well as down,
   keeping every card consistent regardless of the source image's resolution. */
.card__logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.25s ease;
}

.card:hover .card__logo img {
  transform: scale(1.04);
}

.card__button {
  display: block;
  align-self: stretch;
  margin-top: auto;
  padding: 10px 26px;
  background: var(--color-primary);
  color: #ffffff;
  text-align: center;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.3px;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.card__button:hover {
  background: var(--color-primary-dark);
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 40px;
}

.pagination__link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
  padding: 8px 14px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #fff;
}

.pagination__link:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
}

.pagination__status {
  color: var(--color-muted);
  font-size: 14px;
}

.empty-state {
  color: var(--color-muted);
  text-align: center;
  padding: 60px 0;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-header);
}

.site-footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px;
  text-align: center;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin-bottom: 10px;
}

.footer-nav a {
  color: var(--color-primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.footer-nav a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
}

.footer-copy {
  margin: 0;
  color: var(--color-muted);
  font-size: 13px;
}

/* ---------- Content pages (Terms / Privacy) ---------- */
.content-page {
  max-width: 760px;
  margin: 0 auto;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 36px 40px;
}

.content-page h1 {
  margin: 0 0 4px;
  color: var(--color-primary);
  font-size: 28px;
}

.content-page h2 {
  margin: 28px 0 8px;
  color: var(--color-primary);
  font-size: 18px;
}

.content-page p {
  margin: 0 0 14px;
  color: var(--color-text);
}

.content-page a {
  color: var(--color-footer-link-hover);
}

.content-page__updated {
  color: var(--color-muted);
  font-size: 13px;
}

.content-page__note {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 13px;
  font-style: italic;
}

/* ---------- Forms (Contact) ---------- */
.form-card {
  max-width: 560px;
  margin: 0 auto;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 32px 36px;
}

.form-card--message {
  text-align: center;
}

.form-card--message h1 {
  margin: 0 0 10px;
  color: var(--color-primary);
}

.form-card--message p {
  color: var(--color-muted);
  margin: 0 0 22px;
}

.form-field {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
}

.form-field label {
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-primary);
}

.form-field .req {
  color: var(--color-accent-dark);
}

.contact-form input,
.contact-form select,
.contact-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--color-text);
  background: #fff;
}

.contact-form input:focus,
.contact-form select:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(31, 58, 95, 0.12);
}

.contact-form textarea {
  resize: vertical;
}

.form-help {
  margin-top: 5px;
  font-size: 12px;
  color: var(--color-muted);
}

.form-error {
  margin: 6px 0 0;
  font-size: 13px;
  color: #c0392b;
}

.form-errors {
  margin-bottom: 18px;
  color: #c0392b;
  font-size: 14px;
}

.btn-primary {
  display: inline-block;
  margin-top: 6px;
  padding: 11px 28px;
  background: var(--color-primary);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px) {
  .card-grid {
    grid-template-columns: 1fr;
  }

  /* Shrink the wordmark so the contact link keeps its own room on one line. */
  .site-logo img {
    height: 32px;
  }
}

/* Narrowest phones: drop to the icon alone, like the icon-only search button.
   The anchor's aria-label carries the name once the wording is gone. */
@media (max-width: 380px) {
  .header-contact__label {
    display: none;
  }
}
