:root {
  color-scheme: light;
  --bg: #ffffff;
  --text: #141414;
  --text-muted: #666666;
  --hairline: #dddddd;
  --focus-ring: #1660c9;
  --error: #c0392b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0 24px;
  background: var(--bg);
  color: var(--text);
  font-family: 'Radio Canada', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  line-height: 1.45;
}

@media (min-width: 900px) {
  body {
    padding: 0 40px;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------- */
/* Header                                                                  */
/* ---------------------------------------------------------------------- */

.site-header {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.75rem 0 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.85rem;
}

@media (min-width: 600px) {
  .site-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
  }
}

.brand {
  display: flex;
  align-items: center;
}

.logo {
  height: 36px;
  width: auto;
  display: block;
}

@media (min-width: 600px) {
  .logo {
    height: 44px;
  }
}

.logo-fallback {
  font-family: 'Radio Canada Big', 'Radio Canada', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  color: var(--text);
}

.heading-block {
  text-align: left;
}

@media (min-width: 600px) {
  .heading-block {
    text-align: right;
  }
}

.price-heading {
  margin: 0;
  font-family: 'Radio Canada Big', 'Radio Canada', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.75rem;
  text-transform: uppercase;
  letter-spacing: -0.03em;
}

.subtitle {
  margin: 0.3rem 0 0;
  font-family: 'Radio Canada', system-ui, sans-serif;
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.rule {
  max-width: 1200px;
  margin: 0 auto;
  height: 0;
  border: none;
  border-top: 1px solid var(--hairline);
}

/* ---------------------------------------------------------------------- */
/* Controls (search / category filter)                                     */
/* ---------------------------------------------------------------------- */

.controls {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.1rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
}

.search-field {
  flex: 1 1 auto;
  width: 100%;
  max-width: none;
}

@media (min-width: 600px) {
  .search-field {
    width: auto;
    max-width: 320px;
  }
}

#search {
  width: 100%;
  padding: 0.5rem 0.05rem;
  font-family: 'Radio Canada', system-ui, sans-serif;
  font-size: 0.95rem;
  color: var(--text);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--hairline);
  border-radius: 0;
}

#search::placeholder {
  color: var(--text-muted);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filters[hidden] {
  display: none;
}

.filter-btn {
  padding: 0.4rem 0.9rem;
  font-family: 'Radio Canada', system-ui, sans-serif;
  font-size: 0.85rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.filter-btn:hover {
  border-color: var(--text);
}

.filter-btn[aria-pressed="true"] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

/* ---------------------------------------------------------------------- */
/* Status (loading / empty / error / no-results)                           */
/* ---------------------------------------------------------------------- */

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.25rem 0 3rem;
  min-height: 40vh;
}

.status {
  margin: 0;
  padding: 1.25rem 0;
  font-family: 'Radio Canada', system-ui, sans-serif;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.status.error {
  color: var(--error);
}

/* ---------------------------------------------------------------------- */
/* Product grid                                                            */
/* ---------------------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px 16px;
}

@media (min-width: 600px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 24px 20px;
  }
}

@media (min-width: 900px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 32px 24px;
  }
}

.card {
  display: flex;
  flex-direction: column;
}

.card-media {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--hairline);
  overflow: hidden;
  border-radius: 0;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-body {
  padding-top: 0.65rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  column-gap: 0.6rem;
  row-gap: 0.25rem;
}

/* DOM order from script.js is title, weight, price (OPTIONAL_FIELDS order) -
   `order` puts price next to the title on row one and pushes weight to its
   own full-width row two, without touching script.js's markup order. */

.card-title {
  order: 1;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-family: 'Radio Canada', system-ui, sans-serif;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
}

.card-price {
  order: 2;
  flex: 0 1 auto;
  margin: 0;
  font-family: 'Radio Canada', system-ui, sans-serif;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
  text-align: right;
  white-space: normal;
}

.card-weight {
  order: 3;
  flex: 1 1 100%;
  margin: 0;
  font-family: 'Radio Canada', system-ui, sans-serif;
  font-weight: 400;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ---------------------------------------------------------------------- */
/* Footer                                                                   */
/* ---------------------------------------------------------------------- */

.site-footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 0 2.5rem;
  border-top: 1px solid var(--hairline);
  color: var(--text-muted);
  font-family: 'Radio Canada', system-ui, sans-serif;
  font-size: 0.8rem;
}
