/* ═══════════════════════════════════════════════════════════════════════════
   market.css — the Dino Market page sheet, on the haven tokens.

   Structure is the live page's (live_capture/pjs/market_market.css: intro,
   lock card, tab row, the card grid, the sales table, two sheets, a toast);
   the look is this tree's. Every colour is a token: ink stays on the --t-*
   ladder, GOLD and VIOLET arrive as borders, fills and glows — RED/GOLD/VIOLET
   ARE LIGHT, NEVER INK (haven.css §1). The two exceptions the contrast gate
   blesses as ink are --ember-core (numbers) and --ember-ink / --violet-ink
   (small labels), and those are the only accent tokens that touch a word here.

   ★ `[hidden]` IS RE-ASSERTED. dominion.css/haven.css set `display:flex` on
     .page-head .facts, .btn and friends, and an author display beats the UA's
     `[hidden]{display:none}`. market.js drives this whole page by toggling the
     hidden attribute exactly as the live script does, so without this one rule
     a "hidden" wallet chip or sign-in button would stay on screen with a
     passing build and a clean console.
   ═══════════════════════════════════════════════════════════════════════════ */
.mk [hidden] { display: none !important; }

/* ── 1. intro ────────────────────────────────────────────────────────────── */
.mk .page-head .lede { margin-bottom: 14px; }
.market-rules {
  margin: 0 auto 18px; max-width: 64ch;
  font-size: 11.5px; line-height: 1.6; letter-spacing: .04em;
  color: var(--t-sec);
}
.mk .wallet-chip { max-width: 320px; margin-top: 8px; }
.mk .wallet-chip .v { color: var(--ember-core); font-size: 18px; font-weight: 600; }
.head-cta { margin: 18px 0 0; }

/* ── 2. the paid gate ────────────────────────────────────────────────────── */
.market-lock { margin-bottom: var(--s7, 48px); text-align: center; }
.lock-b { padding: clamp(26px, 4vw, 44px) clamp(18px, 3vw, 36px); }
.lock-b .page-sub { margin-bottom: 10px; }
.lock-b .d3 { margin: 0 0 14px; }
.lock-lede { margin: 0 auto 24px; max-width: 58ch; }
.lock-stats {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  margin: 0 auto 24px; max-width: 760px;
}
.lock-stat {
  flex: 1 1 150px; max-width: 240px;
  display: grid; gap: 7px; padding: 14px 18px;
  border: 1px solid var(--line); border-radius: var(--r, 9px);
  background: rgba(6, 5, 6, .55);
}
.lock-stat .k {
  font: 500 9.5px/1 var(--data); letter-spacing: .2em; text-transform: uppercase;
  color: var(--t-dim);
}
.lock-stat .v { font: 600 20px/1 var(--data); color: var(--ember-core); font-variant-numeric: tabular-nums; }
.lock-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.lock-note { margin: 14px 0 0; font-size: 13px; color: var(--t-sec); }
.lock-mine-note { margin: 0 0 14px; font-size: 13px; color: var(--t-sec); max-width: 70ch; }

/* ── 3. tabs ─────────────────────────────────────────────────────────────── */
.market-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.mtab {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 16px;
  cursor: pointer; background: rgba(12, 9, 10, .62);
  border: 1px solid var(--line-up); border-radius: var(--r-pill, 999px);
  font: 600 10.5px/1 var(--data); letter-spacing: .16em; text-transform: uppercase;
  color: var(--t-sec);
  transition: color var(--quick), border-color var(--quick), background var(--quick);
}
.mtab:hover { color: var(--t-hi); border-color: var(--line-hot); }
.mtab.active, .mtab[aria-selected="true"] {
  color: #fff; border-color: rgba(255, 198, 77, .55);
  background: linear-gradient(180deg, var(--ember), var(--ember-deep));
  box-shadow: var(--glow-2, none);
}

/* ── 4. browse toolbar + grid ────────────────────────────────────────────── */
.mpane { margin-bottom: var(--s8, 64px); }
.market-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 16px; }
.market-toolbar .input { flex: 1 1 220px; width: auto; }
.market-toolbar .select { flex: 0 1 220px; width: auto; }
.market-count { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--t-dim); }

.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.mgrid:empty { display: none; }
.mcard {
  display: flex; flex-direction: column; gap: 9px; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: var(--r, 9px);
  background: linear-gradient(180deg, rgba(21, 15, 16, .94), rgba(8, 6, 7, .97));
  box-shadow: var(--lit-edge), var(--crush);
  cursor: pointer; text-align: left;
  transition: border-color var(--quick), transform var(--quick);
}
.mcard:hover { border-color: rgba(255, 198, 77, .45); transform: translateY(-2px); }
.mcard:focus-visible { outline: 2px solid var(--ember-core); outline-offset: 3px; }
.mc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.mc-species {
  font: 700 15px/1.2 var(--display); letter-spacing: .04em; text-transform: uppercase;
  color: var(--t-hi);
}
.mc-price { font: 600 13px/1 var(--data); color: var(--ember-core); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mc-name { min-height: 1em; font-size: 13px; font-style: italic; color: var(--t-sec); }
.mc-growth { display: flex; align-items: center; gap: 9px; font: 500 11px/1 var(--data); color: var(--t-sec); }
.growth-bar { flex: 1; height: 6px; overflow: hidden; border-radius: var(--r-pill, 999px); background: var(--panel-hi); border: 1px solid var(--line-up); }
.growth-fill { height: 100%; border-radius: var(--r-pill, 999px); background: var(--ember); }
.mc-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.mc-tags:empty { display: none; }
.mc-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--t-ter); }
.mc-foot span:last-child { text-align: right; }

