/* Limitless Tracker — light/dark aware, no dependencies. */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #e2e5ea;
  --ink: #14171c;
  --muted: #626b78;
  --accent: #2f6fd0;
  --accent-soft: #e8f0fd;
  --gold: #b8860b;
  --radius: 10px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216;
    --panel: #171b21;
    --line: #262c35;
    --ink: #e6e9ee;
    --muted: #98a2b1;
    --accent: #6aa4f5;
    --accent-soft: #1b2739;
    --gold: #d9a520;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── top bar ─────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 1.25rem;
  align-items: center;
  padding: .75rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
  white-space: nowrap;
}
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }

.search { flex: 1; max-width: 32rem; }
.search input {
  width: 100%;
  padding: .5rem .8rem;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.search input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

main { max-width: 60rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

.foot {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  max-width: 60rem;
  margin: 0 auto;
  padding: 1rem 1.25rem 2.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .8rem;
}

.foot-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .5rem 2rem;
}

/*
 * Whose the cards and the data are. Set quieter than the rest of the footer, but not
 * faded: a notice nobody can read is not a notice, so it keeps the footer's own colour
 * and only steps down in size.
 */
.disclaimer { font-size: .75rem; line-height: 1.5; max-width: 52rem; }
.disclaimer p { margin: 0 0 .4rem; }
.disclaimer p:last-child { margin-bottom: 0; }
.disclaimer a { color: inherit; text-decoration: underline; }

/* ── generic ─────────────────────────────────────────────────────────────── */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
}

.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 2rem 0; text-align: center; }

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1.5rem;
  color: var(--muted);
  font-size: .9rem;
}
.stat-row b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ── search results ──────────────────────────────────────────────────────── */

.results { display: grid; gap: .5rem; }

.result {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .9rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
}
.result:hover { border-color: var(--accent); text-decoration: none; }
.result .name { font-weight: 600; }
.result .handle { color: var(--muted); font-size: .875rem; }
.result .spacer { flex: 1; }
.result .count { color: var(--muted); font-size: .875rem; white-space: nowrap; }

