/* Mythox shell kit, app shell stage S1 draft. Menus, tabs, modals, settings controls, village pieces.
   Requires 02-color/tokens.css, 03-type/type-tokens.css, 07-ui-kit/motion-tokens.css and 07-ui-kit/ui-kit.css (loaded first; this file only adds).
   Same rules as ui-kit.css: glass slab, quiet, no glow or shine. Pillar color marks edges and icons; icons and words carry the meaning.
   Dark only (menu look decision 1). Targets are at least 44px, text at least 12px. Durations come from motion tokens, so reduced motion collapses them. */
.mx-ui {
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --bar-bg: color-mix(in srgb, var(--mx-brand-deep) 96%, var(--mx-brand-pine));
}
.mx-ui .is-market { --p: var(--mx-brand-cream); }
.mx-ui .is-gold { --cur: var(--mx-brand-gold); }
.mx-ui .is-renown { --cur: #d98a63; }      /* copper lifted for contrast on dark */
.mx-ui .is-peridot { --cur: var(--mx-tier-peridot-glow); }

/* ---------- top bar: currency, title, currency ---------- */
.mx-topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: .5rem;
  min-height: 56px; padding: calc(.5rem + var(--safe-top)) .75rem .5rem; background: var(--bar-bg); border-bottom: 1px solid var(--edge); }
.mx-topbar > :first-child { justify-self: start; } .mx-topbar > :last-child { justify-self: end; }
.mx-topbar-title { margin: 0; font: var(--mx-display-weight) var(--mx-text-h3)/1.1 var(--mx-font-display); text-align: center; white-space: nowrap; }
.mx-currency { display: inline-flex; align-items: center; gap: .375rem; min-height: 36px; padding: .25rem .75rem .25rem .5rem; border-radius: 999px;
  background: color-mix(in srgb, var(--mx-health-track) 80%, var(--mx-brand-deep)); border: 1px solid var(--edge);
  font: var(--mx-weight-strong) var(--mx-text-sm)/1 var(--mx-font-ui); font-variant-numeric: tabular-nums; color: var(--mx-text-on-dark); }
.mx-currency .mx-ic { width: 1.25rem; height: 1.25rem; color: var(--cur, var(--mx-brand-gold)); }
.mx-currency.gain { animation: mx-bump var(--mx-dur-base) var(--mx-ease-pop); }
@keyframes mx-bump { 40% { transform: scale(1.12); } }

/* the settings gear floats over scenes (March, Village) */
.mx-float-btn { position: absolute; z-index: 5; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border-radius: 12px;
  border: 1px solid var(--edge); background: color-mix(in srgb, var(--mx-brand-deep) 82%, transparent); color: var(--mx-text-on-dark-muted); cursor: pointer; touch-action: manipulation; }
.mx-float-btn:hover { color: var(--mx-text-on-dark); }
.mx-float-btn:focus-visible { outline: 3px solid var(--mx-brand-gold); outline-offset: 2px; }

/* ---------- tab bar: four pillars plus Market ---------- */
.mx-tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: end; min-height: 72px; padding-bottom: var(--safe-bottom);
  background: var(--bar-bg); border-top: 1px solid var(--edge); }
.mx-tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 64px; min-width: 44px; padding: .25rem 0;
  border: 0; border-top: 3px solid transparent; background: transparent; color: var(--mx-text-on-dark-muted); cursor: pointer; touch-action: manipulation;
  font: var(--mx-weight-strong) var(--mx-text-xs)/1.1 var(--mx-font-ui); letter-spacing: .02em;
  transition: background-color var(--mx-dur-base) var(--mx-ease), color var(--mx-dur-base) var(--mx-ease); }
.mx-tab .mx-ic { width: 1.625rem; height: 1.625rem; }
.mx-tab:focus-visible { outline: 3px solid var(--mx-brand-gold); outline-offset: -3px; }
.mx-tab[aria-current="page"] { color: var(--mx-text-on-dark); border-top-color: var(--p); min-height: 76px; border-radius: 12px 12px 0 0;
  background: color-mix(in srgb, var(--p) 16%, var(--bar-bg)); }
.mx-tab[aria-current="page"] .mx-ic { color: var(--p); }
.mx-tab[aria-disabled="true"] { color: color-mix(in srgb, var(--mx-text-on-dark-muted) 55%, transparent); cursor: not-allowed; }
.mx-tab[aria-disabled="true"] .mx-lockmark { position: absolute; top: 10px; left: calc(50% + 6px); width: 1rem; height: 1rem; color: var(--mx-text-on-dark-muted);
  background: var(--bar-bg); border-radius: 50%; padding: 1px; }
