:root {
  --ink: #111111;
  --muted: #5e5e5e;
  --rule: #e2e2de;
  --chip-rule: #cfcfca;
  --star-off: #d5d5d0;
  --paper: #ffffff;
  --accent: #2443d6;
  --gutter: clamp(16px, 4vw, 48px);
  --display: "Archivo", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--display);
}

a { color: var(--ink); }
a:hover { color: var(--accent); }
button, select { font: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.wrap {
  max-width: 1344px;
  margin: 0 auto;
  padding-inline: var(--gutter);
  box-sizing: content-box;
}

.label {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

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

.star-on { fill: var(--accent); }
.star-off { fill: var(--star-off); }

/* Header */

.site-header { border-bottom: 2px solid var(--ink); }

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 32px;
  padding-block: 18px;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-size: 34px;
  line-height: 1;
  font-weight: 850;
  font-stretch: 75%;
  letter-spacing: -0.01em;
}

/* Hero and rating tiles */

.hero {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding-block: 56px 48px;
}

.hero__copy { display: flex; flex-direction: column; gap: 16px; }

.hero h1 {
  margin: 0;
  max-width: 16ch;
  font-size: clamp(44px, 6.4vw, 92px);
  line-height: 0.92;
  font-weight: 800;
  font-stretch: 75%;
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0;
  max-width: 58ch;
  font-size: 18px;
  line-height: 1.5;
  color: var(--muted);
}

fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.ratings legend { padding: 0; margin-bottom: 12px; }

.ratings__tiles { display: flex; flex-wrap: wrap; gap: 8px; }

.tile {
  flex: 1 1 140px;
  min-height: 148px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
}

.tile__numeral {
  font-size: 68px;
  line-height: 0.85;
  font-weight: 800;
  font-stretch: 75%;
  letter-spacing: -0.02em;
}

.tile__foot { display: flex; flex-direction: column; gap: 8px; }
.tile__stars { display: flex; gap: 2px; }

.tile[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}
.tile[aria-pressed="true"] .label { color: var(--paper); }
.tile[aria-pressed="true"] .star-on { fill: var(--paper); }
.tile[aria-pressed="true"] .star-off { fill: rgb(255 255 255 / 0.35); }

/* Toolbar */

.toolbar {
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

.toolbar__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 32px;
  padding-block: 14px;
}

.sections__chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--chip-rule);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.toolbar__controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }

.sort { display: flex; align-items: center; gap: 10px; }

.sort select {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: 0;
  text-transform: none;
}

.view-toggle { display: flex; }

.view-toggle button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.view-toggle button + button { margin-left: -1px; }
.view-toggle button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.view-toggle svg { fill: none; stroke: currentColor; stroke-width: 1.5; }

/* Results */

.results { padding-block: 28px 0; }
.results[aria-busy="true"] .reviews { opacity: 0.45; }

.results__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  padding-bottom: 24px;
}

.results__head h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.1;
  font-weight: 800;
  font-stretch: 80%;
}

.reviews { list-style: none; margin: 0; padding: 0; transition: opacity 120ms; }

.stars { display: flex; gap: 3px; }

/* Grid view */

.reviews[data-view="grid"] {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 44px 24px;
}

.reviews[data-view="grid"] li { display: flex; min-width: 0; }

.card {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 14px;
  border-top: 2px solid var(--ink);
  text-decoration: none;
}

.card__image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 3;
  object-fit: cover;
  background: #f0f0ec;
}

.card__image--empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

.card__image--empty svg { fill: var(--star-off); }

.card__meta { display: flex; justify-content: space-between; gap: 12px; }

.card__text { display: flex; flex-direction: column; gap: 8px; }

.card__tagline {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  font-size: 16px;
  line-height: 1.4;
  color: var(--muted);
}

.card:hover .card__tagline { color: var(--ink); }

.card h3 {
  margin: 0;
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
  font-stretch: 75%;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.card__foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 15px;
  color: var(--muted);
}

.card__foot svg { flex: none; fill: none; stroke: var(--accent); stroke-width: 1.75; stroke-linecap: round; }

/* List view: the same items laid out as rows, scrolling sideways on a phone */

.list-head { display: none; }

.results:has(.reviews[data-view="list"]) { overflow-x: auto; }

.results:has(.reviews[data-view="list"]) .list-head,
.reviews[data-view="list"] .card {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr) 120px 200px 112px;
  gap: 16px;
  min-width: 760px;
}

.results:has(.reviews[data-view="list"]) .list-head {
  padding-bottom: 10px;
  border-bottom: 2px solid var(--ink);
}

.reviews[data-view="list"] .card {
  align-items: center;
  padding: 14px 0;
  border-top: 0;
  border-bottom: 1px solid var(--rule);
}

/* Reorder the card's parts into columns: stars, title, section, critic, date. */
.reviews[data-view="list"] .card__meta,
.reviews[data-view="list"] .card__foot { display: contents; }
.reviews[data-view="list"] .stars { grid-column: 1; grid-row: 1; }
.reviews[data-view="list"] .card .stars svg { width: 18px; height: 18px; }
.reviews[data-view="list"] .card__image { display: none; }
.reviews[data-view="list"] .card__text { grid-column: 2; grid-row: 1; gap: 4px; }
.reviews[data-view="list"] h3 { font-size: 21px; line-height: 1.15; font-weight: 750; font-stretch: 80%; }
.reviews[data-view="list"] .card__tagline { -webkit-line-clamp: 1; font-size: 14px; }
.reviews[data-view="list"] .card__section { grid-column: 3; grid-row: 1; }
.reviews[data-view="list"] .card__critic { grid-column: 4; grid-row: 1; }
.reviews[data-view="list"] .card__date { grid-column: 5; grid-row: 1; }
.reviews[data-view="list"] .card__foot svg { display: none; }

.results__foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-top: 56px;
}

.results__foot:empty { padding-top: 0; }

.button {
  min-height: 50px;
  padding: 0 30px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.button:disabled { opacity: 0.6; cursor: progress; }

.message {
  margin: 0;
  max-width: 28ch;
  font-size: 30px;
  line-height: 1.05;
  font-weight: 800;
  font-stretch: 75%;
  text-align: center;
}

/* Footer */

.site-footer { margin-top: 72px; border-top: 2px solid var(--ink); }

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px 32px;
  padding-block: 28px 44px;
}

.site-footer p:first-child {
  margin: 0;
  max-width: 62ch;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.site-footer .label a { color: inherit; }

/* On a phone the rating tiles and section chips scroll sideways instead of stacking. */
@media (max-width: 640px) {
  .hero { padding-block: 28px 20px; gap: 20px; }
  .hero h1 { font-size: 46px; }
  .hero p { font-size: 16px; }

  .ratings__tiles,
  .sections__chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-inline: calc(-1 * var(--gutter));
    padding-inline: var(--gutter);
    scrollbar-width: none;
  }

  .tile { flex: 0 0 104px; min-height: 120px; padding: 12px; }
  .tile__numeral { font-size: 46px; }
  .tile .label { font-size: 11px; letter-spacing: 0.04em; }
  .chip { flex: none; }

  .reviews[data-view="grid"] { gap: 28px; }
  .card h3 { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .reviews { transition: none; }
}
