:root {
  color-scheme: light;
  --paper: #fffbf7;
  --card: #fff;
  --ink: #2f2223;
  --muted: #6e5354;
  --brand: #982e3d;
  --brand-dark: #7d2431;
  --brand-light: #f7e3e1;
  --line: #e8dbd7;
  --hero: #f5dacf;
  font-family: "Noto Sans Thai", "Leelawadee UI", Thonburi, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, h3, p, ul { margin: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.55;
}

button, input { font: inherit; }
a { color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.frame {
  width: min(76rem, calc(100% - 4rem));
  margin-inline: auto;
}

.header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.header__main {
  display: grid;
  grid-template-columns: auto minmax(12rem, 1fr) auto;
  align-items: center;
  gap: clamp(1rem, 4vw, 4rem);
  min-height: 5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  color: var(--brand);
  font: 700 clamp(1.25rem, 2.4vw, 1.8rem)/1.1 Georgia, serif;
  letter-spacing: -.045em;
  text-decoration: none;
  white-space: nowrap;
}

.brand__mark {
  position: relative;
  width: 1.45rem;
  height: 1.45rem;
  flex: 0 0 1.45rem;
  transform: rotate(45deg);
}

.brand__mark::before,
.brand__mark::after {
  position: absolute;
  inset: 29% 0;
  border-radius: 99px;
  background: currentColor;
  content: "";
}

.brand__mark::after { transform: rotate(90deg); }

.search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 3rem;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--card);
}

.search:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }
.search :focus-visible { outline: 0; }

.search input {
  width: 100%;
  min-width: 0;
  padding: .6rem 1rem;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: var(--ink);
}

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

.search__button {
  display: grid;
  min-height: 2.75rem;
  place-items: center;
  border: 0;
  border-radius: 0 .4375rem .4375rem 0;
  background: var(--brand-light);
  color: var(--brand);
}

.search__button:hover,
.search__button:focus-visible { background: #efc9c9; }

.search__icon {
  position: relative;
  width: .875rem;
  height: .875rem;
  margin: 0 .1875rem .1875rem 0;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.search__icon::after {
  position: absolute;
  right: -.3rem;
  bottom: -.15rem;
  width: .45rem;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(45deg);
  content: "";
}

.cart-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: .5rem;
  min-height: 2.75rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
}

.cart-button:hover { color: var(--brand); }

.bag-icon {
  position: relative;
  width: 1rem;
  height: .875rem;
  border: 2px solid currentColor;
  border-radius: 2px;
}

.bag-icon::before {
  position: absolute;
  top: -.48rem;
  left: .125rem;
  width: .5rem;
  height: .45rem;
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: .5rem .5rem 0 0;
  content: "";
}

.cart-count {
  min-width: 1.5rem;
  padding-inline: .3rem;
  border-radius: 1rem;
  background: var(--brand-light);
  color: var(--brand-dark);
  font-size: .875rem;
  text-align: center;
}

.category-bar { border-top: 1px solid var(--line); }

.category-bar__inner {
  display: flex;
  gap: clamp(.625rem, 2vw, 1.5rem);
  overflow-x: auto;
  scrollbar-width: none;
}

.category {
  flex: 0 0 auto;
  min-height: 2.75rem;
  padding: .5rem .3rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: .9375rem;
  white-space: nowrap;
}

.category:hover,
.category[aria-pressed="true"] { color: var(--brand-dark); }
.category[aria-pressed="true"] { border-bottom-color: var(--brand); font-weight: 750; }
.category:focus-visible { outline-offset: -3px; }

.hero {
  display: grid;
  grid-template-columns: 5fr 6fr;
  align-items: stretch;
  overflow: hidden;
  margin-block-start: 1.75rem;
  border-radius: .875rem;
  background: var(--hero);
}

.hero__copy {
  align-self: center;
  min-width: 0;
  padding: clamp(1.5rem, 4.5vw, 4rem);
}

.eyebrow {
  margin-block-end: .75rem;
  color: var(--brand-dark);
  font-size: .9375rem;
  font-weight: 750;
}

h1 {
  font-size: clamp(2.25rem, 5vw, 4.5rem);
  font-weight: 800;
  line-height: 1.15;
}

.hero__description {
  max-width: 21rem;
  margin-block-start: .875rem;
  color: var(--muted);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: .5rem 1.25rem;
  border: 1px solid transparent;
  border-radius: .4375rem;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.button:hover { background: var(--brand-dark); }
.hero__link { margin-block-start: 1.25rem; }

.hero__photo {
  position: relative;
  min-height: 25rem;
  background: #c78974;
}

.hero__photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.catalog {
  padding-block: clamp(1.75rem, 4vw, 3rem) 3rem;
  scroll-margin-top: 1rem;
}

.catalog__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem;
  margin-block-end: 1rem;
}

h2 { font-size: clamp(1.375rem, 2.7vw, 2rem); line-height: 1.35; }
.catalog__heading p, .footer { color: var(--muted); }

.product-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(.625rem, 2vw, 1.25rem);
}