.mx-dot { position: absolute; top: 6px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--mx-health-danger);
  border: 2px solid var(--bar-bg); box-sizing: content-box; color: #fff; font-size: var(--mx-text-xs); line-height: 18px; font-weight: 700; text-align: center; }
.mx-dot:empty { min-width: 10px; height: 10px; padding: 0; border-radius: 50%; line-height: 0; }
.mx-tabbar.is-hidden { display: none; }

/* ---------- segmented switch (sits just above the tab bar) ---------- */
.mx-seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--mx-health-track); border: 1px solid var(--edge); }
.mx-seg button { min-height: 44px; min-width: 44px; padding: 0 1.125rem; border: 0; border-radius: 10px; background: transparent; color: var(--mx-text-on-dark-muted);
  font: var(--mx-weight-strong) var(--mx-text-sm)/1 var(--mx-font-ui); cursor: pointer; touch-action: manipulation; transition: background-color var(--mx-dur-fast) var(--mx-ease); }
.mx-seg button[aria-selected="true"] { background: color-mix(in srgb, var(--mx-pillar-hold) 30%, var(--mx-brand-pine)); color: var(--mx-text-on-dark); }
.mx-seg button:focus-visible { outline: 3px solid var(--mx-brand-gold); outline-offset: 1px; }
.mx-seg button[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

/* ---------- large button ---------- */
.mx-btn-lg { min-height: 56px; font-size: var(--mx-text-lg); border-radius: 14px; width: 100%; }
.mx-btn-sm { min-height: 44px; padding: .375rem .875rem; font-size: var(--mx-text-sm); }
.mx-btn .mx-ic { width: 1.25rem; height: 1.25rem; }
.mx-need { margin: .25rem 0 0; font-size: var(--mx-text-sm); color: var(--mx-text-on-dark-muted); text-align: center; }
.mx-need.bad { color: #ff9a85; }

/* ---------- modal: card plus a close puck under it, over a dimmed screen ---------- */
.mx-scrim { position: absolute; inset: 0; z-index: 20; background: rgb(6 16 11 / .78); animation: mx-fade var(--mx-dur-base) var(--mx-ease); }
.mx-modal-wrap { position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px 18px calc(16px + var(--safe-bottom)); pointer-events: none; }
.mx-modal-wrap > * { pointer-events: auto; }
.mx-modal { width: 100%; max-width: 420px; max-height: calc(100% - 96px); overflow: auto; display: flex; flex-direction: column; gap: .75rem; padding: 1rem;
  background: var(--slab-solid); border: 1px solid var(--edge); border-radius: 18px; box-shadow: 0 16px 40px rgb(0 0 0 / .4);
  animation: mx-rise var(--mx-dur-base) var(--mx-ease); }
.mx-modal > h2 { margin: 0; text-align: center; font: var(--mx-display-weight) var(--mx-text-h3)/1.15 var(--mx-font-display); }
.mx-modal .mx-sub { margin: 0; text-align: center; font-size: var(--mx-text-sm); color: var(--mx-text-on-dark-muted); }
.mx-puck { flex: none; width: 56px; height: 56px; display: grid; place-items: center; padding: 0; border-radius: 50%; cursor: pointer; touch-action: manipulation;
  border: 2px solid var(--mx-health-danger); background: color-mix(in srgb, var(--mx-health-danger) 38%, var(--mx-brand-deep)); color: var(--mx-text-on-dark);
  animation: mx-rise var(--mx-dur-base) var(--mx-ease); }
.mx-puck .mx-ic { width: 1.5rem; height: 1.5rem; }
.mx-puck:active { transform: scale(.94); }
.mx-puck:focus-visible { outline: 3px solid var(--mx-brand-gold); outline-offset: 3px; }
@keyframes mx-fade { from { opacity: 0; } }
@keyframes mx-rise { from { opacity: 0; transform: translateY(12px); } }

/* ---------- list rows ---------- */
.mx-rows { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.mx-row { display: flex; align-items: center; gap: .75rem; min-height: 56px; padding: .5rem .75rem; border-radius: 12px; border: 1px solid var(--edge);
  border-left: 4px solid var(--p, var(--edge)); background: color-mix(in srgb, var(--mx-brand-pine) 62%, transparent); color: var(--mx-text-on-dark); }
.mx-row-ic { flex: none; width: 2.5rem; height: 2.5rem; display: grid; place-items: center; border-radius: 10px; background: color-mix(in srgb, var(--mx-brand-deep) 60%, transparent); color: var(--p, var(--mx-brand-gold)); }
.mx-row-ic .mx-ic { width: 1.5rem; height: 1.5rem; }
.mx-row-tx { flex: 1; min-width: 0; }
.mx-row-tx b { display: block; font-size: var(--mx-text-base); line-height: 1.2; }
.mx-row-tx small { display: block; margin-top: 2px; font-size: var(--mx-text-sm); color: var(--mx-text-on-dark-muted); line-height: 1.25; }
.mx-row.is-selected { border-color: var(--mx-brand-gold); background: color-mix(in srgb, var(--mx-brand-gold) 12%, var(--mx-brand-pine)); }
.mx-row.is-locked { opacity: .6; border-left-style: dashed; }
.mx-row.is-claim { border-color: var(--mx-interact-valid); }
button.mx-row { width: 100%; text-align: left; font: inherit; cursor: pointer; touch-action: manipulation; }
button.mx-row:focus-visible { outline: 3px solid var(--mx-brand-gold); outline-offset: 2px; }
.mx-row .mx-bar { margin-top: 6px; height: 10px; }
.mx-badge { display: inline-flex; align-items: center; gap: .25rem; min-height: 22px; padding: 0 .5rem; border-radius: 999px; font-size: var(--mx-text-xs); font-weight: var(--mx-weight-strong);
  background: color-mix(in srgb, var(--mx-brand-pine) 90%, var(--mx-brand-cream) 6%); color: var(--mx-text-on-dark-muted); border: 1px solid var(--edge); white-space: nowrap; }
.mx-badge .mx-ic { width: .875rem; height: .875rem; }
.mx-badge.new { background: var(--mx-health-danger); border-color: transparent; color: #fff; }
.mx-badge.good { color: var(--mx-interact-valid); border-color: color-mix(in srgb, var(--mx-interact-valid) 50%, transparent); }
.mx-badge.lock { border-style: dashed; }

/* ---------- offer card (Market, daily offer) ---------- */
.mx-offer { display: grid; gap: .75rem; padding: .875rem; border-radius: 14px; background: color-mix(in srgb, var(--mx-brand-pine) 70%, transparent); border: 1px solid var(--edge); }
.mx-offer-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.mx-offer-head h3 { margin: 0; font: var(--mx-display-weight) var(--mx-text-lg)/1.15 var(--mx-font-display); }
.mx-offer-body { display: flex; align-items: center; gap: .75rem; }
.mx-offer-body .mx-row-tx { flex: 1; }

/* ---------- settings controls ---------- */
.mx-setting { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: 56px; padding: .25rem .75rem; border-radius: 12px; border: 1px solid var(--edge);
  background: color-mix(in srgb, var(--mx-brand-pine) 62%, transparent); }
.mx-setting > .mx-row-tx { flex: 1; }
.mx-range { -webkit-appearance: none; appearance: none; width: 128px; height: 44px; background: transparent; cursor: pointer; }
.mx-range::-webkit-slider-runnable-track { height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--mx-brand-gold) var(--fill, 50%), var(--mx-health-track) var(--fill, 50%)); border: 1px solid var(--edge); }
.mx-range::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -10px; border-radius: 50%; background: var(--mx-brand-cream); border: 2px solid var(--mx-brand-deep); }
.mx-range::-moz-range-track { height: 8px; border-radius: 4px; background: var(--mx-health-track); border: 1px solid var(--edge); }
.mx-range::-moz-range-progress { height: 8px; border-radius: 4px; background: var(--mx-brand-gold); }
.mx-range::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--mx-brand-cream); border: 2px solid var(--mx-brand-deep); }
.mx-range:focus-visible { outline: 3px solid var(--mx-brand-gold); outline-offset: 2px; border-radius: 6px; }
.mx-stepper { display: inline-flex; align-items: center; gap: .25rem; }
.mx-stepper button { min-width: 44px; min-height: 44px; border-radius: 12px; border: 1px solid var(--edge); background: color-mix(in srgb, var(--mx-brand-pine) 82%, transparent); color: var(--mx-text-on-dark);
  font: var(--mx-weight-strong) var(--mx-text-lg)/1 var(--mx-font-ui); cursor: pointer; touch-action: manipulation; }
