/* MTG Collection Tracker — read-only UI.
   Single stylesheet, no build step, light and dark. */

:root {
  --bg: #fbfaf8;
  --panel: #ffffff;
  --ink: #1a1a1c;
  --ink-soft: #5f6169;
  --line: #e4e2dd;
  --accent: #6b4fa8;
  --ok: #2c7a4b;
  --warn: #a8602c;
  --err: #b3352c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 18, 16, .06), 0 4px 12px rgba(20, 18, 16, .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --panel: #1e1f24;
    --ink: #ececf0;
    --ink-soft: #9b9ca6;
    --line: #303138;
    --accent: #a892e0;
    --ok: #62c48c;
    --warn: #e0a267;
    --err: #ef8279;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 900px; margin: 0 auto; padding: 0 20px; }

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

/* ---------------------------------------------------------------- header -- */

header.site {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 5;
}
header.site .wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 58px;
  flex-wrap: wrap;
}
.brand {
  font-weight: 650;
  color: var(--ink);
  letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; }
header nav { display: flex; gap: 18px; margin-left: auto; font-size: 15px; }
header nav a { color: var(--ink-soft); }
header nav a.on { color: var(--ink); font-weight: 600; }
header nav a.quiet { color: var(--ink-soft); opacity: .7; }

footer.wrap {
  margin: 56px auto 32px;
  color: var(--ink-soft);
  font-size: 13px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

/* --------------------------------------------------------------- headings -- */

h1 { font-size: 27px; letter-spacing: -.02em; margin: 26px 0 10px; }
h2 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-soft);
  margin: 32px 0 10px;
  font-weight: 650;
}
h2 .count { color: var(--ink-soft); opacity: .65; font-weight: 400; }
h3 { font-size: 15px; margin: 0 0 6px; }

.crumb { color: var(--ink-soft); font-size: 13px; margin: 18px 0 0; }
.sub { color: var(--ink-soft); font-size: 14px; }
.empty { color: var(--ink-soft); font-style: italic; padding: 20px 0; }
.error { color: var(--err); }
.more { margin: 34px 0; }

.deck-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }

/* ----------------------------------------------------------------- cards -- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.stats { display: flex; gap: 12px; flex-wrap: wrap; margin: 20px 0 8px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 116px;
  flex: 1 1 auto;
}
.stat-v { display: block; font-size: 21px; font-weight: 650; letter-spacing: -.02em; }
.stat-l { display: block; font-size: 12px; color: var(--ink-soft);
          text-transform: uppercase; letter-spacing: .06em; }
.stat.warn .stat-v { color: var(--warn); }

/* --------------------------------------------------------------- badges --- */

.badge {
  font-size: 12.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  white-space: nowrap;
}
.badge.ok   { color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }

.tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-weight: 600;
}
.tag.warn { color: var(--warn); }

/* ------------------------------------------------------------ deck lists -- */

.decklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.row {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--ink);
  transition: border-color .12s ease;
}
.row:hover { text-decoration: none; border-color: var(--accent); }
.row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-main strong { font-weight: 600; }
.colors { display: flex; gap: 2px; }

ul.cards { list-style: none; padding: 0; margin: 0; }
ul.cards li { border-bottom: 1px solid var(--line); }
ul.cards li:last-child { border-bottom: 0; }
.cardrow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 4px;
  color: var(--ink);
}
.cardrow:hover { text-decoration: none; background: var(--panel); }
.cardrow .qty {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  min-width: 22px;
  font-size: 14px;
}
.cardrow .nm { flex: 1; min-width: 0; }
.cardrow .loc { color: var(--ink-soft); font-size: 13px; }
.cardrow .cost { display: flex; gap: 2px; }

/* ------------------------------------------------------- mana symbols ----- */

/* Real Magic symbols, served from assets/mana. Sized to sit on the text
   baseline without disturbing line height. */
