/* /metered-ai/ — the page's own rules (prefix mx-).
   The hero is a [data-sequence] story: credit topped up, drawn down by meter events, refilled by
   auto top-up when it crosses the threshold, then spent by an agent over HTTP 402. Its words are
   the API's (modules/credits: credits.topped_up, credits.low_balance; packages/http402: accepts,
   Tuppence-Credits) and the dashboard's (Credits: "Credit left"). */

/* ---------- Hero stage ---------- */
.mx-hero {
  padding-bottom: 128px;
}
.mx-hero__grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.mx-stage {
  position: relative;
  margin: 0;
  padding: 0 0 0 12%;
}

/* The customer's credit, as the business sees it */
.mx-credit {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 22px 18px;
  border-radius: var(--radius-panel);
  background: var(--surface-card);
  color: var(--ink-900);
  box-shadow:
    0 50px 100px -30px rgba(5, 8, 20, 0.7),
    0 0 0 1px rgba(255, 255, 255, 0.1);
  text-align: left;
}
.mx-credit__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.mx-credit__who {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.mx-credit__who > span:last-child {
  display: flex;
  flex-direction: column;
}
.mx-credit__who small {
  font-size: var(--fs-caption);
  color: var(--ink-500);
}
.mx-credit__who b {
  font-size: var(--fs-label);
}
.mx-credit__logo {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--lilac-600);
  color: #fff;
  font-weight: 700;
}
.mx-credit__auto {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: var(--mint-50);
  color: var(--mint-800);
  font-size: var(--fs-caption);
  font-weight: 600;
  white-space: nowrap;
}
.mx-credit__auto .icon {
  width: 14px;
  height: 14px;
}
.mx-credit__balance {
  display: flex;
  flex-direction: column;
}
.mx-credit__balance small {
  font-size: var(--fs-caption);
  color: var(--ink-500);
}
.mx-credit__amount {
  font-size: 44px;
  line-height: 1.1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  transition: color 0.4s ease;
}
.mx-stage[data-step="4"] .mx-credit__amount {
  color: #d9541e;
}
.mx-credit__rule {
  font-size: var(--fs-caption);
  color: var(--ink-500);
}

/* The gauge: the balance out of £60, with the auto top-up threshold marked at £10. */
.mx-gauge {
  position: relative;
  height: 10px;
  margin-top: 4px;
  border-radius: 99px;
  background: var(--ink-100);
}
.mx-gauge__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 98%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint-500), var(--tp-blue));
  transition:
    width 0.9s cubic-bezier(0.2, 0.7, 0.2, 1),
    background 0.4s ease;
}
.mx-stage[data-step="1"] .mx-gauge__fill {
  width: 83%;
}
.mx-stage[data-step="2"] .mx-gauge__fill {
  width: 47.5%;
}
.mx-stage[data-step="3"] .mx-gauge__fill {
  width: 17.5%;
}
.mx-stage[data-step="4"] .mx-gauge__fill {
  width: 15.8%;
  background: linear-gradient(90deg, #ff8a5b, #ff6a3d);
}
.mx-stage[data-step="5"] .mx-gauge__fill {
  width: 99.2%;
}
.mx-gauge__mark {
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: 16.7%;
  width: 2px;
  border-radius: 2px;
  background: var(--ink-900);
}
.mx-gauge__mark small {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-600);
  white-space: nowrap;
}
.mx-credit__rule {
  margin-top: 12px;
}

