// Steps body line-height through default → 1.5 → 1.8 → 2.0 → reset.
const STEPS = [0, 1.5, 1.8, 2.0] as const;
let stepIdx = 0;

export function cycle(): number {
  stepIdx = (stepIdx + 1) % STEPS.length;
  apply();
  return STEPS[stepIdx];
}

export function setStep(idx: number): void {
  stepIdx = Math.max(0, Math.min(STEPS.length - 1, idx));
  apply();
}

export function getStep(): number {
  return stepIdx;
}

export function reset(): void {
  stepIdx = 0;
  apply();
}

function apply(): void {
  const val = STEPS[stepIdx];
  if (val === 0) {
    document.body.style.removeProperty('line-height');
  } else {
    document.body.style.lineHeight = String(val);
  }
}
