:root {
  --paper: #f3eee4;
  --paper-deep: #ebe4d6;
  --ink: #1d1a16;
  --ink-soft: #6b6357;
  --rule: #d6ccba;
  --accent: #ff4343;
  --accent-ink: #ffffff;
  --display: "Young Serif", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16130f;
    --paper-deep: #1f1b16;
    --ink: #efe8da;
    --ink-soft: #a39a8b;
    --rule: #3a342b;
    --accent: #ff6b6b;
    --accent-ink: #16130f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.page {
  max-width: 58rem;
  margin: 0 auto;
  padding: 3rem 1rem 4rem;
}

/* Masthead */

.kicker,
.drawer-head,
.meta {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.kicker { margin: 0 0 1rem; }

h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.2rem, 7vw, 4rem);
  line-height: 1.02;
  letter-spacing: -0.01em;
  margin: 0 0 1.25rem;
}

.lede {
  max-width: 34rem;
  margin: 0 0 2.5rem;
  color: var(--ink-soft);
}

/* The input line */

.ask {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.5rem;
  margin-bottom: 2rem;
}

.ask input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--display);
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  padding: 0.25rem 0;
  outline: none;
}

.ask input::placeholder { color: var(--ink-soft); opacity: 0.6; }

.ask button {
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.7rem 1.4rem;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.ask button:hover { transform: translateY(-1px); }
.ask button:disabled { opacity: 0.55; cursor: wait; transform: none; }
.ask input:focus-visible { outline: none; }
.ask:focus-within { border-bottom-color: var(--accent); }

/* Results */

.result { margin-bottom: 2.5rem; }

.picks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1.25rem 1.75rem;
}

.pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  animation: rise 0.35s ease both;
  animation-delay: calc(var(--rank) * 70ms);
}

.pick button {
  font-size: 2.75rem;
  line-height: 1;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

.pick:first-child button { font-size: 6rem; }

.pick .bar {
  width: 100%;
  min-width: 3rem;
  height: 3px;
  background: var(--rule);
  border-radius: 2px;
  overflow: hidden;
}

.pick .bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  width: calc(var(--p) * 100%);
}

.pick .pct {
  font-size: 0.8125rem;
  color: var(--ink-soft);
}

.pick:first-child .pct { color: var(--ink); font-weight: 500; }

.meta { margin: 1.25rem 0 0; }

.error {
  color: var(--accent);
  margin: -1rem 0 2rem;
}

/* The drawer: every emoji Jev can choose from */

.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.drawer {
  list-style: none;
  margin: 0;
  padding: 1px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.5rem, 1fr));
  gap: 1px;
  background: var(--rule);
  border-radius: 6px;
  overflow: hidden;
}

@media (min-width: 48rem) {
  .drawer { grid-template-columns: repeat(17, 1fr); }
}

.drawer li {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  background: var(--paper);
  cursor: default;
  animation: settle 0.4s ease both;
  animation-delay: calc(var(--i) * 3ms);
  transition: opacity 0.3s ease, background-color 0.3s ease;
}

.drawer li:hover { background: var(--paper-deep); }

/* After a pick: dim the drawer, light up the chosen few */
.drawer.has-picks li { opacity: 0.22; }

.drawer.has-picks li.is-picked {
  opacity: 1;
  background: var(--paper-deep);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.drawer li .tag {
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 0.5625rem;
  font-family: var(--mono);
  color: var(--accent);
}

/* While Jev is thinking, a slow scan across the drawer */
.drawer.is-thinking li { animation: scan 1.2s ease-in-out infinite; animation-delay: calc(var(--i) * 4ms); }

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

@keyframes settle { from { opacity: 0; transform: translateY(4px); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes scan { 50% { opacity: 0.35; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Embedded in the course notes (?embed): drop the masthead, keep it tight */
.embed body { background: var(--paper); }
.embed .page { padding: 1.25rem 1rem 1rem; }
.embed .masthead { display: none; }
.embed .ask { margin-bottom: 1.5rem; }
.embed .result { margin-bottom: 1.5rem; }