/* The events, as they happen */
.mx-feed {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--ink-100);
  padding-top: 6px;
}
.mx-ev {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-radius: 10px;
}
[data-sequence][data-step] .mx-ev[data-seq-from]:not(.is-on) {
  transform: translateY(-6px);
}
.mx-ev > i {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--blue-50);
  color: var(--blue-600);
}
.mx-ev .icon {
  width: 16px;
  height: 16px;
}
.mx-ev > span {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.mx-ev b {
  font-size: 13px;
  font-weight: 600;
}
.mx-ev small {
  font-size: 11.5px;
  color: var(--ink-500);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mx-ev em {
  font-style: normal;
  font-weight: 600;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-700);
}
.mx-ev--mint > i {
  background: var(--mint-50);
  color: var(--mint-700);
}
.mx-ev--mint em {
  color: var(--mint-700);
}
.mx-ev--sunrise {
  background: #fff4ee;
}
.mx-ev--sunrise > i {
  background: #ffe3d6;
  color: #c24f1f;
}
.mx-ev--auto.is-on {
  animation: mx-flash 1.6s ease-out;
}
@keyframes mx-flash {
  0%,
  40% {
    background: var(--mint-50);
  }
}
.mx-ev--lilac > i {
  background: var(--tp-lilac);
  color: var(--lilac-700);
}

/* The agent's side: a terminal over the card's corner */
.mx-term {
  position: relative;
  z-index: 2;
  width: 72%;
  margin: -12px 0 0 -13.6%;
  border-radius: var(--radius-lg);
  background: var(--ink-900);
  color: var(--ink-200);
  overflow: hidden;
  box-shadow:
    0 40px 80px -24px rgba(5, 8, 20, 0.8),
    0 0 0 1px rgba(255, 255, 255, 0.1);
  text-align: left;
}
[data-sequence][data-step] .mx-term:not(.is-on) {
  transform: translateY(16px);
}
.mx-term .terminal__bar {
  padding: 10px 12px;
}
.mx-term .terminal__bar span {
  width: 9px;
  height: 9px;
}
.mx-term__body {
  display: flex;
  flex-direction: column;
  padding: 12px 16px 14px;
  font: 12.5px / 1.65 var(--font-mono);
}
.mx-term__line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mx-term.is-on .mx-term__line {
  animation: mx-line 0.35s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i) * 0.55s + 0.2s);
}
@keyframes mx-line {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }
}
.mx-term__line--dim {
  color: var(--ink-400);
}
.mx-term__me {
  color: var(--blue-300);
}
.mx-term__them {
  color: var(--ink-400);
}
.mx-term__402 {
  color: var(--sunrise-300);
}
.mx-term__ok {
  color: var(--mint-300);
}
.mx-stage__toggle {
  position: absolute;
  right: 0;
  bottom: 2%;
}

/* ---------- Prepaid credit: the hosted top-up page and the auto top-up rule ---------- */
.mx-spec {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px 32px;
  margin-top: 32px;
}
.mx-spec > div > .icon {
  width: 40px;
  height: 40px;
  padding: 10px;
  border-radius: 12px;
  background: var(--mint-50);
  color: var(--mint-700);
}
.mx-spec h3 {
  margin-top: 12px;
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--ink-900);
}
.mx-spec p {
  margin-top: 6px;
  font-size: var(--fs-label);
  line-height: 1.6;
  color: var(--text-secondary);
  text-wrap: pretty;
}
.mx-topstage {
  min-height: 560px;
  padding: 48px 32px;
}
.mx-phone {
  width: 250px;
  padding: 11px;
  flex: none;
}
.mx-topup {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75em;
  padding: 0 1.1em;
  font-size: calc(100cqw / 18);
  line-height: 1.3;
  color: var(--tp-midnight);
  text-align: left;
  background: var(--tp-cloud);
}
.mx-topup__status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.9em;
  font-size: 0.8em;
  font-weight: 600;
}
.mx-topup__island {
  width: 4.4em;
  height: 1.3em;
  border-radius: 1em;
  background: var(--tp-midnight);
}
.mx-topup__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  margin-top: 0.6em;
  font-weight: 700;
}
.mx-topup__logo {
  display: grid;
  place-items: center;
  width: 1.8em;
  height: 1.8em;
  border-radius: 0.5em;
  background: var(--tp-midnight);
  color: var(--mint-300);
}
.mx-topup__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1em;
  border-radius: 1em;
  background: #fff;
  border: 1px solid var(--ink-100);
}
.mx-topup__card small {
  font-size: 0.8em;
  color: var(--ink-500);
}
.mx-topup__card b {
  font-size: 1.7em;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.mx-topup__h {
  margin-top: 0.4em;
  font-weight: 600;
}
.mx-topup__presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45em;
}
.mx-topup__presets span {
  padding: 0.75em 0;
  border-radius: 0.7em;
  background: #fff;
  border: 1px solid var(--ink-200);
  text-align: center;
  font-weight: 600;
  font-size: 0.9em;
}
.mx-topup__presets .is-on {
  border-color: var(--tp-blue);
  box-shadow: 0 0 0 1px var(--tp-blue) inset;
  color: var(--tp-blue);
}
.mx-topup__label {
  font-size: 0.8em;
  color: var(--ink-500);
}
.mx-topup__row {
  display: flex;
  gap: 0.4em;
  margin-top: -0.4em;
}
.mx-topup__input {
  flex: 1;
  height: 2.4em;
  border-radius: 0.6em;
  background: #fff;
  border: 1px solid var(--ink-200);
}
.mx-topup__go {
  padding: 0 1em;
  line-height: 2.4em;
  border-radius: 0.6em;
  background: var(--tp-blue);
  color: #fff;
  font-weight: 600;
  font-size: 0.9em;
}
.mx-topup__foot {
  margin-top: auto;
  padding-bottom: 2.2em;
  font-size: 0.72em;
  text-align: center;
  color: var(--ink-500);
}
.mx-auto {
  position: absolute;
  z-index: 2;
  right: 24px;
  bottom: 36px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 230px;
  padding: 16px 18px;
  border-radius: var(--radius-card);
  background: var(--ink-900);
  color: var(--ink-200);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
}
.mx-auto__title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-weight: 600;
}
.mx-auto__title .icon {
  width: 16px;
  height: 16px;
  color: var(--mint-300);
}
.mx-auto__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.mx-auto__row b {
  color: #fff;
  font-variant-numeric: tabular-nums;
}