.ms {
  display: inline-block;
  width: 16px;
  height: 16px;
  vertical-align: -2px;
  border-radius: 50%;
  box-shadow: -1px 1px 0 rgba(0, 0, 0, .22);
}
.ms + .ms { margin-left: 1px; }
.cost.big .ms { width: 22px; height: 22px; vertical-align: -4px; }
.colors .ms { width: 15px; height: 15px; }

/* Fallback pip for a symbol newer than the last fetch_symbols run. */
.pip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  font-size: 10.5px;
  font-weight: 700;
  color: #17161a;
  background: #cdc7bd;
  border: 1px solid rgba(0, 0, 0, .12);
}
.pip-w { background: #f6f0dc; }
.pip-u { background: #97c5e8; }
.pip-b { background: #a9a19c; }
.pip-r { background: #ec9c8a; }
.pip-g { background: #97ceac; }
.pip-c, .pip-n, .pip-x { background: #cdc7bd; }
.cost.big .pip { width: 22px; height: 22px; font-size: 13px; }

/* ----------------------------------------------------------- card detail -- */

.card-detail { display: flex; gap: 26px; flex-wrap: wrap; align-items: flex-start; margin-top: 8px; }
.art {
  width: 280px;
  max-width: 100%;
  height: auto;
  border-radius: 13px;
  box-shadow: var(--shadow);
}
.card-facts { flex: 1; min-width: 260px; }
.card-facts h1 { margin-top: 0; }
.card-facts dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 18px;
  margin: 18px 0;
  font-size: 15px;
}
.card-facts dt { color: var(--ink-soft); font-size: 13px; text-transform: uppercase;
                 letter-spacing: .05em; align-self: center; }
.card-facts dd { margin: 0; }

/* --------------------------------------------------------------- tables --- */

table.grid { width: 100%; border-collapse: collapse; font-size: 14.5px; margin: 12px 0; }
table.grid th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  padding: 8px 10px 8px 0;
  font-weight: 650;
}
table.grid td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); }
table.grid td.sub { font-size: 13px; }
table.grid .num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums;
                                     padding-right: 0; }

/* --------------------------------------------------------------- search --- */

.filters { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; margin: 16px 0 4px; }
.filters .f { display: flex; flex-direction: column; gap: 5px; flex: 1 1 150px; }
.filters label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
                 color: var(--ink-soft); font-weight: 600; }
input, select, button {
  font: inherit;
  padding: 8px 10px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
  cursor: pointer;
  padding: 9px 18px;
}
button:hover { filter: brightness(1.08); }

/* -------------------------------------------------------------- history --- */

.batch { margin: 12px 0; }
.batch.undone { opacity: .55; }
.batch h3 { color: var(--ink-soft); font-weight: 600; font-size: 13px; }
.reason { margin: 6px 0 12px; font-size: 14.5px; }
.sub-reason {
  margin: 16px 0 6px;
  padding-left: 12px;
  border-left: 2px solid var(--line);
  color: var(--ink-soft);
  font-size: 13.5px;
}
.batch > .sub-reason:first-of-type { margin-top: 8px; }
ul.changes { list-style: none; padding: 0; margin: 0; display: grid; gap: 5px; font-size: 14.5px; }
.act {
  display: inline-block;
  min-width: 44px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 700;
  color: var(--ink-soft);
}
.act-add { color: var(--ok); }
.act-move { color: var(--accent); }
.act-remove { color: var(--err); }

.findings { border-left: 3px solid var(--warn); padding: 2px 0 2px 14px; margin: 18px 0; }
.findings ul { margin: 6px 0 0; padding-left: 18px; font-size: 14.5px; }
.sev-error { color: var(--err); }
.sev-warning { color: var(--warn); }
.sev-info { color: var(--ink-soft); }

.notes { margin: 34px 0; }
.notes summary { cursor: pointer; font-size: 13px; text-transform: uppercase;
                 letter-spacing: .06em; color: var(--ink-soft); font-weight: 650; }
.notes pre {
  white-space: pre-wrap;
  font: 13.5px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
  overflow-x: auto;
}

/* ---------------------------------------------------------------- login --- */

