/* Market Time Machine (/tools/market-time-machine). Loaded after report.css; uses its tokens. */

.tm { --tm-max: var(--grid-max, 1280px); }
.tm-wrap { max-width: var(--tm-max); margin: 0 auto; padding: 0 var(--page-pad, 24px); }
.tm-label { font: var(--label); text-transform: uppercase; letter-spacing: 0.12em; }
.tm-figure { font-family: var(--font-body); font-weight: 300; font-size: clamp(1.75rem, 3vw, 2.75rem); line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tm-ledger { font-family: var(--font-ledger); font-variant-numeric: tabular-nums; }

/* Cover */
.tm-cover { background: var(--ink); color: var(--bond); padding: 64px 0 56px; }
.tm-cover .tm-label { color: var(--foil); }
.tm-cover h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(2.25rem, 5.5vw, 4.5rem); line-height: 1.02; letter-spacing: -0.01em; margin: 16px 0 12px; max-width: 18ch; }
.tm-cover h1::after { content: ""; display: block; width: 72px; height: 1px; background: var(--foil); margin-top: 20px; }
.tm-lede { max-width: 60ch; color: var(--slate-wash); font-size: 1.05rem; margin: 0 0 32px; }

.tm-controls { display: flex; flex-wrap: wrap; gap: 24px 40px; align-items: flex-end; margin-bottom: 40px; }
.tm-control { display: flex; flex-direction: column; gap: 8px; }
.tm-control > .tm-label { color: var(--slate); }
.tm-seg { display: inline-flex; border: 1px solid var(--slate); }
.tm-seg button { appearance: none; background: transparent; color: var(--bond); border: 0; border-right: 1px solid var(--slate); font: var(--label); text-transform: uppercase; letter-spacing: 0.12em; padding: 14px 18px; min-height: 44px; cursor: pointer; }
.tm-seg button:last-child { border-right: 0; }
.tm-seg button[aria-pressed="true"] { background: var(--foil); color: var(--ink-deep); }
.tm-seg button:focus-visible { outline: 2px solid var(--foil); outline-offset: 2px; }

.tm-dial { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--slate); border-bottom: 1px solid var(--slate); }
.tm-dial-item { padding: 24px 20px 22px 0; border-right: 1px solid rgba(169, 184, 203, 0.35); }
.tm-dial-item:last-child { border-right: 0; }
.tm-dial-item + .tm-dial-item { padding-left: 20px; }
.tm-dial-item .tm-figure { color: var(--bond); transition: opacity 0.25s ease; }
.tm-dial-item .tm-label { color: var(--slate); display: block; margin-top: 10px; }
.tm-dial-item .tm-was { display: block; margin-top: 6px; font-size: 0.85rem; color: var(--slate); min-height: 1.2em; }
.tm-dial.is-swapping .tm-figure { opacity: 0.15; }
.tm-dial-when { margin: 14px 0 0; font-size: 0.85rem; color: var(--slate); }

/* Sections */
.tm-section { padding: 64px 0; border-bottom: 1px solid var(--rule-light); }
.tm-section h2 { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.5rem, 2.4vw, 2rem); line-height: 1.15; margin: 10px 0 12px; }
.tm-section .tm-kicker { color: var(--stamp); }
.tm-section-intro { max-width: 64ch; color: var(--muted); margin: 0 0 32px; }

