:root {
  --butter: #f6e7a6;      /* page */
  --butter-deep: #ecd47a; /* wells, inputs */
  --rind: #2e2416;        /* text */
  --rind-soft: #6b5a3c;   /* secondary text */
  --wax: #b3202a;         /* selection, focus */
  --mould: #3c5a74;       /* links */
  --paper: #fffbe8;       /* dialog */

  /* rind colours per style */
  --st-blue: #4f6f8c;
  --st-washed: #c9772f;
  --st-bloomy: #f4f1e6;
  --st-stretched: #f3efe2;
  --st-whey: #b97a45;
  --st-brined: #e6ecea;
  --st-fresh: #fbfaf3;
  --st-processed: #e8a33b;
  --st-hard: #b8923f;
  --st-semi: #dcb75b;
  --st-none: #cdb46a;

  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --text: "Literata", Georgia, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--butter);
  color: var(--rind);
  font: 400 1.0625rem/1.6 var(--text);
  /* faint eyes in the paste */
  background-image:
    radial-gradient(circle at 12% 18%, rgba(201,161,63,.18) 0 22px, transparent 23px),
    radial-gradient(circle at 86% 9%, rgba(201,161,63,.14) 0 34px, transparent 35px),
    radial-gradient(circle at 70% 32%, rgba(201,161,63,.12) 0 14px, transparent 15px);
  background-attachment: fixed;
}
a { color: var(--mould); text-underline-offset: .18em; }
a:hover { color: var(--wax); }
:focus-visible { outline: 3px solid var(--wax); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- masthead ---------- */
.masthead {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(28px, 6vw, 72px) 16px 8px;
}
.wordmark {
  margin: 0;
  font: 800 clamp(3.4rem, 15vw, 10.5rem)/.82 var(--display);
  font-variation-settings: "opsz" 96;
  letter-spacing: -.035em;
}
.wordmark a { color: var(--rind); text-decoration: none; }
.wordmark .dot { color: var(--wax); }
.lede {
  max-width: 34em;
  margin: 22px 0 26px;
  font-size: 1.2rem;
  line-height: 1.55;
  color: var(--rind-soft);
}
.search { display: flex; gap: 10px; flex-wrap: wrap; max-width: 760px; }
.search input {
  flex: 1 1 280px;
  min-width: 0;
  padding: 14px 18px;
  border: 2px solid var(--rind);
  border-radius: 999px;
  background: var(--paper);
  color: var(--rind);
  font: 400 1.05rem var(--text);
}
.search input::placeholder { color: #8f7c55; }
button {
  font: 600 1rem var(--display);
  cursor: pointer;
}
#random {
  padding: 14px 22px;
  border: 2px solid var(--wax);
  border-radius: 999px;
  background: var(--wax);
  color: #fff7e0;
}
#random:hover { background: #8f1820; border-color: #8f1820; }

/* ---------- filters ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "milk country" "style style";
  gap: 22px 36px;
  margin-top: 40px;
  padding: 22px 0;
  border-top: 2px solid var(--rind);
  border-bottom: 1px solid rgba(46,36,22,.25);
}
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.filters .milk { grid-area: milk; }
.filters .style { grid-area: style; }
.filters .country { grid-area: country; }
legend {
  padding: 0;
  margin-bottom: 10px;
  font: 600 .95rem var(--display);
  color: var(--rind-soft);
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px 6px 8px;
  border: 1.5px solid rgba(46,36,22,.4);
  border-radius: 999px;
  background: transparent;
  color: var(--rind);
  font: 400 .95rem var(--display);
}
.chip .swatch { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid rgba(46,36,22,.45); }
.chip .n { color: var(--rind-soft); font-size: .82rem; }
.chip[aria-pressed="true"] { background: var(--rind); border-color: var(--rind); color: var(--butter); }
.chip[aria-pressed="true"] .n { color: var(--butter-deep); }
.chip:hover { border-color: var(--rind); }
select {
  padding: 9px 14px;
  border: 1.5px solid rgba(46,36,22,.4);
  border-radius: 999px;
  background: var(--paper);
  color: var(--rind);
  font: 400 .95rem var(--display);
  max-width: 100%;
}

.resultbar { display: flex; align-items: baseline; gap: 16px; margin: 20px 0 8px; }
#count { margin: 0; font: 600 1.05rem var(--display); }
#clear { padding: 0; border: 0; background: none; color: var(--mould); text-decoration: underline; text-underline-offset: .18em; font: 400 .95rem var(--display); }

/* ---------- the counter: wheels ---------- */
.counter {
  list-style: none;
  margin: 0;
  padding: 18px 0 64px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 34px 22px;
}
.wheel { text-align: center; }
.wheel a { display: block; color: var(--rind); text-decoration: none; }
.disc {
  --rind-c: var(--st-none);
  position: relative;
  display: block;
  aspect-ratio: 1;
  width: 100%;
  border-radius: 50%;
  border: 9px solid var(--rind-c);
  box-shadow: 0 0 0 2px var(--rind), 0 6px 0 2px var(--rind);
  overflow: hidden;
  background: radial-gradient(circle at 35% 30%, #f8e6a8, #e2c26b);
  transition: transform .18s ease;
}
.disc img { width: 100%; height: 100%; object-fit: cover; display: block; }
.disc .initial {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font: 800 3rem var(--display); color: rgba(46,36,22,.35);
}
.wheel a:hover .disc { transform: translateY(-4px) rotate(-4deg); }
.wheel .name {
  display: block;
  margin-top: 14px;
  font: 600 1.02rem/1.2 var(--display);
  overflow-wrap: anywhere;
}
.wheel .where { display: block; margin-top: 3px; font-size: .84rem; color: var(--rind-soft); }

.empty { padding: 40px 0 80px; font-size: 1.15rem; }

/* style → rind colour */
[data-st="Blue"] { --rind-c: var(--st-blue); }
[data-st="Washed rind"] { --rind-c: var(--st-washed); }
[data-st="Bloomy rind"] { --rind-c: var(--st-bloomy); }
[data-st="Stretched curd"] { --rind-c: var(--st-stretched); }
[data-st="Whey"] { --rind-c: var(--st-whey); }
[data-st="Brined"] { --rind-c: var(--st-brined); }
[data-st="Fresh"] { --rind-c: var(--st-fresh); }
[data-st="Processed"] { --rind-c: var(--st-processed); }
[data-st="Hard"] { --rind-c: var(--st-hard); }
[data-st="Semi-soft"] { --rind-c: var(--st-semi); }
.swatch { background: var(--rind-c, var(--st-none)); }

/* ---------- detail ---------- */
dialog {
  width: min(920px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 2px solid var(--rind);
  border-radius: 22px;
  background: var(--paper);
  color: var(--rind);
  box-shadow: 0 10px 0 var(--rind);
}
dialog::backdrop { background: rgba(46,36,22,.55); }
dialog[open] { animation: cut .22s ease-out; }
@keyframes cut { from { transform: translateY(18px) scale(.98); opacity: 0; } }
dialog article { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 42px; height: 42px;
  border: 2px solid var(--rind); border-radius: 50%;
  background: var(--paper); color: var(--rind);
  font: 400 1.6rem/1 var(--display);
}
.d-photo { margin: 0; background: var(--butter-deep); min-height: 280px; position: relative; }
.d-photo img { width: 100%; height: 100%; object-fit: cover; display: block; position: absolute; inset: 0; }
.d-photo figcaption {
  position: absolute; left: 10px; bottom: 10px;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(255,251,232,.9); font: 400 .78rem var(--display);
}
.d-body { padding: 34px 34px 30px; }
#d-name { margin: 0 44px 4px 0; font: 800 clamp(2rem, 5vw, 3rem)/1 var(--display); letter-spacing: -.03em; }
.d-tag { margin: 6px 0 16px; color: var(--rind-soft); font-style: italic; }
.d-summary { margin: 0 0 22px; max-width: 38em; line-height: 1.7; }
.d-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; margin: 0 0 22px; font-size: .97rem; }
.d-facts dt { font: 600 .95rem var(--display); color: var(--rind-soft); }
.d-facts dd { margin: 0; }
.d-facts button {
  padding: 0; border: 0; background: none; color: var(--mould);
  font: inherit; text-decoration: underline; text-underline-offset: .18em;
}
.d-links { margin: 0; font: 400 .92rem var(--display); }

/* ---------- footer ---------- */
.colophon {
  max-width: 1180px; margin: 0 auto; padding: 22px 16px 48px;
  border-top: 2px solid var(--rind);
  font-size: .85rem; color: var(--rind-soft);
}
.colophon p { max-width: 60em; margin: 0; }

@media (max-width: 760px) {
  .filters { grid-template-columns: 1fr; grid-template-areas: "milk" "style" "country"; }
  .counter { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 26px 16px; }
  .disc { border-width: 7px; }
  dialog article { grid-template-columns: 1fr; }
  .d-photo { min-height: 0; aspect-ratio: 4 / 3; }
  .d-body { padding: 24px 20px 26px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