/* ---------- HTTP 402 facts ---------- */
.mx-402facts .feature p {
  text-wrap: pretty;
}

/* ---------- MCP: the server and its tools ---------- */
.mx-mcp {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.4fr);
  gap: 40px;
  padding: 36px;
  border-radius: var(--radius-panel);
  border: 1px solid var(--ink-100);
  background: var(--surface-card);
}
.mx-mcp__intro {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}
.mx-mcp__intro p {
  color: var(--text-secondary);
  text-wrap: pretty;
}
.mx-mcp__intro .install__cmd {
  width: 100%;
}
.mx-tools {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.mx-tools__group {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
}
.mx-tools__name {
  font-size: var(--fs-label);
  font-weight: 600;
  color: var(--ink-900);
}
.mx-tools__name small {
  margin-left: 4px;
  font-size: var(--fs-caption);
  font-weight: 500;
  color: var(--ink-400);
}
.mx-tools__list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.mx-tools__list code {
  padding: 3px 8px;
  border-radius: 7px;
  font-size: 12px;
  background: var(--blue-50);
  color: var(--blue-700);
}
.mx-tools__group--mint code {
  background: var(--mint-50);
  color: var(--mint-800);
}
.mx-tools__group--lilac code {
  background: var(--lilac-50);
  color: var(--lilac-700);
}
.mx-tools__group--sunrise code {
  background: #fff1ea;
  color: #a8431a;
}
.mx-agents__code {
  margin-top: 4px;
}
.mx-agents__code pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
}

/* ---------- Pricing: one fee, when credit is bought ---------- */
.mx-bill {
  display: flex;
  flex-direction: column;
  padding: 12px 28px;
  border-radius: var(--radius-panel);
  background: var(--surface-card);
  border: 1px solid var(--ink-100);
  box-shadow: var(--shadow-md);
}
.mx-bill__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
  border-top: 1px dashed var(--ink-200);
}
.mx-bill__row:first-child {
  border-top: 0;
}
.mx-bill__row > span {
  display: flex;
  flex-direction: column;
}
.mx-bill__row b {
  color: var(--ink-900);
}
.mx-bill__row > b {
  font-size: 22px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.mx-bill__row small {
  font-size: var(--fs-label);
  color: var(--text-secondary);
}
.mx-bill__row--fee > b {
  color: var(--tp-blue);
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .mx-hero__grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .mx-stage {
    max-width: 620px;
    margin: 0 auto;
  }
  .mx-mcp {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 640px) {
  .mx-stage {
    padding: 0 0 0 6%;
  }
  .mx-credit {
    padding: 18px 16px 14px;
  }
  .mx-credit__amount {
    font-size: 36px;
  }
  .mx-credit__auto {
    display: none;
  }
  .mx-term {
    width: 92%;
    margin-left: -6.4%;
  }
  .mx-term__body {
    font-size: 11px;
  }
  .mx-spec {
    grid-template-columns: minmax(0, 1fr);
  }
  .mx-topstage {
    flex-direction: column;
    min-height: 0;
    padding: 32px 16px;
  }
  .mx-auto {
    position: relative;
    right: auto;
    bottom: auto;
    width: 100%;
    margin-top: -60px;
  }
  .mx-mcp {
    padding: 24px 18px;
  }
  .mx-tools__group {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }
  .mx-bill {
    padding: 8px 20px;
  }
}
