/* ════════════════════════════════════════════════════════════
   money-ladder.css — The Money Ladder / Pénzlétra page
   One draggable "month" block climbs a diagonal path; consequences
   stack to its left, the balance reads to its right. Life events sit
   above and push the block up or down.
   All classes are prefixed ml- to avoid collisions with style.css.
   ════════════════════════════════════════════════════════════ */

.ml-wrap {
  /* Widget tokens, mapped onto the site palette */
  --ml-surface: var(--bg-card);
  --ml-fg:      var(--text-primary);
  --ml-muted:   var(--text-secondary);
  --ml-line:    var(--border-hover);
  --ml-axis:    var(--text-secondary);
  --ml-debt:    #F87171;
  --ml-even:    var(--accent);
  --ml-save:    var(--info);
  --ml-invest:  var(--success);
  --ml-debt-bg:   rgba(248, 113, 113, 0.10);
  --ml-invest-bg: var(--success-light);
  --ml-event:   var(--chart-real);
  --ml-f-display: 'Fraunces', Georgia, serif;
  --ml-f-body:    'Plus Jakarta Sans', -apple-system, sans-serif;
  --ml-f-num:     'SF Mono', 'Fira Code', 'Roboto Mono', 'Courier New', monospace;

  max-width: 1100px;
  margin: 0 auto;
  padding: 56px max(16px, env(safe-area-inset-right, 0px)) 56px max(16px, env(safe-area-inset-left, 0px));
  display: grid;
  gap: 18px;
  color: var(--ml-fg);
  font-family: var(--ml-f-body);
  line-height: 1.5;
}
.ml-wrap h1 { font-family: var(--ml-f-display); font-weight: 700; font-size: clamp(28px, 5vw, 44px); line-height: 1.05; margin: 0; text-wrap: balance; letter-spacing: -.01em; }
.ml-lede { margin: 10px 0 0; color: var(--ml-muted); max-width: 62ch; }
.ml-controls { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: end; }
.ml-field { display: grid; gap: 4px; }
.ml-field label, .ml-group h3 { font-family: var(--ml-f-body); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ml-muted); font-weight: 600; margin: 0; }
.ml-row { display: flex; gap: 6px; }
.ml-wrap input[type=number], .ml-wrap select { font: 500 15px var(--ml-f-num); background: var(--ml-surface); color: var(--ml-fg); border: 1px solid var(--ml-line); border-radius: var(--radius-md); padding: 7px 10px; }
.ml-wrap #income { width: 130px; }
.ml-wrap input:focus-visible, .ml-wrap select:focus-visible, .ml-wrap button:focus-visible { outline: 2px solid var(--ml-save); outline-offset: 1px; }
.ml-stats { display: flex; flex-wrap: wrap; gap: 8px 28px; font-variant-numeric: tabular-nums; }
.ml-stat { display: grid; align-content: start; }
.ml-stat span { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ml-muted); font-weight: 600; }
.ml-stat b { font: 500 20px var(--ml-f-num); }
.ml-stat small { font: 500 12px var(--ml-f-num); color: var(--ml-muted); }

.ml-events { border: 1px solid var(--ml-line); border-radius: var(--radius-lg); background: var(--ml-surface); padding: 14px 16px 16px; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px 26px; }
.ml-events legend { font: 700 16px var(--ml-f-display); padding: 0 6px; }
.ml-head { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: -6px; }
.ml-head p { margin: 0; color: var(--ml-muted); font-size: 13.5px; }
.ml-events button { font: 600 13px var(--ml-f-body); background: transparent; color: var(--ml-fg); border: 1px solid var(--ml-line); border-radius: var(--radius-md); padding: 5px 12px; cursor: pointer; }
.ml-events button:hover { border-color: var(--ml-event); }
.ml-group { display: grid; gap: 6px; align-content: start; min-width: 0; }
.ml-opt { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; font-size: 14px; line-height: 1.35; }
.ml-opt input { margin: 2px 0 0; width: 16px; height: 16px; flex: none; accent-color: var(--ml-event); }
.ml-inline { display: flex; flex-wrap: wrap; gap: 4px 14px; padding-left: 24px; font-size: 13.5px; }
.ml-inline label { display: flex; gap: 5px; align-items: center; cursor: pointer; }
.ml-inline input { accent-color: var(--ml-event); }
.ml-inline[hidden], .ml-num[hidden] { display: none !important; }
.ml-num { display: flex; gap: 6px; align-items: center; font-size: 13.5px; padding-left: 24px; }
.ml-num input { width: 68px; padding: 3px 8px !important; font-size: 14px !important; }
.ml-range { display: grid; gap: 2px; font-size: 14px; }
.ml-range-top { display: flex; justify-content: space-between; gap: 8px; }
.ml-range output { font: 500 13px var(--ml-f-num); color: var(--ml-event); white-space: nowrap; }
.ml-range input { width: 100%; accent-color: var(--ml-event); }

