/* Moneypal Marketplaces — shared stylesheet.
 *
 * Apps override the --brand-* custom properties in an inline <style> block;
 * everything else, including the focus treatment, is shared so that keyboard
 * behaviour cannot drift between marketplaces.
 */

:root {
  --brand: #1f5f4f;
  --brand-dark: #16453a;
  --brand-tint: #e8f2ee;
  --accent: #b4591f;

  --bg: #fbfaf8;
  --surface: #ffffff;
  --surface-2: #f3f1ed;
  --ink: #1b1d1c;
  --ink-soft: #4d524f;
  --line: #d9d5cf;
  --focus: #0b4ff0;
  --danger: #a5231b;

  --radius: 10px;
  --wrap: 68rem;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: ui-serif, Georgia, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #6cc0a7;
    --brand-dark: #8ad3bc;
    --brand-tint: #16241f;
    --accent: #e9a165;

    --bg: #121413;
    --surface: #1b1e1d;
    --surface-2: #232726;
    --ink: #f0efec;
    --ink-soft: #b4bab7;
    --line: #353a38;
    --focus: #7fb0ff;
    --danger: #ff9b92;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1rem/1.65 var(--font);
}

body.dialog-open { overflow: hidden; }

/* --- focus -------------------------------------------------------------- */

/* A single, high-contrast focus treatment for everything. Never removed. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Older engines without :focus-visible still get a ring. */
@supports not selector(:focus-visible) {
  :focus { outline: 3px solid var(--focus); outline-offset: 2px; }
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--surface);
  color: var(--ink);
  padding: 0.75rem 1rem;
  border: 2px solid var(--focus);
  border-radius: 0 0 var(--radius) 0;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

/* Screen-reader-only, still focusable. */
.vh {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- layout ------------------------------------------------------------- */

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 1.25rem;
}
.wrap.narrow { max-width: 42rem; }

main { display: block; }
main:focus { outline: none; }

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

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  min-height: 4.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  font-weight: 600;
  margin-right: auto;
}

.brand .mark {
  display: grid;
  place-items: center;
  width: 2.4rem; height: 2.4rem;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

@media (prefers-color-scheme: dark) {
  .brand .mark { color: #10211b; }
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text small { font-weight: 400; color: var(--ink-soft); font-size: 0.78rem; }

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem 1rem;
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 0.4rem 0.2rem;
  border-bottom: 2px solid transparent;
  font-weight: 500;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brand); }

/* `.site-nav a` is more specific than `.btn-primary`, so a button in the nav
   would otherwise inherit the muted link colour and sit dark-on-dark against
   its own brand background. Restore the button colours explicitly. */
.site-nav a.btn { border-bottom: 0; }
.site-nav a.btn-primary { color: #fff; }
.site-nav a.btn-ghost { color: var(--ink); }

@media (prefers-color-scheme: dark) {
  .site-nav a.btn-primary { color: #10211b; }
}

.inline-form { display: inline; margin: 0; }

.nav-toggle { display: none; }

@media (max-width: 52rem) {
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface-2);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.5rem 0.8rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
  }
  .nav-toggle .bars {
    width: 1rem; height: 2px;
    background: currentColor;
    box-shadow: 0 5px 0 currentColor, 0 -5px 0 currentColor;
  }
  .site-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    padding-bottom: 0.9rem;
    gap: 0.25rem;
  }
  .site-nav.is-open { display: flex; }
}

/* --- type --------------------------------------------------------------- */

h1 { font: 700 clamp(1.9rem, 4.4vw, 3rem)/1.12 var(--serif); margin: 0 0 0.6rem; letter-spacing: -0.01em; }
h2 { font: 700 clamp(1.4rem, 2.6vw, 2rem)/1.2 var(--serif); margin: 0 0 0.75rem; }
h3 { font: 600 1.06rem/1.35 var(--font); margin: 0 0 0.4rem; }

p { margin: 0 0 1rem; }
.lead { font-size: 1.1rem; color: var(--ink-soft); max-width: 46rem; }
.small { font-size: 0.875rem; color: var(--ink-soft); }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--brand);
  margin: 0 0 0.5rem;
}

