/* anime search — dark, responsive, zero framework. */
:root {
  --bg: #0e1116;
  --bg2: #161b23;
  --card: #1a2029;
  --line: #262e3a;
  --text: #e6ebf2;
  --dim: #8b96a5;
  --accent: #7aa2f7;
  --accent2: #9ece6a;
  --radius: 14px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8; --bg2: #eceef2; --card: #ffffff; --line: #dde1e8;
    --text: #1b2129; --dim: #5d6875; --accent: #3a64c8; --accent2: #3e8a2e;
  }
}
* { box-sizing: border-box; }
/* global scale knob: every rem size (titles, cards, small print) keys off this.
   18.5px ≈ +16% over the browser default 16px. Bump for bigger UI. */
html { font-size: 18.5px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0 auto; max-width: 78rem; padding: 1.2rem 1rem 3rem;
  background: var(--bg); color: var(--text);
  font: .85rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 1.7rem; margin: .4rem 0 0; letter-spacing: -.02em; }
h1 .accent { color: var(--accent); }
h1 .logo { color: inherit; text-decoration: none; }
h1 .logo:hover { text-decoration: underline; text-underline-offset: .18em; text-decoration-thickness: 2px; }
.tagline { color: var(--dim); margin: .15rem 0 1.1rem; font-size: .88rem; }

#f { display: flex; gap: .5rem; }
#q {
  flex: 1; min-width: 0; padding: .8rem 1rem; font-size: 1rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg2); color: var(--text); outline: none;
  transition: border-color .15s;
}
#q:focus { border-color: var(--accent); }
#bar { position: relative; flex: 1; min-width: 0; }
#bar #q { width: 100%; }
#clear {
  /* round ✕ inside the search bar's right edge; visible only with text */
  position: absolute; right: .5rem; top: 50%; transform: translateY(-50%);
  width: 1.45rem; height: 1.45rem; line-height: 1; padding: 0;
  border: 0; border-radius: 50%;
  background: var(--line); color: var(--dim);
  font-size: .8rem; cursor: pointer; display: none;
}
#clear:hover { color: var(--text); }
#bar.has-text #clear { display: block; }
#bar.has-text #q { padding-right: 2.4rem; }
#go {
  padding: 0 1.3rem; border: 0; border-radius: var(--radius);
  background: var(--accent); color: #0b0e14; font-weight: 600; font-size: .95rem;
  cursor: pointer;
}
#go:active { transform: translateY(1px); }

#controls {
  display: flex; align-items: center; flex-wrap: wrap; gap: .9rem;
  margin: .8rem 0 1.1rem; color: var(--dim); font-size: .82rem;
}
#popwrap { display: flex; align-items: center; gap: .5rem; }
#pop { accent-color: var(--accent); width: clamp(7rem, 30vw, 14rem); }
.toggle { display: flex; align-items: center; gap: .35rem; cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent2); }
#status { margin-left: auto; font-variant-numeric: tabular-nums; }
#status .rr { color: var(--accent2); }

.grid {
  display: grid; gap: .8rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 12.5rem), 1fr));
}
@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
}

.card {
  display: flex; flex-direction: column; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  cursor: pointer; transition: border-color .15s;
  animation: pop .18s ease-out both;
}
@keyframes pop { from { opacity: 0; transform: translateY(4px); } }
/* the entry animation must play exactly once per node: slider reordering
   re-inserts card nodes (replaceChildren), and re-inserting a node restarts
   its CSS animation — that replay is the flashing seen while dragging */
.card.entered { animation: none; }
@media (prefers-reduced-motion: reduce) { .card { animation: none; } }
.card:hover { border-color: var(--accent); }
/* poster-ratio card: AniList covers are ~2:3 portraits — with a matching box
   object-fit barely crops anything, so the full artwork stays visible */
.cover { aspect-ratio: 2/3; width: 100%; object-fit: cover; object-position: top; background: var(--bg2); }
.cbody { padding: .55rem .7rem .7rem; display: flex; flex-direction: column; gap: .3rem; }
.ct { font-weight: 600; font-size: .92rem; line-height: 1.25; }
.ctitles { display: none; flex-direction: column; gap: .1rem; font-size: .82rem; color: var(--text); }
.ctitles span {
  display: inline-block; min-width: 4.2rem; color: var(--dim);
  font-size: .68rem; text-transform: uppercase; letter-spacing: .04em;
}
.card.open .ctitles { display: flex; }
.cmeta { color: var(--dim); font-size: .76rem; display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.cmeta b { color: var(--text); font-weight: 600; }
.genres { display: flex; flex-wrap: wrap; gap: .3rem; }
.g {
  font-size: .68rem; color: var(--dim); border: 1px solid var(--line);
  border-radius: 99px; padding: .06rem .5rem;
}
.cdesc {
  display: none; color: var(--dim); font-size: .8rem; margin-top: .2rem;
  overflow: hidden;
}
.card.open .cdesc { display: block; }
.card.open { grid-column: 1 / -1; flex-direction: row; }
.card.open .cover { aspect-ratio: auto; width: 10rem; align-self: stretch; object-fit: cover; }
@media (max-width: 520px) { .card.open { flex-direction: column; } .card.open .cover { width: 100%; aspect-ratio: 16/9; } }
.scorechip { font-weight: 700; border-radius: 6px; padding: .05rem .35rem; }
.badge {
  font-size: .66rem; border-radius: 99px; padding: .05rem .45rem;
  background: var(--accent); color: #0b0e14; font-weight: 700;
}

.skel {
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--card);
  aspect-ratio: 12.5/21.4; position: relative; overflow: hidden;
}
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, var(--bg2) 50%, transparent 70%);
  animation: shimmer 1.1s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%);} to { transform: translateX(100%);} }
@media (prefers-reduced-motion: reduce) { .skel::after { animation: none; } }

#empty .chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.4rem; }
.chip {
  border: 1px solid var(--line); background: var(--bg2); color: var(--dim);
  border-radius: 99px; padding: .4rem .85rem; font-size: .8rem; cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--accent); }
footer { color: var(--dim); font-size: .75rem; margin-top: 2.2rem; text-align: center; }
footer a { color: var(--dim); }