.alias {
  font-size: .72rem;
  padding: .1rem .4rem;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

/* ── player header ───────────────────────────────────────────────────────── */

.player-head { margin-bottom: 1.25rem; }
.player-head h1 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: -.02em;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.flag { height: 1em; border-radius: 2px; vertical-align: -.1em; }
.player-head .handle { color: var(--muted); font-weight: 400; font-size: 1rem; }
.aka { color: var(--muted); font-size: .875rem; margin: .3rem 0 .6rem; }

/* ── history table ───────────────────────────────────────────────────────── */

.history { display: grid; gap: .4rem; }

.event {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.event-row {
  display: grid;
  grid-template-columns: 5.5rem 4.5rem 4.5rem 1fr auto;
  gap: .75rem;
  align-items: center;
  width: 100%;
  padding: .6rem .9rem;
  background: none;
  border: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.event-row:hover { background: var(--accent-soft); }
.event-row .date { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.event-row .placing { font-weight: 600; font-variant-numeric: tabular-nums; }
.event-row .placing.top { color: var(--gold); }
.event-row .placing.none { color: var(--muted); font-weight: 400; }
.event-row .record { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .875rem; }
.event-row .tname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-row .deck { display: flex; align-items: center; gap: .3rem; white-space: nowrap; }
.event-row .deck span { font-size: .875rem; color: var(--muted); }

/* Sprites are small pixel art; keep the edges crisp when scaled. */
.icon {
  height: 30px;
  width: auto;
  image-rendering: pixelated;
  vertical-align: middle;
}
.icon.small { height: 22px; }

/* ── decklist ────────────────────────────────────────────────────────────── */

.decklist { border-top: 1px solid var(--line); padding: 1rem .9rem; }

.dl-tools {
  display: flex;
  gap: .5rem;
  align-items: center;
  margin-bottom: .9rem;
  flex-wrap: wrap;
}
.dl-tools button {
  font: inherit;
  font-size: .8rem;
  padding: .25rem .7rem;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
}
.dl-tools button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.dl-tools .dl-copy { margin-left: auto; }
.dl-tools .dl-copy:hover { border-color: var(--accent); color: var(--accent); }
.dl-tools .dl-copy.done { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Shown only when the browser blocks clipboard access, pre-selected for Ctrl+C. */
.dl-export {
  display: block;
  width: 100%;
  margin: 0 0 .9rem;
  padding: .5rem .6rem;
  font: .8rem/1.45 ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  resize: vertical;
}

/* Text view: three columns, the way Limitless lays a decklist out. */
.dl-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.25rem;
  align-items: start;
}
.dl-group h3 {
  margin: 0 0 .4rem;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: .25rem;
}
.dl-group p { margin: .15rem 0; font-size: .9rem; }
.dl-group .n { display: inline-block; min-width: 1.2em; font-variant-numeric: tabular-nums; color: var(--muted); }
.dl-group .set { color: var(--muted); font-size: .8em; }

/* Image view: the card grid. */
.dl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: .65rem;
}
.dl-card { position: relative; display: block; }
.dl-card img {
  width: 100%;
  aspect-ratio: 245 / 342;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
  display: block;
}
.dl-card .qty {
  position: absolute;
  right: .3rem;
  bottom: .3rem;
  min-width: 1.5rem;
  padding: .05rem .35rem;
  text-align: center;
  font-size: .8rem;
  font-weight: 700;
  color: #fff;
  background: rgba(0, 0, 0, .78);
  border-radius: 99px;
  backdrop-filter: blur(2px);
}
.dl-grid-group { margin-bottom: 1.1rem; }
.dl-grid-group h3 {
  margin: 0 0 .5rem;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

/* ── responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 44rem) {
  .topbar { flex-wrap: wrap; }
  .event-row {
    grid-template-columns: 4.5rem 1fr;
    row-gap: .2rem;
  }
  .event-row .record { display: none; }
  .event-row .tname { grid-column: 1 / -1; font-size: .85rem; color: var(--muted); }
}

/* ── card page ────────────────────────────────────────────────────────────── */

.card-head {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.card-head h1 { margin: 0 0 .25rem; font-size: 1.5rem; }

.card-art img {
    width: 150px;
    border-radius: 8px;
    display: block;
    box-shadow: 0 2px 10px rgb(0 0 0 / .28);
}

.page-title { font-size: 1.5rem; margin: 0 0 .25rem; }

/* Result tables shared by the card and archetype pages. */
.ctable { margin: .5rem 0 1.5rem; }

.crow {
    display: grid;
    grid-template-columns: 5.5rem minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1.2fr);
    gap: .75rem;
    align-items: center;
    padding: .45rem .6rem;
    border-radius: 6px;
    color: inherit;
    text-decoration: none;
    font-size: .9rem;
}

a.crow:hover { background: var(--accent-soft); }

.crow > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crow.head {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    border-radius: 0;
}

/* Event separator inside the expanded history. */
.crow.sub {
    border-top: 1px solid var(--line);
    margin-top: .4rem;
    padding-top: .6rem;
    border-radius: 0;
}

.crow.sub .ev { font-weight: 600; }

.crow .place { font-variant-numeric: tabular-nums; color: var(--muted); }
.crow .deck { display: flex; align-items: center; gap: .3rem; min-width: 0; }
.crow .deck > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow .qty-inline { font-variant-numeric: tabular-nums; color: var(--muted); }
.crow .ev { color: var(--muted); }

.more {
    font: inherit;
    font-size: .875rem;
    padding: .45rem .9rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    margin-bottom: 1rem;
}

.more:hover { background: var(--accent-soft); }

.note { font-size: .8125rem; }

/* ── archetype controls ───────────────────────────────────────────────────── */

.controls {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin: 1rem 0 1.5rem;
}

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font: inherit;
    font-size: .8125rem;
    padding: .3rem .6rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.chip:hover { background: var(--accent-soft); }

.chip.on {
    background: var(--accent, #2f6feb);
    border-color: transparent;
    color: #fff;
}

.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.on .n { color: rgb(255 255 255 / .75); }

/* The average is a fraction, so it needs more room than a plain 1-4 count. */
.qty.avg {
    min-width: 2.4rem;
    font-size: .7rem;
    font-variant-numeric: tabular-nums;
}

.result .tag {
    font-size: .625rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: .1rem .35rem;
    border-radius: 3px;
    border: 1px solid var(--line);
    color: var(--muted);
}

.result .ico { display: inline-flex; align-items: center; }

.browse { margin: 1rem 0 0; }

@media (max-width: 640px) {
    .crow { grid-template-columns: 4rem minmax(0, 1fr) minmax(0, 1fr); font-size: .8125rem; }
    .crow > :nth-child(4) { display: none; }
    .card-head { flex-direction: column; }
    .card-art img { width: 120px; }
}

/* Result-kind filter above search results. */
.search-tabs { margin-bottom: .75rem; }
.search-tabs .chip[disabled] { opacity: .4; cursor: default; }
.search-tabs .chip[disabled]:hover { background: transparent; }

/* Field size beside a placement. */
.crow .of { opacity: .55; font-weight: 400; }

/* Expandable result rows: the row itself opens the list, the player name still links. */
.crow[role="button"] { cursor: pointer; }
.crow[role="button"]:hover { background: var(--hover, rgba(127,127,127,.08)); }
.crow[aria-expanded="true"] { background: var(--hover, rgba(127,127,127,.12)); }
.crow a.who { color: inherit; text-decoration: none; }
.crow a.who:hover { text-decoration: underline; }
.row-decklist { padding: .75rem 1rem 1rem; border-bottom: 1px solid var(--line, rgba(127,127,127,.2)); }

/* Card search page. */
.inline-search { margin: .75rem 0 1rem; }
.inline-search input {
  width: 100%; padding: .6rem .8rem; font: inherit;
  border: 1px solid var(--line, rgba(127,127,127,.35)); border-radius: 8px;
  background: transparent; color: inherit;
}
.mini-card { width: 30px; height: 42px; object-fit: cover; border-radius: 3px; flex: none; }
.browse a + a { margin-left: 1.25rem; }

/* Other printings of the same card. */
.prints { font-size: .875rem; margin: .4rem 0 0; }
.prints a { color: inherit; }

/* Variant rows in the split view sit visually under their archetype. */
.result .name.sub { opacity: .92; }

/* Custom date-range form behind the Custom… chip. */
.range-form {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
  margin: .6rem 0 .2rem; font-size: .875rem;
}
.range-form label { display: flex; align-items: center; gap: .35rem; }
.range-form input[type="number"] { width: 4.5rem; }
.range-form input[type="number"], .range-form input[type="date"] {
  padding: .25rem .4rem; font: inherit; font-size: .875rem; color: inherit;
  background: transparent; border: 1px solid var(--line, rgba(127,127,127,.35));
  border-radius: 5px;
}
.range-form button {
  padding: .3rem .7rem; font: inherit; font-size: .875rem; cursor: pointer;
  color: inherit; background: transparent;
  border: 1px solid var(--line, rgba(127,127,127,.35)); border-radius: 5px;
}

/* ── find-by-cards slots ──────────────────────────────────────────────────── */

.slots { display: grid; gap: .5rem; margin: 1rem 0; }

.slot {
  display: grid;
  grid-template-columns: 7rem 4.5rem minmax(0, 1fr) auto;
  gap: .5rem;
  align-items: center;
}

/*
 * Every cell is placed by hand rather than left to flow in.
 *
 * "none" has no copy count to ask for, so that cell is not rendered — and with
 * auto-placement the card and the Remove button then each slide a column left, which
 * squeezes the card name into the 4.5rem number column and stretches Remove across the
 * rest of the row. Naming the columns keeps a slot's shape the same whether or not the
 * count applies to it.
 */
.slot-op { grid-column: 1; }
.slot-n { grid-column: 2; }
.slot-card { grid-column: 3; }
.slot-del { grid-column: 4; }

.slot select, .slot input, .slot button {
  font: inherit; font-size: .875rem; color: inherit; background: transparent;
  border: 1px solid var(--line); border-radius: 5px; padding: .3rem .4rem;
}
.slot button { cursor: pointer; }
.slot button:hover:not(:disabled) { background: var(--accent-soft); }
.slot button:disabled { opacity: .45; cursor: default; }

/* The picker and its dropdown share this box, so the list hangs off the input. */
.slot-card { position: relative; min-width: 0; }
.slot-q { width: 100%; }

.slot-pick { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.slot-pick .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-pick .slot-clear { font-size: .8125rem; }

.slot-hits {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 2px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  max-height: 16rem; overflow: auto;
}

.slot-hit {
  display: flex; align-items: center; gap: .4rem; width: 100%;
  border: 0; border-radius: 0; text-align: left; padding: .35rem .5rem;
}
.slot-hit:hover { background: var(--accent-soft); }
.slot-hit .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-hit .spacer { flex: 1; }

@media (max-width: 640px) {
  /* Controls on one line, the card on its own beneath them. */
  .slot { grid-template-columns: 1fr 4.5rem auto; }
  .slot-op { grid-column: 1; grid-row: 1; }
  .slot-n { grid-column: 2; grid-row: 1; }
  .slot-del { grid-column: 3; grid-row: 1; }
  .slot-card { grid-column: 1 / -1; grid-row: 2; }
}