/* Then / now ledger */
.tm-table { width: 100%; border-collapse: collapse; }
.tm-table th, .tm-table td { text-align: left; padding: 14px 12px 14px 0; border-bottom: 1px solid var(--rule-light); vertical-align: baseline; }
.tm-table thead th { font: var(--label); text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); border-bottom: 1px solid var(--rule); }
.tm-table td.num, .tm-table th.num { text-align: right; padding-right: 20px; }
.tm-table td.num { font-family: var(--font-ledger); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tm-table tbody tr:nth-child(even) { background: var(--bond-tint); }
.tm-table .tm-measure { font-weight: 600; }
.tm-table .tm-measure small { display: block; font-weight: 400; color: var(--muted); font-size: 0.82rem; margin-top: 2px; }
.tm-stamp { display: inline-block; font: var(--label); text-transform: uppercase; letter-spacing: 0.12em; border: 1.5px solid currentColor; border-radius: 2px; padding: 3px 8px; white-space: nowrap; }
.tm-stamp.is-buyers { color: var(--stamp); }
.tm-stamp.is-sellers { color: var(--muted); }
.tm-stamp.is-even { color: var(--muted); border-style: dashed; }

/* Chart */
.tm-chart { width: 100%; height: auto; display: block; }
.tm-chart text { font-family: var(--font-body); font-size: 11px; fill: var(--muted); }
.tm-chart .bar { fill: var(--slate); }
.tm-chart .bar.is-mark { fill: var(--ink); }
.tm-chart .line { fill: none; stroke: var(--stamp); stroke-width: 2; }
.tm-chart .now-dot { fill: var(--stamp); }
.tm-chart text.now-label { fill: var(--stamp); font-weight: 600; font-size: 13px; stroke: var(--bond); stroke-width: 4px; paint-order: stroke; }
.tm-chart .grid { stroke: var(--rule-light); stroke-width: 1; }
.tm-legend { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 12px; font-size: 0.85rem; color: var(--muted); }
.tm-legend i { display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px; }
.tm-legend .k-bar { background: var(--slate); }
.tm-legend .k-mark { background: var(--ink); }
.tm-legend .k-line { height: 2px; vertical-align: 3px; background: var(--stamp); }

/* Lean meter */
.tm-meter { position: relative; margin: 48px 0 16px; }
.tm-meter-track { display: grid; grid-template-columns: 4fr 2fr 2fr; height: 14px; }
.tm-meter-track span:nth-child(1) { background: var(--slate-wash); }
.tm-meter-track span:nth-child(2) { background: var(--slate); }
.tm-meter-track span:nth-child(3) { background: var(--ink); }
.tm-meter-zones { display: grid; grid-template-columns: 4fr 2fr 2fr; margin-top: 10px; }
.tm-meter-zones span { font: var(--label); text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.tm-meter-pin { position: absolute; top: -40px; transform: translateX(-50%); text-align: center; white-space: nowrap; }
.tm-meter-pin b { display: block; font: var(--label); text-transform: uppercase; letter-spacing: 0.12em; }
.tm-meter-pin em { font-style: normal; font-family: var(--font-ledger); font-size: 0.9rem; }
.tm-meter-pin::after { content: ""; display: block; width: 2px; height: 22px; margin: 2px auto 0; background: currentColor; }
.tm-meter-pin.is-then { color: var(--muted); }
.tm-meter-pin.is-now { color: var(--stamp); }
.tm-verdict { font-family: var(--font-display); font-size: clamp(1.25rem, 2vw, 1.6rem); line-height: 1.3; max-width: 46ch; margin: 32px 0 0; }

/* Buyer moves */
.tm-moves { list-style: none; margin: 0; padding: 0; counter-reset: move; display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 48px; }
.tm-moves li { counter-increment: move; border-top: 1px solid var(--rule); padding: 20px 0 24px 48px; position: relative; }
.tm-moves li::before { content: counter(move, decimal-leading-zero); position: absolute; left: 0; top: 22px; font-family: var(--font-ledger); color: var(--foil-deep); }
.tm-moves h3 { font-family: var(--font-display); font-weight: 400; font-size: 1.25rem; margin: 0 0 8px; }
.tm-moves p { margin: 0; color: var(--muted); }
.tm-moves strong { color: var(--ink); font-weight: 600; }

/* Buydown */
.tm-turnback { background: var(--slate-wash); padding: 32px; margin: 0 0 48px; }
.tm-turnback h3 { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.35rem, 2.2vw, 1.75rem); margin: 0 0 8px; }
.tm-turnback-lede { max-width: 70ch; margin: 0 0 24px; }
.tm-turnback-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 32px; }
.tm-turnback-grid > div { border-top: 2px solid var(--ink); padding-top: 14px; }
.tm-turnback-grid > div:nth-child(2) { border-top-color: var(--stamp); }
.tm-turnback-grid .tm-figure { display: block; color: var(--ink); margin: 8px 0; }
.tm-turnback-grid p { margin: 0; color: var(--ink); font-size: 0.95rem; }
.tm-turnback-note { font-size: 0.82rem; color: var(--muted); margin: 20px 0 0; }
.tm-kinds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 32px; margin-bottom: 48px; }
.tm-kinds div { border-top: 2px solid var(--ink); padding-top: 16px; }
.tm-kinds h3 { font-family: var(--font-display); font-weight: 400; font-size: 1.2rem; margin: 6px 0 8px; }
.tm-kinds p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.tm-calc { display: grid; grid-template-columns: 1fr 2fr; gap: 48px; }
.tm-fields { display: flex; flex-direction: column; gap: 22px; }
.tm-field label { display: block; font: var(--label); text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin-bottom: 6px; }
.tm-field input { width: 100%; border: 0; border-bottom: 1px solid var(--rule); background: transparent; padding: 10px 0; font-family: var(--font-ledger); font-size: 1.1rem; color: var(--ink); border-radius: 0; }
.tm-field input:focus { outline: none; border-bottom: 2px solid var(--ink); }
.tm-field small { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 6px; }
.tm-credit { background: var(--slate-wash); padding: 20px 24px; margin-top: 24px; }
.tm-credit p { margin: 0; }
.tm-credit p + p { margin-top: 8px; }
.tm-more { margin: 28px 0 0; font-weight: 600; }
.tm-more a { color: var(--ink); }
.tm-fineprint { font-size: 0.82rem; color: var(--muted); margin-top: 20px; max-width: 80ch; }

