/* Wildcard Ledger. Colour means rarity or status, nothing else. See .impeccable.md.
   Rarity colours tuned so every pair stays apart under deuteranopia/protanopia (judge panel,
   2026-09-30: weakest pair dE 12.8, was 5.3). */

:root {
  /* dark (primary): warm charcoal tinted toward rare-gold, hue 75 */
  --paper: oklch(0.175 0.011 75);
  --paper-2: oklch(0.21 0.013 75);
  --paper-3: oklch(0.255 0.014 75);
  --rule: oklch(0.305 0.013 75);
  --rule-strong: oklch(0.42 0.014 75);
  --ink: oklch(0.93 0.012 85);
  --ink-2: oklch(0.77 0.014 80);
  --ink-3: oklch(0.64 0.014 78);
  --owned: oklch(0.52 0.014 80);

  --mythic: oklch(0.7 0.18 38);
  --rare: oklch(0.87 0.13 88);
  --uncommon: oklch(0.68 0.1 235);
  --common: oklch(0.92 0.004 250);
  --ready: oklch(0.8 0.13 152);

  --body-weight: 380;
  --display: "Spectral", ui-serif, Georgia, serif;
  --ui: "Archivo", ui-sans-serif, system-ui, sans-serif;

  --t-xs: 0.75rem; --t-sm: 0.875rem; --t-md: 1rem; --t-lg: 1.25rem; --t-num: 1.375rem; --t-xl: 1.75rem; --t-2xl: 2.5rem;
  --s-2xs: 4px; --s-xs: 8px; --s-sm: 12px; --s-md: 16px; --s-lg: 24px; --s-xl: 32px; --s-2xl: 48px; --s-3xl: 64px;
  --page: min(1256px, 100% - 64px);
  --rank-w: 2rem;
  --bill-w: 3.25rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --paper: oklch(0.965 0.011 85); --paper-2: oklch(0.935 0.014 83); --paper-3: oklch(0.905 0.016 82);
    --rule: oklch(0.85 0.016 80); --rule-strong: oklch(0.7 0.018 78);
    --ink: oklch(0.23 0.016 70); --ink-2: oklch(0.4 0.016 70); --ink-3: oklch(0.5 0.015 72);
    --owned: oklch(0.77 0.014 80);
    --mythic: oklch(0.5 0.19 35); --rare: oklch(0.7 0.14 82); --uncommon: oklch(0.55 0.08 235); --common: oklch(0.33 0.012 250);
    --ready: oklch(0.47 0.12 152);
    --body-weight: 420; color-scheme: light;
  }
}
:root[data-theme="light"] {
  --paper: oklch(0.965 0.011 85); --paper-2: oklch(0.935 0.014 83); --paper-3: oklch(0.905 0.016 82);
  --rule: oklch(0.85 0.016 80); --rule-strong: oklch(0.7 0.018 78);
  --ink: oklch(0.23 0.016 70); --ink-2: oklch(0.4 0.016 70); --ink-3: oklch(0.5 0.015 72);
  --owned: oklch(0.77 0.014 80);
  --mythic: oklch(0.5 0.19 35); --rare: oklch(0.7 0.14 82); --uncommon: oklch(0.55 0.08 235); --common: oklch(0.33 0.012 250);
  --ready: oklch(0.47 0.12 152);
  --body-weight: 420; color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--ui); font-size: var(--t-md); font-weight: var(--body-weight); line-height: 1.5;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
code { font-family: var(--ui); font-stretch: 87.5%; font-weight: 600; font-size: 0.95em; color: var(--ink); }
[hidden] { display: none !important; }
.label {
  font-family: var(--ui); font-size: var(--t-xs); font-weight: 650; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--ink-3); margin: 0 0 var(--s-sm);
}
.flag { font-weight: 650; color: var(--ink); text-decoration: underline dotted var(--ink-3); text-underline-offset: 3px; }

