/* ==========================================================================
   Home, section 7: MLS auto-updates (partials/home-mls.html, js/home-mls.js)
   One change on the MLS flows MLS -> listing -> pipeline -> team, then the
   steps a sale asks for by hand vs. what happens on its own.
   Uses site.css tokens only. Every class here starts with .mls-.
   ========================================================================== */

.mls-sec { isolation: isolate; }
/* a soft lamplight behind the relay */
.mls-sec::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 30% 0 auto;
  height: 60%;
  background: radial-gradient(50% 50% at 50% 40%, rgba(240, 180, 106, .09), transparent 70%);
  pointer-events: none;
}

/* approved-vendor line: small glass pill under the lede */
.mls-vendor {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 26px;
  padding: 8px 16px 8px 12px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--pill);
  background: linear-gradient(180deg, rgba(255, 255, 255, .1), rgba(255, 255, 255, .035));
  -webkit-backdrop-filter: var(--lg-blur);
  backdrop-filter: var(--lg-blur);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 14px 34px -18px rgba(0, 0, 0, .75);
  font-size: .8rem;
  font-weight: 500;
  letter-spacing: .02em;
  color: var(--text);
}
.mls-vendor .icon { width: 16px; height: 16px; color: var(--amber-2); }

/* ---------- large glass panels (same recipe as site.css's liquid glass) ---------- */
.mls-relay, .mls-ledger {
  position: relative;
  padding: clamp(20px, 3vw, 36px);
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: var(--radius-lg);
  background: var(--lg-fill);
  -webkit-backdrop-filter: var(--lg-blur);
  backdrop-filter: var(--lg-blur);
  box-shadow: var(--lg-shadow);
}
.mls-relay::before, .mls-ledger::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  padding: 1px;
  border-radius: inherit;
  background: var(--lg-rim);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.mls-ledger { margin-top: clamp(20px, 2.6vw, 28px); }

/* ---------- relay head: title + change picker ---------- */
.mls-relay-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 20px;
  margin-bottom: clamp(22px, 3vw, 34px);
}
.mls-relay-title { flex: 1 1 auto; }
.mls-relay-title b { display: block; font-weight: 600; letter-spacing: -0.01em; }
.mls-relay-title span { display: block; margin-top: 2px; font-size: .8rem; color: var(--text-2); }

.mls-events { display: flex; flex-wrap: wrap; gap: 8px; }
.mls-event, .mls-pause {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: var(--pill);
  background: rgba(255, 255, 255, .05);
  color: var(--text-2);
  font-size: .82rem;
  font-weight: 500;
  transition: color .3s var(--ease), background-color .3s var(--ease), border-color .3s var(--ease), transform .3s var(--ease);
}
.mls-event:hover, .mls-pause:hover { color: var(--text); border-color: rgba(255, 255, 255, .3); transform: translateY(-1px); }
.mls-event:active, .mls-pause:active { transform: translateY(0) scale(.98); }
.mls-event[aria-pressed="true"] {
  color: var(--amber-2);
  border-color: rgba(240, 180, 106, .42);
  background: rgba(240, 180, 106, .13);
  box-shadow: 0 0 22px -8px rgba(240, 180, 106, .6);
}
.mls-pause { padding: 0 14px; border-style: dashed; margin-left: -12px; }
.mls-pause[hidden] { display: none; }

/* ---------- the track: four stations joined by links ---------- */
.mls-track {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.mls-station { position: relative; display: flex; flex-direction: column; align-items: center; }
.mls-station--2 { --d: .55s; }
.mls-station--3 { --d: 1.1s; }
.mls-station--4 { --d: 1.65s; }

.mls-node {
  position: relative;
  z-index: 2;
  width: 48px; height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(240, 180, 106, .38);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, rgba(240, 180, 106, .28), rgba(20, 27, 46, .95) 70%);
  color: var(--amber-2);
  box-shadow: 0 0 0 6px rgba(6, 9, 17, .55), 0 10px 24px -10px rgba(0, 0, 0, .8);
}
.mls-node .icon { width: 20px; height: 20px; }

/* link from this node's centre to the next node's centre */
.mls-link {
  position: absolute;
  z-index: 1;
  top: 23px;
  left: 50%;
  width: calc(100% + 16px);
  height: 2px;
  border-radius: var(--pill);
  background: rgba(255, 255, 255, .12);
  overflow: hidden;
}
.mls-link i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 45%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(240, 180, 106, 0), var(--amber) 70%, var(--amber-2));
  transform: translateX(-110%);
}

