/* Single light theme by choice — these tokens are repeated under every theme
   selector so the viewer's dark toggle can't repaint the page. */
:root,
:root[data-theme="dark"],
:root[data-theme="light"] {
  color-scheme: light;
  --paper:      #ffffff;
  --sunk:       #faf9f5;   /* ivory */
  --ivory:      #f0eee6;   /* deeper ivory */
  --ink:        #141413;
  --muted:      #6b665c;
  --quiet:      #767061;
  --rule:       #e8e5dd;
  --mark:       #fbdccb;   /* pale clay wash */
  --clay:       #d97757;   /* Claude clay — fills, borders */
  --clay-ink:   #b0522c;   /* deeper clay — text, focus rings */
  --shadow:      0 1px 2px rgba(20,20,19,.05), 0 6px 20px rgba(20,20,19,.06);
  --shadow-lift: 0 1px 2px rgba(20,20,19,.07), 0 10px 34px rgba(20,20,19,.11);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans:  "Avenir Next", Avenir, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- stage ---------------- */
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1.25rem 3rem;
}
.hero {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(3.5rem, 14vh, 9rem) 0 0;
}
body.searched .hero { justify-content: flex-start; padding-top: 3.5rem; }

.head { width: 100%; max-width: 34rem; }

/* ---------------- wordmark ---------------- */
.wordmark {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2rem, 6.4vw, 3.1rem);
  line-height: 1.12;
  letter-spacing: -.02em;
  text-align: center;
  margin: 0 0 1.75rem;
  text-wrap: balance;
  transition: font-size .3s ease, margin .3s ease;
}
body.searched .wordmark { font-size: clamp(1.3rem, 3.8vw, 1.65rem); margin-bottom: 1.25rem; }

.wordmark .fill { color: var(--clay); font-style: italic; }
.wordmark .fill .blankline {
  display: inline-block;
  width: 1.7em;
  height: .68em;
  border-bottom: .055em solid var(--clay);
  vertical-align: baseline;
}
.wordmark .fill::after {
  content: "";
  display: inline-block;
  width: .045em; height: .78em;
  background: var(--clay);
  margin-left: .07em;
  vertical-align: -.06em;
  animation: blink 1.15s steps(1) infinite;
}
body.typing .wordmark .fill::after { animation: none; opacity: 1; }
@keyframes blink { 0%,49% { opacity: 1 } 50%,100% { opacity: 0 } }

/* ---------------- search ---------------- */
.searchwrap { position: relative; }

.pill {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: .75rem 1.15rem;
  box-shadow: var(--shadow);
  transition: box-shadow .18s ease, border-color .18s ease;
}
.pill:hover { box-shadow: var(--shadow-lift); }
.pill:focus-within { box-shadow: var(--shadow-lift); border-color: var(--clay); }
.searchwrap.open .pill { border-radius: 1.45rem 1.45rem 0 0; box-shadow: var(--shadow-lift); }

.prefix {
  font-family: var(--serif);
  color: var(--quiet);
  white-space: nowrap;
  user-select: none;
  font-size: 1.0625rem;
}
#q {
  flex: 1;
  min-width: 0;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: none;
  padding: 0;
}
#q::placeholder { color: var(--quiet); }
#q::-webkit-search-cancel-button { -webkit-appearance: none; }

.iconbtn {
  flex: none;
  display: grid; place-items: center;
  width: 1.75rem; height: 1.75rem;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--quiet);
  cursor: pointer; padding: 0;
}
.iconbtn:hover { background: var(--ivory); color: var(--ink); }
.iconbtn:focus-visible { outline: 2px solid var(--clay-ink); outline-offset: 2px; }
.iconbtn svg { width: 1rem; height: 1rem; display: block; }

/* ---------------- suggestions ---------------- */
.suggest {
  position: absolute;
  left: 0; right: 0; top: 100%;
  background: var(--paper);
  border: 1px solid var(--clay);
  border-top: 0;
  border-radius: 0 0 1.45rem 1.45rem;
  box-shadow: var(--shadow-lift);
  padding: .4rem 0 .6rem;
  z-index: 20;
  display: none;
  max-height: 21rem;
  overflow-y: auto;
}
.searchwrap.open .suggest { display: block; }

.sg {
  display: flex; align-items: baseline; gap: .6rem;
  padding: .45rem 1.15rem;
  cursor: pointer;
}
.sg:hover, .sg.on { background: var(--sunk); }
.sg .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg .t b { font-weight: 600; color: var(--ink); }
.sg .n { font-size: .75rem; color: var(--quiet); font-variant-numeric: tabular-nums; flex: none; }

/* ---------------- actions ---------------- */
.actions { display: flex; gap: .625rem; justify-content: center; margin-top: 1.5rem; flex-wrap: wrap; }
body.searched .actions { display: none; }
.btn {
  font-family: var(--sans); font-size: .875rem;
  background: var(--sunk); color: var(--muted);
  border: 1px solid var(--rule); border-radius: 999px;
  padding: .55rem 1.25rem; cursor: pointer;
}
.btn:hover { border-color: var(--clay); color: var(--clay-ink); background: var(--paper); }
.btn:focus-visible { outline: 2px solid var(--clay-ink); outline-offset: 2px; }

.tagline {
  text-align: center; color: var(--quiet); font-size: .9375rem;
  margin-top: 2.25rem; line-height: 1.65;
}
.tagline em { font-family: var(--serif); font-size: .9375rem; }
.tagline .hl { color: var(--clay); font-weight: 700; }
body.searched .tagline { display: none; }