/* ---------- masthead ---------- */
.masthead {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-lg);
  width: var(--page); margin: 0 auto; padding: var(--s-2xl) 0 var(--s-lg); border-bottom: 1px solid var(--rule);
}
.wordmark { font-family: var(--display); font-weight: 700; font-size: var(--t-2xl); line-height: 1; letter-spacing: -0.015em; margin: 0; }
.dek { margin: var(--s-xs) 0 0; color: var(--ink-2); max-width: 60ch; text-wrap: balance; }
.mast-links { display: flex; gap: var(--s-lg); align-items: center; font-size: var(--t-sm); font-weight: 500; flex: none; }
.textbtn {
  background: none; border: 0; padding: var(--s-2xs) 0; cursor: pointer; color: var(--ink-2); font-size: var(--t-sm); font-weight: 500;
  text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 3px;
}
.textbtn:hover { color: var(--ink); text-decoration-color: currentColor; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 272px minmax(0, 1fr); gap: var(--s-2xl); width: var(--page); margin: 0 auto; padding: var(--s-xl) 0 var(--s-2xl); }
.rail { position: sticky; top: var(--s-lg); align-self: start; display: grid; gap: var(--s-xl); }
.note { font-size: var(--t-sm); color: var(--ink-3); margin: var(--s-sm) 0 0; }
.method p { font-size: var(--t-sm); color: var(--ink-2); margin: 0 0 var(--s-sm); max-width: 42ch; }

/* collection */
.drop {
  position: relative; display: grid; gap: var(--s-2xs); padding: var(--s-lg) var(--s-md); cursor: pointer;
  border: 1px solid var(--rule-strong); border-radius: 2px; background: var(--paper-2);
  transition: background 200ms var(--ease), border-color 200ms var(--ease);
}
.drop strong { font-family: var(--display); font-size: var(--t-lg); font-weight: 700; line-height: 1.2; }
.drop span { font-size: var(--t-sm); color: var(--ink-2); }
.drop:hover, .drop.over { background: var(--paper-3); border-color: var(--ink); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.how { font-size: var(--t-sm); color: var(--ink-2); margin: var(--s-sm) 0 0; }
.err { font-size: var(--t-sm); font-weight: 650; color: var(--ink); margin: var(--s-sm) 0 0; text-decoration: underline dotted var(--ink-3); text-underline-offset: 3px; }
.paste { margin-top: var(--s-md); font-size: var(--t-sm); }
.paste summary { cursor: pointer; color: var(--ink-2); }
.paste textarea {
  display: block; width: 100%; min-height: 140px; margin: var(--s-xs) 0; padding: var(--s-xs);
  background: var(--paper-2); border: 1px solid var(--rule-strong); border-radius: 2px; font-size: var(--t-sm); line-height: 1.45; resize: vertical;
}
.col-line { margin: 0; display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 var(--s-xs); }
.col-line .big { font-family: var(--display); font-size: var(--t-xl); font-weight: 700; letter-spacing: -0.015em; line-height: 1.1; }
.col-line .unit { font-size: var(--t-sm); color: var(--ink-2); }
.rar { display: flex; gap: var(--s-md); margin: var(--s-xs) 0 0; padding: 0; list-style: none; font-size: var(--t-sm); font-weight: 600; }
.rar li { display: flex; align-items: center; gap: 5px; }
.rar abbr { text-decoration: none; color: var(--ink-3); font-size: var(--t-xs); }
.col-meta { font-size: var(--t-xs); color: var(--ink-3); margin: var(--s-sm) 0 var(--s-2xs); }
.col-actions { display: flex; gap: var(--s-md); }
.col-actions label { position: relative; }
.col-actions input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.col-actions label:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }

/* card-shaped rarity marks: the same shape as a strip cell */
.gem { display: inline-block; width: 7px; height: 10px; border-radius: 1px; flex: none; }
.gem.m { background: var(--mythic); } .gem.r { background: var(--rare); } .gem.u { background: var(--uncommon); } .gem.k { background: var(--common); }

/* wildcards: one inline row of editable figures */
.wc-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-sm); }
.wc { display: grid; gap: 2px; cursor: text; }
.wc-name { display: flex; align-items: center; gap: 5px; font-size: var(--t-xs); color: var(--ink-3); font-weight: 650; letter-spacing: 0.06em; }
.wc input {
  width: 100%; border: 0; border-bottom: 1px solid var(--rule-strong); background: none; padding: 2px 0; border-radius: 0;
  font-size: var(--t-num); font-weight: 650; font-stretch: 87.5%; line-height: 1.2; -moz-appearance: textfield;
}
.wc input:hover { border-bottom-color: var(--ink-3); }
.wc input:focus { outline: none; border-bottom: 2px solid var(--ink); padding-bottom: 1px; }
.wc input::-webkit-outer-spin-button, .wc input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.wc input::placeholder { color: var(--rule-strong); }

/* ---------- formats + ledger head ---------- */
.formats { display: flex; gap: var(--s-lg); overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--rule); margin-bottom: var(--s-md); }
.formats::-webkit-scrollbar { display: none; }
.formats button {
  background: none; border: 0; padding: var(--s-xs) 0 var(--s-sm); cursor: pointer; white-space: nowrap;
  font-family: var(--display); font-size: 1.0625rem; font-weight: 500; color: var(--ink-3);
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color 160ms var(--ease), border-color 160ms var(--ease);
}
.formats button span { font-family: var(--ui); font-size: var(--t-xs); font-weight: 600; margin-left: 5px; vertical-align: 1px; }
.formats button:hover { color: var(--ink-2); }
.formats button[aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }

.ledger-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-md); flex-wrap: wrap; }
.fmt-meta { margin: 0; font-size: var(--t-sm); color: var(--ink-2); }
.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: 2px; overflow: hidden; }
.seg button { background: none; border: 0; padding: 6px var(--s-sm); cursor: pointer; font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.seg button span { font-weight: 400; color: var(--ink-3); margin-left: 3px; }
.seg button + button { border-left: 1px solid var(--rule-strong); }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.seg button[aria-checked="true"] span { color: var(--paper-3); }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-2xs) var(--s-lg); padding: 0; margin: var(--s-lg) 0 var(--s-md); font-size: var(--t-xs); color: var(--ink-3); }
.legend li { display: flex; align-items: flex-end; gap: 3px; }
.legend li .c:last-of-type { margin-right: 4px; }
.legend .c { width: 6px; height: 12px; display: inline-block; }
.legend .c.free { height: 5px; }

/* ---------- the ledger ---------- */
.row-grid {
  display: grid; align-items: center; gap: var(--s-lg);
  grid-template-columns: var(--rank-w) minmax(0, 15rem) minmax(0, 1fr) calc(var(--bill-w) * 4);
}
.cols { padding: 0 var(--s-sm) var(--s-xs) 0; border-bottom: 2px solid var(--ink); font-size: var(--t-xs); font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.cols .bill-h { display: grid; grid-template-columns: repeat(4, var(--bill-w)); justify-items: end; }
.cols .bill-h span { display: flex; align-items: center; gap: 5px; }

.ledger { list-style: none; margin: 0; padding: 0; }
.section { padding: var(--s-xl) 0 var(--s-xs); border-bottom: 1px solid var(--rule-strong); display: flex; align-items: baseline; gap: var(--s-md); flex-wrap: wrap; }
.section:first-child { padding-top: var(--s-md); }
.section h2 { margin: 0; font-family: var(--display); font-size: var(--t-lg); font-weight: 700; }
.section h2 span { font-family: var(--ui); font-size: var(--t-sm); font-weight: 600; color: var(--ink-3); margin-left: 6px; }
.section p { margin: 0; font-size: var(--t-sm); color: var(--ink-2); }
.section.ready h2 { color: var(--ready); }

.entry { border-bottom: 1px solid var(--rule); animation: rise 420ms var(--ease) both; animation-delay: calc(var(--i, 0) * 22ms); }
.entry:last-child { border-bottom: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.entry-head { width: 100%; padding: var(--s-md) var(--s-sm) var(--s-md) 0; background: none; border: 0; text-align: left; cursor: pointer; transition: background 160ms var(--ease); }
.entry-head:hover, .entry.open .entry-head { background: var(--paper-2); }
.rank { font-weight: 650; font-size: var(--t-md); color: var(--ink-3); text-align: right; align-self: start; padding-top: 3px; }
.entry[data-tier="0"] .rank { color: var(--ready); }
.who { display: grid; gap: 3px; min-width: 0; align-self: start; }
.name-line { display: flex; align-items: center; gap: var(--s-xs); flex-wrap: wrap; }
.name { font-family: var(--display); font-weight: 700; font-size: var(--t-lg); line-height: 1.2; overflow-wrap: anywhere; }
.pips { display: inline-flex; gap: 3px; }
.pips i {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  background: var(--ink-3); color: var(--paper); font-style: normal; font-size: 11px; font-weight: 750; line-height: 1;
}
.sub { font-size: var(--t-sm); color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 0 var(--s-xs); }
.status { font-weight: 600; color: var(--ink); }
.status.ready { color: var(--ready); }
.status.short { color: var(--ink-2); font-weight: 500; }

.strip { display: grid; grid-template-columns: repeat(var(--cells), minmax(0, 1fr)); gap: 1px; height: 18px; align-items: end; }
.c { background: var(--owned); border-radius: 1px; height: 100%; }
.c.free { height: 35%; }
.c.m { background: var(--mythic); } .c.r { background: var(--rare); } .c.u { background: var(--uncommon); } .c.k { background: var(--common); }
.c.off { background: repeating-linear-gradient(135deg, var(--ink-3) 0 1px, transparent 1px 3px); }
.pct { display: block; font-size: 0.8125rem; color: var(--ink-3); margin-top: 5px; }

.bill { display: grid; grid-template-columns: repeat(4, var(--bill-w)); justify-items: end; align-items: center; }
.bill .b { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-num); font-weight: 650; font-stretch: 87.5%; line-height: 1; }
.bill .b .gem { height: 12px; width: 8px; display: none; }
.bill .z { font-size: var(--t-lg); line-height: 1; color: var(--rule-strong); font-weight: 400; }
.bill abbr { display: none; }

/* expansion */
.entry-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 280ms var(--ease); background: var(--paper-2); }
.entry.open .entry-body { grid-template-rows: 1fr; }
.entry-body > .inner { overflow: hidden; }
.detail { display: grid; gap: var(--s-md); padding: var(--s-xs) var(--s-lg) var(--s-lg) calc(var(--rank-w) + var(--s-lg)); }
.actions { display: flex; flex-wrap: wrap; gap: var(--s-xs); }
.btn {
  display: inline-flex; align-items: center; gap: var(--s-xs); min-height: 36px; padding: 0 var(--s-md);
  border: 1px solid var(--rule-strong); border-radius: 2px; background: transparent; cursor: pointer;
  font-size: var(--t-sm); font-weight: 600; text-decoration: none; white-space: nowrap; transition: background 160ms var(--ease), border-color 160ms var(--ease);
}
.btn:hover { background: var(--paper-3); border-color: var(--ink-3); }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn.done { background: var(--paper); color: var(--ready); border-color: var(--ready); }
.need ul { list-style: none; margin: 0; padding: 0; columns: 4 12.5rem; column-gap: var(--s-lg); }
.need li { display: flex; align-items: baseline; gap: var(--s-xs); padding: 3px 0; break-inside: avoid; font-size: var(--t-sm); }
.need li .gem { transform: translateY(1px); }
.need .q { font-weight: 650; min-width: 1.5ch; text-align: right; }
.need .have { color: var(--ink-3); font-size: var(--t-xs); white-space: nowrap; }
.need .all { font-size: var(--t-sm); color: var(--ready); margin: 0; }
.off-note { font-size: var(--t-sm); color: var(--ink-2); margin: var(--s-sm) 0 0; }

