/* ══════════════════════════════════════════════════════════════════
   market.css — the swap (mk-), and the Village's Talk | Market switch.

   A stall board, not a bank statement: each offer is a little wooden
   stall card with its price as a stack of coins, and the colour says the
   direction — sun (--solar) for "offered", water (--water) for "wanted",
   gold only for the moment money actually moves. Same house rules as the
   rest of the Slate: one curve, transform and opacity only, 44px targets,
   and every flourish off under reduced motion.
   ══════════════════════════════════════════════════════════════════ */

.mk-root { --give: var(--solar); --ask: var(--water); padding-bottom: 28px; }

/* ─── the switch (drawn by village.js) ─────────────────────────── */

.mk-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  margin: 4px 0 14px; padding: 4px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--line);
  position: sticky; top: 0; z-index: 3;
  /* a band of page colour around it, so cards scrolling under it do not peek out at the rounded corners */
  box-shadow: 0 0 0 6px var(--bg), 0 10px 18px -8px rgba(0,0,0,.9);
}
.mk-switch button {
  min-height: 44px; border: 0; border-radius: 12px; background: transparent;
  color: var(--dim); font: inherit; font-size: 14.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.mk-switch button:active { transform: scale(.96); }
.mk-switch button[aria-selected="true"] { background: var(--panel-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.mk-switch .vl-ic { width: 18px; height: 18px; }
.mk-switch-coin {
  width: 16px; height: 16px; border-radius: 50%; display: inline-block;
  background: radial-gradient(circle at 35% 30%, #fbe7a8, var(--gold) 55%, #b38a2e);
  box-shadow: inset 0 0 0 1.5px rgba(80,55,10,.35);
}
.mk-switch button[aria-selected="false"] .mk-switch-coin { filter: grayscale(.7) brightness(.8); }

/* ─── head and purse ──────────────────────────────────────────── */

.mk-head { padding: 2px 2px 0; }
.mk-head .eyebrow-rune { color: var(--gold); }
.mk-head .eyebrow-rune::before, .mk-head .eyebrow-rune::after { background: linear-gradient(90deg, rgba(233,196,106,.42), transparent); }
.mk-head h2 { margin: 8px 0 14px; font-size: 28px; line-height: 1.06; color: var(--ink); }

.mk-purse {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: stretch;
  padding: 12px; border-radius: var(--r-lg);
  background: linear-gradient(160deg, rgba(233,196,106,.12), rgba(233,196,106,.02) 60%), var(--panel);
  border: 1px solid rgba(233,196,106,.28);
}
.mk-purse-main {
  display: flex; align-items: center; gap: 12px; min-height: 64px; text-align: left;
  background: none; border: 0; color: inherit; font: inherit; padding: 0 4px; cursor: pointer;
  transition: transform var(--dur-fast) var(--ease);
}
.mk-purse-main:active { transform: scale(.97); }
.mk-purse i, .mk-w-split i { display: block; font-style: normal; font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--faint); }
.mk-free { display: block; font-size: 38px; line-height: 1; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.mk-purse-side { display: flex; flex-direction: column; justify-content: center; gap: 6px; padding-left: 12px; border-left: 1px solid var(--line); }
.mk-purse-side b { font-size: 17px; font-variant-numeric: tabular-nums; color: var(--ink-2, var(--ink)); }
.mk-purse-note { grid-column: 1 / -1; margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--dim); }
.mk-purse-coin {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #fff1c2 0 8%, #f3d27e 22%, var(--gold) 50%, #a77d22 100%);
  box-shadow: inset 0 0 0 3px rgba(120,84,14,.35), inset 0 -4px 6px rgba(80,50,0,.35), 0 4px 14px -6px rgba(233,196,106,.7);
  position: relative;
}
.mk-purse-coin::after { content: ""; position: absolute; inset: 10px; border-radius: 50%; border: 1.5px solid rgba(110,78,10,.35); }

/* ─── the rules ───────────────────────────────────────────────── */

.mk-rules { margin: 12px 0 0; border-radius: var(--r); border: 1px dashed var(--line-2); background: rgba(240,226,205,.03); }
.mk-rules summary {
  min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 14px; cursor: pointer;
  color: var(--parchment); font-size: 14px; font-weight: 600; list-style: none;
}
.mk-rules summary::-webkit-details-marker { display: none; }
.mk-rules summary::before { content: "?"; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; background: rgba(240,226,205,.1); color: var(--parchment); }
.mk-rules summary::after { content: "›"; margin-left: auto; color: var(--faint); transition: transform var(--dur) var(--ease); }
.mk-rules[open] summary::after { transform: rotate(90deg); }
.mk-rules ol { margin: 0; padding: 0 14px 12px 36px; font-size: 13.5px; line-height: 1.45; color: var(--dim); }
.mk-rules li { margin: 0 0 6px; }
.mk-rules li b { color: var(--ink); font-weight: 600; }

/* ─── composer ────────────────────────────────────────────────── */

.mk-compose { margin: 14px 0 4px; scroll-margin-top: 76px; }
.mk-open { width: 100%; border-style: dashed; border-color: rgba(233,196,106,.45); color: var(--gold); background: rgba(233,196,106,.06); }
.mk-plus { font-size: 24px; line-height: 1; font-weight: 400; }
.mk-comp { padding: 14px; border-radius: var(--r-lg); background: var(--panel); border: 1px solid var(--line-2); animation: mk-rise var(--dur) var(--ease) both; }
.mk-comp-hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mk-comp h3, .mk-thx h3, .mk-lane h3, .mk-shop h3 { margin: 0; font-size: 22px; line-height: 1.1; color: var(--ink); }
.mk-kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 4px; }
.mk-kind {
  min-height: 84px; padding: 12px; border-radius: var(--r); text-align: left; font: inherit; color: var(--ink);
  background: var(--panel-2); border: 1.5px solid var(--line); display: flex; flex-direction: column; gap: 4px; justify-content: center;
  transition: transform var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.mk-kind:active { transform: scale(.96); }
.mk-kind b { font-size: 17px; }
.mk-kind span { font-size: 12.5px; color: var(--dim); line-height: 1.3; }
.mk-kind.give b { color: var(--give); }
.mk-kind.ask b { color: var(--ask); }
.mk-kind.give[aria-pressed="true"] { border-color: var(--give); background: rgba(227,169,92,.1); }
.mk-kind.ask[aria-pressed="true"] { border-color: var(--ask); background: rgba(191,234,255,.08); }
.mk-lbl { display: block; margin: 14px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .13em; color: var(--faint); }
.mk-what-in { width: 100%; min-height: 64px; resize: vertical; font-size: 15px; }
.mk-rule { margin: 14px 0 0; font-size: 13px; color: var(--dim); line-height: 1.4; }
.mk-rule.bad { color: #f0a497; }
.mk-areas { padding: 2px; }
/* sixteen places do not fit; the fade says there are more below */
.mk-areas.many { max-height: 150px; overflow-y: auto; padding-bottom: 30px;
  -webkit-mask-image: linear-gradient(180deg, #000 80%, transparent); mask-image: linear-gradient(180deg, #000 80%, transparent); }
.mk-areas .chip, .mk-quick .chip { min-height: 44px; }

.mk-step { display: flex; align-items: center; gap: 10px; }
.mk-step-b {
  width: 52px; height: 52px; flex: none; border-radius: 50%; font: inherit; font-size: 24px; line-height: 1;
  background: var(--panel-2); border: 1px solid var(--line-2); color: var(--ink);
  transition: transform var(--dur-fast) var(--ease);
}
.mk-step-b:active { transform: scale(.9); }
.mk-step-n { flex: 1; display: flex; justify-content: center; }
.mk-quick { display: flex; gap: 6px; margin-top: 10px; }
.mk-quick .chip { flex: 1; justify-content: center; padding: 6px 0; font-size: 14px; font-weight: 600; }

/* ─── coins ───────────────────────────────────────────────────── */

.mk-coins { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; flex: none; }
.mk-coins b { font-size: 16px; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; line-height: 1; }
.mk-stack { position: relative; width: 30px; height: calc(10px + var(--k) * 4px); display: block; }
.mk-stack i {
  position: absolute; left: 0; right: 0; bottom: calc(var(--i) * 4px); height: 10px; border-radius: 50%;
  background: radial-gradient(ellipse at 40% 35%, #fbe7a8, var(--gold) 55%, #9c7420);
  box-shadow: 0 1.5px 0 #7d5b16, inset 0 0 0 1px rgba(90,60,10,.35);
}
.mk-coins.big { flex-direction: row; gap: 10px; }
.mk-coins.big b { font-size: 30px; }
.mk-coins.big .mk-stack { width: 40px; height: calc(13px + var(--k) * 5px); }
.mk-coins.big .mk-stack i { height: 13px; bottom: calc(var(--i) * 5px); }

/* ─── lanes ───────────────────────────────────────────────────── */

.mk-lanes {
  display: flex; gap: 4px; margin: 18px 0 6px; overflow-x: auto; scrollbar-width: none;
  padding: 3px; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--line);
}
.mk-lanes::-webkit-scrollbar { display: none; }
.mk-lanes button {
  flex: 1 0 auto; min-height: 44px; padding: 0 12px; border: 0; border-radius: 11px; background: none;
  color: var(--dim); font: inherit; font-size: 13.5px; font-weight: 600; white-space: nowrap;
}
.mk-lanes button i { font-style: normal; font-size: 11px; color: var(--faint); margin-left: 2px; font-variant-numeric: tabular-nums; }
.mk-lanes button[aria-selected="true"] { background: var(--panel-2); color: var(--ink); }

.mk-lane { margin-top: 16px; scroll-margin-top: 76px; }
.mk-lane > header { margin: 0 2px 10px; }
.mk-lane > header p { margin: 3px 0 0; font-size: 12.5px; color: var(--dim); }

/* ─── a stall card ────────────────────────────────────────────── */

.mk-card {
  --c: var(--give);
  position: relative; margin: 0 0 10px; padding: 30px 14px 12px; border-radius: var(--r-lg);
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.012) 0 2px, transparent 2px 9px),
    linear-gradient(180deg, color-mix(in srgb, var(--c) 7%, transparent), transparent 60%),
    var(--panel);
  border: 1px solid var(--line);
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--c) 70%, transparent), var(--shadow);
  animation: mk-rise var(--dur-slow) var(--ease) both; animation-delay: var(--d, 0ms);
  overflow: hidden;
}
.mk-card.k-ask { --c: var(--ask); }
.mk-card.tmp { opacity: .7; }
.mk-card.mine-to-pay { border-color: rgba(233,196,106,.55); box-shadow: inset 3px 0 0 var(--gold), 0 0 0 1px rgba(233,196,106,.18), var(--shadow); }
.mk-card.s-settled { opacity: .78; }
.mk-card-top { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; padding-right: 2px; }
.mk-pair { position: relative; display: block; width: 40px; }
.mk-pair svg, .mk-pair .mk-init { display: block; border-radius: 50%; }
.mk-with { position: absolute; right: -8px; bottom: -10px; border-radius: 50%; box-shadow: 0 0 0 2px var(--panel); background: var(--panel); }
.mk-card-txt { min-width: 0; }
.mk-by { display: block; font-size: 12px; color: var(--faint); }
.mk-by time { color: var(--faint); }
.mk-what { margin: 2px 0 6px; font-size: 16px; line-height: 1.3; color: var(--ink); font-weight: 560; overflow-wrap: anywhere; }
.mk-place {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 6px; border-radius: 99px;
  font-size: 12px; color: var(--dim); background: var(--panel-2); border: 1px solid var(--line);
}
.mk-place .ic { width: 14px; height: 14px; color: var(--c); }
.mk-card .mk-coins { margin-top: 2px; }
.mk-next { margin: 10px 0 0; font-size: 13px; line-height: 1.4; color: var(--dim); }
.mk-acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.mk-acts .btn { min-height: 44px; padding: 8px 16px; font-size: 14px; }
.mk-acts .btn.go { flex: 1 1 auto; }
.mk-pay { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--gold) !important; border-color: var(--gold) !important; color: #2a1d02 !important; }
.mk-coin-ic { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff4cf, #d6ae4c 60%, #8f6a17); box-shadow: inset 0 0 0 1.5px rgba(60,40,0,.4); }
.mk-short { font-size: 12.5px; color: var(--faint); padding: 6px 0; }

/* The status ribbon: a folded tag in the top-right corner of the stall. */
.mk-ribbon {
  position: absolute; top: 0; right: 14px; padding: 3px 9px 4px; border-radius: 0 0 8px 8px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
  background: color-mix(in srgb, var(--c) 20%, var(--panel-2)); color: var(--c);
}
.mk-ribbon.taken, .mk-ribbon.wait { background: var(--panel-2); color: var(--dim); }
.mk-ribbon.pay { background: var(--gold); color: #2a1d02; }
.mk-ribbon.done { background: rgba(134,185,111,.16); color: var(--life); }

/* The clink: a settled card lifts, glows gold and settles back. */
.mk-card.clink { animation: mk-clink .8s var(--ease) both; }
@keyframes mk-clink {
  0% { transform: scale(1); }
  30% { transform: scale(1.025); box-shadow: 0 0 0 2px var(--gold), 0 0 34px -6px rgba(233,196,106,.7); }
  100% { transform: scale(1); }
}
@keyframes mk-rise { from { opacity: 0; transform: translate3d(0, 8px, 0); } to { opacity: 1; transform: none; } }

.mk-empty { color: var(--faint); font-size: 13.5px; padding: 14px 4px; margin: 0; }
.mk-loading { animation: mk-breathe 1.4s var(--ease) infinite alternate; }
@keyframes mk-breathe { from { opacity: .45; } to { opacity: 1; } }

/* ─── say thanks ──────────────────────────────────────────────── */

.mk-thanks { margin-top: 26px; padding: 14px; border-radius: var(--r-lg); background: var(--panel); border: 1px solid var(--line); scroll-margin-top: 70px; }
.mk-thx > header p { margin: 4px 0 0; font-size: 13px; color: var(--dim); }
.mk-thx > header p.mk-left { color: var(--gold); font-weight: 600; font-size: 12.5px; }
.mk-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; margin: 12px 0 0; }
.mk-who {
  min-height: 88px; padding: 8px 4px; border-radius: var(--r); font: inherit; color: var(--dim); font-size: 12.5px;
  background: var(--panel-2); border: 1.5px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: transform var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.mk-who:active { transform: scale(.94); }
.mk-who span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-who[aria-pressed="true"] { border-color: var(--gold); color: var(--ink); background: rgba(233,196,106,.08); }
.mk-thx .f-in { width: 100%; }

/* ─── reward shop (FarmWire's section, embedded) ──────────────── */

.mk-shop { margin-top: 26px; }
.mk-shop > header { margin: 0 2px 10px; }
.mk-shop > header p { margin: 3px 0 0; font-size: 12.5px; color: var(--dim); }
/* Our purse is already at the top of the page; the shop's own would be a second, different-looking one. */
.mk-shop .wr-purse { display: none; }

/* ─── the settle confirm ──────────────────────────────────────── */

.mk-confirm { position: relative; padding-top: 6px; }
.mk-confirm h2 { margin: 4px 0 16px; overflow-wrap: anywhere; }
.mk-flow { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 16px 10px; border-radius: var(--r-lg); background: var(--panel); border: 1px solid rgba(233,196,106,.3); }
.mk-flow-p { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 64px; }
.mk-flow-p i { font-style: normal; font-size: 13px; color: var(--dim); }
.mk-flow-p.to i { color: var(--ink); font-weight: 600; }
.mk-flow-p svg { border-radius: 50%; }
.mk-flow-arrow { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mk-flow-arrow > svg { width: 100%; max-width: 110px; height: 12px; fill: none; stroke: var(--gold); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.mk-confirm-say { margin: 16px 0 4px; font-size: 18px; font-weight: 600; color: var(--ink); text-align: center; }
.mk-confirm-fine { margin: 0 0 6px; font-size: 13px; color: var(--dim); text-align: center; line-height: 1.4; }
.mk-got { animation: mk-got .5s var(--ease) .45s both; }
@keyframes mk-got { 50% { transform: scale(1.14); } }

.mk-fly {
  position: absolute; z-index: 60; width: 18px; height: 18px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #fff4cf, var(--gold) 55%, #8f6a17);
  box-shadow: inset 0 0 0 1.5px rgba(60,40,0,.35);
  animation: mk-hop .62s var(--ease) var(--d, 0ms) both;
}
@keyframes mk-hop {
  0% { opacity: 0; transform: translate3d(0, 0, 0) scale(.6); }
  15% { opacity: 1; }
  50% { transform: translate3d(calc(var(--dx) * .5), -46px, 0) scale(1); }
  100% { opacity: 0; transform: translate3d(var(--dx), 0, 0) scale(.7); }
}
.mk-fly.up { animation-name: mk-up; animation-duration: .8s; }
@keyframes mk-up {
  0% { opacity: 0; transform: translate3d(0, 0, 0) scale(.6); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(0, -120px, 0) scale(1); }
}

/* ─── the wallet sheet ────────────────────────────────────────── */

.mk-wallet { padding-top: 4px; }
.mk-w-big { display: flex; align-items: center; gap: 12px; margin: 8px 0 12px; }
.mk-w-big b { font-size: 46px; line-height: 1; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.mk-w-big i { font-style: normal; color: var(--dim); font-size: 14px; align-self: flex-end; padding-bottom: 6px; }
.mk-w-split { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.mk-w-split span { padding: 9px 11px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.mk-w-split b { font-size: 19px; font-variant-numeric: tabular-nums; }
.mk-w-split .go b { color: var(--life); }
.mk-spark { display: block; width: 100%; height: 56px; margin: 12px 0 4px; }
.mk-spark-l { fill: none; stroke: var(--gold); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.mk-spark-a { fill: rgba(233,196,106,.1); }
.mk-spark-d { fill: var(--gold); }
.mk-w-acts .btn { flex: 1; min-height: 44px; }
.mk-w-h { margin: 18px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .13em; color: var(--faint); font-weight: 600; }
.mk-hist { list-style: none; margin: 0; padding: 0; }
.mk-hist li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); min-height: 44px; }
.mk-h-txt { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-size: 14px; }
.mk-h-txt em { font-style: normal; font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); }
.mk-h-txt > span { flex-basis: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); order: 2; }
.mk-h-txt time { font-size: 11.5px; color: var(--faint); }
.mk-hist b { font-size: 16px; font-variant-numeric: tabular-nums; }
.mk-hist li.in b { color: var(--life); }
.mk-hist li.out b { color: var(--now); }

/* ─── the header pill, now a button ───────────────────────────── */

.bar .embers.mk-pill { cursor: pointer; }
.bar .embers.mk-pill:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.mk-init { display: grid; place-items: center; border-radius: 50%; background: var(--panel-2); color: var(--dim); font-weight: 700; }

/* ─── reduced motion: no flourishes at all ────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .mk-card, .mk-comp, .mk-card.clink, .mk-got, .mk-loading { animation: none !important; }
  .mk-fly { display: none; }
  .mk-switch button, .mk-kind, .mk-who, .mk-step-b, .mk-purse-main { transition: none; }
}