body.centered { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login { display: grid; gap: 10px; width: 100%; max-width: 340px; }
.login h1 { font-size: 19px; margin: 0 0 6px; }
.login label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
               color: var(--ink-soft); font-weight: 600; }

/* --------------------------------------------------------------- mobile --- */

@media (max-width: 620px) {
  .wrap { padding: 0 14px; }
  h1 { font-size: 23px; }
  .cardrow .loc { display: none; }
  .card-detail { gap: 18px; }
  .art { width: 100%; max-width: 300px; margin: 0 auto; }
  table.grid { display: block; overflow-x: auto; white-space: nowrap; }
  header.site .wrap { min-height: 52px; }
  header nav { gap: 14px; font-size: 14px; }
}

/* -------------------------------------------------- account & admin pages -- */

.who { color: var(--ink-soft); font-size: 13px; }
.notice {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14.5px;
}
.card.stack { display: grid; gap: 10px; margin: 12px 0; justify-items: start; }
.card.stack label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
                    color: var(--ink-soft); font-weight: 600; }
.card.stack input[type=text], .card.stack input[type=password], .card.stack input:not([type]) {
  width: 100%; max-width: 360px;
}
.card.stack .sub { margin: 0; }
label.check { text-transform: none; letter-spacing: 0; font-weight: 400;
              font-size: 14.5px; color: var(--ink); display: flex; gap: 8px;
              align-items: center; }
.keys p { margin: 14px 0 6px; font-size: 14.5px; }
.keys p:first-child { margin-top: 0; }
code.key {
  display: block;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  overflow-x: auto;
  white-space: nowrap;
  user-select: all;
}
code.key.secret { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
button.danger { background: var(--err); }
button.small { padding: 5px 11px; font-size: 13px; }
table.grid form { margin: 0; }

/* ------------------------------------------------------- card grid view --- */

.viewtoggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin: 18px 0 4px;
  background: var(--panel);
}
.viewtoggle a {
  padding: 6px 15px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
}
.viewtoggle a:hover { text-decoration: none; background: var(--bg); }
.viewtoggle a.on { background: var(--accent); color: #fff; }
.viewtoggle a + a { border-left: 1px solid var(--line); }

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 14px;
  margin: 12px 0 4px;
}

.tile {
  position: relative;
  display: block;
  color: var(--ink);
  border-radius: 9px;
}
.tile:hover { text-decoration: none; }
.tile img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 244 / 340;
  border-radius: 4.75% / 3.5%;   /* matches the printed corner radius */
  box-shadow: var(--shadow);
  background: var(--panel);
  transition: transform .12s ease, box-shadow .12s ease;
}
.tile:hover img {
  transform: translateY(-3px);
  box-shadow: 0 6px 18px rgba(20, 18, 16, .22);
}

/* Placeholder for a card with no art: unresolved names, odd printings. */
.tile-blank {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 12px;
  aspect-ratio: 244 / 340;
  border: 1px dashed var(--line);
  border-radius: 4.75% / 3.5%;
  background: var(--panel);
}
.tile-blank-name { font-size: 13px; font-weight: 600; line-height: 1.3; }

/* The card name repeats under the art: it is what you scan for, and the
   printed name is unreadable at this size. */
.tile-name {
  display: block;
  margin-top: 6px;
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--ink-soft);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.tile:hover .tile-name { color: var(--ink); }

.tile-qty, .tile-foil, .tile-warn {
  position: absolute;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  line-height: 1.5;
}
.tile-qty {
  top: 6px; right: 6px;
  background: var(--ink);
  color: var(--bg);
  min-width: 22px;
  text-align: center;
}
.tile-foil {
  top: 6px; left: 6px;
  background: linear-gradient(110deg, #9ad4e8, #d7a8e8, #f2d98c);
  color: #17161a;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.tile-warn {
  bottom: 34px; left: 6px; right: 6px;
  background: var(--warn);
  color: #fff;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .04em;
}

@media (max-width: 620px) {
  .grid-cards { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
  .tile-name { font-size: 11.5px; }
}
