:root {
  --paper: #f6f3ec;
  --card: #fffdf8;
  --ink: #17150f;
  --muted: #7d776b;
  --line: rgba(23, 21, 15, 0.1);
  --accent: #1f6b52;
  --accent-soft: rgba(31, 107, 82, 0.1);
  --top: 56px;
}

* { box-sizing: border-box; margin: 0; }

html, body { height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

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

.stage {
  position: relative;
  width: 100%;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(255, 255, 255, 0.7), transparent 60%),
    var(--paper);
}

/* a whisper of grain on the paper */
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---- the header ---- */
.top {
  position: absolute;
  inset: 0 0 auto 0;
  height: var(--top);
  display: flex;
  align-items: center;
  gap: clamp(12px, 3vw, 28px);
  padding: 0 clamp(14px, 3.4vw, 36px);
  z-index: 3;
}

.top::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: var(--line);
  transform-origin: 50% 50%;
  transform: scaleX(var(--rule, 0));
}

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 640;
  font-size: 14px;
  letter-spacing: -0.01em;
  flex: none;
}

.brand svg { width: 18px; height: 18px; color: var(--accent); }

.slot { pointer-events: none; }
.slot--bar { flex: 1; height: 38px; max-width: 560px; }

.top__meta {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  flex: none;
}

/* ---- the home ---- */
.hero {
  position: absolute;
  inset: var(--top) 0 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 20px 4vh;
  gap: clamp(8px, 1.8vh, 16px);
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 560;
}

.title {
  font-family: "Fraunces Variable", Georgia, serif;
  font-weight: 420;
  font-variation-settings: "opsz" 120, "SOFT" 30;
  font-size: clamp(26px, min(6.2vw, 7.4vh), 64px);
  line-height: 1.02;
  letter-spacing: -0.025em;
}

.title em { font-style: italic; color: var(--accent); font-variation-settings: "opsz" 120, "SOFT" 100, "WONK" 1; }

.slot--home {
  width: min(560px, 86vw);
  height: clamp(48px, 8vh, 60px);
  margin-top: clamp(6px, 1.4vh, 14px);
}

.hint { font-size: 12.5px; color: var(--muted); }
.hint span { color: var(--ink); font-weight: 560; }

/* ---- the field: one element, moved between the two slots ---- */
.field {
  position: absolute;
  left: 0; top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0 0.42em 0 0.9em;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(23, 21, 15, 0.12);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 1px 2px rgba(23, 21, 15, 0.06),
    0 8px 24px -10px rgba(23, 21, 15, 0.18),
    0 22px 48px -28px rgba(23, 21, 15, 0.22);
  font-size: 17px;
  overflow: hidden;
  will-change: left, top, width, height;
}

.field.is-focus { border-color: rgba(31, 107, 82, 0.55); box-shadow: 0 0 0 4px var(--accent-soft), 0 8px 24px -10px rgba(23, 21, 15, 0.18); }

.field__lens { width: 1.05em; height: 1.05em; flex: none; color: var(--muted); }

.field__input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 1em;
  color: var(--ink);
  letter-spacing: -0.005em;
  caret-color: var(--accent);
}

.field__input::placeholder { color: #aaa397; }

.field__key, .field__close {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.9em;
  height: 1.9em;
  border-radius: 999px;
}

.field__key { background: var(--ink); color: #fff; opacity: 0; transform: scale(0.6); }
.field__key svg { width: 0.9em; height: 0.9em; }

.field__close {
  border: 0;
  background: rgba(23, 21, 15, 0.06);
  color: var(--ink);
  cursor: pointer;
  display: none;
}
.field__close svg { width: 0.8em; height: 0.8em; }

.field.is-results .field__key { display: none; }
.field.is-results .field__close { display: grid; }

.field__run {
  position: absolute;
  left: 18px; right: 18px; bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  transform-origin: 0 50%;
  transform: scaleX(0);
  opacity: 0;
}

/* ---- the results ---- */
.results {
  position: absolute;
  inset: var(--top) 0 0 0;
  display: flex;
  flex-direction: column;
  padding: clamp(10px, 2vh, 18px) clamp(14px, 3.4vw, 36px) clamp(12px, 2.6vh, 28px);
  gap: clamp(10px, 2vh, 18px);
  pointer-events: none;
  visibility: hidden;
}

.results.is-on { pointer-events: auto; visibility: visible; }

.filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-width: 0;
}

.pill {
  flex: none;
  font: inherit;
  font-size: 12px;
  font-weight: 540;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
  cursor: pointer;
}

.pill.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }

.count {
  margin-left: auto;
  flex: none;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.count__num {
  display: inline-flex;
  align-items: flex-start;
  height: 1.3em;
  overflow: hidden;
  color: var(--ink);
  font-weight: 620;
  font-variant-numeric: tabular-nums;
}

.count__col { display: flex; flex-direction: column; flex: none; align-self: flex-start; height: auto; }
.count__col span { height: 1.3em; line-height: 1.3em; }

.grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: clamp(8px, 1.6vw, 16px);
}

.card {
  position: relative;
  min-height: 0;
  container-type: size;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(23, 21, 15, 0.05), 0 10px 26px -18px rgba(23, 21, 15, 0.3);
  padding: clamp(10px, 4cqh, 18px) clamp(12px, 5cqw, 18px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  outline: none;
  cursor: pointer;
  transition: box-shadow 0.35s ease, border-color 0.35s ease;
}

.card__spec {
  position: absolute;
  left: clamp(12px, 5cqw, 18px);
  top: 2cqh;
  font-family: var(--f);
  font-variation-settings: var(--v);
  font-size: min(54cqh, 40cqw);
  line-height: 1;
  letter-spacing: -0.02em;
  transition: font-variation-settings 0.6s cubic-bezier(0.2, 0.9, 0.2, 1);
}

.card__name { font-size: 13px; font-weight: 620; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card__meta { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.card::after {
  content: "";
  position: absolute;
  right: clamp(12px, 5cqw, 18px);
  bottom: clamp(14px, 6cqh, 22px);
  width: 6px; height: 6px;
  border-right: 1.5px solid var(--accent);
  border-top: 1.5px solid var(--accent);
  transform: rotate(45deg) translate(-4px, 4px);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.2, 0.9, 0.2, 1);
}

.card.is-hover, .card:focus-visible { border-color: rgba(31, 107, 82, 0.35); box-shadow: 0 1px 2px rgba(23, 21, 15, 0.05), 0 18px 34px -18px rgba(23, 21, 15, 0.38); }
.card.is-hover .card__spec, .card:focus-visible .card__spec { font-variation-settings: var(--vh); }
.card.is-hover::after, .card:focus-visible::after { opacity: 1; transform: rotate(45deg) translate(0, 0); }

@media (hover: hover) {
  .card:hover { border-color: rgba(31, 107, 82, 0.35); box-shadow: 0 1px 2px rgba(23, 21, 15, 0.05), 0 18px 34px -18px rgba(23, 21, 15, 0.38); }
  .card:hover .card__spec { font-variation-settings: var(--vh); }
  .card:hover::after { opacity: 1; transform: rotate(45deg) translate(0, 0); }
  .pill:hover { border-color: rgba(23, 21, 15, 0.3); }
  .field__close:hover { background: rgba(23, 21, 15, 0.1); }
}

@media (max-width: 620px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid .card:nth-child(n + 5) { display: none; }
  .pill:nth-child(n + 4) { display: none; }
  .top__meta { display: none; }
  .field { font-size: 15px; }
}

@media (max-height: 520px) {
  .hint { display: none; }
  .eyebrow { display: none; }
}