/* the tag pill: the same vocabulary as .tag, with the card's own variants.
   Colour arrives as a border or a fill; the word stays on an ink token. */
.mtag {
  display: inline-flex; align-items: center; padding: 4px 9px;
  border: 1px solid var(--line-up); border-radius: var(--r-pill, 999px);
  font: 500 9.5px/1 var(--data); letter-spacing: .14em; text-transform: uppercase;
  color: var(--t-sec); white-space: nowrap;
}
.mtag.prime { border-color: rgba(255, 198, 77, .55); color: var(--ember-ink); }
.mtag.elder { border-color: rgba(194, 75, 224, .6); color: var(--violet-ink); }
.mtag.skin { border-color: var(--line-hot); color: var(--t-body); }
.mtag.glitch { border-color: var(--t-ter); background-image: var(--hatch); color: var(--t-hi); }
.mtag.mine {
  color: #fff; border-color: rgba(255, 198, 77, .55);
  background: linear-gradient(180deg, var(--ember), var(--ember-deep));
}

/* mutation chips: own = the page's own light, inherited = the cold flank,
   elder = the brightest gold. Words stay bone; the family is the border. */
.mc-mutations { display: flex; flex-wrap: wrap; gap: 6px; }
.mc-mutations:empty { display: none; }
.mchip {
  display: inline-block; padding: 4px 9px; border-radius: var(--r-pill, 999px);
  border: 1px solid var(--line-up); background: rgba(6, 5, 6, .5);
  font-size: 11px; line-height: 1.4; color: var(--t-body);
}
.mchip.own { border-color: rgba(232, 144, 26, .5); }
.mchip.parent { border-color: rgba(163, 43, 200, .55); }
.mchip.elder { border-color: rgba(255, 198, 77, .7); }
.mchip.more { color: var(--t-dim); }

/* the 2D look — the fallback the live page renders when no engine is present,
   made visible: one swatch per skin slot, in slot order, plus the page's own
   note line for a glitch or code-only row. Display only; nothing here is
   written back to anything. */
.mk-look { display: grid; gap: 6px; }
.mk-swatches { display: flex; gap: 4px; height: 14px; }
.mk-swatch { flex: 1 1 0; display: block; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .55); min-width: 0; }
.mk-note { margin: 0; font-size: 11px; line-height: 1.45; color: var(--t-ter); }
.mcard .mk-look { margin: -4px 0 0; }

/* the live engine's card stage, kept styled so a module that does announce
   itself (mkt3d:ready) has somewhere to paint */
.mc-stage { position: relative; height: 172px; margin: -14px -16px 2px; overflow: hidden;
  border-radius: var(--r, 9px) var(--r, 9px) 0 0;
  background: linear-gradient(180deg, rgba(10, 8, 11, .35), rgba(4, 3, 5, .72)); }
.mcard.has3d:hover { transform: none; }
.mc-stage-spin { position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px;
  border: 3px solid var(--line-up); border-top-color: var(--ember); border-radius: 50%; animation: mk-spin .9s linear infinite; z-index: 4; }
.mc-stage-note { position: absolute; left: 8px; right: 8px; bottom: 4px; z-index: 4; margin: 0; text-align: center;
  font-size: 11px; color: var(--t-sec); text-shadow: 0 1px 3px rgba(0, 0, 0, .8); }

/* ── 5. empties ──────────────────────────────────────────────────────────── */
.mgrid-empty h2 {
  margin: 0 0 8px; font: 700 15px/1.3 var(--display); letter-spacing: .04em;
  text-transform: uppercase; color: var(--t-sec);
}
.mgrid-empty p { margin: 0 auto; max-width: 52ch; font-size: 13px; }
.mgrid-empty b { color: var(--t-hi); }
.mgrid-empty a { color: var(--ember-ink); text-decoration: underline; text-underline-offset: 3px; }
.sell-signin p { margin: 0; font-size: 14px; color: var(--t-body); }
.sell-hint { margin: 0 0 14px; font-size: 13px; color: var(--t-sec); max-width: 70ch; }
.sell-wrap .sell-list { margin-bottom: 0; }

/* ── 6. sales ────────────────────────────────────────────────────────────── */
.sales-table { min-width: 620px; }
.sales-table .sales-empty { padding: 26px var(--s4, 16px); text-align: center; color: var(--t-ter); }
.sales-table .sold-dino b { color: var(--t-hi); font-family: var(--display); letter-spacing: .04em; text-transform: uppercase; font-size: 13px; }
.sales-table .sold-sub { font-size: 12px; color: var(--t-ter); }
.sales-table .sold-price { font: 600 13px/1 var(--data); color: var(--ember-core); font-variant-numeric: tabular-nums; }
.sales-table td { font-size: 13px; color: var(--t-body); }