/* Call to action */
.tm-cta { background: var(--ink); color: var(--bond); padding: 56px 0; }
.tm-cta h2 { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.5rem, 2.4vw, 2rem); margin: 0 0 12px; }
.tm-cta p { color: var(--slate-wash); max-width: 56ch; margin: 0 0 24px; }
.tm-cta a.tm-btn { display: inline-flex; align-items: center; min-height: 44px; padding: 14px 22px; background: var(--foil); color: var(--ink-deep); font: var(--label); text-transform: uppercase; letter-spacing: 0.12em; text-decoration: none; }
.tm-cta a.tm-btn:hover { background: var(--bond); }
.tm-sources { font-size: 0.8rem; color: var(--muted); padding: 24px 0 48px; }
.tm-sources p { margin: 4px 0; max-width: 90ch; }

.tm-loading { font-family: var(--font-ledger); color: var(--slate); padding: 24px 0; }
.tm-error { color: var(--stamp); background: var(--stamp-wash); padding: 16px; }

@media (max-width: 900px) {
  .tm-dial { grid-template-columns: repeat(2, 1fr); }
  .tm-dial-item:nth-child(2) { border-right: 0; }
  .tm-dial-item:nth-child(3) { padding-left: 0; }
  .tm-dial-item:nth-child(n+3) { border-top: 1px solid rgba(169, 184, 203, 0.35); }
  .tm-moves, .tm-kinds, .tm-calc, .tm-turnback-grid { grid-template-columns: 1fr; }
  .tm-turnback-grid { gap: 20px; }
  .tm-turnback { padding: 24px 16px; }
  .tm-kinds { gap: 24px; }
}
@media (max-width: 640px) {
  .tm-wrap { padding: 0 16px; }
  .tm-cover { padding: 40px 0; }
  .tm-section { padding: 40px 0; }
  .tm-seg button { padding: 12px 12px; }
  .tm-table .tm-col-who { display: none; }
  .tm-table th, .tm-table td { padding-right: 8px; }
  .tm-table td.num, .tm-table th.num { padding-right: 8px; }
  .tm-table td.num { font-size: 0.85rem; }
  .tm-table .tm-measure small { display: none; }
  .tm-meter-pin em { font-size: 0.8rem; }
}
@media (prefers-reduced-motion: reduce) {
  .tm-dial-item .tm-figure { transition: none; }
}