.product {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: .625rem;
  background: var(--card);
}

.product__photo {
  aspect-ratio: 1;
  background-image: url("../img/mali-market-catalog.jpg");
  background-size: 200% 200%;
  background-repeat: no-repeat;
}

.product__photo[data-image="tote"] { background-position: left top; background-color: #e5baaa; }
.product__photo[data-image="mug"] { background-position: right top; background-color: #e9d0b6; }
.product__photo[data-image="headphones"] { background-position: left bottom; background-color: #d2c5dd; }
.product__photo[data-image="plant"] { background-position: right bottom; background-color: #efcfba; }

.product__details {
  display: grid;
  align-content: start;
  grid-template-rows: auto 1fr auto auto;
  flex: 1;
  gap: .25rem;
  padding: clamp(.625rem, 2vw, 1rem);
}

.product__category { color: var(--muted); font-size: .875rem; }
.product__name { font-size: 1.0625rem; line-height: 1.4; }
.product__price { margin-block: .25rem; font-size: 1.125rem; font-weight: 750; }

.product__add, .quiet-button {
  min-height: 2.75rem;
  padding: .35rem .5rem;
  border: 1px solid var(--line);
  border-radius: .375rem;
  background: var(--card);
  color: var(--brand-dark);
  font-weight: 700;
}

.product__add:hover, .quiet-button:hover { background: var(--brand-light); }

.empty-state {
  padding: 2rem 1rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  color: var(--muted);
  text-align: center;
}

.game-entry {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-block-end: 1.5rem;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: .625rem;
  background: var(--card);
}

.game-entry h2 { font-size: 1.25rem; }
.game-entry p { margin-block-start: .25rem; color: var(--muted); }

.footer { padding-block: 1.25rem; border-top: 1px solid var(--line); }

.cart {
  width: min(100%, 27rem);
  max-width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  padding: 1.5rem;
  border: 0;
  background: var(--paper);
  color: var(--ink);
}

.cart::backdrop { background: rgb(47 34 35 / .5); }

.cart__heading, .cart__total, .cart-item, .quantity { display: flex; align-items: center; gap: .65rem; }
.cart__heading, .cart-item, .cart__total { justify-content: space-between; }
.cart__empty { padding-block: 2rem; color: var(--muted); }
.cart__list { padding: 0; list-style: none; }
.cart-item { padding-block: 1rem; border-bottom: 1px solid var(--line); }
.cart-item__price { color: var(--muted); }
.quantity .quiet-button { min-width: 2.75rem; }
.cart__total { padding-block: 1.25rem; font-size: 1.15rem; }

@media (max-width: 49.99rem) {
  .frame { width: calc(100% - 2rem); }
  .header__main { grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; min-height: 0; padding-block: .625rem; }
  .search { grid-column: 1 / -1; grid-row: 2; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { margin-block-start: 1rem; }
  .hero__photo { min-height: 19rem; }
}

@media (max-width: 34.99rem) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero__photo { min-height: 0; aspect-ratio: 2 / 1; }
  .hero__photo img { object-position: 50% 52%; }
}