/* ── 7. the two sheets ───────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 125;
  display: flex; align-items: center; justify-content: center; padding: 18px;
  background: rgba(2, 1, 3, .78);
}
.modal-card {
  position: relative; width: min(920px, 96vw); max-height: 92vh; overflow: auto;
  display: grid; grid-template-columns: 1.15fr 1fr;
  border: 1px solid var(--line-up); border-radius: var(--r, 9px);
  background: linear-gradient(180deg, rgba(21, 15, 16, .98), rgba(8, 6, 7, .99));
  box-shadow: var(--lit-edge), 0 40px 90px -30px #000;
}
.modal-card.sell-card { grid-template-columns: 1fr; width: min(480px, 96vw); }
.modal-close {
  position: absolute; top: 10px; right: 12px; z-index: 2;
  width: 36px; height: 36px; cursor: pointer;
  border: 1px solid var(--line-up); border-radius: var(--r, 9px);
  background: rgba(6, 5, 6, .8); color: var(--t-hi); font-size: 18px; line-height: 1;
}
.modal-close:hover { border-color: var(--line-hot); }
.modal-stage {
  position: relative; min-height: 340px; display: grid; align-content: center; padding: 28px 26px 36px;
  background: radial-gradient(120% 100% at 50% 0%, rgba(232, 144, 26, .12), transparent 62%), rgba(4, 3, 5, .6);
}
.modal-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.mk-look-stage { justify-items: stretch; }
.mk-look-stage .mk-swatches { height: 42px; }
.mk-look-stage .mk-note { text-align: center; font-size: 12px; }
.stage-note { position: absolute; left: 0; right: 0; bottom: 10px; margin: 0; text-align: center; font-size: 12px; color: var(--t-sec); }
.stage-spinner { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line-up); border-top-color: var(--ember); border-radius: 50%; animation: mk-spin .9s linear infinite; }
@keyframes mk-spin { to { transform: rotate(360deg); } }

.modal-body { padding: 26px 26px 30px; }
.m-name { margin: 0 0 6px; font-size: 22px; letter-spacing: .04em; padding-right: 40px; }
.m-sub { margin: 0 0 14px; font-size: 13px; color: var(--t-sec); }
.m-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.m-mutations { display: flex; flex-direction: column; gap: 8px; margin: 0 0 14px; }
.m-mutations:empty { display: none; }
.m-mutgroup { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.m-mutlabel { margin-right: 2px; font: 700 9px/1.3 var(--data); letter-spacing: .16em; text-transform: uppercase; color: var(--t-dim); }
.m-mutlabel.own { color: var(--ember-ink); }
.m-mutlabel.parent { color: var(--violet-ink); }
.m-mutlabel.elder { color: var(--ember-core); }
.m-mutnone { margin: 0; font-size: 13px; color: var(--t-ter); }
.m-stats { min-height: 1em; margin: 0 0 16px; font-size: 12px; line-height: 1.6; color: var(--t-sec); }
.m-actions { display: flex; flex-direction: column; gap: 10px; }
.m-actions .btn { width: 100%; }
.m-price-line { margin: 0 0 2px; font: 600 22px/1 var(--data); color: var(--ember-core); font-variant-numeric: tabular-nums; }
.m-balance-line { margin: 0 0 6px; font-size: 13px; color: var(--t-sec); }

.sell-label {
  display: block; margin: 14px 0 6px;
  font: 500 10px/1 var(--data); letter-spacing: .18em; text-transform: uppercase; color: var(--t-dim);
}
.sell-rails, .sell-fee { margin: 6px 0 0; font-size: 12px; color: var(--t-sec); }
.sell-fee b { color: var(--ember-core); font-family: var(--data); font-weight: 600; }
.sell-card .m-actions { margin-top: 18px; }

/* ── 8. toast — the live page's .on / .ok / .err contract, above the live bar ─ */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--livebar-h, 34px) + 14px); z-index: 145;
  max-width: 90vw; padding: 11px 18px; transform: translateX(-50%);
  border: 1px solid var(--line-up); border-radius: var(--r, 9px);
  background: rgba(8, 6, 7, .96); color: var(--t-hi); font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
#toast.on { opacity: 1; }
#toast.err { border-color: var(--t-ter); background-image: var(--hatch); }
#toast.ok { border-color: rgba(255, 198, 77, .55); box-shadow: var(--glow-2, none); }

/* ── 9. responsive ───────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .modal-card { grid-template-columns: 1fr; }
  .modal-stage { min-height: 200px; }
  .lock-stat { flex-basis: 100%; max-width: none; }
  .market-toolbar .select { flex-basis: 100%; }
  .mk .wallet-chip { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  .mcard:hover { transform: none; }
  .spinner, .mc-stage-spin { animation: none; }
}