a { color: var(--brand-dark); }
@media (prefers-color-scheme: dark) { a { color: var(--brand-dark); } }

kbd {
  font: 600 0.8em/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.2em 0.42em;
  white-space: nowrap;
}

/* --- buttons ------------------------------------------------------------ */

.btn {
  display: inline-block;
  padding: 0.7rem 1.15rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
}
.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.9rem; }

.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
@media (prefers-color-scheme: dark) {
  .btn-primary { color: #10211b; }
}

.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.linklike {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--brand-dark);
  text-decoration: underline;
  cursor: pointer;
}

.actions { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center; }

/* --- bands -------------------------------------------------------------- */

.hero, .page-head { padding: clamp(2.5rem, 7vw, 4.75rem) 0 clamp(1.75rem, 4vw, 2.5rem); }
.hero { background: linear-gradient(180deg, var(--brand-tint), var(--bg)); }
.hero h1 { max-width: 34rem; }

/* Dark hero: the headline sits on the brand colour with an accent highlight. */
.hero-dark {
  background: var(--hero-bg, var(--brand-dark));
  color: var(--hero-ink, #fff);
  padding: clamp(3.25rem, 9vw, 7rem) 0 clamp(2.75rem, 8vw, 5.5rem);
}
.hero-dark h1 { color: inherit; max-width: 16ch; }
.hero-dark h1 em { font-style: normal; color: var(--accent-light, var(--accent)); }
.hero-dark .eyebrow { color: var(--accent-light, var(--accent)); }
.hero-dark .lead { color: var(--hero-ink-soft, #e2ded6); max-width: 60ch; }
.hero-dark .crumb { color: var(--hero-ink-soft, #cfd8c9); font-size: 0.9375rem; margin-top: 1.75rem; }
.hero-dark .crumb a { color: var(--hero-ink, #fff); }

.hero-dark .btn-ghost {
  border-color: rgba(255, 255, 255, 0.55);
  color: var(--hero-ink, #fff);
  background: transparent;
}
.hero-dark .btn-ghost:hover { background: #fff; color: var(--hero-bg, var(--brand-dark)); }
.hero-dark .btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink, #1d1a19);
}
.hero-dark .btn-primary:hover {
  background: var(--accent-light, var(--accent));
  border-color: var(--accent-light, var(--accent));
  color: var(--accent-ink, #1d1a19);
}

.band { padding: clamp(2rem, 5vw, 3.5rem) 0; border-top: 1px solid var(--line); }
.band.tone-soft { background: var(--surface-2); }
.band.tone-brand { background: var(--brand-tint); }

.prose { max-width: 46rem; }
.prose h3 { margin-top: 1.25rem; }

ul.ticks { padding-left: 0; list-style: none; margin: 0 0 1rem; }
ul.ticks li { position: relative; padding-left: 1.6rem; margin-bottom: 0.6rem; }
ul.ticks li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.62em;
  width: 0.5rem; height: 0.5rem;
  background: var(--brand);
  border-radius: 2px;
}

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
}
.card p:last-child { margin-bottom: 0; }
.cards-wide { grid-template-columns: repeat(auto-fit, minmax(21rem, 1fr)); }
.card-points { margin: 0.75rem 0 0; padding-left: 1.1rem; color: var(--ink-soft); }
.card-points li { margin-bottom: 0.3rem; }

/* Anchor targets must clear the sticky header when jumped to. */
.band[id], .hero[id] { scroll-margin-top: 5rem; }

.steps { counter-reset: s; list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.steps > li {
  counter-increment: s;
  position: relative;
  padding-left: 3rem;
}
.steps > li::before {
  content: counter(s);
  position: absolute; left: 0; top: 0;
  width: 2.1rem; height: 2.1rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--brand); color: #fff;
  font-weight: 700;
}
@media (prefers-color-scheme: dark) { .steps > li::before { color: #10211b; } }
.steps p:last-child { margin-bottom: 0; }

.facts { margin: 0; display: grid; gap: 0.85rem;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.fact {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}
.fact dt { font-weight: 700; margin-bottom: 0.15rem; }
.fact dd { margin: 0; color: var(--ink-soft); }

.pull {
  margin: 0;
  border-left: 4px solid var(--brand);
  padding: 0.25rem 0 0.25rem 1.1rem;
  max-width: 44rem;
}
.pull p { font: 500 1.15rem/1.5 var(--serif); }
.pull footer { color: var(--ink-soft); font-size: 0.9rem; }

.cta-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  max-width: 46rem;
}

/* --- question and answer ------------------------------------------------ */

.qa { max-width: 46rem; display: grid; gap: 1.4rem; }
.qa-item h3 { font-size: 1.05rem; margin-bottom: 0.3rem; }
.qa-item p { margin: 0 0 0.5rem; color: var(--ink-soft); }
.qa-item p:last-child { margin-bottom: 0; }

.note {
  max-width: 46rem;
  background: var(--surface-2);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin: 1.25rem 0 0;
  color: var(--ink-soft);
}

/* --- role groups -------------------------------------------------------- */

.groups {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
}
.group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
}
.group h3 { font: 600 1.3rem/1.25 var(--serif); margin-bottom: 0.25rem; }
.group-lead { color: var(--ink-soft); margin-bottom: 1.1rem; }
.group-items { margin: 0; display: grid; gap: 0.9rem; }
.group-item dt { font-weight: 700; margin-bottom: 0.15rem; }
.group-item dd { margin: 0; color: var(--ink-soft); }

/* --- forms -------------------------------------------------------------- */

fieldset.checks { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1.1rem 1rem; }
fieldset.checks legend { font-weight: 600; padding: 0 0.35rem; }
.check-grid {
  display: grid;
  gap: 0.5rem 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
}
.check { display: flex; align-items: flex-start; gap: 0.55rem; }
.check input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0.15rem 0 0;
  flex: none;
  accent-color: var(--brand);
}
/* Must out-rank `.field label`, which is equally specific and declared later. */
.checks .check label { font-weight: 400; margin: 0; }

.form fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem 0.4rem;
  margin: 0 0 1.25rem;
  background: var(--surface);
}
.form legend { font-weight: 700; padding: 0 0.4rem; }

.field { margin-bottom: 1.1rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.field .optional { font-weight: 400; color: var(--ink-soft); }
.field .help { font-size: 0.86rem; color: var(--ink-soft); margin: 0 0 0.4rem; }

input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
}
textarea { resize: vertical; }

.field.has-error input,
.field.has-error select,
.field.has-error textarea { border-color: var(--danger); border-width: 2px; }

.field .error { color: var(--danger); font-weight: 600; font-size: 0.9rem; margin: 0.35rem 0 0; }

.summary {
  border: 2px solid var(--danger);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
}
.summary h2 { font-size: 1.1rem; color: var(--danger); margin-bottom: 0.5rem; }
.summary ul { margin: 0; padding-left: 1.2rem; }
.summary a { color: var(--danger); }

/* --- chat --------------------------------------------------------------- */

.chat { padding: clamp(1.5rem, 4vw, 2.5rem) 0 3rem; }
.chat-head h1 { font-size: clamp(1.5rem, 3vw, 2.1rem); }

.transcript {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  /* A real scroll container, so wheel, PageUp/PageDown, Home/End and arrow
     keys all work once it has focus. Never a fixed height with hidden overflow. */
  max-height: min(58vh, 40rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.turn { margin: 0 0 1.4rem; }
.turn:last-child { margin-bottom: 0; }

.turn-who {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-soft);
  margin: 0 0 0.3rem;
}

.turn-body p { margin: 0 0 0.7rem; }
.turn-body p:last-child, .turn-body ul:last-child { margin-bottom: 0; }
.turn-body ul { margin: 0 0 0.7rem; padding-left: 1.2rem; }
.turn-body li { margin-bottom: 0.4rem; }

.turn-member .turn-body {
  background: var(--brand-tint);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
}

.turn.pending .turn-body { color: var(--ink-soft); font-style: italic; }

.status { min-height: 1.4rem; margin: 0.5rem 0 0; font-size: 0.88rem; color: var(--ink-soft); }

.suggestions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.25rem 0 1rem; }
.chip {
  font: inherit;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
}
.chip:hover { background: var(--surface-2); border-color: var(--brand); }

.composer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 0.9rem;
}
.composer textarea {
  border: 0;
  background: transparent;
  padding: 0.2rem 0.1rem;
  resize: none;
  /* Grown by ui.js up to ~40% of the viewport, then scrolls internally. */
  max-height: 40vh;
  overflow-y: auto;
}
.composer textarea:focus-visible { outline-offset: 4px; }

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  margin-top: 0.5rem;
  padding-top: 0.6rem;
}
.hint { margin: 0; font-size: 0.82rem; color: var(--ink-soft); }

/* --- dialog ------------------------------------------------------------- */

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 11, 0.55);
  display: grid;
  place-items: center;
  padding: 1.25rem;
  z-index: 50;
}
.dialog-backdrop[hidden] { display: none; }

.dialog {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  width: min(34rem, 100%);
  max-height: 85vh;
  overflow-y: auto;
}
.dialog h2 { font-size: 1.3rem; }

.shortcuts { margin: 0 0 1.2rem; display: grid; gap: 0.5rem; }
.shortcut { display: grid; grid-template-columns: minmax(8rem, auto) 1fr; gap: 0.75rem; align-items: baseline; }
.shortcut dt { text-align: right; }
.shortcut dd { margin: 0; color: var(--ink-soft); }

@media (max-width: 30rem) {
  .shortcut { grid-template-columns: 1fr; gap: 0.1rem; }
  .shortcut dt { text-align: left; }
}

/* --- the Nirmund stack strip -------------------------------------------- */

.stack-strip {
  background: #16191b;
  color: #d9d6cf;
  padding: 1.4rem 0;
  font-size: 0.875rem;
  line-height: 1.45;
  margin-top: 2rem;
}
.stack-strip .ss-title {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.stack-strip .ss-title a { color: #e4c878; text-decoration: none; }
.stack-strip .ss-title a:hover { text-decoration: underline; }
.stack-strip ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}
.stack-strip li {
  border-top: 2px solid #3b4044;
  padding-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.stack-strip li.here { border-top-color: #e4c878; }
.stack-strip .lyr {
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #9a968f;
  margin-bottom: 0.15rem;
}
.stack-strip a { color: #f2efe8; text-decoration: none; }
.stack-strip a:hover { text-decoration: underline; }
.stack-strip a[aria-current] { color: #e4c878; font-weight: 700; }
.stack-strip :focus-visible { outline-color: #e4c878; }

@media (max-width: 44rem) {
  .stack-strip ol { grid-template-columns: repeat(2, 1fr); row-gap: 1rem; }
}

/* --- footer ------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 2rem 0;
  margin-top: 0;
}
.site-footer p { margin: 0 0 0.6rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 0.6rem; }
.site-footer a { color: var(--ink-soft); }

.footer-cols {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  margin-bottom: 1.25rem;
}
/* `.site-footer nav` is the more specific selector, so the column needs to
   out-rank it or the heading sits beside its links instead of above them. */
.site-footer nav.footer-col { display: block; gap: 0; margin-bottom: 0; }
.footer-col h2 {
  font: 700 0.75rem/1.4 var(--font);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 0.5rem;
}
.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin-bottom: 0.35rem; }

.site-footer .supported {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.1rem 0;
  font-weight: 600;
  color: var(--ink);
}
.site-footer .supported img {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
  width: 64px;
  height: auto;
  flex: none;
}
.site-footer .legal { color: var(--ink-soft); margin-top: 0.75rem; }

.brand-logo { height: 2.5rem; width: auto; display: block; }
@media (prefers-color-scheme: dark) {
  /* The supplied mark is dark-on-transparent, so give it a light plate. */
  .brand-logo { background: #fff; border-radius: 6px; padding: 3px 5px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