.mx-stepper button:focus-visible { outline: 3px solid var(--mx-brand-gold); outline-offset: 2px; }
.mx-stepper output { min-width: 3.5ch; text-align: center; font: var(--mx-weight-strong) var(--mx-text-base)/1 var(--mx-font-ui); font-variant-numeric: tabular-nums; }

/* ---------- toast (sits above the tab bar) ---------- */
.mx-toast { display: flex; align-items: center; gap: .625rem; max-width: 100%; padding: .625rem .875rem; border-radius: 12px; background: var(--slab-solid); border: 1px solid var(--edge);
  border-left: 4px solid var(--p, var(--mx-brand-gold)); box-shadow: 0 8px 24px rgb(0 0 0 / .35); font-size: var(--mx-text-sm); line-height: 1.3; animation: mx-rise var(--mx-dur-base) var(--mx-ease); }
.mx-toast .mx-ic { color: var(--p, var(--mx-brand-gold)); width: 1.25rem; height: 1.25rem; }

/* ---------- loading ---------- */
.mx-loading { display: grid; justify-items: center; gap: 1rem; text-align: center; }
.mx-progress { width: min(260px, 70%); height: 10px; border-radius: 5px; background: var(--mx-health-track); border: 1px solid var(--edge); overflow: hidden; }
.mx-progress > i { display: block; height: 100%; width: var(--v, 0%); background: var(--mx-brand-gold); transition: width var(--mx-dur-base) var(--mx-ease); }