/* ---------- footer ---------- */
.foot { width: var(--page); margin: 0 auto; padding: var(--s-lg) 0 var(--s-3xl); border-top: 1px solid var(--rule); font-size: var(--t-xs); color: var(--ink-3); }
.foot p { margin: 0 0 var(--s-2xs); max-width: 90ch; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  :root { --bill-w: 2.9rem; }
  .row-grid { grid-template-columns: var(--rank-w) minmax(0, 1fr) calc(var(--bill-w) * 4); }
  .entry-head .strip-wrap { grid-column: 2 / -1; grid-row: 2; }
  .cols .strip-h { display: none; }
  .formats { gap: var(--s-md); mask-image: linear-gradient(to right, #000 88%, transparent); }
}
@media (max-width: 860px) {
  :root { --page: calc(100% - 32px); --rank-w: 1.5rem; }
  .masthead { padding: var(--s-xl) 0 var(--s-md); flex-direction: column; align-items: flex-start; gap: var(--s-sm); }
  .wordmark { font-size: 2rem; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: var(--s-lg); padding: var(--s-lg) 0 var(--s-xl); }
  .rail { position: static; gap: var(--s-lg); }
  .method, .col-meta, .rar, #wc-note { display: none; }
  .drop { padding: var(--s-md); }
  .how { display: none; }
  .cols { display: none; }
  .row-grid { grid-template-columns: var(--rank-w) minmax(0, 1fr); gap: var(--s-xs) var(--s-sm); }
  .entry-head { padding: var(--s-md) var(--s-xs) var(--s-md) 0; }
  :root { --bill-w: 3.4rem; }
  .entry-head .bill { grid-column: 2; grid-row: 2; justify-items: start; justify-content: start; }
  .bill .b .gem { display: inline-block; }
  .bill .z { padding-left: 14px; }
  .entry[data-tier="0"] .bill { display: none; }   /* no column head on phones: "Ready to play" says it */
  .entry-head .strip-wrap { grid-column: 2; grid-row: 3; }
  .pct { display: none; }
  .detail { padding: var(--s-xs) var(--s-md) var(--s-lg) calc(var(--rank-w) + var(--s-sm)); }
  .need ul { columns: 1; }
  .legend { gap: var(--s-2xs) var(--s-md); margin-top: var(--s-md); }
  .foot { padding: var(--s-lg) 0 var(--s-2xl); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
