Magnetic-field-driven superconductor–insulator-type transition in graphite