/* ---------------- results ---------------- */
.results { width: 100%; max-width: 40rem; margin-top: 2rem; }
body:not(.searched) .results { display: none; }

.rcount { font-size: .8125rem; color: var(--quiet); margin-bottom: 1.25rem; padding-left: .1rem; }
.rcount b { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }

.card {
  display: block; text-decoration: none; color: inherit;
  padding: 1rem 1.15rem;
  border-radius: .875rem;
  border: 1px solid transparent;
}
.card:hover { background: var(--sunk); border-color: var(--rule); }
.card:focus-visible { outline: 2px solid var(--clay-ink); outline-offset: 1px; }

.chead { display: flex; align-items: baseline; gap: .55rem; flex-wrap: wrap; margin-bottom: .3rem; }
.cname { font-weight: 600; font-size: 1rem; letter-spacing: -.008em; }
.card:hover .cname { color: var(--clay-ink); }
.cbatch { font-size: .75rem; color: var(--quiet); }
.cdot { color: var(--rule); }
.csays {
  font-size: .75rem; color: var(--muted);
  background: var(--ivory); border-radius: 999px; padding: .12rem .55rem;
}
.card.hot .csays { background: var(--clay-ink); color: #fff; }

.cline { font-family: var(--serif); font-size: 1rem; color: var(--muted); line-height: 1.55; }
.cline mark { background: var(--mark); color: var(--ink); padding: .06em .2em; border-radius: 3px; }

/* ---------------- empty ---------------- */
.empty { padding: .5rem .1rem 1rem; max-width: 34rem; }
.empty h2 {
  font-family: var(--serif); font-weight: 400;
  font-size: 1.4375rem; letter-spacing: -.015em; margin: 0 0 .6rem;
}
.empty p { color: var(--muted); font-size: .9375rem; margin: 0 0 1.1rem; }
.near { display: flex; flex-wrap: wrap; gap: .4rem; }
.near button {
  font-family: var(--sans); font-size: .8125rem; cursor: pointer;
  background: var(--sunk); border: 1px solid var(--rule); border-radius: 999px;
  padding: .28rem .75rem; color: var(--muted);
}
.near button:hover { color: var(--clay-ink); border-color: var(--clay); background: var(--paper); }
.near button:focus-visible { outline: 2px solid var(--clay-ink); outline-offset: 2px; }

/* ---------------- leaderboard (inline on landing) ---------------- */
.landing-board { width: 100%; max-width: 40rem; margin-top: 2.5rem; }
body.searched .landing-board { display: none; }

.lb-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
  padding: 1.75rem 1.9rem 1.6rem;
}
.lb-eyebrow {
  font-size: .72rem; letter-spacing: .13em; text-transform: uppercase;
  color: var(--quiet); margin-bottom: .9rem;
}
.lb-head {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(1.4rem, 4.6vw, 1.85rem); line-height: 1.28;
  letter-spacing: -.01em; margin: 0 0 1.5rem; text-wrap: balance;
}
.lb-head mark { background: var(--mark); color: var(--ink); padding: .04em .25em; border-radius: 5px; }

.lb-rows { display: flex; flex-direction: column; gap: .5rem; }
.lb-row {
  display: flex; align-items: center; gap: .85rem; width: 100%;
  font: inherit; color: inherit; text-align: left; cursor: pointer;
  background: none; border: 0; padding: .12rem 0;
}
.lb-name {
  flex: none; width: 7rem; text-align: right;
  font-size: .95rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lb-track { flex: 1; height: .62rem; min-width: 3rem; background: #efece4; border-radius: 999px; overflow: hidden; }
.lb-bar { display: block; height: 100%; background: #c9c4b7; border-radius: 999px; }
.lb-count {
  flex: none; width: 2rem; text-align: right;
  font-variant-numeric: tabular-nums; color: var(--muted); font-size: .95rem;
}
.lb-row.hot .lb-name { color: var(--ink); font-weight: 600; }
.lb-row.hot .lb-bar { background: var(--clay); }
.lb-row.hot .lb-count { color: var(--ink); font-weight: 600; }
.lb-row:hover .lb-name { color: var(--ink); }
.lb-row:hover .lb-bar { filter: brightness(.96); }
.lb-row:focus-visible { outline: 2px solid var(--clay-ink); outline-offset: 3px; border-radius: 4px; }
.lb-caption { margin: 1.4rem 0 0; font-size: .8rem; color: var(--quiet); }

/* ---------------- submit ribbon ---------------- */
.ribbon {
  width: 100%; max-width: 40rem;
  text-align: center; padding: 1.5rem 1rem 0;
  font-size: .8125rem; color: var(--quiet);
}
.ribbon a { color: var(--clay-ink); font-weight: 600; text-decoration: none; }
.ribbon a:hover { text-decoration: underline; }
.ribbon a:focus-visible { outline: 2px solid var(--clay-ink); outline-offset: 2px; border-radius: 3px; }
body.searched .ribbon { display: none; }

/* ---------------- footer (results view) ---------------- */
footer {
  width: 100%; max-width: 40rem;
  margin-top: 3rem; padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  color: var(--quiet); font-size: .75rem; line-height: 1.7;
}
body:not(.searched) footer { display: none; }
footer p { margin: 0 0 .75rem; }
footer b { color: var(--muted); font-weight: 600; }
footer a { color: var(--clay-ink); font-weight: 600; text-decoration: none; }
footer a:hover { text-decoration: underline; }

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