.mls-card {
  width: 100%;
  flex: 1;
  margin-top: 16px;
  padding: 16px 18px 18px;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(20, 27, 46, .72), rgba(10, 14, 26, .78));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07);
}
.mls-where {
  font-size: .64rem;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-3);
}
.mls-what { margin-top: 8px; font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.mls-detail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin-top: 6px;
  font-size: .84rem;
  line-height: 1.45;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* only the chosen change's text shows (no JS: the sale) */
.mls-say { display: none; }
.mls-relay[data-event="price"] .mls-say[data-ev="price"],
.mls-relay[data-event="pending"] .mls-say[data-ev="pending"],
.mls-relay[data-event="sold"] .mls-say[data-ev="sold"] { display: block; }

/* deal stage bar: coming soon, active, escrow, closed */
.mls-stages { display: flex; gap: 3px; margin-top: 14px; }
.mls-stages i { flex: 1; height: 4px; border-radius: var(--pill); background: rgba(255, 255, 255, .12); transition: background-color .5s var(--ease), box-shadow .5s var(--ease); }
.mls-relay[data-event="price"] .mls-stages i:nth-child(-n+2),
.mls-relay[data-event="pending"] .mls-stages i:nth-child(-n+3),
.mls-relay[data-event="sold"] .mls-stages i {
  background: var(--amber);
  box-shadow: 0 0 10px rgba(240, 180, 106, .5);
}

/* the run: each station lights in turn and a spark travels the link to the next */
@media (prefers-reduced-motion: no-preference) {
  .mls-relay.is-armed:not(.is-run) :is(.mls-card) { opacity: .3; filter: saturate(0); }
  .mls-relay.is-run .mls-card { animation: mls-light .7s var(--ease-out) both; animation-delay: var(--d, 0s); }
  .mls-relay.is-run .mls-node { animation: mls-glow 1.1s var(--ease-out) both; animation-delay: var(--d, 0s); }
  .mls-relay.is-run .mls-link i { animation: mls-spark .55s var(--ease) both; animation-delay: calc(var(--d, 0s) + .1s); }
  .mls-relay.is-run .mls-stages i { transition-delay: 1.3s; }
}
@keyframes mls-light {
  from { opacity: .3; transform: translateY(8px); filter: saturate(0); }
  to   { opacity: 1; transform: none; filter: none; }
}
@keyframes mls-glow {
  0%   { box-shadow: 0 0 0 6px rgba(6, 9, 17, .55), 0 10px 24px -10px rgba(0, 0, 0, .8); }
  35%  { box-shadow: 0 0 0 6px rgba(240, 180, 106, .22), 0 0 30px 2px rgba(240, 180, 106, .55); }
  100% { box-shadow: 0 0 0 6px rgba(6, 9, 17, .55), 0 10px 24px -10px rgba(0, 0, 0, .8); }
}
@keyframes mls-spark {
  from { transform: translateX(-110%); }
  to   { transform: translateX(240%); }
}
@keyframes mls-spark-down {
  from { transform: translateY(-110%); }
  to   { transform: translateY(240%); }
}

/* tablets and phones: the track runs down the left */
@media (max-width: 899px) {
  .mls-track { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .mls-station { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 14px; align-items: start; }
  .mls-card { margin-top: 0; }
  .mls-link { top: 24px; left: 23px; width: 2px; height: calc(100% + 14px); }
  .mls-link i {
    inset: 0 0 auto 0;
    width: auto;
    height: 45%;
    background: linear-gradient(180deg, rgba(240, 180, 106, 0), var(--amber) 70%, var(--amber-2));
    transform: translateY(-110%);
  }
}
@media (max-width: 899px) and (prefers-reduced-motion: no-preference) {
  .mls-relay.is-run .mls-link i { animation-name: mls-spark-down; }
}

/* ---------- ledger: steps that disappear ---------- */
.mls-ledger-head { max-width: 640px; }
.mls-ledger-head .muted { margin-top: 12px; font-size: .95rem; }

.mls-table { margin-top: clamp(22px, 3vw, 32px); }
.mls-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 170px;
  align-items: center;
  gap: 8px 20px;
  padding: 13px 4px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}
.mls-row--head {
  padding-block: 0 12px;
  border-top: 0;
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text-3);
}
.mls-row--head span:last-child { color: var(--amber-2); }
.mls-step { color: var(--text); font-size: .95rem; line-height: 1.45; }
.mls-hand, .mls-auto {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 12px;
  border-radius: var(--pill);
  font-size: .78rem;
  font-weight: 500;
  white-space: nowrap;
}
.mls-hand {
  border: 1px dashed rgba(255, 255, 255, .2);
  color: var(--text-3);
  text-decoration: line-through;
  text-decoration-color: rgba(243, 241, 236, .35);
}
.mls-auto {
  border: 1px solid rgba(240, 180, 106, .34);
  background: rgba(240, 180, 106, .11);
  color: var(--amber-2);
}
.mls-auto .icon { width: 14px; height: 14px; }

/* on reveal (site.js), the hand-work strikes out and the automatic tags light, row by row */
.mls-hand { transition: text-decoration-color .6s var(--ease-out), opacity .6s var(--ease-out); }
.mls-auto { transition: opacity .55s var(--ease-out), transform .55s var(--ease-out); }
.mls-ledger.reveal-pending .mls-hand { text-decoration-color: transparent; opacity: 1; }
.mls-ledger.reveal-pending .mls-auto { opacity: 0; transform: translateX(-8px) scale(.96); }
.mls-row:nth-child(2) > * { transition-delay: .45s; }
.mls-row:nth-child(3) > * { transition-delay: .55s; }
.mls-row:nth-child(4) > * { transition-delay: .65s; }
.mls-row:nth-child(5) > * { transition-delay: .75s; }
.mls-row:nth-child(6) > * { transition-delay: .85s; }
.mls-row:nth-child(7) > * { transition-delay: .95s; }
.mls-row:nth-child(8) > * { transition-delay: 1.05s; }
.mls-row:nth-child(9) > * { transition-delay: 1.15s; }

.mls-left {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  padding: 14px 16px;
  border: 1px solid var(--glass-line);
  border-radius: 14px;
  background: var(--glass);
  font-size: .9rem;
  color: var(--text-2);
}
.mls-left .icon { width: 18px; height: 18px; margin-top: 2px; color: var(--ice); }
.mls-left b { color: var(--text); font-weight: 600; }

@media (max-width: 639px) {
  .mls-row--head { display: none; }
  .mls-row { grid-template-columns: 112px minmax(0, 1fr); gap: 10px; padding: 14px 0; }
  .mls-row:nth-child(2) { border-top: 0; }
  .mls-step { grid-column: 1 / -1; }
  .mls-relay-title { flex: 1 1 0; }
  .mls-pause { margin-left: 0; }
  .mls-events { order: 3; width: 100%; gap: 6px; }
  .mls-event { flex: 1 1 auto; padding: 0 10px; }
}