/* ---------- village pieces ---------- */
.mx-plot { position: absolute; width: 96px; height: 48px; transform: translate(-50%, -50%); border: 0; padding: 0; background: transparent; cursor: pointer; touch-action: manipulation; }
.mx-plot::before { content: ""; position: absolute; inset: 0; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); background: color-mix(in srgb, var(--mx-brand-cream) 12%, transparent); }
.mx-plot::after { content: ""; position: absolute; inset: 3px; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); background: repeating-linear-gradient(45deg, rgb(247 243 232 / .5) 0 4px, transparent 4px 9px); opacity: .5; mask: linear-gradient(#000, #000); }
.mx-plot .mx-ic { position: relative; z-index: 1; margin: auto; width: 1.5rem; height: 1.5rem; color: var(--mx-text-on-dark); }
.mx-plot:focus-visible { outline: 3px solid var(--mx-brand-gold); outline-offset: 4px; }
.mx-plot.is-locked::after { opacity: 0; } .mx-plot.is-locked { opacity: .55; }
.mx-bubble { position: absolute; transform: translate(-50%, -50%); min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 2px; padding: 0 .5rem;
  border-radius: 999px; border: 2px solid var(--mx-brand-deep); background: var(--mx-brand-gold); color: var(--mx-brand-deep);
  font: var(--mx-weight-strong) var(--mx-text-sm)/1 var(--mx-font-ui); font-variant-numeric: tabular-nums; cursor: pointer; touch-action: manipulation; }
.mx-bubble .mx-ic { width: 1rem; height: 1rem; }
.mx-bubble:focus-visible { outline: 3px solid var(--mx-brand-cream); outline-offset: 3px; }
@media (prefers-reduced-motion: no-preference) { .mx-bubble { animation: mx-bob 2.4s ease-in-out infinite; } }
@keyframes mx-bob { 50% { transform: translate(-50%, calc(-50% - 4px)); } }
.mx-scene-label { position: absolute; z-index: 2; padding: .125rem .5rem; border-radius: 6px; background: color-mix(in srgb, var(--mx-brand-deep) 85%, transparent); font-size: var(--mx-text-xs); font-weight: var(--mx-weight-strong); transform: translateX(-50%); white-space: nowrap; }

/* ---------- screen frame (menus) ---------- */
.mx-screen { position: relative; display: flex; flex-direction: column; min-height: 0; height: 100%; background: var(--mx-brand-deep); overflow: hidden; }
.mx-screen-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: .75rem; padding: .75rem; overflow: auto; }
.mx-screen-body > .mx-seg { margin-top: auto; align-self: center; flex: none; }
.mx-stars { display: flex; justify-content: center; gap: .5rem; }
.mx-stars .mx-ic { width: 2.25rem; height: 2.25rem; color: var(--mx-brand-gold); }
.mx-stars .off { color: var(--mx-health-track); }
.mx-bigtext { margin: 0; text-align: center; font: var(--mx-display-weight) var(--mx-text-display)/1 var(--mx-font-display); font-variant-numeric: tabular-nums; }