.ml-chart { position: relative; height: clamp(460px, 68vh, 640px); background: var(--ml-surface); border: 1px solid var(--ml-line); border-radius: var(--radius-lg); overflow: hidden; touch-action: none; user-select: none; }
.ml-zone-up, .ml-zone-down { position: absolute; left: 0; right: 0; }
.ml-zone-up   { top: 0;    background: linear-gradient(to top, transparent, var(--ml-invest-bg)); }
.ml-zone-down { bottom: 0; background: linear-gradient(to bottom, transparent, var(--ml-debt-bg)); }
.ml-yaxis { position: absolute; left: 56px; top: 16px; bottom: 16px; width: 2px; background: var(--ml-axis); }
.ml-xaxis { position: absolute; left: 24px; right: 16px; height: 2px; background: var(--ml-axis); }
.ml-zero { position: absolute; left: 30px; font: 500 13px var(--ml-f-num); transform: translateY(-120%); }
.ml-tick { position: absolute; left: 8px; width: 42px; text-align: right; font: 500 11px var(--ml-f-num); color: var(--ml-muted); transform: translateY(-50%); }
.ml-axis-title { position: absolute; left: 66px; top: 14px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ml-muted); }
.ml-trail { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; max-width: none; }
.ml-knob { position: absolute; border-radius: var(--radius-lg); border: 3px solid var(--c); background: color-mix(in srgb, var(--c) 14%, var(--ml-surface)); cursor: grab; display: grid; place-items: center; transform: translate(-50%, -50%); transition: width .15s, height .15s, border-color .2s, background .2s; touch-action: none; }
.ml-knob:active { cursor: grabbing; }
.ml-knob:focus-visible { outline: 3px solid var(--ml-fg); outline-offset: 3px; }
.ml-grip { font: 700 13px var(--ml-f-display); color: var(--c); text-transform: uppercase; letter-spacing: .06em; text-align: center; line-height: 1.1; padding: 0 6px; }
.ml-ghost { position: absolute; border: 2px dashed var(--ml-muted); border-radius: var(--radius-lg); transform: translate(-50%, -50%); pointer-events: none; display: grid; place-items: center; font-size: 11px; color: var(--ml-muted); text-align: center; line-height: 1.15; opacity: .85; }
.ml-ghost[hidden] { display: none; }
.ml-readout { position: absolute; transform: translateY(-50%); font-variant-numeric: tabular-nums; pointer-events: none; white-space: nowrap; }
.ml-big { font: 700 30px/1 var(--ml-f-display); color: var(--c); }
.ml-small { font-size: 13px; color: var(--ml-muted); }
.ml-opps { position: absolute; display: grid; gap: 5px; justify-items: end; pointer-events: none; width: min(330px, 40%); }
.ml-opp { font-size: 13.5px; line-height: 1.3; text-align: right; border-right: 3px solid var(--c); padding: 1px 8px 1px 0; color: var(--ml-fg); animation: ml-pop .25s ease-out; }
.ml-opp--new { font-weight: 600; }
.ml-opp--ev  { font-style: italic; }
@keyframes ml-pop { from { opacity: .2; transform: translateX(8px); } to { opacity: 1; transform: none; } }
.ml-hint { position: absolute; right: 16px; bottom: 12px; font-size: 12px; color: var(--ml-muted); }
.ml-panel { display: none; background: var(--ml-surface); border: 1px solid var(--ml-line); border-radius: var(--radius-lg); padding: 14px 16px; gap: 6px; }
.ml-panel h2 { margin: 0 0 4px; font: 700 18px var(--ml-f-display); color: var(--c); }
.ml-panel .ml-opp { text-align: left; border-right: 0; border-left: 3px solid var(--c); padding: 1px 0 1px 8px; }
.ml-foot { font-size: 12.5px; color: var(--ml-muted); max-width: 80ch; margin: 0; }

@media (max-width: 700px) {
  .ml-opps { display: none; }
  .ml-panel { display: grid; }
  .ml-big { font-size: 24px; }
  .ml-grip { font-size: 11px; letter-spacing: .02em; }
  .ml-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ml-opp { animation: none; }
  .ml-knob { transition: none; }
}
